Codeforces Round 257 (Div. 2)


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

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

Examples
Input
2 3
3
Output
1
Input
0 -1
2
Output
1000000006
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. 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
----------------------------------------------------------------------------------------------------
E. 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
----------------------------------------------------------------------------------------------------
