Codeforces Round 191 (Div. 2)


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

Examples
Input
5
1 0 0 1 0
Output
4
Input
4
1 0 0 1
Output
4
----------------------------------------------------------------------------------------------------
B. Hungry Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
2 9 15
Input
5
Output
11 14 20 27 31
----------------------------------------------------------------------------------------------------
C. Magic Five
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1256
1
Output
4
Input
13990
2
Output
528
Input
555
2
Output
63
----------------------------------------------------------------------------------------------------
D. Block Tower
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
..#
.#.
Output
4
B 1 1
R 1 2
R 2 1
B 2 3
Input
1 3
...
Output
5
B 1 1
B 1 2
R 1 3
D 1 2
R 1 2
----------------------------------------------------------------------------------------------------
E. Axis Walking
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 5
2
5 7
Output
1
Input
3
2 2 2
2
1 3
Output
6
----------------------------------------------------------------------------------------------------
