Codeforces Round 529 (Div. 3)


A. Repeating Cipher
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
baabbb
Output
bab
Input
10
ooopppssss
Output
oops
Input
1
z
Output
z
----------------------------------------------------------------------------------------------------
B. Array Stabilization
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 3 7
Output
2
Input
2
1 100000
Output
0
----------------------------------------------------------------------------------------------------
C. Powers Of Two
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 4
Output
YES
1 2 2 4 
Input
8 1
Output
YES
8 
Input
5 1
Output
NO
Input
3 7
Output
NO
----------------------------------------------------------------------------------------------------
D. Circular Dance
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 5
1 4
2 4
1 5
2 3
Output
3 2 4 1 5 
Input
3
2 3
3 1
1 2
Output
3 1 2 
----------------------------------------------------------------------------------------------------
E. Almost Regular Bracket Sequence
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
(((())
Output
3
Input
6
()()()
Output
0
Input
1
)
Output
0
Input
8
)))(((((
Output
0
----------------------------------------------------------------------------------------------------
F. Make It Connected
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 3 3
2 3 5
2 1 1
Output
5
Input
4 0
1 3 3 7
Output
16
Input
5 4
1 2 3 4 5
1 2 8
1 3 10
1 4 7
1 5 15
Output
18
----------------------------------------------------------------------------------------------------
