Codeforces Round 257 (Div. 1)


A. Jzzhu and Chocolate
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 1
Output
6
Input
6 4 2
Output
8
Input
2 3 4
Output
-1
----------------------------------------------------------------------------------------------------
B. Jzzhu and Cities
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5 3
1 2 1
2 3 2
1 3 3
3 4 4
1 5 5
3 5
4 5
5 5
Output
2
Input
2 2 3
1 2 2
2 1 3
2 1
2 2
2 3
Output
2
----------------------------------------------------------------------------------------------------
C. Jzzhu and Apples
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
Output
2
6 3
2 4
Input
9
Output
3
9 3
2 4
6 8
Input
2
Output
0
----------------------------------------------------------------------------------------------------
D. Jzzhu and Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 3
Output
0
Input
4
0 1 2 3
Output
10
Input
6
5 2 0 5 2 1
Output
53
----------------------------------------------------------------------------------------------------
E. Jzzhu and Squares
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3
2 2
2 5
3 4
Output
3
8
26
58
----------------------------------------------------------------------------------------------------
