Codeforces Round 708 (Div. 2)


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

Examples
Input
3
7
4 2 0 1 3 3 7
5
2 2 8 6 9
1
0
Output
0 1 2 3 4 7 3 
2 6 8 9 2 
0 
----------------------------------------------------------------------------------------------------
B. M-arrays
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6 4
2 2 8 6 9 4
10 8
1 1 1 5 2 4 4 8 6 7
1 1
666
2 2
2 4
Output
3
6
1
1
----------------------------------------------------------------------------------------------------
C1. k-LCM (easy version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 3
8 3
14 3
Output
1 1 1
4 2 2
2 6 6
----------------------------------------------------------------------------------------------------
C2. k-LCM (hard version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
6 4
9 5
Output
1 2 2 1 
1 3 3 1 1 
----------------------------------------------------------------------------------------------------
D. Genius
time limit per test: 2 seconds
memory limit per test: 32 megabytes
input: standard input
output: standard output

Examples
Input
5
4
1 2 3 4
5 10 15 20
4
1 2 1 2
5 10 15 20
4
2 2 4 1
2 8 19 1
2
1 1
6 9
1
1
666
Output
35
30
42
0
0
----------------------------------------------------------------------------------------------------
E1. Square-Free Division (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 0
18 6 2 4 1
5 0
6 8 1 24 8
1 0
1
Output
3
2
1
----------------------------------------------------------------------------------------------------
E2. Square-Free Division (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 2
18 6 2 4 1
11 4
6 2 2 8 9 1 3 6 3 9 7
1 0
1
Output
1
2
1
----------------------------------------------------------------------------------------------------
