Codeforces Round 150 (Div. 1)


A. The Brand New Function
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 0
Output
4
Input
10
1 2 3 4 5 6 1 2 9 10
Output
11
----------------------------------------------------------------------------------------------------
B. Hydra
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 12 2 3
1 2
2 3
1 3
1 4
2 5
4 5
4 6
6 5
6 7
7 5
8 7
9 1
Output
YES
4 1
5 6 
9 3 2 
Input
7 10 3 3
1 2
2 3
1 3
1 4
2 5
4 5
4 6
6 5
6 7
7 5
Output
NO
----------------------------------------------------------------------------------------------------
C. Colorado Potato Beetle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
R 8
U 9
L 9
D 8
L 2
Output
101
Input
7
R 10
D 2
L 7
U 9
D 2
R 3
D 10
Output
52
----------------------------------------------------------------------------------------------------
D. Cubes
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 -1 2
5 0 0 0 1
0 0 0 0 2
0 0 0 1 2
0 0 0 0 2
2 2 2 2 3
Output
20
Input
5 1 -2
5 0 0 0 1
0 0 0 0 2
0 0 0 1 2
0 0 0 0 2
2 2 2 2 3
Output
15
----------------------------------------------------------------------------------------------------
E. Matrix
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
100010
110110
011001
010010
000100
011001
Output
YES
011000
111100
000111
001100
100000
000111
Input
3
110
101
011
Output
NO
----------------------------------------------------------------------------------------------------
