Educational Codeforces Round 98 (Rated for Div. 2)


A. Robot Program
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 5
3 4
7 1
0 0
2 0
Output
10
7
13
0
3
----------------------------------------------------------------------------------------------------
B. Toy Blocks
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
3 2 2
4
2 2 3 2
3
0 3 0
Output
1
0
3
----------------------------------------------------------------------------------------------------
C. Two Brackets
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
()
[]()
([)]
)]([
)[(]
Output
1
2
2
0
1
----------------------------------------------------------------------------------------------------
D. Radio Towers
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
748683265
Input
3
Output
748683265
Input
5
Output
842268673
Input
200000
Output
202370013
----------------------------------------------------------------------------------------------------
E. Two Editorials
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 5 3
1 3
2 4
6 9
6 9
1 8
Output
14
Input
10 3 3
2 4
4 6
3 5
Output
8
Input
4 4 1
3 3
1 1
2 2
4 4
Output
2
Input
5 4 5
1 2
2 3
3 4
4 5
Output
8
----------------------------------------------------------------------------------------------------
F. Divide Powers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 11
0 1 0 0 1 0
2 1 5
2 4 18
1 1 0
2 2 5
2 0 17
1 0 3
2 1 2
1 1 4
1 4 0
1 5 1
2 2 8
Output
4
16
4
-1
0
1
----------------------------------------------------------------------------------------------------
G. Game On Tree
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
2 4
3 1
3 4
3 5
2
4 5
Output
2 1 2 0 0
Input
8
4 1
8 4
4 5
6 4
2 5
4 3
1 7
3
2 8 3
Output
3 0 0 3 1 2 3 0
Input
10
2 5
4 3
7 3
7 2
5 8
3 6
8 10
7 9
7 1
4
10 6 9 1
Output
0 2 2 2 2 0 2 2 0 0
----------------------------------------------------------------------------------------------------
