Codeforces Round 318 [RussianCodeCup Thanks-Round] (Div. 2)


A. Bear and Elections
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5 1 11 2 8
Output
4
Input
4
1 8 8 8
Output
6
Input
2
7 6
Output
0
----------------------------------------------------------------------------------------------------
B. Bear and Three Musketeers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
1 2
1 3
2 3
2 4
3 4
4 5
Output
2
Input
7 4
2 1
3 6
5 1
1 7
Output
-1
----------------------------------------------------------------------------------------------------
C. Bear and Poker
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
75 150 75 50
Output
Yes
Input
3
100 150 250
Output
No
----------------------------------------------------------------------------------------------------
D. Bear and Blocks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 1 4 6 2 2
Output
3
Input
7
3 3 3 1 3 3 3
Output
2
----------------------------------------------------------------------------------------------------
E. Bear and Drawing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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