Codeforces Round 239 (Div. 2)


A. Line to Cashier
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1
1
Output
20
Input
4
1 4 3 2
100
1 2 2 3
1 9 1
7 8
Output
100
----------------------------------------------------------------------------------------------------
B. Garland
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aaabbac
aabbccac
Output
6
Input
a
z
Output
-1
----------------------------------------------------------------------------------------------------
C. Triangle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
Output
NO
Input
5 5
Output
YES
2 1
5 5
-2 4
Input
5 10
Output
YES
-10 4
-2 -2
1 2
----------------------------------------------------------------------------------------------------
D. Long Path
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
Output
4
Input
4
1 1 2 3
Output
20
Input
5
1 1 1 1 1
Output
62
----------------------------------------------------------------------------------------------------
E. Curious Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
0 0 0 0 0
1 5 0
Output
1 1 1 1 1
Input
10 2
1 2 3 4 5 0 0 0 0 0
1 6 1
6 10 2
Output
2 4 6 8 10 7 3 6 10 15
----------------------------------------------------------------------------------------------------
