Codeforces Round 796 (Div. 1)


A. 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
----------------------------------------------------------------------------------------------------
B. 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
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. Cute number
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 8 10
Output
1
Input
5
2 3 8 9 11
Output
8
Input
8
1 2 3 4 5 6 7 8
Output
48
----------------------------------------------------------------------------------------------------
E. Become Big For Me
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
6 10 15
Output
1
0 3 1 2 3
Input
4
2 4 8 16
Output
2
0 1 4
1 1 1
----------------------------------------------------------------------------------------------------
F. Koishi's Unconscious Permutation
time limit per test: 12 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
2 0
Output
1 0
Input
4 1
Output
0 3 6 0
Input
8 3
Output
0 0 0 35 770 980 70 0
----------------------------------------------------------------------------------------------------
