Codeforces Round 560 (Div. 3)


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

Examples
Input
11 5 2
11010100101
Output
1
Input
11 5 1
11010100101
Output
3
----------------------------------------------------------------------------------------------------
B. Polycarp Training
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4
good
Output
0
good
Input
4
aabc
Output
2
ab
Input
3
aaa
Output
3
----------------------------------------------------------------------------------------------------
D. Almost All Divisors
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
8
8 2 12 6 4 24 16 3
1
2
Output
48
4
----------------------------------------------------------------------------------------------------
E. Two Arrays and Sum of Functions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 8 7 2 4
9 7 2 9 3
Output
646
Input
1
1000000
1000000
Output
757402647
Input
2
1 3
4 2
Output
20
----------------------------------------------------------------------------------------------------
F1. Microtransactions (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
1 2 0 2 0
2 4
3 3
1 5
1 2
1 5
2 3
Output
8
Input
5 3
4 2 1 3 2
3 5
4 2
2 5
Output
20
----------------------------------------------------------------------------------------------------
F2. Microtransactions (hard version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
1 2 0 2 0
2 4
3 3
1 5
1 2
1 5
2 3
Output
8
Input
5 3
4 2 1 3 2
3 5
4 2
2 5
Output
20
----------------------------------------------------------------------------------------------------
