Codeforces Round 878 (Div. 3)


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

Examples
Input
3
8
abacabac
5
qzxcq
20
ccooddeeffoorrcceess
Output
ac
q
codeforces
----------------------------------------------------------------------------------------------------
B. Binary Cafe
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2
2 1
2 2
10 2
179 100
Output
2
2
3
4
180
----------------------------------------------------------------------------------------------------
C. Ski Resort
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
3 1 15
-5 0 -10
5 3 -33
8 12 9 0 5
4 3 12
12 12 10 15
4 1 -5
0 -1 2 5
5 5 0
3 -1 4 -5 -3
1 1 5
5
6 1 3
0 3 -2 5 -4 -4
Output
6
0
1
0
0
1
9
----------------------------------------------------------------------------------------------------
D. Wooden Toy Festival
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
6
1 7 7 9 9 9
6
5 4 2 1 30 60
9
14 19 37 59 1 4 4 98 73
1
2
6
3 10 1 17 15 11
Output
0
2
13
0
1
----------------------------------------------------------------------------------------------------
E. Character Blocking
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
codeforces
codeblocks
5 7
3
1 5
1 6
1 7
1 9
3
3
cool
club
2 5
2 1 2 2 3
2 2 2 2 4
1 2
3
3
Output
NO
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
F. Railguns
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3
4
1 2 0
2 2 1
3 2 2
4 1 1
3 3
6
2 1 0
2 1 1
2 1 2
2 2 0
2 2 1
2 2 2
2 1
3
7 1 2
2 1 1
7 2 1
2 2
5
9 1 2
3 2 0
5 1 2
4 2 2
7 1 0
4 6
7
6 1 2
12 1 3
4 1 0
17 2 3
1 2 6
16 2 6
3 2 4
Output
5
-1
3
6
10
----------------------------------------------------------------------------------------------------
G1. In Search of Truth (Easy Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5
6
7
2
10
9
8
4
3
1
Output
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
! 10
----------------------------------------------------------------------------------------------------
G2. In Search of Truth (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5
6
7
2
10
9
8
4
3
1
Output
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
! 10
----------------------------------------------------------------------------------------------------
