CodeCraft-21 and Codeforces Round 711 (Div. 2)


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

Examples
Input
3
11
31
75
Output
12
33
75
----------------------------------------------------------------------------------------------------
B. Box Fitting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 16
1 2 8 4 8
6 10
2 8 8 2 2 8
Output
2
3
----------------------------------------------------------------------------------------------------
C. Planar Reflections
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 3
2 2
3 1
1 3
Output
4
3
1
2
Input
3
1 1
1 500
500 250
Output
1
2
257950823
----------------------------------------------------------------------------------------------------
D. Bananas in a Microwave
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 20
1 300000 2
2 400000 2
1 1000000 3
Output
-1 -1 1 -1 -1 1 -1 -1 -1 3 -1 2 3 -1 -1 3 -1 -1 -1 3 
Input
3 20
1 399999 2
2 412345 2
1 1000001 3
Output
-1 -1 -1 1 -1 -1 -1 1 -1 -1 3 -1 -1 -1 3 -1 2 -1 3 -1 
----------------------------------------------------------------------------------------------------
E. Two Houses
time limit per test: 3.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 1
Yes
Output
? 1 2
! 1 2
Input
4
1 2 0 3
No
No
No
No
No
No
Output
? 2 1
? 1 3
? 4 1
? 2 3
? 4 2
? 4 3
! 0 0
----------------------------------------------------------------------------------------------------
F. Christmas Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
1 2
1 3
5 2
4 3
0 3 2 4 4
Output
1 0 0 1 1 
----------------------------------------------------------------------------------------------------
