Codeforces Round 738 (Div. 2)


A. Mocha and Math
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1 2
3
1 1 3
4
3 11 3 7
5
11 7 15 3 7
Output
0
1
3
3
----------------------------------------------------------------------------------------------------
B. Mocha and Red and Blue
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
7
?R???BR
7
???R???
1
?
1
B
10
?R??RB??B?
Output
BRRBRBR
BRBRBRB
B
B
BRRBRBBRBR
----------------------------------------------------------------------------------------------------
C. Mocha and Hiking
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
0 1 0
3
1 1 0
Output
1 4 2 3 
4 1 2 3 
----------------------------------------------------------------------------------------------------
D1. Mocha and Diana (Easy Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 2
1 2
2 3
1 2
1 3
Output
0
Input
5 3 2
5 4
2 1
4 3
4 3
1 4
Output
1
2 4
Input
8 1 2
1 7
2 6
1 5
Output
5
5 2
2 3
3 4
4 7
6 8
----------------------------------------------------------------------------------------------------
D2. Mocha and Diana (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 2
1 2
2 3
1 2
1 3
Output
0
Input
5 3 2
5 4
2 1
4 3
4 3
1 4
Output
1
2 4
Input
8 1 2
1 7
2 6
1 5
Output
5
5 2
2 3
3 4
4 7
6 8
----------------------------------------------------------------------------------------------------
E. Mocha and Stars
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
1 3
1 2
Output
4
Input
5 10
1 10
1 10
1 10
1 10
1 10
Output
251
Input
5 100
1 94
1 96
1 91
4 96
6 97
Output
47464146
----------------------------------------------------------------------------------------------------
