Educational Codeforces Round 115 (Rated for Div. 2)


A. Computer Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
000
000
4
0011
1100
4
0111
1110
6
010101
101010
Output
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
B. Groups
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
1 0 0 1 0
0 1 0 0 1
0 0 0 1 0
0 1 0 1 0
2
0 0 0 1 0
0 0 0 1 0
Output
YES
NO
----------------------------------------------------------------------------------------------------
C. Delete Two Elements
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
8 8 8 8
3
50 20 10
5
1 4 7 3 5
7
1 2 3 4 5 6 7
Output
6
0
2
3
----------------------------------------------------------------------------------------------------
D. Training Session
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
2 4
3 4
2 1
1 3
5
1 5
2 4
3 3
4 2
5 1
Output
3
10
----------------------------------------------------------------------------------------------------
E. Staircases
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 8
1 1
1 1
1 1
2 2
1 1
1 2
2 1
1 1
Output
5
10
5
2
5
3
1
0
Input
3 4 10
1 4
1 2
2 3
1 2
2 3
3 2
1 3
3 4
1 3
3 1
Output
49
35
24
29
49
39
31
23
29
27
Input
1000 1000 2
239 634
239 634
Output
1332632508
1333333000
----------------------------------------------------------------------------------------------------
F. RBS
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
(
)
Output
1
Input
4
()()())
(
(
)
Output
4
Input
1
(())
Output
1
Input
1
)(()
Output
0
----------------------------------------------------------------------------------------------------
G. The Sum of Good Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1256133
17
Output
1 2
3 3
Input
9544715561
525
Output
2 3
4 6
Input
239923
5
Output
1 1
2 2
Input
1218633757639
976272
Output
2 7
8 13
----------------------------------------------------------------------------------------------------
