Codeforces Round 767 (Div. 2)


A. Download More RAM
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 10
20 30 10
9 100 10
5 1
1 1 5 1 1
1 1 1 1 1
5 1
2 2 2 2 2
100 100 100 100 100
5 8
128 64 32 16 8
128 64 32 16 8
Output
29
6
1
256
----------------------------------------------------------------------------------------------------
B. GCD Arrays
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
1 1 0
3 5 1
13 13 0
4 4 0
3 7 4
4 10 3
2 4 0
1 7 3
1 5 3
Output
NO
NO
YES
YES
YES
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
C. Meximum Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
6
5
zx
ab
cc
zx
ba
2
ab
bad
4
co
def
orc
es
3
a
b
c
3
ab
cd
cba
2
ab
ab
Output
YES
NO
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
E. Grid Xor
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
1 5
5 1
4
1 14 8 9
3 1 5 9
4 13 11 1
1 15 4 11
4
2 4 1 6
3 7 3 10
15 9 4 2
12 7 15 1
Output
4
9
5
----------------------------------------------------------------------------------------------------
F1. Game on Sum (Easy Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 3 2
2 1 10
6 3 10
6 4 10
100 1 1
4 4 0
69 4 20
Output
6
5
375000012
500000026
958557139
0
49735962
----------------------------------------------------------------------------------------------------
F2. Game on Sum (Hard Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 3 2
2 1 10
6 3 10
6 4 10
100 1 1
4 4 0
69 4 20
Output
6
5
375000012
500000026
958557139
0
49735962
----------------------------------------------------------------------------------------------------
