Codeforces Round 831 (Div. 1 + Div. 2)


A. Factorise N+M
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7
2
75619
Output
2
7
47837
----------------------------------------------------------------------------------------------------
B. Jumbo Extra Cheese 2
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
4 1
4 5
1 1
2 3
3
2 4
2 6
2 3
1
2 65
Output
26
24
134
----------------------------------------------------------------------------------------------------
C. Bricks and Bags
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5
3 1 5 2 3
4
17 8 19 45
8
265 265 265 265 265 265 265 265
Output
6
63
0
----------------------------------------------------------------------------------------------------
D. Knowledge Cards
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 3 6
3 6 4 1 2 5
3 3 10
1 2 3 4 5 6 7 8 9 10
5 4 4
2 1 3 4
3 4 10
10 4 9 3 5 6 8 2 7 1
Output
YA
TIDAK
YA
YA
----------------------------------------------------------------------------------------------------
E. Hanging Hearts
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1 2 1 4 2
Output
4
Input
2
1
Output
2
----------------------------------------------------------------------------------------------------
F. Conditional Mix
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
1 1 2 1 4 3
Output
7
Input
7
3 5 4 3 7 4 5
Output
11
----------------------------------------------------------------------------------------------------
G. Dangerous Laser Power
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 3
8 8 2
6 5 7
Output
110
100
Input
1 2
420 69
Output
10
----------------------------------------------------------------------------------------------------
H. MEX Tree Manipulation
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
7
1
1
3
2
5
2
1
Output
1
1
3
2
4
4
7
Input
8
1
1
1
1
5
6
7
8
Output
1
1
1
1
3
2
4
3
----------------------------------------------------------------------------------------------------
I. Arranging Crystal Balls
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 9 3
8 1 4 5 0
Output
7
Input
4 4 2
1 0 0 0
Output
-1
Input
5 5 2
1 0 0 0 0
Output
10
----------------------------------------------------------------------------------------------------
