Educational Codeforces Round 99 (Rated for Div. 2)


A. Strange Functions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
37
998244353
1000000007
12345678901337426966631415
Output
1
2
9
10
26
----------------------------------------------------------------------------------------------------
B. Jumps
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
2
3
4
5
Output
1
3
2
3
4
----------------------------------------------------------------------------------------------------
C. Ping-pong
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1
2 1
1 7
Output
0 1
1 1
0 7
----------------------------------------------------------------------------------------------------
D. Sequence and Swaps
time limit per test: 1.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
4 1
2 3 5 4
5 6
1 1 3 4 4
1 10
2
2 10
11 9
2 10
12 11
5 18
81 324 218 413 324
Output
3
0
0
-1
1
3
----------------------------------------------------------------------------------------------------
E. Four Points
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 2
4 2
2 0
2 4
1 0
2 0
4 0
6 0
1 6
2 2
2 5
4 1
Output
8
7
5
----------------------------------------------------------------------------------------------------
F. String and Operations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4 2
bbab
7 5
cceddda
6 5
ecdaed
7 4
dcdbdaa
8 3
ccabbaca
5 7
eabba
Output
aaaa
baccacd
aabdac
aabacad
aaaaaaaa
abadb
----------------------------------------------------------------------------------------------------
G. Forbidden Value
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
set 1 10
set 2 15
if 2
set 1 7
end
Output
17
Input
7 2
set 3 4
if 3
set 10 4
set 2 7
set 10 1
end
set 4 2
Output
4
Input
9 200
if 0
set 5 5
if 5
set 100 13
end
if 100
set 200 1
end
end
Output
1
Input
1 10
set 1 15
Output
0
----------------------------------------------------------------------------------------------------
