Codeforces Round 680 (Div. 1, based on Moscow Team Olympiad)


A. Division
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
10 4
12 6
179 822
Output
10
4
179
----------------------------------------------------------------------------------------------------
B. Divide and Sum
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1
1 4
Output
6
Input
2
2 1 2 1
Output
12
Input
3
2 2 2 2 2 2
Output
0
Input
5
13 8 35 94 9284 34 54 69 123 846
Output
2588544
----------------------------------------------------------------------------------------------------
C. Team-Building
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 8 3
1 1 2 2 3 3
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
Output
2
Input
4 3 3
1 1 2 2
1 2
2 3
3 4
Output
3
Input
4 4 2
1 1 1 2
1 2
2 3
3 1
1 4
Output
0
Input
5 5 2
1 2 1 2 1
1 2
2 3
3 4
4 5
5 1
Output
0
----------------------------------------------------------------------------------------------------
D. Rectangular Polyline
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
2
1 1
2
1 1
2
1 2
2
3 3
Output
Yes
1 0
1 1
0 1
0 0
No
Input
2
4
1 1 1 1
4
1 1 1 1
3
2 1 1
3
2 1 1
Output
Yes
1 0
1 1
2 1
2 2
1 2
1 1
0 1
0 0
Yes
0 -2
2 -2
2 -1
1 -1
1 0
0 0
Input
2
4
1 4 1 2
4
3 4 5 12
4
1 2 3 6
2
1 3
Output
Yes
2 0
2 3
3 3
3 7
4 7
4 12
0 12
0 0
No
----------------------------------------------------------------------------------------------------
E. Finding the Vertex
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2
2 3
3 4
4 5
3
2
1
Output
? 3 4
? 2 3
? 1 2
! 1
Input
5
2 1
3 1
4 1
5 1
1
1
4
Output
? 1 2
? 1 3
? 1 4
! 4
----------------------------------------------------------------------------------------------------
