Codeforces Round 355 (Div. 2)


A. Vanya and Fence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 7
4 5 14
Output
4
Input
6 1
1 1 1 1 1 1
Output
6
Input
6 5
7 6 8 9 10 5
Output
11
----------------------------------------------------------------------------------------------------
B. Vanya and Food Processor
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6 3
5 4 3 2 1
Output
5
Input
5 6 3
5 5 5 5 5
Output
10
Input
5 6 3
1 2 1 1 1
Output
2
----------------------------------------------------------------------------------------------------
C. Vanya and Label
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
z
Output
3
Input
V_V
Output
9
Input
Codeforces
Output
130653412
----------------------------------------------------------------------------------------------------
D. Vanya and Treasure
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 3
2 1 1 1
1 1 1 1
2 1 1 3
Output
5
Input
3 3 9
1 3 5
8 9 7
4 6 2
Output
22
Input
3 4 12
1 2 3 4
8 7 6 5
9 10 11 12
Output
11
----------------------------------------------------------------------------------------------------
E. Vanya and Balloons
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
1233
0213
2020
0303
Output
108
Input
5
00300
00300
33333
00300
00300
Output
19683
Input
5
00003
02030
00300
03020
30000
Output
108
Input
5
21312
10003
10002
10003
23231
Output
3
Input
5
12131
12111
12112
21311
21212
Output
24
----------------------------------------------------------------------------------------------------
