Codeforces Beta Round 33 (Codeforces format)


A. What is for dinner?
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 18
2 3
1 2
3 6
2 3
Output
11
Input
2 2 13
1 13
2 12
Output
13
----------------------------------------------------------------------------------------------------
B. String Problem
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
uayd
uxxd
3
a x 8
x y 13
d c 3
Output
21
uxyd
Input
a
b
3
a b 2
a b 3
b a 5
Output
2
b
Input
abc
ab
6
a b 4
a b 7
b a 8
c b 11
c a 3
a c 0
Output
-1
----------------------------------------------------------------------------------------------------
C. Wonderful Randomized Sum
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

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

Examples
Input
3 3 4
calculus
algebra
history
58 23 15
00:00-08:15
08:20-08:35
09:30-10:25
19:00-19:45
calculus 1 09:36 100
english 4 21:15 5000
history 1 19:50 50
Output
150
2
1 1 08:16 1 09:29
3 1 10:26 1 10:40
Input
2 2 1
matan
codeforces
1 2
00:00-08:00
09:00-09:00
12:00-12:00
18:00-18:00
codeforces 1 08:04 2
matan 1 08:02 1
Output
3
2
2 1 08:01 1 08:01
1 1 08:02 1 08:03
Input
2 2 1
matan
codeforces
2 2
00:00-08:00
09:00-09:00
12:00-12:00
18:00-18:00
codeforces 1 08:04 2
matan 1 08:03 1
Output
2
1
1 1 08:01 1 08:02
----------------------------------------------------------------------------------------------------
