Codeforces Round 273 (Div. 2)


A. Initial Bet
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 5 4 0 4
Output
3
Input
4 5 9 2 1
Output
-1
----------------------------------------------------------------------------------------------------
B. Random Teams
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
Output
10 10
Input
3 2
Output
1 1
Input
6 3
Output
3 6
----------------------------------------------------------------------------------------------------
C. Table Decorations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
4 6
Output
2
Input
9 7
Output
6
Input
1 1
Output
2
----------------------------------------------------------------------------------------------------
E. Wavy numbers
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
123 4
Output
1845
Input
100 1
Output
-1
Input
97461 457
Output
1805270103
----------------------------------------------------------------------------------------------------
