Codeforces Round 330 (Div. 1)


A. 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
----------------------------------------------------------------------------------------------------
B. 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
----------------------------------------------------------------------------------------------------
C. 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
----------------------------------------------------------------------------------------------------
D. REQ
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
1 2 3 4 5 6 7 8 9 10
7
1 1
3 8
5 6
4 8
8 10
7 9
7 10
Output
1
4608
8
1536
192
144
1152
Input
7
24 63 13 52 6 10 1
6
3 5
4 7
1 7
2 4
3 6
2 6
Output
1248
768
12939264
11232
9984
539136
----------------------------------------------------------------------------------------------------
E. Cutting the Line
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aba
2
Output
aab
Input
aaaabacaba
2
Output
aaaaabacab
Input
bababa
1
Output
ababab
Input
abacabadabacaba
4
Output
aababacabacabad
----------------------------------------------------------------------------------------------------
