Codeforces Round 383 (Div. 2)


A. Arpa’s hard exam and Mehrdad’s naive cheat
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
8
Input
2
Output
4
----------------------------------------------------------------------------------------------------
B. Arpa’s obvious problem and Mehrdad’s terrible solution
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
1 2
Output
1
Input
6 1
5 1 2 3 4 1
Output
2
----------------------------------------------------------------------------------------------------
C. Arpa's loud Owf and Mehrdad's evil plan
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 3 1 4
Output
3
Input
4
4 4 4 4
Output
-1
Input
4
2 1 4 3
Output
1
----------------------------------------------------------------------------------------------------
D. Arpa's weak amphitheater and Mehrdad's valuable Hoses
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 5
3 2 5
2 4 2
1 2
Output
6
Input
4 2 11
2 4 6 6
6 4 2 1
1 2
2 3
Output
7
----------------------------------------------------------------------------------------------------
E. Arpa’s overnight party and Mehrdad’s silent entering
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 4
2 5
3 6
Output
1 2
2 1
1 2
----------------------------------------------------------------------------------------------------
