Codeforces Round 520 (Div. 2)


A. A Prank
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 3 4 5 6 9
Output
2
Input
3
998 999 1000
Output
2
Input
5
1 2 3 4 5
Output
4
----------------------------------------------------------------------------------------------------
B. Math
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
20
Output
10 2
Input
5184
Output
6 4
----------------------------------------------------------------------------------------------------
C. Banh-mi
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1011
1 4
3 4
Output
14
3
Input
3 2
111
1 2
3 3
Output
3
1
----------------------------------------------------------------------------------------------------
D. Fun with Integers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
8
Input
6
Output
28
Input
2
Output
0
----------------------------------------------------------------------------------------------------
E. Company
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11 5
1 1 3 3 3 4 2 7 7 6
4 6
4 8
1 11
9 11
8 11
Output
4 1
8 1
1 0
11 3
8 1
----------------------------------------------------------------------------------------------------
F. Upgrading Cities
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 7
1 2
2 3
3 4
4 7
2 5
5 4
6 4
Output
4
Input
6 7
1 2
2 3
3 4
1 5
5 3
2 6
6 4
Output
4
----------------------------------------------------------------------------------------------------
