Codeforces Round 274 (Div. 1)


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

Examples
Input
3
5 2
3 1
4 2
Output
2
Input
3
6 1
5 2
4 3
Output
6
----------------------------------------------------------------------------------------------------
B. Long Jumps
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 250 185 230
0 185 250
Output
1
230
Input
4 250 185 230
0 20 185 250
Output
0
Input
2 300 185 230
0 300
Output
2
185 230
----------------------------------------------------------------------------------------------------
C. Riding in a Lift
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 2
0 1 1 1 1
1 2 1 1 1
0 2 1 1 1
Output
3
Input
5 5
0 6 1 2 1
1 2 1 1 1
1 3 1 1 1
3 6 2 1 2
4 5 1 1 1
Output
5
----------------------------------------------------------------------------------------------------
E. Parking Lot
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 8 4
........
X.....X.
........
........
.X......
........
........
1 5
6 4
3 5
4 6
Output
5
4
4
3
----------------------------------------------------------------------------------------------------
