Educational Codeforces Round 52 (Rated for Div. 2)


A. Vasya and Chocolate
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
10 3 1 1
1000000000 1 1000000000 1
Output
13
1000000001000000000
----------------------------------------------------------------------------------------------------
B. Vasya and Isolated Vertices
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
Output
0 1
Input
3 1
Output
1 1
----------------------------------------------------------------------------------------------------
C. Make It Equal
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5
3 1 2 2 4
Output
2
Input
4 5
2 3 4 5
Output
2
----------------------------------------------------------------------------------------------------
D. Three Pieces
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 9 3
8 6 7
4 2 5
Output
12 1
----------------------------------------------------------------------------------------------------
E. Side Transmutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 2
1
Output
6
Input
9 2 26
2 3
Output
150352234
Input
12 3 1
2 5 6
Output
1
----------------------------------------------------------------------------------------------------
F. Up and Down the Tree
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 1
1 1 3 3 4 4
Output
4
Input
8 2
1 1 2 3 4 5 5
Output
2
----------------------------------------------------------------------------------------------------
G. Fibonacci Suffix
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5 3
Output
110
Input
4 3 3
Output
1
----------------------------------------------------------------------------------------------------
