Codeforces Round 503 (by SIS, Div. 1)


A. Elections
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
1 100
Output
0
Input
5 5
2 100
3 200
4 300
5 400
5 900
Output
500
Input
5 5
2 100
3 200
4 300
5 800
5 900
Output
600
----------------------------------------------------------------------------------------------------
B. The hat
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
2
2
Output
? 4
? 8
! 4
Input
6
1
2
3 
2
1
0
Output
? 1
? 2
? 3
? 4
? 5
? 6
! -1
----------------------------------------------------------------------------------------------------
C. Sergey's problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
1 2
2 3
2 4
2 5
Output
4
1 3 4 5 
Input
3 3
1 2
2 3
3 1
Output
1
3 
----------------------------------------------------------------------------------------------------
D. Large Triangle
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 7
0 0
3 0
0 4
Output
No
Input
4 3
0 0
2 0
1 2
1 3
Output
Yes
0 0
1 3
2 0
----------------------------------------------------------------------------------------------------
E. Raining season
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 10
1 2 0 100
1 3 0 100
1 4 10 80
1 5 20 0
Output
200 200 200 210 220 230 260 290 320 350
----------------------------------------------------------------------------------------------------
