Codeforces Round 330 (Div. 2)


A. Vitaly and Night
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
0 0 0 1
1 0 1 1
Output
3
Input
1 3
1 1 0 1 0 0
Output
2
----------------------------------------------------------------------------------------------------
B. Pasha and Phone
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2
38 56 49
7 3 4
Output
8
Input
8 2
1 22 3 44
5 4 3 2
Output
32400
----------------------------------------------------------------------------------------------------
C. Warrior and Archer
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
0 1 3 7 15 31
Output
7
Input
2
73 37
Output
36
----------------------------------------------------------------------------------------------------
D. Max and Bike
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1 2
1 10
5 9
Output
3.849644710502
1.106060157705
----------------------------------------------------------------------------------------------------
E. Edo and Magnets
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
1 1 2 2
2 2 3 3
3 3 4 4
Output
1
Input
4 1
1 1 2 2
1 9 2 10
9 9 10 10
9 1 10 2
Output
64
Input
3 0
1 1 2 2
1 1 1000000000 1000000000
1 3 8 12
Output
249999999000000001
----------------------------------------------------------------------------------------------------
