Codeforces Round 727 (Div. 2)


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

Examples
Input
4
4 2 5
3 1 2
3 3 10
2000000000 1 2000000000
Output
5
3
3
1999999999000000000
----------------------------------------------------------------------------------------------------
B. Love Song
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 3
abacaba
1 3
2 5
1 7
Output
4
7
11
Input
7 4
abbabaa
1 3
5 7
6 6
2 4
Output
5
4
1
5
Input
13 7
sonoshikumiwo
1 5
2 10
7 7
1 13
4 8
2 5
3 9
Output
82
125
9
191
62
63
97
----------------------------------------------------------------------------------------------------
C. Stable Groups
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 2 3
1 1 5 8 12 13 20 22
Output
2
Input
13 0 37
20 20 80 70 70 70 420 5 1 5 1 60 90
Output
3
----------------------------------------------------------------------------------------------------
D. PriceFixed
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 4
1 3
1 5
Output
8
Input
5
2 7
2 8
1 2
2 4
1 8
Output
12
----------------------------------------------------------------------------------------------------
E. Game with Cards
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 10
3
0 3
0 2
2
0 4
0 2
Output
Yes
0 1 
Input
2 10
3
0 3
0 2
2
3 4
0 1
Output
No
Input
5 10
3
0 3
0 3
7
4 7
1 3
2
2 3
3 7
8
1 8
1 8
6
1 6
7 10
Output
Yes
1 0 0 1 0 
----------------------------------------------------------------------------------------------------
F. Strange Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 4 3 2 1
Output
2 1 1 2 2 
Input
7
3 6 5 6 2 1 3
Output
2 3 1 3 2 3 1 
----------------------------------------------------------------------------------------------------
