Codeforces Round 350 (Div. 2)


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

Examples
Input
14
Output
4 4
Input
2
Output
0 2
----------------------------------------------------------------------------------------------------
B. Game of Robots
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
1 2
Output
1
Input
4 5
10 4 18 3
Output
4
----------------------------------------------------------------------------------------------------
C. Cinema
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 2
2
3 2
2 3
Output
2
Input
6
6 3 1 1 3 7
5
1 2 3 4 5
2 3 4 5 1
Output
1
----------------------------------------------------------------------------------------------------
D1. Magic Powder - 1
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
2 1 4
11 3 16
Output
4
Input
4 3
4 3 5 6
11 12 14 20
Output
3
----------------------------------------------------------------------------------------------------
D2. Magic Powder - 2
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1000000000
1
1000000000
Output
2000000000
Input
10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
1 1 1 1 1 1 1 1 1 1
Output
0
Input
3 1
2 1 4
11 3 16
Output
4
Input
4 3
4 3 5 6
11 12 14 20
Output
3
----------------------------------------------------------------------------------------------------
E. Correct Bracket Sequence Editor
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 4 5
(())()()
RDLD
Output
()
Input
12 5 3
((()())(()))
RRDLD
Output
(()(()))
Input
8 8 8
(())()()
LLLLLLDD
Output
()()
----------------------------------------------------------------------------------------------------
F. Restore a Number
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
003512
021
Output
30021
Input
199966633300
63
Output
3036366999
----------------------------------------------------------------------------------------------------
