Codeforces Round 513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2)


A. Phone Numbers
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
11
00000000008
Output
1
Input
22
0011223344556677889988
Output
2
Input
11
31415926535
Output
0
----------------------------------------------------------------------------------------------------
B. Maximum Sum of Digits
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
35
Output
17
Input
10000000000
Output
91
----------------------------------------------------------------------------------------------------
C. Maximum Subrectangle
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2 3
1 2 3
9
Output
4
Input
5 1
5 4 2 4 5
2
5
Output
1
----------------------------------------------------------------------------------------------------
D. Social Circles
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1
1 1
1 1
Output
6
Input
4
1 2
2 1
3 5
5 3
Output
15
Input
1
5 6
Output
7
----------------------------------------------------------------------------------------------------
E. Sergey and Subway
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
1 3
1 4
Output
6
Input
4
1 2
2 3
3 4
Output
7
----------------------------------------------------------------------------------------------------
F. Shrinking Tree
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
1 3
1 4
Output
0.1250000000
0.2916666667
0.2916666667
0.2916666667
Input
7
1 2
1 3
2 4
2 5
3 6
3 7
Output
0.0850694444
0.0664062500
0.0664062500
0.1955295139
0.1955295139
0.1955295139
0.1955295139
----------------------------------------------------------------------------------------------------
G. Balls and Pockets
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 15
1 3 4
0 0
1 0
2 0
3 0
4 0
0 1
1 1
2 1
3 1
4 1
0 2
1 2
2 2
3 2
4 2
Output
0
1
2
3
4
0
2
5
6
7
0
5
8
9
10
----------------------------------------------------------------------------------------------------
H. Sophisticated Device
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
