Educational Codeforces Round 127 (Rated for Div. 2)


A. String Building
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
8
aaaabbb
bbaaaaabbb
aaaaaa
abab
a
b
aaaab
bbaaa
Output
YES
YES
YES
NO
NO
NO
NO
YES
----------------------------------------------------------------------------------------------------
B. Consecutive Points Segment
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2
1 4
3
1 2 3
4
1 2 3 7
1
1000000
3
2 5 6
Output
YES
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
C. Dolce Vita
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 7
2 1 2
5 9
10 20 30 40 50
1 1
1
2 1000
1 1
Output
11
0
1
1500
----------------------------------------------------------------------------------------------------
D. Insert a Progression
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 5
10
3 8
7 2 10
10 2
6 1 5 7 3 3 9 10 10 1
4 10
1 3 1 2
Output
9
15
31
13
----------------------------------------------------------------------------------------------------
E. Preorder
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
BAAAAAAAABBABAB
Output
16
Input
2
BAA
Output
1
Input
2
ABA
Output
2
Input
2
AAB
Output
2
Input
2
AAA
Output
1
----------------------------------------------------------------------------------------------------
F. Permutation Counting
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
10 6 4
7 3 1
163316 11 7
136373 11 1
325902 11 11
Output
465
12
986128624
7636394
57118194
----------------------------------------------------------------------------------------------------
