Codeforces Round 356 (Div. 2)


A. Bear and Five Cards
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3 7 3 20
Output
26
Input
7 9 3 1 8
Output
28
Input
10 10 10 10 10
Output
20
----------------------------------------------------------------------------------------------------
B. Bear and Finding Criminals
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
1 1 1 0 1 0
Output
3
Input
5 2
0 0 0 1 0
Output
1
----------------------------------------------------------------------------------------------------
C. Bear and Prime 100
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
yes
no
yes
Output
2
80
5
composite
Input
no
yes
no
no
no
Output
58
59
78
78
2
prime
----------------------------------------------------------------------------------------------------
D. Bear and Tower of Cubes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
48
Output
9 42
Input
6
Output
6 6
----------------------------------------------------------------------------------------------------
E. Bear and Square Grid
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
..XXX
XX.XX
X.XXX
X...X
XXXX.
Output
10
Input
5 3
.....
.XXX.
.XXX.
.XXX.
.....
Output
25
----------------------------------------------------------------------------------------------------
