Educational Codeforces Round 24


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

Examples
Input
18 2
Output
3 6 9
Input
9 10
Output
0 0 9
Input
1000000000000 5
Output
83333333333 416666666665 500000000002
Input
1000000000000 499999999999
Output
1 499999999999 500000000000
----------------------------------------------------------------------------------------------------
B. Permutation Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
2 3 1 4 4
Output
3 1 2 4 
Input
3 3
3 1 2
Output
-1
----------------------------------------------------------------------------------------------------
C. Sofa Thief
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4 1
2 1 4 2
Output
2
Input
5 2
2 2 4 5 3
Output
-1
Input
3 10
1 2 3
Output
4
----------------------------------------------------------------------------------------------------
E. Card Game Again
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
6 2 8
Output
4
Input
3 6
9 1 14
Output
1
----------------------------------------------------------------------------------------------------
F. Level Generation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
4
6
Output
2
3
6
----------------------------------------------------------------------------------------------------
G. Four Melodies
time limit per test: 5 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

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