Codeforces Round 754 (Div. 2)


A. A.M. Deviation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 4 5
2 2 6
1 6 5
Output
0
1
0
----------------------------------------------------------------------------------------------------
B. Reverse Sort
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7
0011111
5
10100
6
001000
Output
0
1
4 1 3 4 5 
1
3 3 5 6 
----------------------------------------------------------------------------------------------------
C. Dominant Character
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
aa
5
cbabb
8
cacabccc
Output
2
-1
3
----------------------------------------------------------------------------------------------------
D. Treelabeling
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
1 2
3
1 2
1 3
Output
1
2 1
1 2 3
----------------------------------------------------------------------------------------------------
E. Array Equalizer
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 7
-1 5
3
1
4
3
Output
2
4
2
Input
6
2 5 4 1 3 6
-1 4 6 2 3 5
3
1
8
4
Output
10
29
9
----------------------------------------------------------------------------------------------------
F. PalindORme
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 998244353
Output
2
Input
3 2 999999733
Output
40
Input
7 3 796735397
Output
1871528
Input
2 46 606559127
Output
177013
----------------------------------------------------------------------------------------------------
