Codeforces Round 329 (Div. 2)


A. 2Char
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
abb
cacc
aaa
bbb
Output
9
Input
5
a
a
bcbcb
cdecdecdecdecdecde
aaaa
Output
6
----------------------------------------------------------------------------------------------------
B. Anton and Lines
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
1 2
1 0
0 1
0 2
Output
NO
Input
2
1 3
1 0
-1 3
Output
YES
Input
2
1 3
1 0
0 2
Output
YES
Input
2
1 3
1 0
0 3
Output
NO
----------------------------------------------------------------------------------------------------
C. Beautiful Function
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 10 4
10 0 4
20 10 4
Output
t 
abs((t-10))
----------------------------------------------------------------------------------------------------
D. Happy Tree Party
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 6
1 2 1
1 3 7
1 4 4
2 5 5
2 6 2
1 4 6 17
2 3 2
1 4 6 17
1 5 5 20
2 4 1
1 5 1 3
Output
2
4
20
3
Input
5 4
1 2 7
1 3 3
3 4 2
3 5 5
1 4 2 100
1 5 4 1
2 2 2
1 1 3 4
Output
2
0
2
----------------------------------------------------------------------------------------------------
E. Strange Calculation and Cats
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 3 3
2 1 2 3
3 1 2 5
1 1 1 7
Output
5
Input
3 3 3
2 2 2 2
1 3 3 5
1 3 3 7
Output
2
42
Input
4 5 5
2 2 5 3
2 2 4 6
3 2 4 9
1 4 4 13
1 4 4 15
Output
490902
10598759
----------------------------------------------------------------------------------------------------
