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


A. Cow and Haybales
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 5
1 0 3 2
2 2
100 1
1 8
0
Output
3
101
0
----------------------------------------------------------------------------------------------------
B. Cow and Friend
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 4
1 3
3 12
3 4 5
1 5
5
2 10
15 4
Output
2
3
1
2
----------------------------------------------------------------------------------------------------
C. Cow and Message
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aaabb
Output
6
Input
usaco
Output
1
Input
lol
Output
2
----------------------------------------------------------------------------------------------------
D. Cow and Fields
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5 3
1 3 5
1 2
2 3
3 4
3 5
2 4
Output
3
Input
5 4 2
2 4
1 2
2 3
3 4
4 5
Output
3
----------------------------------------------------------------------------------------------------
E. Cow and Treats
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1 1 1 1 1
1 2
1 3
Output
2 2
Input
5 2
1 1 1 1 1
1 2
1 4
Output
1 4
Input
3 2
2 3 2
3 1
2 1
Output
2 4
Input
5 1
1 1 1 1 1
2 5
Output
0 1
----------------------------------------------------------------------------------------------------
F. Cow and Vacation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2 1
1 2
2 3
2 4
4 5
5 6
2
3
1 3
3 5
3 6
Output
YES
YES
NO
Input
8 3 3
1 2
2 3
3 4
4 5
4 6
6 7
7 8
2 5 8
2
7 1
8 1
Output
YES
NO
----------------------------------------------------------------------------------------------------
G. Cow and Exercise
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2 2
2 3 2
1 3 3
5
0
1
2
3
4
Output
3.0000000000
4.0000000000
4.5000000000
5.0000000000
5.5000000000
----------------------------------------------------------------------------------------------------
