Codeforces Beta Round 72 (Div. 2 Only)


A. Toy Army
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
3
Input
4
Output
6
----------------------------------------------------------------------------------------------------
B. Magical Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 1 1 4
Output
5
Input
5
-2 -2 -2 0 1
Output
8
----------------------------------------------------------------------------------------------------
C. Biathlon
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 3
1 2 1
Output
2 
Input
4 10
3 3 2 1
Output
-1
Input
7 10
1 3 3 1 2 3 1
Output
6 2 3 
----------------------------------------------------------------------------------------------------
E. Track
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 2
Sba
ccc
aac
ccc
abT
Output
bcccc
Input
3 4 1
Sxyy
yxxx
yyyT
Output
xxxx
Input
1 3 3
TyS
Output
y
Input
1 4 1
SxyT
Output
-1
----------------------------------------------------------------------------------------------------
