Codeforces Round 518 (Div. 2) [Thanks, Mail.Ru!]


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

Examples
Input
20 15 2 3
Output
1
Input
10 11 2 4
Output
-1
----------------------------------------------------------------------------------------------------
B. LCM
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
1
Input
2
Output
2
----------------------------------------------------------------------------------------------------
C. Colored Rooks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 2
2 3
Output
2
3 4
1 4
4
1 2
2 2
2 4
5 4
1
5 1
Input
3 3
1 2
2 3
3 1
Output
1
1 1
1
1 2
1
1 3
Input
3 1
1 3
Output
1
1 1
1
2 2
1
3 1
----------------------------------------------------------------------------------------------------
D. Array Without Local Maximums
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 -1 2
Output
1
Input
2
-1 -1
Output
200
----------------------------------------------------------------------------------------------------
E. Multihedgehog
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
14 2
1 4
2 4
3 4
4 13
10 5
11 5
12 5
14 5
5 13
6 7
8 6
13 6
9 6
Output
Yes
Input
3 1
1 3
2 3
Output
No
----------------------------------------------------------------------------------------------------
F. Knights
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
1 1
3 1
1 5
4 4
Input
7
Output
2 1
1 2
4 1
5 2
2 6
5 7
6 6
----------------------------------------------------------------------------------------------------
