Codeforces Round 846 (Div. 2)


A. Hayato and School
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3
1 1 1
4
1 1 2 2
3
1 2 3
5
1 4 5 1 2
4
2 6 2 4
5
5 6 3 2 1
Output
YES
1 2 3
YES
3 4 1
NO
YES
1 3 4
NO
YES
1 3 5
----------------------------------------------------------------------------------------------------
B. GCD Partition
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4
2 2 1 3
2
1 2
3
1 4 5
6
1 2 1 1 1 3
10
12 30 37 88 12 78 89 17 2 12
6
7 7 7 7 7 7
Output
4
1
5
3
1
21
----------------------------------------------------------------------------------------------------
D. Bit Guessing Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
0
1
1
0
2
1
0
Output
- 1
! 1
- 1
- 1
! 2
- 2
- 1
! 3
----------------------------------------------------------------------------------------------------
E. Josuke and Complete Graph
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2 4
16 24
2 6
1 10
3 3
2562 2568
125 100090
Output
2
6
3
5
0
5
50045
----------------------------------------------------------------------------------------------------
F. Three Chairs
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
1
Input
4
1 6 2 3
Output
3
Input
4
16 4 8 2
Output
0
Input
10
10 1 6 7 9 8 4 3 5 2
Output
77
----------------------------------------------------------------------------------------------------
G. Delicious Dessert
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
abacaba
Output
11
Input
8
abaababa
Output
11
Input
10
deadinside
Output
12
Input
5
aaaaa
Output
12
----------------------------------------------------------------------------------------------------
