Codeforces Round 924 (Div. 2)


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

Examples
Input
7
1 1
2 1
2 6
3 2
2 2
2 4
6 3
Output
No
No
Yes
Yes
Yes
Yes
No
----------------------------------------------------------------------------------------------------
B. Equalize
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2
1 2
4
7 1 4 1
3
103 102 104
5
1 101 1 100 1
5
1 10 100 1000 1
2
3 1
3
1000000000 999999997 999999999
Output
2
2
3
2
1
1
2
----------------------------------------------------------------------------------------------------
C. Physical Education Lesson
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
10 2
3 1
76 4
100 99
1000000000 500000000
Output
4
1
9
0
1
----------------------------------------------------------------------------------------------------
D. Lonely Mountain Dungeons
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 1 0
1 2 3
3 5 10
2 5 3
4 3 3
3 2 1 2
4 1 0
4 1 4 2
4 1 10
4 1 4 2
Output
4
40
9
13
0
----------------------------------------------------------------------------------------------------
E. Modular Sequence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 8 3 28
3 5 3 6
9 1 5 79
Output
YES
8 11 2 2 5 
NO
NO
----------------------------------------------------------------------------------------------------
F. Digital Patterns
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4 0
1 1 2 3
1 2 2 3
Output
20
Input
3 3 2
1 1 1
2 2 8
1 2 3 1
2 2 3 -6
Output
9
10
11
Input
3 2 2
-1000000000 0 1000000000
-1000000000 1000000000
1 1 1 1000000000
2 2 2 -1000000000
Output
8
7
7
----------------------------------------------------------------------------------------------------
