Good Bye 2021: 2022 is NEAR


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

Examples
Input
3
4
1 1 2 2
3
1 2 3
2
0 0
Output
4
3
1
----------------------------------------------------------------------------------------------------
B. Mirror in the String
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
10
codeforces
9
cbacbacba
3
aaa
4
bbaa
Output
cc
cbaabc
aa
bb
----------------------------------------------------------------------------------------------------
C. Representative Edges
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
1 2 3 4
4
1 1 2 2
2
0 -1
6
3 -2 4 -1 -4 0
1
-100
Output
0
2
0
3
0
----------------------------------------------------------------------------------------------------
D. Keep the Average High
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
1 2 3 4 5
2
10
2 4 2 4 2 4 2 4 2 4
3
3
-10 -5 -10
-8
3
9 9 -3
5
Output
4
8
2
2
----------------------------------------------------------------------------------------------------
E. Lexicographically Small Enough
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
a
a
3
rll
rrr
3
caa
aca
5
ababa
aabba
Output
-1
0
2
2
----------------------------------------------------------------------------------------------------
F. Tricolor Triangles
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 3
1 2 1
2 3 2
3 1 -1
3 3
1 2 1
2 3 1
3 1 -1
4 4
1 2 -1
2 3 -1
3 4 -1
4 1 -1
3 3
1 2 1
2 3 1
3 1 2
Output
1 2 3 
1 1 1 
1 2 2 3 
-1
----------------------------------------------------------------------------------------------------
G. Just Add an Edge
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 2
1 2
2 3
4 3
1 2
3 4
1 4
4 4
1 3
1 4
2 3
3 4
Output
3
1
4
----------------------------------------------------------------------------------------------------
H. Keep XOR Low
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
0 1 2 3
Output
8
Input
3 6
4 2 2
Output
7
Input
4 0
1 1 2 2
Output
6
----------------------------------------------------------------------------------------------------
