Codeforces Round 491 (Div. 2)


A. If at first you don't succeed...
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 10 5 20
Output
5
Input
2 2 0 4
Output
-1
Input
2 2 2 1
Output
-1
----------------------------------------------------------------------------------------------------
B. Getting an A
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
68
Output
3
----------------------------------------------------------------------------------------------------
D. Bishwock
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
00
00
Output
1
Input
00X00X0XXX0
0XXX0X00X00
Output
4
Input
0X0X0
0X0X0
Output
0
Input
0XXX0
00000
Output
2
----------------------------------------------------------------------------------------------------
E. Bus Number
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
97
Output
2
Input
2028
Output
13
----------------------------------------------------------------------------------------------------
F. Concise and clear
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2018
Output
2018
Input
1000000007
Output
10^9+7
Input
10000000000
Output
100^5
Input
2000000000
Output
2*10^9
----------------------------------------------------------------------------------------------------
