Codeforces Round 687 (Div. 1, based on Technocup 2021 Elimination Round 2)


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

Examples
Input
3
10 3 2
0101010101
2 2
5 4 1
00000
2 10
11 2 3
10110011000
4 3
Output
2
4
10
----------------------------------------------------------------------------------------------------
B. XOR-gun
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 5 6 8
Output
1
Input
3
1 2 3
Output
-1
Input
5
1 2 4 6 20
Output
2
----------------------------------------------------------------------------------------------------
C. New Game Plus!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 0
1 1 1
Output
3
Input
5 1
-1 -2 -3 -4 5
Output
11
Input
13 2
3 1 4 1 5 -9 -2 -6 -5 -3 -5 -8 -9
Output
71
----------------------------------------------------------------------------------------------------
D. Cakes for Clones
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 2
5 5
6 1
Output
YES
Input
3
1 0
5 5
6 2
Output
YES
Input
3
2 1
5 5
6 0
Output
NO
----------------------------------------------------------------------------------------------------
E. XOR-ranges
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
3 3
5 5
6 6
1 1
5 2 7
Output
30
Input
3 3
2 2
3 4
4 6
1 10 100
Output
102
----------------------------------------------------------------------------------------------------
