Технокубок 2018 - Финал (только для онсайт-финалистов)


A. World Cup
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1 2
Output
1
Input
8 2 6
Output
Final!
Input
8 7 5
Output
2
----------------------------------------------------------------------------------------------------
B. Laboratory Work
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
-1 1 1 0 0 -1
Output
2
0 0 0 0 0 0 
Input
3
100 100 101
Output
3
101 100 100 
Input
7
-10 -9 -10 -8 -10 -9 -9
Output
5
-10 -10 -9 -9 -9 -9 -9 
----------------------------------------------------------------------------------------------------
C. Peculiar apple-tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1
Output
1
Input
5
1 2 2 2
Output
3
Input
18
1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4
Output
4
----------------------------------------------------------------------------------------------------
D. Game with String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
technocup
Output
1.000000000000000
Input
tictictactac
Output
0.333333333333333
Input
bbaabaabbb
Output
0.100000000000000
----------------------------------------------------------------------------------------------------
E. Teodor is not a liar!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
1 2
3 4
Output
4
Input
4 6
1 3
2 3
4 6
5 6
Output
5
----------------------------------------------------------------------------------------------------
F. Game with Tokens
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
-2 -1
0 1
0 -3
2 -1
Output
4
Input
4
-2 0
-1 1
0 -2
1 -1
Output
2
Input
16
2 1
1 2
-1 1
0 1
0 0
1 1
2 -1
2 0
1 0
-1 -1
1 -1
2 2
0 -1
-1 0
0 2
-1 2
Output
4
----------------------------------------------------------------------------------------------------
G. Coins Exhibition
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2 2
1 3
3 5
2 2
4 5
Output
8
Input
5 3 2
1 3
2 2
3 5
2 2
4 5
Output
0
Input
60 5 7
1 3
50 60
1 60
30 45
20 40
4 5
6 37
5 18
50 55
22 27
25 31
44 45
Output
732658600
----------------------------------------------------------------------------------------------------
