Educational Codeforces Round 84 (Rated for Div. 2)


A. Sum of Odd Integers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3 1
4 2
10 3
10 2
16 4
16 5
Output
YES
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
B. Princesses and Princes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
2 2 3
2 1 2
2 3 4
1 3
2
0
0
3
3 1 2 3
3 1 2 3
3 1 2 3
1
1 1
4
1 1
1 2
1 3
1 4
Output
IMPROVE
4 4
IMPROVE
1 1
OPTIMAL
OPTIMAL
OPTIMAL
----------------------------------------------------------------------------------------------------
C. Game with Chips
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2
1 2
2 1
3 3
3 2
Output
3
DRD
Input
5 4 3
3 4
3 1
3 3
5 3
1 3
1 4
Output
9
DDLUUUURR
----------------------------------------------------------------------------------------------------
D. Infinite Path
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
1 3 4 2
1 2 2 3
5
2 3 4 5 1
1 2 3 4 5
8
7 4 5 6 1 8 3 2
5 3 6 4 7 5 8 4
Output
1
5
2
----------------------------------------------------------------------------------------------------
E. Count The Blocks
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
Output
10
Input
2
Output
180 10
----------------------------------------------------------------------------------------------------
F. AND Segments
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 2
1 3 3
3 4 6
Output
3
Input
5 2 3
1 3 2
2 5 0
3 3 3
Output
33
----------------------------------------------------------------------------------------------------
G. Letters and Question Marks
time limit per test: 4 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4
abc -10
a 1
b 1
c 3
?b?
Output
5
Input
2
a 1
a 1
?
Output
2
Input
3
a 1
b 3
ab 4
ab
Output
8
Input
1
a -1
?????????????
Output
0
Input
1
a -1
??????????????
Output
-1
----------------------------------------------------------------------------------------------------
