Codeforces Round 206 (Div. 1)


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

Examples
Input
3 4 4 19 1
42 3 99
Output
576
Input
4 7 2 3 9
1 2 3 4
Output
34
----------------------------------------------------------------------------------------------------
B. Game with Strings
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
ab
cd
Output
DRAW
Input
2
xa
ay
Output
FIRST
Input
3
aab
bcb
bac
Output
DRAW
----------------------------------------------------------------------------------------------------
C. Vasya and Beautiful Arrays
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 1
3 6 10 12 13 16
Output
3
Input
5 3
8 21 52 15 77
Output
7
----------------------------------------------------------------------------------------------------
D. Transferring Pyramid
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
5
42
17
444
7
51
Output
7 7 7 7 7 7
-1
400 0 40 0 4 0
7 0 0 0 0 0
47 4 0 0 0 0
----------------------------------------------------------------------------------------------------
