Codeforces Round 119 (Div. 2)


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

Examples
Input
5 5 3 2
Output
2
Input
7 5 5 2
Output
2
----------------------------------------------------------------------------------------------------
B. Counting Rhombi
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
Output
1
Input
1 2
Output
0
----------------------------------------------------------------------------------------------------
C. Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4 2 3
0 1 5 6
2 0 3 6
1 3 0 1
6 6 7 0
0 3 5 6
2 0 1 6
1 3 0 2
6 6 7 0
1 4 2
1 4 1
1 4 3
Output
3
4
3
Input
4 2 3
0 7 3 3
8 0 10 5
1 1 0 4
8 9 2 0
0 3 3 9
7 0 4 9
3 8 0 4
4 8 9 0
2 3 3
2 1 3
1 2 2
Output
4
5
3
----------------------------------------------------------------------------------------------------
E. Weak Memory
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 6 3
1 3 6
1 2
2 3
4 2
5 6
4 5
3 4
1 6
Output
3
Input
6 5 3
1 5 6
1 2
2 3
3 4
4 5
6 3
1 5
Output
3
----------------------------------------------------------------------------------------------------
