Codeforces Round 477 (rated, Div. 2, based on VK Cup 2018 Round 3)


A. Mind the Gap
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 60
0 0
1 20
3 21
5 0
19 30
23 40
Output
6 1
Input
16 50
0 30
1 20
3 0
4 30
6 10
7 50
9 30
11 10
12 50
14 30
16 10
17 50
19 30
21 10
22 50
23 59
Output
24 50
Input
3 17
0 30
1 0
12 0
Output
0 0
----------------------------------------------------------------------------------------------------
B. Watering System
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 10 3
2 2 2 2
Output
1
Input
4 80 20
3 2 1 4
Output
0
Input
5 10 10
1000 1 1 1 1
Output
4
----------------------------------------------------------------------------------------------------
C. Stairs and Elevators
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6 1 1 3
2
5
3
1 1 5 6
1 3 5 4
3 3 5 3
Output
7
5
4
----------------------------------------------------------------------------------------------------
D. Resource Distribution
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 8 16
3 5 2 9 8 7
Output
Yes
3 2
1 2 6
5 4
Input
4 20 32
21 11 11 12
Output
Yes
1 3
1
2 3 4
Input
4 11 32
5 5 16 16
Output
No
Input
5 12 20
7 8 4 11 9
Output
No
----------------------------------------------------------------------------------------------------
E. Big Secret
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
No
Input
6
4 7 7 12 31 61
Output
Yes
4 12 7 31 7 61 
----------------------------------------------------------------------------------------------------
F. Aztec Catacombs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2
2 3
1 3
3 4
Output
2
1 3 4 
Input
4 2
1 2
2 3
Output
4
1 2 3 1 4 
----------------------------------------------------------------------------------------------------
