Codeforces Round 850 (Div. 2, based on VK Cup 2022 - Final Round)


A1. Non-alternating Deck (easy version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
10
6
17
8
1000000
Output
5 5
1 5
10 7
3 5
500202 499798
----------------------------------------------------------------------------------------------------
A2. Alternating Deck (hard version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
10
6
17
8
1000000
Output
3 2 2 3
1 0 2 3
6 4 3 4
2 1 2 3
250278 249924 249722 250076
----------------------------------------------------------------------------------------------------
B. Cake Assembly Line
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 10 5
65 95 165
40 65 145
5 2 1
1 6 11 16 21
4 9 14 19 24
3 3 2
13 22 29
5 16 25
4 4 1
27 36 127 136
35 50 141 144
Output
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Monsters (easy version)
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
3
3 1 2
6
4 1 5 4 1 1
Output
0
4
----------------------------------------------------------------------------------------------------
D. Letter Exchange
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
2
nwi
inw
3
inn
nww
wii
4
win
www
iii
nnn
Output
0
2
2 w 3 i
3 w 1 n
3
2 w 3 i
2 w 4 n
3 i 4 n
----------------------------------------------------------------------------------------------------
E. Monsters (hard version)
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
3
3 1 2
6
4 1 5 4 1 1
Output
2 1 0
3 2 4 4 4 4
----------------------------------------------------------------------------------------------------
F. Wooden Spoon
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
0
2
Input
2
Output
0
0
8
16
Input
3
Output
0
0
0
1536
4224
7680
11520
15360
----------------------------------------------------------------------------------------------------
