VK Cup 2015 - Round 3 (unofficial online mirror, Div. 1 only)


A. Place Your Ad Here
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
7 9
1 4
2 8 2
0 4 1
8 9 3
Output
4
2 1
Input
1 1
0 0
1 1 10
Output
0
----------------------------------------------------------------------------------------------------
B. Duck Hunt
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
-3 0
1 3
-1 2
Output
3
Input
4 5
-1 1
2 4
5 9
6 8
Output
3
----------------------------------------------------------------------------------------------------
C. Idempotent functions
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 2 4
Output
1
Input
3
2 3 3
Output
2
Input
3
2 3 1
Output
3
----------------------------------------------------------------------------------------------------
D. Superhero's Job
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
1
Input
24
Output
3
----------------------------------------------------------------------------------------------------
E. Playing on Graph
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
1 2
2 3
3 4
3 5
Output
3
Input
4 6
1 2
2 3
1 3
3 4
2 4
1 4
Output
-1
Input
4 2
1 3
2 4
Output
2
----------------------------------------------------------------------------------------------------
F. Quest
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
1 1
1 1
2 2
3 3
4 4
Output
11
Input
5 5
4 1
4 2
4 3
4 4
4 5
Output
9
Input
2 2
1 1
2 10
Output
10
----------------------------------------------------------------------------------------------------
