Divide by Zero 2021 and Codeforces Round 714 (Div. 2)


A. Array and Peaks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 0
5 2
6 6
2 1
6 1
Output
1 
2 4 1 5 3 
-1
-1
1 3 6 5 4 2
----------------------------------------------------------------------------------------------------
B. AND Sequences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 1 1
5
1 2 3 4 5
5
0 2 0 3 0
4
1 3 5 1
Output
6
0
36
4
----------------------------------------------------------------------------------------------------
C. Add One
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1912 1
5 6
999 1
88 2
12 100
Output
5
2
6
4
2115
----------------------------------------------------------------------------------------------------
D. GCD and MST
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 5
10 10
2 5
3 3
4 5
5 2 4 9
8 8
5 3 3 6 10 100 9 15
Output
5
3
12
46
----------------------------------------------------------------------------------------------------
E. Cost Equilibrium
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
Output
6
Input
4
0 4 0 4
Output
2
Input
5
0 11 12 13 14
Output
120
----------------------------------------------------------------------------------------------------
F. Swapping Problem
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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