Educational Codeforces Round 83 (Rated for Div. 2)


A. Two Regular Polygons
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
6 3
7 3
Output
YES
NO
----------------------------------------------------------------------------------------------------
B. Bogosort
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
5
4 100
0 0 0 0
1 2
1
3 4
1 4 1
3 2
0 1 3
3 9
0 59049 810
Output
YES
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
D. Count the Arrays
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4
Output
6
Input
3 5
Output
10
Input
42 1337
Output
806066790
Input
100000 200000
Output
707899035
----------------------------------------------------------------------------------------------------
E. Array Shrinking
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 3 2 2 3
Output
2
Input
7
3 3 4 4 4 3 3
Output
2
Input
3
1 3 5
Output
3
Input
1
1000
Output
1
----------------------------------------------------------------------------------------------------
F. Attack on Red Kingdom
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1 3 4
7 6
1 1 2 3
1
1 1 2 2
3
Output
2
3
0
Input
10
6 5 4 5
2 3 2 3 1 3
1 5 2 3
10
4 4 2 3
8 10 8 5
2 2 1 4
8 5
3 5 3 5
9 2 10
4 5 5 5
2 10 4 2
2 3 1 4
1 10
3 1 5 3
9 8 7
2 5 4 5
8 8
3 5 1 4
5 5 10
Output
0
2
1
2
5
12
5
0
0
2
----------------------------------------------------------------------------------------------------
G. Autocompletion
time limit per test: 7 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
10
0 i
1 q
2 g
0 k
1 e
5 r
4 m
5 h
3 p
3 e
5
8 9 1 10 6
Output
2 4 1 3 3 
Input
8
0 a
1 b
2 a
2 b
4 a
4 b
5 c
6 d
5
2 3 4 7 8
Output
1 2 2 4 4 
----------------------------------------------------------------------------------------------------
