Codeforces Round 112 (Div. 2)


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

Examples
Input
8
1 1
4 2
3 1
1 2
0 2
0 1
1 0
1 3
Output
2
Input
5
0 0
0 1
1 0
0 -1
-1 0
Output
1
----------------------------------------------------------------------------------------------------
B. Burning Midnight Oil
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 2
Output
4
Input
59 9
Output
54
----------------------------------------------------------------------------------------------------
C. Another Problem on Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1010
Output
6
Input
2
01010
Output
4
Input
100
01010
Output
0
----------------------------------------------------------------------------------------------------
D. Beard Graph
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
2 3
7
3 1 2
3 1 3
3 2 3
2 2
3 1 2
3 1 3
3 2 3
Output
1
2
1
1
-1
-1
Input
6
1 5
6 4
2 3
3 5
5 6
6
3 3 4
2 5
3 2 6
3 1 2
2 3
3 3 1
Output
3
-1
3
2
----------------------------------------------------------------------------------------------------
E. Compatible Numbers
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
90 36
Output
36 90
Input
4
3 6 3 6
Output
-1 -1 -1 -1
Input
5
10 6 9 8 2
Output
-1 8 2 2 8
----------------------------------------------------------------------------------------------------
