Codeforces Round 736 (Div. 1)


A. Web of Lies
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
2 1
1 3
3 4
4
3
1 2 3
2 3 1
3
Output
2
1
Input
4 3
2 3
3 4
4 1
1
3
Output
1
----------------------------------------------------------------------------------------------------
B. Integers Have Friends
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
1 5 2 4 6
4
8 2 5 10
2
1000 2000
8
465 55 3 54 234 12 45 78
Output
3
3
2
6
----------------------------------------------------------------------------------------------------
C. The Three Little Pigs
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 3
1
5
6
Output
9
6
1
Input
5 4
2
4
6
8
Output
225
2001
6014
6939
----------------------------------------------------------------------------------------------------
D1. Gregor and the Odd Cows (Easy)
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0
2 0
0 4
Output
1
Input
5
0 0
2 16
30 14
4 6
2 10
Output
3
----------------------------------------------------------------------------------------------------
D2. Gregor and the Odd Cows (Hard)
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0
2 0
0 4
Output
1
Input
4
1 8
0 6
5 2
5 6
Output
1
Input
10
170 59
129 54
5 98
129 37
58 193
154 58
24 3
13 138
136 144
174 150
Output
29
----------------------------------------------------------------------------------------------------
E. Gregor and the Two Painters
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4 11
9 8 5
10 6 7 2
Output
2
Input
3 4 12
9 8 5
10 6 7 2
Output
1
Input
3 3 2
1 2 1
1 2 1
Output
4
Input
5 23 6
1 4 3 5 2
2 3 1 6 1 5 5 6 1 3 2 6 2 3 1 6 1 4 1 6 1 5 5
Output
6
----------------------------------------------------------------------------------------------------
