Codeforces Round 824 (Div. 2)


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

Examples
Input
3
6
10
1033
Output
0
1
342
----------------------------------------------------------------------------------------------------
B. Tea with Tangerines
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5
1 2 3 4 5
1
1033
5
600 900 1300 2000 2550
Output
10
0
4
----------------------------------------------------------------------------------------------------
C. Phase Shift
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
a
2
ba
10
codeforces
26
abcdefghijklmnopqrstuvwxyz
26
abcdefghijklmnopqrstuvwxzy
Output
b
ac
abcdebfadg
bcdefghijklmnopqrstuvwxyza
bcdefghijklmnopqrstuvwxyaz
----------------------------------------------------------------------------------------------------
D. Meta-set
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 4
0 0 0 0
0 0 0 1
0 0 0 2
0 0 1 0
0 0 2 0
0 1 0 0
1 0 0 0
2 2 0 0
Output
1
Input
7 4
0 0 0 0
0 0 0 1
0 0 0 2
0 0 1 0
0 0 2 0
0 1 0 0
0 2 0 0
Output
3
Input
9 2
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
Output
54
Input
20 4
0 2 0 0
0 2 2 2
0 2 2 1
0 2 0 1
1 2 2 0
1 2 1 0
1 2 2 1
1 2 0 1
1 1 2 2
1 1 0 2
1 1 2 1
1 1 1 1
2 1 2 0
2 1 1 2
2 1 2 1
2 1 1 1
0 1 1 2
0 0 1 0
2 2 0 0
2 0 0 2
Output
0
----------------------------------------------------------------------------------------------------
E. House Planning
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
5
5
2
10 12
5 20
2
10 33
26 69
4
0 2 1 2
2 2 1 0
Output
YES
5 
0 10
NO
YES
0 43 
33 69
YES
1 0 3 3
1 1
----------------------------------------------------------------------------------------------------
F. Pebbles and Beads
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 6 0
2 3
4 2
3 0 6
4 2 10
2 3 10
1 10 10
33
1000
Output
6
8
4
6
9.000000
10.33
----------------------------------------------------------------------------------------------------
