Codeforces Round 313 (Div. 2)


A. Currency System in Geraldion
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
-1
----------------------------------------------------------------------------------------------------
B. Gerald is into Art
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 3
2 1
Output
YES
Input
5 5
3 3
3 3
Output
NO
Input
4 2
2 3
1 2
Output
YES
----------------------------------------------------------------------------------------------------
C. Gerald's Hexagon
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 1 1 1 1
Output
6
Input
1 2 1 2 1 2
Output
13
----------------------------------------------------------------------------------------------------
D. Equivalent Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aaba
abaa
Output
YES
Input
aabb
abab
Output
NO
----------------------------------------------------------------------------------------------------
E. Gerald and Giant Chess
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 2
2 2
2 3
Output
2
Input
100 100 3
15 16
16 15
99 88
Output
545732279
----------------------------------------------------------------------------------------------------
