Codeforces Round 764 (Div. 3)


A. Plus One on the Subset
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6
3 4 2 4 1 2
3
1000 1002 998
2
12 11
Output
3
4
1
----------------------------------------------------------------------------------------------------
B. Make AP
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11
10 5 30
30 5 10
1 2 3
1 6 3
2 6 3
1 1 1
1 1 2
1 1 3
1 100000000 1
2 1 1
1 2 2
Output
YES
YES
YES
YES
NO
YES
NO
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Division by Two and Permutation
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4
1 8 25 2
2
1 1
9
9 8 3 4 2 7 1 5 6
3
8 2 1
4
24 7 16 7
5
22 6 22 4 22
Output
YES
NO
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
D. Palindromes Coloring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
8 2
bxyaxzay
6 3
aaaaaa
6 1
abcdef
6 6
abcdef
3 2
dxd
11 2
abcabcabcac
6 6
sipkic
7 2
eatoohd
3 1
llw
6 2
bfvfbv
Output
3
2
1
1
1
5
1
1
3
3
----------------------------------------------------------------------------------------------------
E. Masha-forgetful
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 8
12340219
20215601
56782022
12300678
12345678
2 3
134
126
123
1 4
1210
1221
4 3
251
064
859
957
054
4 7
7968636
9486033
4614224
5454197
9482268
Output
3
1 4 1
5 6 2
3 4 3
-1
2
1 2 1
2 3 1
-1
3
1 3 2
5 6 3
3 4 1
----------------------------------------------------------------------------------------------------
F. Interacdive Problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
Output
+ 1
! 3
Input
5
0
0
1
Output
+ 1
+ 1
+ 1
! 5
Input
10
0
0
1
2
Output
+ 2
+ 2
+ 3
+ 8
! 20
----------------------------------------------------------------------------------------------------
G. MinOr Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 3
1 2 1
2 3 2
1 3 2
5 7
4 2 7
2 5 8
3 4 2
3 2 1
2 4 2
4 1 2
1 2 2
3 4
1 2 1
2 3 2
1 3 3
3 1 4
Output
2
10
3
----------------------------------------------------------------------------------------------------
