Codeforces Round 951 (Div. 2)


A. Guess the Maximum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4
2 4 1 7
5
1 2 3 4 5
2
1 1
3
37 8 16
5
10 10 10 10 9
10
3 12 9 5 2 3 2 9 8 2
Output
3
1
0
15
9
2
----------------------------------------------------------------------------------------------------
B. XOR Sequences
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0 1
12 4
57 37
316560849 14570961
Output
1
8
4
33554432
----------------------------------------------------------------------------------------------------
C. Earning on Bets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3
3 2 7
2
3 3
5
5 5 5 5 5
6
7 9 3 17 9 13
3
6 3 2
5
9 4 6 8 3
Output
27 41 12 
1 1 
-1
1989 1547 4641 819 1547 1071 
-1
8 18 12 9 24
----------------------------------------------------------------------------------------------------
D. Fixing a Binary String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
8 4
11100001
4 2
1110
12 3
111000100011
5 5
00000
6 1
101001
8 4
01110001
12 2
110001100110
Output
3
-1
7
5
4
-1
3
----------------------------------------------------------------------------------------------------
E. Manhattan Triangle
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
6 4
3 1
0 0
0 -2
5 -3
3 -5
2 -2
5 4
0 0
0 -2
5 -3
3 -5
2 -2
6 6
3 1
0 0
0 -2
5 -3
3 -5
2 -2
4 4
3 0
0 3
-3 0
0 -3
10 8
2 1
-5 -1
-4 -1
-5 -3
0 1
-2 5
-4 4
-4 2
0 0
-4 1
4 400000
100000 100000
-100000 100000
100000 -100000
-100000 -100000
Output
2 6 1
4 3 5
3 5 1
0 0 0
6 1 3
0 0 0
----------------------------------------------------------------------------------------------------
F. Kostyanych's Theorem
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
0 0
1 4
2 3
4
1 0
4 2
2
1 0
Output
? 3
? 2
? 1
! 4 3 1 2
? 3
? 0
! 4 1 2 3
? 0
! 2 1
----------------------------------------------------------------------------------------------------
