Codeforces Round 533 (Div. 2)


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

Examples
Input
3
10 1 4
Output
3 7
Input
5
1 1 2 2 3
Output
2 0
----------------------------------------------------------------------------------------------------
B. Zuhair and Strings
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 2
aaacaabb
Output
2
Input
2 1
ab
Output
1
Input
4 2
abab
Output
0
----------------------------------------------------------------------------------------------------
C. Ayoub and Lost Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 3
Output
3
Input
3 2 2
Output
1
Input
9 9 99
Output
711426616
----------------------------------------------------------------------------------------------------
D. Kilani and the Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2
1 1
1..
...
..2
Output
6 3 
Input
3 4 4
1 1 1 1
....
#...
1234
Output
1 4 3 3 
----------------------------------------------------------------------------------------------------
E. Helping Hiasat
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
1
2 motarack
2 mike
1
2 light
Output
2
Input
4 3
1
2 alice
2 bob
2 tanyaromanova
Output
1
----------------------------------------------------------------------------------------------------
