Codeforces Round 424 (Div. 1, rated, based on VK Cup Finals)


A. Office Keys
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4 50
20 100
60 10 40 80
Output
50
Input
1 2 10
11
15 7
Output
7
----------------------------------------------------------------------------------------------------
B. Cards Sorting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6 3 1 2
Output
7
Input
1
1000
Output
1
Input
7
3 3 3 3 3 3 3
Output
7
----------------------------------------------------------------------------------------------------
C. Bamboo Partition
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1 3 5
Output
3
Input
3 40
10 30 50
Output
32
----------------------------------------------------------------------------------------------------
D. Singer House
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
9
Input
3
Output
245
Input
20
Output
550384565
----------------------------------------------------------------------------------------------------
E. Perpetual Motion Machine
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
 
4 4
1 2
2 3
3 4
4 2
 
3 2
2 3
3 1
 
4 6
1 2
3 4
4 2
1 4
1 3
3 2
 
10 9
2 1
3 2
5 2
6 2
2 7
2 8
2 9
2 10
4 2
Output
YES
1 2 2 1
NO
YES
1 1 1 1
YES
1 5 1 1 1 1 1 1 1 1
----------------------------------------------------------------------------------------------------
