Codeforces Round 776 (Div. 3)


A. Deletions of Two Adjacent Letters
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
abcde
c
abcde
b
x
y
aaaaaaaaaaaaaaa
a
contest
t
Output
YES
NO
NO
YES
YES
----------------------------------------------------------------------------------------------------
B. DIV + MOD
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 4 3
5 8 4
6 10 6
1 1000000000 1000000000
10 12 8
Output
2
4
5
999999999
5
----------------------------------------------------------------------------------------------------
C. Weight of the System of Nested Segments
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 8
0 10
-2 1
4 10
11 20
7 -1
9 1
2 3
5 -2
3 6
-1 2
1 3
3 -1
2 4
4 0
8 2
2 5
5 -1
3 -2
1 0
-2 0
-5 -3
Output
12
2 6
5 1
7 8
10
1 6
5 2
3 4
-6
5 1
4 2
----------------------------------------------------------------------------------------------------
D. Twist the Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
6
3 2 5 6 1 4
3
3 1 2
8
5 8 1 3 2 6 4 7
Output
0 1 1 2 0 4 
0 0 1 
0 1 2 0 2 5 6 2 
----------------------------------------------------------------------------------------------------
E. Rescheduling the Exam
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9
3 12
3 5 9
2 5
1 5
2 100
1 2
5 15
3 6 9 12 15
3 1000000000
1 400000000 500000000
2 10
3 4
2 2
1 2
4 15
6 11 12 13
2 20
17 20
Output
2
1
1
2
99999999
3
0
1
9
----------------------------------------------------------------------------------------------------
F. Vitaly and Advanced Useless Algorithms
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 5
5 7 8
1 1 30
2 3 50
2 3 100
1 1 80
3 3 100
1 5
51
1 36 91
1 8 40
1 42 83
1 3 45
1 13 40
2 9
9 20
2 8 64
2 7 64
1 20 56
2 8 76
2 20 48
1 2 89
1 3 38
2 18 66
1 7 51
3 2
7 18 33
1 5 80
3 4 37
2 5
569452312 703565975
1 928391659 66
1 915310 82
2 87017081 92
1 415310 54
2 567745964 82
Output
4
1 4 3 5 
3
2 4 5 
4
6 7 1 2 
-1
4
2 4 3 5 
Input
3
3 9
20 31 40
1 9 64
3 17 100
3 9 59
3 18 57
3 20 49
2 20 82
2 14 95
1 8 75
2 16 67
2 6
20 36
2 2 66
2 20 93
1 3 46
1 10 64
2 8 49
2 18 40
1 1
1000000000
1 1000000000 100
Output
-1
4
3 4 1 5 
1
1 
----------------------------------------------------------------------------------------------------
G. Counting Shortcuts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 4
1 4
1 2
3 4
2 3
2 4
6 8
6 1
1 4
1 6
1 5
1 2
5 6
4 6
6 3
2 6
5 6
1 3
3 5
5 4
3 1
4 2
2 1
1 4
8 18
5 1
2 1
3 1
4 2
5 2
6 5
7 3
8 4
6 4
8 7
1 4
4 7
1 6
6 7
3 8
8 5
4 5
4 3
8 2
Output
2
4
1
11
----------------------------------------------------------------------------------------------------
