Codeforces Round 837 (Div. 2)


A. Hossam and Combinatorics
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
6 2 3 8 1
6
7 2 8 3 2 10
Output
2
4
----------------------------------------------------------------------------------------------------
B. Hossam and Friends
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3 2
1 3
2 3
4 2
1 2
2 3
Output
4
5
----------------------------------------------------------------------------------------------------
C. Hossam and Trainees
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
32 48 7
3
14 5 9
Output
YES
NO
----------------------------------------------------------------------------------------------------
D. Hossam and (sub-)palindromic tree
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5
abaca
1 2
1 3
3 4
4 5
9
caabadedb
1 2
2 3
2 4
1 5
5 6
5 7
5 8
8 9
Output
3
5
----------------------------------------------------------------------------------------------------
E. Hossam and a Letter
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
#m.
.#.
Output
0
Input
7 8
...#.m..
..m...m.
.#..#.m#
...m..m.
m.......
..#.m.mm
......m.
Output
16
----------------------------------------------------------------------------------------------------
F. Hossam and Range Minimum Query
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 1 2 2
6
1 2
0 2
0 6
0 5
2 2
3 7
Output
1
2
1
0
2
2
Input
10
51 43 69 48 23 52 48 76 19 55
10
1 1
57 57
54 62
20 27
56 56
79 69
16 21
18 30
25 25
62 61
Output
51
55
19
48
76
19
23
19
55
19
----------------------------------------------------------------------------------------------------
