Codeforces Round 415 (Div. 2)


A. Straight «A»
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 10
8 9
Output
4
Input
3 5
4 4 4
Output
3
----------------------------------------------------------------------------------------------------
B. Summer sell-off
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
2 1
3 5
2 3
1 5
Output
10
Input
4 1
0 2
0 3
3 5
0 6
Output
5
----------------------------------------------------------------------------------------------------
C. Do you want a date?
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 7
Output
3
Input
3
4 3 1
Output
9
----------------------------------------------------------------------------------------------------
D. Glad to see you!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
NIE
TAK
NIE
TAK
TAK
TAK
Output
1 1 2
1 2 1
1 1 3
1 3 1
1 2 3
1 3 2
2 2 3
----------------------------------------------------------------------------------------------------
E. Find a car
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1 1 1
3 2 5 4 5
1 1 5 5 10000
1 4 2 5 2
Output
1
13
93
0
----------------------------------------------------------------------------------------------------
