Codeforces Round 539 (Div. 2)


A. Sasha and His Trip
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
Output
4
Input
7 6
Output
6
----------------------------------------------------------------------------------------------------
B. Sasha and Magnetic Machines
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
14
Input
4
4 2 4 4
Output
14
Input
5
2 4 2 3 7
Output
18
----------------------------------------------------------------------------------------------------
C. Sasha and a Bit of Relax
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
1
Input
6
3 2 2 3 7 6
Output
3
Input
3
42 4 2
Output
0
----------------------------------------------------------------------------------------------------
D. Sasha and One More Name
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
nolon
Output
2
Input
otto
Output
1
Input
qqqq
Output
Impossible
Input
kinnikkinnik
Output
1
----------------------------------------------------------------------------------------------------
E. Sasha and a Patient Friend
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2 1
1 4 -3
3 1 6 1
3 1 6 3
3 1 6 4
3 1 6 5
Output
5
5.666667
6
-1
Input
10
1 2 2
1 4 4
1 7 -10
3 2 4 1
3 5 6 0
3 1 15 1
2 4
3 1 15 1
1 8 1
3 1 15 1
Output
-1
5
8.7
8.1
-1
Input
5
1 1000 9999999
1 2000 -9999
3 1000 2000 0
2 1000
3 1000 2002 1
Output
1000
2000.0001
----------------------------------------------------------------------------------------------------
F. Sasha and Interesting Fact from Graph Theory
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 1 3
Output
5
Input
3 1 1 2
Output
2
Input
5 15 1 5
Output
345444
----------------------------------------------------------------------------------------------------
