Codeforces Round 666 (Div. 1)


A. Multiples of Length
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 2 4
Output
1 1 
-1
3 4
4 2
2 4
-3 -6 -6
----------------------------------------------------------------------------------------------------
B. Stoned Game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1
2
2
1 1
Output
T
HL
----------------------------------------------------------------------------------------------------
C. Monster Invaders
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 1 3 4 3
3 2 5 1
Output
34
Input
4 2 4 4 1
4 5 1 2
Output
31
----------------------------------------------------------------------------------------------------
D. Rainbow Rectangles
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 2 4
3 2 2
3 1 1
1 1 1
1 2 1
Output
20
Input
5 3 10
6 5 3
5 3 1
7 9 1
2 3 2
5 0 2
Output
300
Input
10 4 10
5 4 4
0 0 3
6 0 1
3 9 2
8 7 1
8 1 3
2 1 3
6 3 2
3 5 3
4 3 4
Output
226
----------------------------------------------------------------------------------------------------
E. Distance Matching
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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