Codeforces Round 728 (Div. 2)


A. Pretty Permutations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2
3
Output
2 1 
3 1 2 
----------------------------------------------------------------------------------------------------
B. Pleasant Pairs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
3 1
3
6 1 5
5
3 1 5 9 2
Output
1
1
3
----------------------------------------------------------------------------------------------------
C. Great Graphs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
0 2 3
2
0 1000000000
1
0
Output
-3
0
0
----------------------------------------------------------------------------------------------------
D. Tree Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
1 3
Output
166666669
Input
6
2 1
2 3
6 1
1 4
2 5
Output
500000009
Input
5
1 2
1 3
1 4
2 5
Output
500000007
----------------------------------------------------------------------------------------------------
E1. Converging Array (Easy Version)
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 4
2 1
1
-1
Output
56
----------------------------------------------------------------------------------------------------
E2. Converging Array (Hard Version)
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 4
2 1
5
-1 0 1 -100000 100000
Output
56
28
4
60
0
----------------------------------------------------------------------------------------------------
