Codeforces Round 611 (Div. 3)


A. Minutes Before the New Year
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
23 55
23 0
0 1
4 20
23 59
Output
5
60
1439
1180
1
----------------------------------------------------------------------------------------------------
B. Candies Division
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 2
19 4
12 7
6 2
100000 50010
Output
5
18
10
6
75015
----------------------------------------------------------------------------------------------------
C. Friends and Gifts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 0 0 2 4
Output
5 3 1 2 4 
Input
7
7 0 0 1 4 0 6
Output
7 3 2 1 4 5 6 
Input
7
7 4 0 3 0 5 1
Output
7 4 2 3 6 5 1 
Input
5
2 1 0 0 0
Output
2 1 4 5 3 
----------------------------------------------------------------------------------------------------
D. Christmas Trees
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4
1 2 4 4
Output
2 4
Input
9
1 1 8 8 8 4 4 4 4
Output
3 8
Input
7
4 3 7 1 4 3 3
Output
3 6
----------------------------------------------------------------------------------------------------
F. DIY Garland
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3 6 3 1 5
Output
3
6 3
6 5
1 3
1 4
5 2
----------------------------------------------------------------------------------------------------
