Educational Codeforces Round 161 (Rated for Div. 2)


A. Tricky Template
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
a
b
c
2
aa
bb
aa
10
mathforces
luckforces
adhoccoder
3
acc
abd
abc
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
B. Forming Triangles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
7
1 1 1 1 1 1 1
4
3 2 1 3
3
1 2 3
1
1
Output
35
2
0
0
----------------------------------------------------------------------------------------------------
C. Closest Cities
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5
0 8 12 15 20
5
1 4
1 5
3 4
3 2
5 1
Output
3
8
1
4
14
----------------------------------------------------------------------------------------------------
D. Berserk Monsters
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5
3 4 7 5 10
4 9 1 18 1
2
2 1
1 3
4
1 1 2 4
3 3 4 2
Output
3 1 0 0 0 
0 0 
1 1 1 0 
----------------------------------------------------------------------------------------------------
E. Increasing Subsequences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
5
13
37
Output
1
0
3
0 1 0
5
2 2 3 4 2
7
-1 -1 0 0 2 3 -1
----------------------------------------------------------------------------------------------------
F. Replace on Segment
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 2
1 2 1
6 3
1 2 3 1 2 3
12 3
3 1 3 1 2 1 1 2 3 1 1 3
Output
1
2
2
----------------------------------------------------------------------------------------------------
