Codeforces Round 430 (Div. 2)


A. Kirill And The Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 10 1 10 1
Output
YES
Input
1 5 6 10 1
Output
NO
----------------------------------------------------------------------------------------------------
B. Gleb And Pizza
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 4
7
7 8 1
-7 3 2
0 2 1
0 -2 2
-3 -3 1
0 6 2
5 3 1
Output
2
Input
10 8
4
0 0 9
0 0 10
1 0 1
1 0 2
Output
0
----------------------------------------------------------------------------------------------------
C. Ilya And The Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
6 2
1 2
Output
6 6 
Input
3
6 2 3
1 2
1 3
Output
6 6 6 
Input
1
10
Output
10 
----------------------------------------------------------------------------------------------------
D. Vitya and Strange Lesson
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

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