Codeforces Round 756 (Div. 3)


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

Examples
Input
4
3876
387
4489
3
Output
0
2
1
-1
----------------------------------------------------------------------------------------------------
B. Team Composition: Programmers and Mathematicians
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5 5
10 1
2 3
0 0
17 2
1000000000 1000000000
Output
2
1
1
0
2
500000000
----------------------------------------------------------------------------------------------------
C. Polycarp Recovers the Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
1 3 2 4
1
1
5
1 3 5 4 2
3
3 2 1
Output
3 1 4 2
1
-1
2 3 1
----------------------------------------------------------------------------------------------------
D. Weights Assignment For Tree Edges
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
3 1 3 3 1
3 1 2 5 4
3
1 1 2
3 1 2
7
1 1 2 3 4 5 6
1 2 3 4 5 6 7
6
4 4 4 4 1 1
4 2 1 5 6 3
Output
1 10 0 102 100
-1
0 3 100 1 1 2 4
6 5 10 0 2 3
----------------------------------------------------------------------------------------------------
E1. Escape The Maze (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
8 2
5 3
4 7
2 5
1 6
3 6
7 2
1 7
6 8
3 1
2
1 2
2 3
3 1
2
1 2
1 3
3 2
2 3
3 1
1 2
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
E2. Escape The Maze (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
8 2
5 3
4 7
2 5
1 6
3 6
7 2
1 7
6 8
8 4
6 5 7 3
4 7
2 5
1 6
3 6
7 2
1 7
6 8
3 1
2
1 2
2 3
3 2
2 3
3 1
1 2
Output
-1
2
1
2
----------------------------------------------------------------------------------------------------
F. ATM and Students
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 10
-16 2 -6 8
3 1000
-100000 -100000 -100000
6 0
2 6 -164 1 -1 -6543
Output
2 4
-1
1 2
----------------------------------------------------------------------------------------------------
G. Robot and Candies
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 2
00
00
3 3
100
000
101
4 5
01000
00001
00010
10000
3 3
111
111
111
Output
0
2
2
4
----------------------------------------------------------------------------------------------------
