Codeforces Round 631 (Div. 1) - Thanks, Denis aramis Shitov!


A. Dreamoon Likes Coloring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
3 2 2
Output
2 4 1
Input
10 1
1
Output
-1
----------------------------------------------------------------------------------------------------
B. Dreamoon Likes Sequences
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
1 1000000000
2 999999999
3 99999998
4 9999997
5 999996
6 99995
7 9994
8 993
9 92
10 1
Output
1
3
5
11
17
23
29
59
89
0
----------------------------------------------------------------------------------------------------
C. Drazil Likes Heap
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 2
7 6 3 5 4 2 1
3 2
7 6 5 4 3 2 1
Output
10
3 2 3 1
8
2 1 3 1
----------------------------------------------------------------------------------------------------
D. Dreamoon Likes Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
aabbcc
aaabbb
aaa
abacad
Output
3
3 3
2 4
1 2
3
3 4
2 3
1 2
3
1 1
1 1
1 1
1
1 6
----------------------------------------------------------------------------------------------------
E. Dreamoon Loves AA
time limit per test: 3.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
80 3 5
11 24 50
81 7 12
4 10 17 26 37 48 61
25 10 14
3 4 7 12 13 15 17 19 21 23
1 0 0
10 2 0
2 4
Output
5
2
0
0
4
----------------------------------------------------------------------------------------------------
