Codeforces Round 305 (Div. 2)


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

Examples
Input
saba
2
Output
NO
Input
saddastavvat
2
Output
YES
----------------------------------------------------------------------------------------------------
B. Mike and Fun
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4 5
0 1 1 0
1 0 0 1
0 1 1 0
1 0 0 1
0 0 0 0
1 1
1 4
1 1
4 2
4 3
Output
3
4
3
3
4
----------------------------------------------------------------------------------------------------
C. Mike and Frog
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 2
1 1
0 1
2 3
Output
3
Input
1023
1 2
1 0
1 2
1 1
Output
-1
----------------------------------------------------------------------------------------------------
D. Mike and Feet
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
1 2 3 4 5 4 3 2 1 6
Output
6 4 4 3 3 2 2 1 1 1 
----------------------------------------------------------------------------------------------------
E. Mike and Foam
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
1 2 3 4 6
1
2
3
4
5
1
Output
0
1
3
5
6
2
----------------------------------------------------------------------------------------------------
