Educational Codeforces Round 8


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

Examples
Input
5 2 3
Output
20 15
Input
8 2 4
Output
35 32
----------------------------------------------------------------------------------------------------
B. New Skateboard
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
124
Output
4
Input
04
Output
3
Input
5810438174
Output
9
----------------------------------------------------------------------------------------------------
C. Bear and String Distance
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 26
bear
Output
roar
Input
2 7
af
Output
db
Input
3 1000
hey
Output
-1
----------------------------------------------------------------------------------------------------
D. Magic Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 6
10
99
Output
8
Input
2 0
1
9
Output
4
Input
19 7
1000
9999
Output
6
----------------------------------------------------------------------------------------------------
E. Zbazi in Zeydabad
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 4
zzzz
zzz.
.z..
zzzz
Output
16
Input
1 4
z.z.
Output
2
Input
2 2
zz
zz
Output
5
----------------------------------------------------------------------------------------------------
F. Bear and Fair Set
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 20 1
10 10
Output
fair
Input
10 20 3
15 10
5 0
10 5
Output
fair
Input
10 20 2
15 3
20 10
Output
unfair
----------------------------------------------------------------------------------------------------
