Codeforces Round 588 (Div. 2)


A. Dawid and Bags of Candies
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 7 11 5
Output
YES
Input
7 3 2 5
Output
NO
----------------------------------------------------------------------------------------------------
B. Ania and Minimizing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
51528
Output
10028
Input
3 2
102
Output
100
Input
1 1
1
Output
0
----------------------------------------------------------------------------------------------------
C. Anadi and Domino
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2
2 3
3 4
4 1
Output
4
Input
7 0
Output
0
Input
3 1
1 3
Output
1
Input
7 21
1 2
1 3
1 4
1 5
1 6
1 7
2 3
2 4
2 5
2 6
2 7
3 4
3 5
3 6
3 7
4 5
4 6
4 7
5 6
5 7
6 7
Output
16
----------------------------------------------------------------------------------------------------
D. Marcin and Training Camp
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2 3 6
2 8 5 10
Output
15
Input
3
1 2 3
1 2 3
Output
0
Input
1
0
1
Output
0
----------------------------------------------------------------------------------------------------
E. Kamil and Making a Stream
time limit per test: 4 seconds
memory limit per test: 768 megabytes
input: standard input
output: standard output

Examples
Input
5
4 5 6 0 8
1 2
1 3
1 4
4 5
Output
42
Input
7
0 2 3 0 0 0 0
1 2
1 3
2 4
2 5
3 6
3 7
Output
30
----------------------------------------------------------------------------------------------------
F. Konrad and Company Evaluation
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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