Codeforces Round 851 (Div. 2)


A. One and Two
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6
2 2 1 2 1 2
3
1 2 1
4
1 1 1 1
Output
2
-1
1
----------------------------------------------------------------------------------------------------
B. Sum of Two Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
161
67
1206
19
Output
1 0
67 94
60 7
1138 68
14 5
----------------------------------------------------------------------------------------------------
C. Matching Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
2
3
4
Output
Yes
1 2
No
Yes
1 6
3 5
4 2
No
----------------------------------------------------------------------------------------------------
D. Moving Dots
time limit per test: 1.5 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 4 6
Output
11
Input
5
1 3 5 11 15
Output
30
----------------------------------------------------------------------------------------------------
E. Sum Over Zero
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 -3 -2 5 -4
Output
4
Input
10
5 -2 -4 -6 2 3 -6 5 3 -2
Output
9
Input
4
-1 -2 -3 -4
Output
0
----------------------------------------------------------------------------------------------------
F. XOR, Tree, and Queries
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2
2 3
3 4
1 4 3
2 4 2
1 3 1
2 3 1
Output
No
Input
6 2
1 2
2 3
3 4
2 5
5 6
1 4 2
2 6 7
Output
Yes
4 2 4 1 6
Input
6 2
1 2
2 3
3 4
2 5
5 6
1 4 3
1 6 5
Output
Yes
6 1 4 3 0
----------------------------------------------------------------------------------------------------
