Codeforces Round 865 (Div. 2)


A. Ian Visits Mary
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
3 4
4 4
3 6
2 2
1 1
7 3
2022 2023
1000000000 1000000000
Output
1
3 4
2
3 2
4 4
2
5 3
3 6
2
1 0
2 2
1
1 1
1
7 3
1
2022 2023
2
69420420 469696969
1000000000 1000000000
----------------------------------------------------------------------------------------------------
B. Grid Reconstruction
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
4
6
Output
3 2
1 4
8 2 6 4
1 5 3 7
11 5 9 1 7 3
6 10 2 8 4 12
----------------------------------------------------------------------------------------------------
C. Ian and Array Sorting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
1 3 2
2
2 1
4
1 3 5 7
4
2 1 4 3
5
5 4 3 2 1
Output
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
D. Sum Graph
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
6
1
1
1
1
1
2
-1
1
2
1
Output
+ 12
+ 2
+ 3
? 1 3
+ 5
? 1 5
? 4 5
! 1 4 2 5 3 6 1 2 3 4 5 6
! 1 2 2 1
----------------------------------------------------------------------------------------------------
E. Between
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 2
3 1
2 1
1 0
2 0
2 2
1 2
2 1
5 5
2 1
3 1
4 2
4 5
5 1
Output
FINITE
5
2 3 1 2 3 
FINITE
1
1 
INFINITE
FINITE
3
2 1 2 
FINITE
10
4 2 3 5 4 1 3 2 5 4 
----------------------------------------------------------------------------------------------------
F. XOR Counting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
69 1
5 2
0 10
420 69
12 26
73 34
1000000000000000000 10
Output
69
6
0
44310
42
1369
216734648
----------------------------------------------------------------------------------------------------
