Codeforces Round 433 (Div. 2, based on Olympiad of Metropolises)


A. Fraction
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
1 2
Input
4
Output
1 3
Input
12
Output
5 7
----------------------------------------------------------------------------------------------------
B. Maxim Buys an Apartment
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 3
Output
1 3
----------------------------------------------------------------------------------------------------
C. Planning
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 2
4 2 1 10 2
Output
20
3 6 7 4 5 
----------------------------------------------------------------------------------------------------
D. Jury Meeting
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 6 5
1 1 0 5000
3 2 0 5500
2 2 0 6000
15 0 2 9000
9 0 1 7000
8 0 2 6500
Output
24500
Input
2 4 5
1 2 0 5000
2 1 0 4500
2 1 0 3000
8 0 1 6000
Output
-1
----------------------------------------------------------------------------------------------------
E. Boredom
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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