Codeforces Round 346 (Div. 2)


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

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

Examples
Input
5 2
Ivanov 1 763
Andreev 2 800
Petrov 1 595
Sidorov 1 790
Semenov 2 503
Output
Sidorov Ivanov
Andreev Semenov
Input
5 2
Ivanov 1 800
Andreev 2 763
Petrov 1 800
Sidorov 1 800
Semenov 2 503
Output
?
Andreev Semenov
----------------------------------------------------------------------------------------------------
C. Tanya and Toys
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 7
1 3 4
Output
2
2 5 
Input
4 14
4 6 12 8
Output
4
7 2 3 1
----------------------------------------------------------------------------------------------------
D. Bicycle Race
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
0 0
0 1
1 1
1 2
2 2
2 0
0 0
Output
1
Input
16
1 1
1 5
3 5
3 7
2 7
2 9
6 9
6 7
5 7
5 3
4 3
4 4
3 4
3 2
5 2
5 1
1 1
Output
6
----------------------------------------------------------------------------------------------------
E. New Reform
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
2 1
1 3
4 3
Output
1
Input
5 5
2 1
1 3
2 3
2 5
4 3
Output
0
Input
6 5
1 2
2 3
4 5
4 6
5 6
Output
1
----------------------------------------------------------------------------------------------------
F. Polycarp and Hay
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 3 35
10 4 9
9 9 7
Output
YES
7 0 7 
7 7 7 
Input
4 4 50
5 9 1 1
5 1 1 5
5 1 5 5
5 5 7 1
Output
YES
5 5 0 0 
5 0 0 5 
5 0 5 5 
5 5 5 0 
Input
2 4 12
1 1 3 1
1 6 2 4
Output
NO
----------------------------------------------------------------------------------------------------
G. Fence Divercity
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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