Codeforces Round 508 (Div. 2)


A. Equality
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 3
ACAABCCAB
Output
6
Input
9 4
ABCABCABC
Output
0
----------------------------------------------------------------------------------------------------
B. Non-Coprime Partition
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
No
Input
3
Output
Yes
1 2
2 1 3 
----------------------------------------------------------------------------------------------------
C. Gambling
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4
2 1 2 1
Output
4
Input
5
0 -1 -1 -1 -1
Output
4
----------------------------------------------------------------------------------------------------
E. Maximum Matching
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 1 4
1 2 4
3 4 4
2 8 3
3 16 3
1 32 2
Output
63
Input
7
1 100000 1
1 100000 2
1 100000 2
4 50000 3
3 50000 4
4 50000 4
3 50000 3
Output
300000
Input
4
1 1000 1
2 500 2
3 250 3
4 125 4
Output
1000
----------------------------------------------------------------------------------------------------
F. Wrap Around
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
0
Output
3
Input
4
1010
Output
2
Input
20
10101010101010
Output
962
----------------------------------------------------------------------------------------------------
