Codeforces Round 603 (Div. 2)


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

Examples
Input
6
1 1 1
1 2 1
4 1 1
7 4 10
8 1 4
8 2 8
Output
1
2
2
10
5
9
----------------------------------------------------------------------------------------------------
B. PIN Codes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
1234
0600
2
1337
1337
4
3139
3139
3139
3139
Output
0
1234
0600
1
1337
1237
3
3139
3138
3939
6139
----------------------------------------------------------------------------------------------------
C. Everyone is a Winner!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
11
1
3
Output
4
0 1 2 5 
6
0 1 2 3 5 11 
2
0 1 
3
0 1 3 
----------------------------------------------------------------------------------------------------
D. Secret Passwords
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
a
b
ab
d
Output
2
Input
3
ab
bc
abc
Output
1
Input
1
codeforces
Output
1
----------------------------------------------------------------------------------------------------
E. Editor
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11
(RaRbR)L)L(
Output
-1 -1 -1 -1 -1 -1 1 1 -1 -1 2 
Input
11
(R)R(R)Ra)c
Output
-1 -1 1 1 -1 -1 1 1 1 -1 1 
----------------------------------------------------------------------------------------------------
F. Economic Difficulties
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6
4 1 1 4 2
6 5 3
4
1 1 1
3 4 2
Output
5
Input
4
6
4 4 1 1 1
3 2 6 5
6
6 6 1 1 1
5 4 3 2
Output
6
Input
5
14
1 1 11 2 14 14 13 7 12 2 5 6 1
9 8 3 10 4
16
1 1 9 9 2 5 10 1 14 3 7 11 6 12 2
8 16 13 4 15
Output
17
----------------------------------------------------------------------------------------------------
