Codeforces Round 922 (Div. 2)


A. Brick Wall
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 2
7 8
16 9
3 5
10000 10000
Output
2
28
64
6
50000000
----------------------------------------------------------------------------------------------------
B. Minimize Inversions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5
1 2 3 4 5
5 4 3 2 1
3
3 1 2
3 1 2
6
2 5 6 1 3 4
1 5 3 6 2 4
Output
3 2 5 1 4
3 4 1 5 2
1 2 3
1 2 3
2 3 4 6 5 1
1 2 4 3 5 6
----------------------------------------------------------------------------------------------------
C. XOR-distance
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
4 6 0
0 3 2
9 6 10
92 256 23
165 839 201
1 14 5
2 7 2
96549 34359 13851
853686404475946 283666553522252166 127929199446003072
735268590557942972 916721749674600979 895150420120690183
Output
2
1
1
164
542
5
3
37102
27934920819538516
104449824168870225
----------------------------------------------------------------------------------------------------
D. Blocking Elements
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6
1 4 5 3 3 2
5
1 2 3 4 5
6
4 1 6 3 10 7
Output
7
5
11
----------------------------------------------------------------------------------------------------
E. ace5 and Task Order
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
>
=
<
=
<
<
2
>
Output
? 4
? 2
? 1
? 5
? 1
? 3
! 2 4 1 5 3
? 1
! 2 1 
----------------------------------------------------------------------------------------------------
F. Caterpillar on a Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 1
1 1 2 2 4 3 3
Output
9
Input
4 0
4 4 1
Output
4
----------------------------------------------------------------------------------------------------
G. Permutation of Given
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
YES
1 2 -2 -1
Input
5
Output
NO
----------------------------------------------------------------------------------------------------
