Avito Cool Challenge 2018


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

Examples
Input
8
Output
1
Input
1
Output
1
----------------------------------------------------------------------------------------------------
B. Farewell Party
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0 0
Output
Possible
1 1 1 
Input
5
3 3 2 2 2
Output
Possible
1 1 2 2 2 
Input
4
0 1 2 3
Output
Impossible
----------------------------------------------------------------------------------------------------
C. Colorful Bricks
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 0
Output
3
Input
3 2 1
Output
4
----------------------------------------------------------------------------------------------------
D. Maximum Distance
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3 2
2 1
1 2 3
1 2 2
2 2 1
Output
2 2 
Input
4 5 3
1 2 3
1 2 5
4 2 1
2 3 2
1 4 4
1 3 3
Output
3 3 3 
----------------------------------------------------------------------------------------------------
E. Missing Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5 11 44
Output
Yes
4 5 16 11 64 44
Input
2
9900
Output
Yes
100 9900
Input
6
314 1592 6535
Output
No
----------------------------------------------------------------------------------------------------
F. Tricky Interactor
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
2
2
0
Output
? 1 1
? 1 1
? 3 4
! 0011
----------------------------------------------------------------------------------------------------
G. Mergesort Strikes Back
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 998244353
Output
499122178
Input
3 2 998244353
Output
665496236
Input
9 3 998244353
Output
449209967
Input
9 4 998244353
Output
665496237
----------------------------------------------------------------------------------------------------
H. Palindromic Magic
time limit per test: 2.5 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
aa
aba
Output
6
Input
aaba
abaa
Output
15
----------------------------------------------------------------------------------------------------
