Codeforces Round 569 (Div. 2)


A. Alex and a Rhombus
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
1
Input
2
Output
5
Input
3
Output
13
----------------------------------------------------------------------------------------------------
B. Nick and Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 2 2 2
Output
-3 -3 -3 -3 
Input
1
0
Output
0 
Input
3
-3 -3 2
Output
-3 -3 2 
----------------------------------------------------------------------------------------------------
C. Valeriy and Deque
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
1 2 3 4 5
1
2
10
Output
1 2
2 3
5 2
Input
2 0
0 0
Output
----------------------------------------------------------------------------------------------------
D. Tolik and His Uncle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
Output
1 1
1 3
1 2
2 2
2 3
2 1
Input
1 1
Output
1 1
----------------------------------------------------------------------------------------------------
E. Serge and Dining Room
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1
1
1
1
1 1 100
Output
100
Input
1 1
1
1
1
2 1 100
Output
-1
Input
4 6
1 8 2 4
3 3 6 1 5 2
3
1 1 1
2 5 10
1 1 6
Output
8
-1
4
----------------------------------------------------------------------------------------------------
