Tinkoff Challenge - Final Round (Codeforces Round 414, rated, Div. 1 + Div. 2)


A. Bank Robbery
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 7
8
4 7 5 5 3 6 2 8
Output
4
Input
6 5 7
5
1 5 7 92 3
Output
0
----------------------------------------------------------------------------------------------------
B. Cutting Carrot
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
Output
1.154700538379 1.632993161855
Input
2 100000
Output
70710.678118654752
----------------------------------------------------------------------------------------------------
C. Naming Company
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
tinkoff
zscoder
Output
fzfsirk
Input
xxxxxx
xxxxxx
Output
xxxxxx
Input
ioi
imo
Output
ioi
----------------------------------------------------------------------------------------------------
D. Labelling Cities
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2
1 3
1 4
3 4
Output
YES
2 3 1 1 
Input
5 10
1 2
1 3
1 4
1 5
2 3
2 4
2 5
3 4
3 5
5 4
Output
YES
1 1 1 1 1 
Input
4 3
1 2
1 3
1 4
Output
NO
----------------------------------------------------------------------------------------------------
E. Choosing Carrot
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 3 5
Output
3 3 5 5
Input
5
1000000000 1000000000 1000000000 1000000000 1
Output
1000000000 1000000000 1000000000 1000000000 1000000000
----------------------------------------------------------------------------------------------------
F. Leha and security system
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 5
38 43 4 12 70
1 1 3 4 8
2 2 4
1 4 5 0 8
1 2 5 8 7
2 1 5
Output
103
207
Input
5 5
25 36 39 40 899
1 1 3 2 7
2 1 2
1 3 5 9 1
1 4 4 0 9
2 1 5
Output
111
1002
----------------------------------------------------------------------------------------------------
G. Replace All
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
A?
?
3
Output
2
Input
A
B
10
Output
2046
----------------------------------------------------------------------------------------------------
