Divide by Zero 2017 and Codeforces Round 399 (Div. 1 + Div. 2, combined)


A. Oath of the Night's Watch
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 5
Output
0
Input
3
1 2 5
Output
1
----------------------------------------------------------------------------------------------------
B. Code For 1
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 2 5
Output
4
Input
10 3 10
Output
5
----------------------------------------------------------------------------------------------------
C. Jon Snow and his Favourite Number
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 2
9 7 11 15 5
Output
13 7
Input
2 100000 569
605 986
Output
986 605
----------------------------------------------------------------------------------------------------
D. Jon and Orbs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
1
Output
1
Input
2 2
1
2
Output
2
2
----------------------------------------------------------------------------------------------------
E. Game of Stones
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5
Output
NO
Input
2
1
2
Output
YES
----------------------------------------------------------------------------------------------------
F. Barrels and boxes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 1
Output
0
Input
1 2 1
Output
666666672
----------------------------------------------------------------------------------------------------
G. The Winds of Winter
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10
0 1
1 2
1 3
1 4
2 5
2 6
3 7
4 8
4 9
5 10
Output
3
4
5
5
5
9
9
9
9
9
Input
2
2 1
0 2
Output
1
1
----------------------------------------------------------------------------------------------------
