Codeforces Round 638 (Div. 2)


A. Phoenix and Balance
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
4
Output
2
6
----------------------------------------------------------------------------------------------------
B. Phoenix and Beauty
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 2
1 2 2 1
4 3
1 2 2 1
3 2
1 2 3
4 4
4 3 4 2
Output
5
1 2 1 2 1
4
1 2 2 1
-1
7
4 3 2 1 4 3 2
----------------------------------------------------------------------------------------------------
C. Phoenix and Distribution
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 2
baba
5 2
baacb
5 3
baacb
5 3
aaaaa
6 4
aaxxzz
7 1
phoenix
Output
ab
abbc
b
aa
x
ehinopx
----------------------------------------------------------------------------------------------------
D. Phoenix and Science
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
9
11
2
Output
3
1 0 2 
3
1 1 2
1
0 
----------------------------------------------------------------------------------------------------
E. Phoenix and Berries
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
5 2
2 1
Output
2
Input
1 5
2 3
Output
1
Input
2 5
2 1
1 3
Output
0
Input
1 2
1000000000 1
Output
500000000
----------------------------------------------------------------------------------------------------
F. Phoenix and Memory
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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