Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)


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

Examples
Input
3
3 4 2
4 5 0
325 265 1231232
Output
7
4
76
----------------------------------------------------------------------------------------------------
B. Uniqueness
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
0
Input
4
1 1 2 2
Output
2
Input
5
1 4 1 4 9
Output
2
----------------------------------------------------------------------------------------------------
C. Magic Grid
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
8 9 1 13
3 12 7 5
0 2 4 11
6 10 15 14
Input
8
Output
19 55 11 39 32 36 4 52
51 7 35 31 12 48 28 20
43 23 59 15 0 8 16 44
3 47 27 63 24 40 60 56
34 38 6 54 17 53 9 37
14 50 30 22 49 5 33 29
2 10 18 46 41 21 57 13
26 42 62 58 1 45 25 61
----------------------------------------------------------------------------------------------------
D. Restore Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0 0
Output
3 2 1
Input
2
0 1
Output
1 2
Input
5
0 1 1 1 10
Output
1 4 3 2 5
----------------------------------------------------------------------------------------------------
E. Let Them Slide
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
3 2 4 8
2 2 5
2 6 3
Output
10 15 16 
Input
2 2
2 7 8
1 -8
Output
7 8 
----------------------------------------------------------------------------------------------------
F. Bits And Pieces
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 4 6
Output
6
Input
4
2 8 4 7
Output
12
----------------------------------------------------------------------------------------------------
G. Polygons
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2
Output
6
Input
200 50
Output
708
----------------------------------------------------------------------------------------------------
H. Red Blue Tree
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1 2
1 3
2 4
2 5
-1 -1 0 1 0
9
1 1
1 2
3 -2
1 1
1 2
3 1
2 5 1
1 1
1 2
Output
0
0
1
1
0
1
----------------------------------------------------------------------------------------------------
