Testing Round 10


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

Examples
Input
10
3 8 10 1 7 9 6 5 2
Output
4
----------------------------------------------------------------------------------------------------
B. Balancer
time limit per test: 0.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 6 2 5 3 7
Output
12
----------------------------------------------------------------------------------------------------
C. One-Based Arithmetic
time limit per test: 0.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
121
Output
6
----------------------------------------------------------------------------------------------------
D. Berland Federalization
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1 2
2 3
3 4
4 5
Output
1
2
Input
5 3
1 2
1 3
1 4
1 5
Output
2
3 4
Input
1 1
Output
0
----------------------------------------------------------------------------------------------------
