Codeforces Round 581 (Div. 2)


A. BowWow and the Timetable
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
100000000
Output
4
Input
101
Output
2
Input
10100
Output
3
----------------------------------------------------------------------------------------------------
B. Mislove Has Lost an Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 2
Output
5 7
Input
5 1 5
Output
5 31
----------------------------------------------------------------------------------------------------
C. Anna, Svyatoslav and Maps
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0110
0010
0001
1000
4
1 2 3 4
Output
3
1 2 4 
Input
4
0110
0010
1001
1000
20
1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
Output
11
1 2 4 2 4 2 4 2 4 2 4 
Input
3
011
101
110
7
1 2 3 1 3 2 1
Output
7
1 2 3 1 3 2 1 
Input
4
0110
0001
0001
1000
3
1 2 4
Output
2
1 4 
----------------------------------------------------------------------------------------------------
D1. Kirk and a Binary String (easy version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
110
Output
010
Input
010
Output
010
Input
0001111
Output
0000000
Input
0111001100111011101000
Output
0011001100001011101000
----------------------------------------------------------------------------------------------------
D2. Kirk and a Binary String (hard version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
110
Output
010
Input
010
Output
010
Input
0001111
Output
0000000
Input
0111001100111011101000
Output
0011001100001011101000
----------------------------------------------------------------------------------------------------
E. Natasha, Sasha and the Prefix Sums
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 2
Output
0
Input
2 0
Output
2
Input
2 2
Output
5
Input
2000 2000
Output
674532367
----------------------------------------------------------------------------------------------------
