Codeforces Raif Round 1 (Div. 1 + Div. 2)


A. Box is Pull
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2 2 2
1 1 2 2
Output
1
4
----------------------------------------------------------------------------------------------------
B. Belted Rooms
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
-><-
5
>>>>>
3
<--
2
<>
Output
3
5
3
0
----------------------------------------------------------------------------------------------------
C. ABBB
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
AAA
BABA
AABBBABBBB
Output
3
2
0
----------------------------------------------------------------------------------------------------
D. Bouncing Boomerangs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 0 3 0 1 1
Output
5
2 1
2 5
3 3
3 6
5 6
Input
1
0
Output
0
Input
6
3 2 2 2 1 1
Output
-1
----------------------------------------------------------------------------------------------------
E. Carrots for Rabbits
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 6
5 3 1
Output
15
Input
1 4
19
Output
91
----------------------------------------------------------------------------------------------------
F. Fruit Sequences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0110
Output
12
Input
7
1101001
Output
30
Input
12
011100011100
Output
156
----------------------------------------------------------------------------------------------------
G1. Lucky Numbers (Easy Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3 4 5 6
1
57
Output
11
Input
3
1 2 3 4 5 6
1
63
Output
8
----------------------------------------------------------------------------------------------------
G2. Lucky Numbers (Hard Version)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3 4 5 6
2
57
63
Output
11
8
----------------------------------------------------------------------------------------------------
H. Rotary Laser Lock
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
4
4
3
Output
? 0 1
? 2 -1
? 1 1
! 1 5
----------------------------------------------------------------------------------------------------
