Codeforces Round 164 (Div. 2)


A. Games
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
2 4
3 4
Output
1
Input
4
100 42
42 100
5 42
100 5
Output
5
Input
2
1 2
1 2
Output
0
----------------------------------------------------------------------------------------------------
B. Buttons
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
3
Input
3
Output
7
----------------------------------------------------------------------------------------------------
C. Beautiful Sets of Points
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
Output
3
0 1
1 2
2 0
Input
4 3
Output
4
0 3
2 1
3 0
4 2
----------------------------------------------------------------------------------------------------
D. Wall Bars
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 1
Output
4
Input
4 2
Output
148
Input
4 3
Output
256
Input
5 2
Output
376
----------------------------------------------------------------------------------------------------
E. Playlist
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
150 20
150 50
100 50
Output
537.500000000
Input
4
300 0
300 50
240 50
360 80
Output
2121.000000000
----------------------------------------------------------------------------------------------------
