Codeforces Round 359 (Div. 1)


A. Robbers' watch
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
Output
4
Input
8 2
Output
5
----------------------------------------------------------------------------------------------------
B. Kay and Snowflake
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
1 1 3 3 5 3
1
2
3
5
Output
3
2
3
6
----------------------------------------------------------------------------------------------------
C. Optimal Point
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5
0 0 4
0 0 -4
0 4 0
4 0 0
1 1 1
Output
0 0 0
Input
2
1
3 5 9
2
3 5 9
3 5 9
Output
3 5 9
3 5 9
----------------------------------------------------------------------------------------------------
D. Kay and Eternity
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
4 5
4 6
5 5
5 6
7 7
Output
10 8 1 4 0 
----------------------------------------------------------------------------------------------------
E. Travelling Through the Snow Queen's Kingdom
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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