Educational Codeforces Round 79 (Rated for Div. 2)


A. New Year Garland
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 3 3
1 10 2
2 1 1
Output
Yes
No
Yes
----------------------------------------------------------------------------------------------------
B. Verse For Santa
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7 11
2 9 1 3 18 1 4
4 35
11 9 10 7
1 8
5
Output
2
1
0
----------------------------------------------------------------------------------------------------
C. Stack of Presents
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 3
3 1 2
3 2 1
7 2
2 1 7 3 4 5 6
3 1
Output
5
8
----------------------------------------------------------------------------------------------------
D. Santa's Bot
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 2 1
1 1
Output
124780545
Input
5
2 1 2
2 3 1
3 2 4 3
2 1 4
3 4 3 2
Output
798595483
----------------------------------------------------------------------------------------------------
E. New Year Permutations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 3
5 15
4 13
6 8
4 2
Output
2 1 3 
3 1 2 5 4 
-1
1 2 6 3 4 5 
1 2 4 3 
----------------------------------------------------------------------------------------------------
F. New Year and Handle Change
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 1 4
PikMike
Output
0
Input
15 2 2
AaAaAAaaAAAAaaA
Output
2
Input
14 2 6
aBcdEFGHIJklMn
Output
0
Input
9 2 2
aAaAAAaaA
Output
1
----------------------------------------------------------------------------------------------------
