Codeforces Round 421 (Div. 1)


A. Mister B and Boring Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 1 8
Output
2
Input
4 2 2 6
Output
3
Input
3 7 4 6
Output
1
----------------------------------------------------------------------------------------------------
B. Mister B and PR Shifts
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
0 0
Input
3
2 3 1
Output
0 1
Input
3
3 2 1
Output
2 1
----------------------------------------------------------------------------------------------------
C. Mister B and Beacons on Field
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1 1
2 1 1
1 1 3
1 5 1
2 2 1
1 1 2
10 6 18
2 103 2
13 1 13
Output
4
7
171
----------------------------------------------------------------------------------------------------
D. Mister B and Astronomers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
2 3
Output
3 1 
Input
5 4
1 1 1 1
Output
2 1 1 1 
----------------------------------------------------------------------------------------------------
E. Mister B and Flight to the Moon
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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