Codeforces Global Round 8


A. C+=
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2 3
5 4 100
Output
2
7
----------------------------------------------------------------------------------------------------
B. Codeforces Subsequences
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
codeforces
Input
3
Output
codeforcesss
----------------------------------------------------------------------------------------------------
C. Even Picture
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
12
1 0
2 0
0 1
1 1
2 1
3 1
0 2
1 2
2 2
3 2
1 3
2 3
----------------------------------------------------------------------------------------------------
D. AND, OR and square sum
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1
123
Output
15129
Input
3
1 3 5
Output
51
Input
2
349525 699050
Output
1099509530625
----------------------------------------------------------------------------------------------------
E. Ski Accidents
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
4 6
1 2
1 3
2 3
2 4
3 4
3 4
7 6
1 2
1 3
2 4
2 5
3 6
3 7
Output
2
3 4 
4
4 5 6 7 
----------------------------------------------------------------------------------------------------
F. Lamps on a Circle
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
0
Input
4
1
Output
2 1 3
0
----------------------------------------------------------------------------------------------------
G. Shifting Dominoes
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 4
UUUU
DDDD
Output
4
Input
2 3
ULR
DLR
Output
6
Input
6 6
ULRUUU
DUUDDD
UDDLRU
DLRLRD
ULRULR
DLRDLR
Output
133
----------------------------------------------------------------------------------------------------
H1. Breadboard Capacity (easy version)
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 5 0
BBRR
RBBR
BBBBB
RRRRR
Output
7
----------------------------------------------------------------------------------------------------
H2. Breadboard Capacity (hard version)
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 5 4
BBRR
RBBR
BBBBB
RRRRR
L 2 3
R 3 4
U 1 5
D 1 5
Output
7
7
9
4
9
----------------------------------------------------------------------------------------------------
