Codeforces Beta Round 66


A. The Elder Trolls IV: Oblivon
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 2 3
Output
8
Input
2 2 2 1
Output
2
----------------------------------------------------------------------------------------------------
B. Need For Brake
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
teama 10
teamb 20
teamc 40
2
10 20
teama
Output
2 3
Input
2
teama 10
teamb 10
2
10 10
teamb
Output
2 2
----------------------------------------------------------------------------------------------------
C. LionAge II
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
winner 4
4
s e 7
o s 8
l o 13
o o 8
Output
36
Input
abcdef 1
5
a b -10
b c 5
c d 5
d e 5
e f 5
Output
20
----------------------------------------------------------------------------------------------------
D. FreeDiv
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
2 4
2 3
Output
2
Input
1 4
2
Output
-1
----------------------------------------------------------------------------------------------------
F. Plane of Tanks
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0 0 10 0
1
5 -5 4.71238 1
0
Output
4.2441
Input
0 0 10 0
1
5 -5 4.71238 1
1
Output
0.0000
----------------------------------------------------------------------------------------------------
