Codeforces Round 845 (Div. 2) and ByteRace 2023


A. Everybody Likes Good Arrays!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5
1 7 11 2 13
4
1 2 3 4
6
1 1 1 2 2 3
Output
2
0
3
----------------------------------------------------------------------------------------------------
B. Emordnilap
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
100
Output
0
4
389456655
----------------------------------------------------------------------------------------------------
C. Quiz Master
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 4
3 7
4 2
3 7 2 9
5 7
6 4 3 5 7
Output
-1
0
3
----------------------------------------------------------------------------------------------------
D. Score of a Tree
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1
6
1 2
1 3
3 4
3 5
3 6
Output
288
----------------------------------------------------------------------------------------------------
E. Edge Reverse
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
2 1
1 2 3
5 4
1 2 10
2 3 10
3 1 10
4 5 10
4 5
1 2 10000
2 3 20000
1 3 30000
4 2 500
4 3 20
4 5
1 2 10000
2 3 20000
1 3 30000
4 2 5
4 3 20
Output
0
-1
20
5
----------------------------------------------------------------------------------------------------
F. Comfortably Numb
time limit per test: 8 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
2
5
1 2 3 4 5
3
10 47 52
Output
7
47
----------------------------------------------------------------------------------------------------
