Codeforces Round 436 (Div. 2)


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

Examples
Input
4
11
27
27
11
Output
YES
11 27
Input
2
6
6
Output
NO
Input
6
10
20
30
20
10
20
Output
NO
Input
6
1
1
2
2
3
3
Output
NO
----------------------------------------------------------------------------------------------------
B. Polycarp and Letters
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11
aaaaBaabAbA
Output
2
Input
12
zACaAbbaazzC
Output
3
Input
3
ABC
Output
0
----------------------------------------------------------------------------------------------------
C. Bus
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 9 2 4
Output
4
Input
6 10 2 4
Output
2
Input
6 5 4 3
Output
-1
----------------------------------------------------------------------------------------------------
D. Make a Permutation!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2 2 3
Output
2
1 2 4 3 
Input
6
4 5 6 3 2 1
Output
0
4 5 6 3 2 1 
Input
10
6 8 4 6 7 1 6 3 4 5
Output
3
2 8 4 6 7 1 9 3 10 5 
----------------------------------------------------------------------------------------------------
E. Fire
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 7 4
2 6 5
3 7 6
Output
11
2
2 3 
Input
2
5 6 1
3 3 5
Output
1
1
1 
----------------------------------------------------------------------------------------------------
F. Cities Excursions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 7 5
1 2
2 3
1 3
3 4
4 5
5 3
4 6
1 4 2
2 6 1
1 7 3
1 3 2
1 3 5
Output
2
-1
-1
2
-1
----------------------------------------------------------------------------------------------------
