Codeforces Round 511 (Div. 1)


A. Enlarge GCD
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 4
Output
1
Input
4
6 9 15 30
Output
2
Input
3
1 1 1
Output
-1
----------------------------------------------------------------------------------------------------
B. Little C Loves 3 II
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
Output
0
Input
3 3
Output
8
----------------------------------------------------------------------------------------------------
C. Region Separation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 1 1
1 2 3
Output
4
Input
4
1 1 1 1
1 2 2
Output
2
Input
4
1 2 1 2
1 1 3
Output
3
----------------------------------------------------------------------------------------------------
D. Intervals of Intervals
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
1 3
2 4
Output
3
Input
3 3
1 4
5 7
3 6
Output
15
----------------------------------------------------------------------------------------------------
E. Little C Loves 3 III
time limit per test: 1 second
memory limit per test: 64 megabytes
input: standard input
output: standard output

Examples
Input
1
11
11
Output
12
Input
2
0123
3210
Output
0322
----------------------------------------------------------------------------------------------------
