Educational Codeforces Round 86 (Rated for Div. 2)


A. Road To Zero
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 3
391 555
0 0
9 4
Output
1337
0
----------------------------------------------------------------------------------------------------
B. Binary Period
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
00
01
111
110
Output
00
01
11111
1010
----------------------------------------------------------------------------------------------------
C. Yet Another Counting Problem
time limit per test: 3.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 6 5
1 1
1 3
1 5
1 7
1 9
7 10 2
7 8
100 200
Output
0 0 0 2 4 
0 91 
----------------------------------------------------------------------------------------------------
D. Multiple Testcases
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
1 2 2 3
4 1 1
Output
3
1 2
2 1 3
1 2
Input
6 10
5 8 1 10 8 7
6 6 4 4 3 2 2 2 1 1
Output
2
3 8 5 7
3 10 8 1
Input
5 1
1 1 1 1 1
5
Output
1
5 1 1 1 1 1
Input
5 1
1 1 1 1 1
1
Output
5
1 1
1 1
1 1
1 1
1 1
----------------------------------------------------------------------------------------------------
E. Placing Rooks
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2
Output
6
Input
3 3
Output
0
Input
4 0
Output
24
Input
1337 42
Output
807905441
----------------------------------------------------------------------------------------------------
F. Make It Ascending
time limit per test: 7 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
8
2 1 3 5 1 2 4 5
15
16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
2
3 3
14
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Output
3
6 8
1 6
4 1
7
1 15
1 13
1 11
1 9
1 7
1 5
1 3
1
2 1
0
----------------------------------------------------------------------------------------------------
