Codeforces Round 609 (Div. 1)


A. Long Beautiful Integer
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
353
Output
3
353
Input
4 2
1234
Output
4
1313
----------------------------------------------------------------------------------------------------
B. Domino for Young
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 2 2 2 1
Output
4
----------------------------------------------------------------------------------------------------
C. K Integers
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 4 3 2 1
Output
0 1 3 6 10 
Input
3
1 2 3
Output
0 0 0 
----------------------------------------------------------------------------------------------------
D. Invertation in Tournament
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
010
001
100
Output
0 1
Input
4
0010
1000
0100
1110
Output
-1
Input
6
010000
001000
100000
111001
111100
111010
Output
2 18
----------------------------------------------------------------------------------------------------
E. Happy Cactus
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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