Codeforces Round 879 (Div. 2)


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

Examples
Input
7
4
-1 -1 1 -1
5
-1 -1 -1 1 1
4
-1 1 -1 1
3
-1 -1 -1
5
1 1 1 1 1
1
-1
2
-1 -1
Output
1
1
0
3
0
1
2
----------------------------------------------------------------------------------------------------
B. Maximum Strength
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
53 57
179 239
13 37
132228 132228
54943329752812629795 55157581939688863366
88 1914
Output
4
19
11
0
163
28
----------------------------------------------------------------------------------------------------
C. Game with Reversing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
5
abcde
abxde
5
hello
olleo
2
ab
cd
7
aaaaaaa
abbbbba
1
q
q
6
yoyoyo
oyoyoy
8
abcdefgh
hguedfbh
Output
1
2
3
9
0
2
6
----------------------------------------------------------------------------------------------------
D. Survey in Class
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 8
2 6
4 8
2 7
1 5
3 3
1 3
2 3
2 2
3 5
1 5
1 5
1 5
3 5
1 1
3 3
5 5
4 7
1 7
1 3
3 3
4 5
2 4
1 3
2 4
Output
6
4
0
2
12
2
----------------------------------------------------------------------------------------------------
E. MEX of LCM
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
3
1 2 3
5
1 2 3 4 5
2
2 3
1
1000000000
12
1 8 4 2 3 5 7 2 9 10 11 13
12
7 2 5 4 2 1 1 2 3 11 8 9
Output
4
7
1
1
16
13
----------------------------------------------------------------------------------------------------
F. Typewriter
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 1
0
Output
1
Input
3
1 2 3
2
2 1
3
Output
0
2
1
Input
5
3 1 2 5 4
5
1 3
3
2 3
1 4
3
Output
3
2
1
2
1
2
----------------------------------------------------------------------------------------------------
