VK Cup 2016 - Round 1 (Div. 2 Edition)


A. Bear and Reverse Radewoosh
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
50 85 250
10 15 25
Output
Limak
Input
3 6
50 85 250
10 15 25
Output
Radewoosh
Input
8 1
10 20 30 40 50 60 70 80
8 10 58 63 71 72 75 76
Output
Tie
----------------------------------------------------------------------------------------------------
B. Bear and Displayed Friends
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2 8
300 950 500 200
1 3
2 4
2 3
1 1
1 2
2 1
2 2
2 3
Output
NO
YES
NO
YES
YES
Input
6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3
Output
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Bear and Forgotten Tree 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 1000000000
10 -9 -3 5
Output
3
Input
3 12
10 -9 -3 5
Output
2
Input
2 20
14 -7 19
Output
0
----------------------------------------------------------------------------------------------------
E. Bear and Contribution
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 100 30
12 2 6 1
Output
220
Input
4 3 30 100
12 2 6 1
Output
190
Input
6 2 987 789
-8 42 -4 -65 -8 -8
Output
0
----------------------------------------------------------------------------------------------------
