Educational Codeforces Round 153 (Rated for Div. 2)


A. Not a Substring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
)(
(()
()
))()
Output
YES
(())
YES
()()()
NO
YES
()(()())
----------------------------------------------------------------------------------------------------
B. Fancy Coins
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
11 3 0 0
11 3 20 20
11 3 6 1
100000000 2 0 0
Output
5
0
1
50000000
----------------------------------------------------------------------------------------------------
C. Game on Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
2 1 3
2
2 1
3
1 2 3
4
2 1 4 3
Output
1
0
1
2
----------------------------------------------------------------------------------------------------
D. Balanced String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
101
Output
0
Input
1000110
Output
0
Input
11010
Output
1
Input
11001100
Output
2
----------------------------------------------------------------------------------------------------
E. Fast Travel Text Editor
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
codecode
3
1 7
3 5
3 6
Output
3
2
2
Input
abcdefghij
3
1 9
9 1
5 5
Output
8
8
0
Input
aaaaaaaaaaaa
4
10 8
3 7
6 1
11 11
Output
1
1
1
0
----------------------------------------------------------------------------------------------------
F. Evaluate RBS
time limit per test: 10 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
1
1 4 (
2 3 )
1
1 2 )
3 4 (
4
16 5 (
12 3 (
19 6 )
4 10 )
3 10 )
19 11 (
19 7 )
7 14 (
4
16 8 (
11 9 )
20 10 )
20 19 )
2 13 (
18 7 (
15 19 )
5 6 (
Output
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
