Codeforces Round 800 (Div. 2)


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

Examples
Input
5
1 1
1 2
5 2
4 5
3 7
Output
10
011
0011000
101010101
0001111111
----------------------------------------------------------------------------------------------------
B. Paranoid String
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
1
2
01
3
100
4
1001
5
11111
Output
1
3
4
8
5
----------------------------------------------------------------------------------------------------
C. Directional Increase
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2
1 0
4
2 -1 -1 0
4
1 -4 3 0
4
1 -1 1 -1
5
1 2 3 4 -10
7
2 -1 1 -2 0 0 0
1
0
Output
No
Yes
No
No
Yes
Yes
Yes
----------------------------------------------------------------------------------------------------
D. Fake Plastic Trees
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1
1 5
2 9
3
1 1
4 5
2 4
6 10
4
1 2 1
6 9
5 6
4 5
2 4
5
1 2 3 4
5 5
4 4
3 3
2 2
1 1
Output
1
2
2
5
----------------------------------------------------------------------------------------------------
E. Keshi in Search of AmShZ
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
1 2
Output
1
Input
4 4
1 2
1 4
2 4
1 4
Output
2
Input
5 7
1 2
2 3
3 5
1 4
4 3
4 5
3 1
Output
4
----------------------------------------------------------------------------------------------------
F. Decinc Dividing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 1
Output
6
Input
6
4 5 2 6 1 3
Output
19
Input
10
7 10 1 8 3 9 2 4 6 5
Output
39
----------------------------------------------------------------------------------------------------
