Codeforces Round 694 (Div. 2)


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

Examples
Input
2
3 3
3 6 9
3 3
6 4 11
Output
6 6
7 8
----------------------------------------------------------------------------------------------------
B. Strange List
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
12
4 2
4 6 8 2
Output
36
44
----------------------------------------------------------------------------------------------------
C. Strange Birthday Party
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 4
2 3 4 3 2
3 5 12 20
5 5
5 4 3 2 1
10 40 90 160 250
Output
30
190
Input
1
1 1
1
1
Output
1
----------------------------------------------------------------------------------------------------
D. Strange Definition
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
6 8 4 2
1
0
6
12 3 20 5 80 1
1
1
Output
2
3
----------------------------------------------------------------------------------------------------
E. Strange Shuffle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
2
1
2
3
2
Output
? 1
? 1
? 2
? 3
? 4
! 2
----------------------------------------------------------------------------------------------------
F. Strange Housing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 2
3 2
2 1
4 2
1 4
2 3
Output
YES
2
1 3 
NO
Input
1
17 27
1 8
2 9
3 10
4 11
5 12
6 13
7 14
8 9
8 14
8 15
9 10
9 15
10 11
10 15
10 17
11 12
11 17
12 13
12 16
12 17
13 14
13 16
14 16
14 15
15 16
15 17
16 17
Output
YES
8
1 3 4 5 6 9 14 17 
----------------------------------------------------------------------------------------------------
