Educational Codeforces Round 33 (Rated for Div. 2)


A. Chess For Three
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
1
2
Output
YES
Input
2
1
2
Output
NO
----------------------------------------------------------------------------------------------------
B. Beautiful Divisors
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
Output
1
Input
992
Output
496
----------------------------------------------------------------------------------------------------
C. Rumor
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
2 5 3 4 8
1 4
4 5
Output
10
Input
10 0
1 2 3 4 5 6 7 8 9 10
Output
55
Input
10 5
1 6 2 7 3 8 4 9 5 10
1 2
3 4
5 6
7 8
9 10
Output
15
----------------------------------------------------------------------------------------------------
D. Credit Card
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 10
-1 5 0 -5 3
Output
0
Input
3 4
-10 0 20
Output
-1
Input
5 10
-5 0 10 -11 0
Output
2
----------------------------------------------------------------------------------------------------
E. Counting Arrays
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
6 3
4 2
Output
36
6
----------------------------------------------------------------------------------------------------
F. Subtree Minimum Query
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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