Codeforces Round 516 (Div. 2, by Moscow Team Olympiad)


A. Make a triangle!
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 5
Output
0
Input
2 5 3
Output
1
Input
100 10 10
Output
81
----------------------------------------------------------------------------------------------------
B. Equations of Mathematical Magic
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0
2
1073741823
Output
1
2
1073741824
----------------------------------------------------------------------------------------------------
C. Oh Those Palindromes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
oolol
Output
ololo
Input
16
gagadbcgghhchbdf
Output
abccbaghghghgdfd
----------------------------------------------------------------------------------------------------
D. Labyrinth
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 5
3 2
1 2
.....
.***.
...**
*....
Output
10
Input
4 4
2 2
0 1
....
..*.
....
....
Output
7
----------------------------------------------------------------------------------------------------
E. Dwarves, Hats and Extrasensory Abilities
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
black
black
white
white
black
Output
0 0
3 1
2 3
4 4
0 2
1 3 4 1
----------------------------------------------------------------------------------------------------
F. Candies for Children
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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