Codeforces Round 240 (Div. 2)


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

Examples
Input
5 4
4 3 1 2
Output
1 1 3 4 4 
Input
5 5
5 4 3 2 1
Output
1 2 3 4 5 
----------------------------------------------------------------------------------------------------
B. Mashmokh and Tokens
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 4
12 6 11 9 1
Output
0 2 3 1 1 
Input
3 1 2
1 2 3
Output
1 0 1 
Input
1 1 1
1
Output
0 
----------------------------------------------------------------------------------------------------
C. Mashmokh and Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
Output
1 2 3 4 5
Input
5 3
Output
2 4 3 7 1
Input
7 2
Output
-1
----------------------------------------------------------------------------------------------------
D. Mashmokh and ACM
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
Output
5
Input
6 4
Output
39
Input
2 1
Output
2
----------------------------------------------------------------------------------------------------
E. Mashmokh and Reverse Operation
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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