Codeforces Round 457 (Div. 2)


A. Jamie and Alarm Snooze
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
11 23
Output
2
Input
5
01 07
Output
0
----------------------------------------------------------------------------------------------------
B. Jamie and Binary Sequence (changed after round)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
23 5
Output
Yes
3 3 2 1 0 
Input
13 2
Output
No
Input
1 2
Output
Yes
-1 -1 
----------------------------------------------------------------------------------------------------
C. Jamie and Interesting Graph
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
Output
7 7
1 2 3
2 3 2
3 4 2
2 4 4
Input
5 4
Output
7 13
1 2 2
1 3 4
1 4 3
4 5 4
----------------------------------------------------------------------------------------------------
D. Jamie and To-do List
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
8
set chemlabreport 1
set physicsexercise 2
set chinesemockexam 3
query physicsexercise
query chinesemockexam
remove physicsexercise
query physicsexercise
query chinesemockexam
Output
1
2
-1
1
Input
8
set physicsexercise 2
set chinesemockexam 3
set physicsexercise 1
query physicsexercise
query chinesemockexam
undo 4
query physicsexercise
query chinesemockexam
Output
0
1
0
-1
Input
5
query economicsessay
remove economicsessay
query economicsessay
undo 2
query economicsessay
Output
-1
-1
-1
Input
5
set economicsessay 1
remove economicsessay
undo 1
undo 1
query economicsessay
Output
-1
----------------------------------------------------------------------------------------------------
E. Jamie and Tree
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 7
1 4 2 8 5 7
1 2
3 1
4 3
4 5
3 6
3 1
2 4 6 3
3 4
1 6
2 2 4 -5
1 4
3 3
Output
27
19
5
Input
4 6
4 3 5 6
1 2
2 3
3 4
3 1
1 3
2 2 4 3
1 1
2 2 4 -3
3 1
Output
18
21
----------------------------------------------------------------------------------------------------
