Codeforces Round 796 (Div. 2)


A. Cirno's Perfect Bitmasks Classroom
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1
2
5
9
16
114514
1000000
Output
3
3
1
1
17
2
64
----------------------------------------------------------------------------------------------------
B. Patchouli's Magical Talisman
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1 9
3
1 1 2
3
2 4 8
3
1049600 33792 1280
Output
0
1
3
10
----------------------------------------------------------------------------------------------------
C. Manipulating History
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
a
ab
b
cd
acd
3
z
a
a
aa
yakumo
ran
yakumoran
Output
a
z
----------------------------------------------------------------------------------------------------
D. The Enchanted Forest
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5 2
5 6 1 2 3
5 7
5 6 1 2 3
1 2
999999
5 70000
1000000000 1000000000 1000000000 1000000000 1000000000
Output
12
37
1000000
5000349985
----------------------------------------------------------------------------------------------------
E. Railway System
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
0
5
9
7
Output
? 0000
? 1110
? 1111
? 1101
! 7
----------------------------------------------------------------------------------------------------
F. Sanae and Giant Robot
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 2
1 5 4 2 3
3 2 5 4 1
1 3
2 5
5 2
1 5 4 2 3
3 2 4 5 1
1 2
2 4
Output
YES
NO
----------------------------------------------------------------------------------------------------
