Educational Codeforces Round 139 (Rated for Div. 2)


A. Extremely Round
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
9
42
13
100
111
Output
9
13
10
19
19
----------------------------------------------------------------------------------------------------
B. Notepad#
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
10
codeforces
8
labacaba
5
uohhh
16
isthissuffixtree
1
x
4
momo
Output
NO
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Hamiltonian Wall
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3
WBB
BBW
1
B
B
5
BWBWB
BBBBB
2
BW
WB
5
BBBBW
BWBBB
6
BWBBWB
BBBBBB
Output
YES
YES
NO
NO
NO
YES
----------------------------------------------------------------------------------------------------
D. Lucky Chains
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
5 15
13 37
8 9
10009 20000
Output
0
1
-1
79
----------------------------------------------------------------------------------------------------
E. Decomposition
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
8
1 3 2 0 1 3 2 1
Output
71
Input
5
0 0 0 0 0
Output
35
----------------------------------------------------------------------------------------------------
F. MCF
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2 3 -10
1 2 3 -15
2 3 2 0
Output
Possible
1 1 2
Input
3 3
1 2 3 -10
1 2 3 -15
2 3 3 0
Output
Impossible
Input
3 3
1 2 3 -10
1 2 3 -15
2 3 4 0
Output
Possible
1 3 4
Input
6 7
5 6 9 -40
1 2 3 -10
1 4 5 20
4 5 7 30
2 5 1 -15
1 3 3 5
3 5 3 0
Output
Possible
5 1 1 1 1 3 3
----------------------------------------------------------------------------------------------------
