Codeforces Round 926 (Div. 2)


A. Sasha and the Beautiful Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
2 1 3
3
69 69 69
5
100 54 80 43 90
4
3 4 3 3
2
2 1
Output
2
0
57
1
1
----------------------------------------------------------------------------------------------------
B. Sasha and the Drawing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 4
3 3
3 10
3 9
4 7
7 11
2 3
Output
2
2
6
5
4
6
2
----------------------------------------------------------------------------------------------------
C. Sasha and the Casino
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
2 1 7
2 1 1
2 3 15
3 3 6
4 4 5
5 4 7
4 88 1000000000
25 69 231
13 97 18806
Output
YES
NO
YES
NO
NO
YES
NO
NO
NO
----------------------------------------------------------------------------------------------------
D. Sasha and a Walk in the City
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 3
3 2
4
3 4
2 3
3 1
5
1 2
3 4
5 1
2 3
4
1 2
2 3
3 4
Output
7
12
16
11
----------------------------------------------------------------------------------------------------
E. Sasha and the Happy Tree Cutting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
1 2
2 3
2 4
2
1 3
4 1
6
1 2
3 1
6 1
5 2
4 2
3
3 1
3 6
2 6
5
1 2
2 3
3 4
4 5
4
1 2
2 3
3 4
4 5
Output
1
2
4
----------------------------------------------------------------------------------------------------
F. Sasha and the Wedding Binary Search Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 5
2 3 -1
-1 -1 2
4 -1 3
-1 5 -1
-1 -1 -1
3 69
2 3 47
-1 -1 13
-1 -1 69
3 3
2 3 -1
-1 -1 -1
-1 -1 -1
Output
4
1
10
----------------------------------------------------------------------------------------------------
