Codeforces Round 376 (Div. 2)


A. Night at the Museum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
zeus
Output
18
Input
map
Output
35
Input
ares
Output
34
----------------------------------------------------------------------------------------------------
B. Coupons and Discounts
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 1 2
Output
YES
Input
3
1 0 1
Output
NO
----------------------------------------------------------------------------------------------------
C. Socks
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 3
1 2 3
1 2
2 3
Output
2
Input
3 2 2
1 1 2
1 2
2 1
Output
0
----------------------------------------------------------------------------------------------------
D. 80-th Level Archeology
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
2 3 2
1 1
3 2 3 1
4 2 3 1 2
Output
1
Input
2 5
2 4 2
2 4 2
Output
0
Input
4 4
1 2
1 3
1 4
1 2
Output
-1
----------------------------------------------------------------------------------------------------
E. Funny Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 4 8
Output
14
Input
4
1 -7 -2 3
Output
-3
----------------------------------------------------------------------------------------------------
F. Video Cards
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2 15 9
Output
27
Input
4
8 2 2 7
Output
18
----------------------------------------------------------------------------------------------------
