Codeforces Round 386 (Div. 2)


A. Compote
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
7
Output
7
Input
4
7
13
Output
21
Input
2
3
2
Output
0
----------------------------------------------------------------------------------------------------
B. Decoding
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
logva
Output
volga
Input
2
no
Output
no
Input
4
abba
Output
baba
----------------------------------------------------------------------------------------------------
C. Tram
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 4
3 4
1 1
Output
8
Input
5 4 0
1 2
3 1
Output
7
----------------------------------------------------------------------------------------------------
D. Green and Black Tea
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 3 2
Output
GBGBG
Input
7 2 2 5
Output
BBGBGBB
Input
4 3 4 0
Output
NO
----------------------------------------------------------------------------------------------------
E. Numbers Exchange
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2
5 6 7 9 4 5
Output
1
5 6 7 9 4 2 
Input
8 6
7 7 7 7 8 8 8 8
Output
6
7 2 4 6 8 1 3 5 
Input
4 1
4 2 1 10
Output
-1
----------------------------------------------------------------------------------------------------
F. Music in Car
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 2 11
3 4 3 5 1 4 6
7 7 3 6 5 3 9
Output
12
Input
8 4 20
5 6 4 3 7 5 4 1
10 12 5 12 14 8 5 8
Output
19
Input
1 1 5
6
9
Output
6
Input
1 1 3
4
7
Output
0
----------------------------------------------------------------------------------------------------
G. New Roads
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3 3
2 3 1
Output
7
1 3
2 1
2 6
2 4
7 4
3 5
Input
14 5 6
4 4 2 2 1
Output
14
3 1
1 4
11 6
1 2
10 13
6 10
10 12
14 12
8 4
5 1
3 7
2 6
5 9
Input
3 1 1
2
Output
-1
----------------------------------------------------------------------------------------------------
