Codeforces Round 499 (Div. 2)


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

Examples
Input
5 3
xyabd
Output
29
Input
7 4
problem
Output
34
Input
2 2
ab
Output
-1
Input
12 1
abaabbaaabbb
Output
1
----------------------------------------------------------------------------------------------------
B. Planning The Expedition
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 10
1 5 2 1 1 1 2 5 7 2
Output
2
Input
100 1
1
Output
0
Input
2 5
5 4 3 2 1
Output
1
Input
3 9
42 42 42 42 42 42 42 42 42
Output
3
----------------------------------------------------------------------------------------------------
C. Fly
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
12
11 8
7 5
Output
10.0000000000
Input
3
1
1 4 1
2 5 3
Output
-1
Input
6
2
4 6 3 3 5 6
2 6 3 6 5 3
Output
85.4800000000
----------------------------------------------------------------------------------------------------
D. Rocket
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1
-1
-1
1
0
Output
1
2
4
5
3
----------------------------------------------------------------------------------------------------
E. Border
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 8
12 20
Output
2
0 4 
Input
3 10
10 20 30
Output
1
0 
----------------------------------------------------------------------------------------------------
F. Mars rover
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
AND 9 4
IN 1
IN 1
XOR 6 5
AND 3 7
IN 0
NOT 10
IN 1
IN 1
AND 2 8
Output
10110
----------------------------------------------------------------------------------------------------
