Codeforces Round 777 (Div. 2)


A. Madoka and Math Dad
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
2
3
4
5
Output
1
2
21
121
212
----------------------------------------------------------------------------------------------------
B. Madoka and the Elegant Gift
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 3
100
011
011
3 3
110
111
110
1 5
01111
4 5
11111
01010
01000
01000
3 2
11
00
11
Output
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Madoka and Childish Pranks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 5
01000
10100
01010
00110
2 3
001
010
3 3
110
101
000
1 1
0
Output
4
1 1 3 3
3 3 4 4
4 3 4 4
4 2 4 3
1
1 2 2 3
-1
0
----------------------------------------------------------------------------------------------------
D. Madoka and the Best School in Russia
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
6 2
12 2
36 2
8 2
1000 10
2376 6
128 4
16384 4
Output
NO
NO
YES
NO
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
E. Madoka and the Sixth-graders
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 5 3 3 1
1 8 2 9 4
Output
1 3 2 5 4 
Input
5
1 3 2 5 2
3 2 5 4 1
Output
3 2 5 4 1 
Input
10
10 8 5 3 7 8 6 6 1 1
5 26 24 27 21 4 18 2 28 1
Output
5 4 2 6 7 8 3 9 1 10 
----------------------------------------------------------------------------------------------------
F. Madoka and Laziness
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 4 3
Output
3
Input
8
2 12 13 7 14 6 11 8
Output
4
Input
7
9 5 3 10 2 6 8
Output
0
Input
8
8 6 10 9 1 5 2 14
Output
0
----------------------------------------------------------------------------------------------------
