Educational Codeforces Round 26


A. Text Volume
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
NonZERO
Output
5
Input
24
this is zero answer text
Output
0
Input
24
Harbour Space University
Output
1
----------------------------------------------------------------------------------------------------
B. Flag of Berland
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 5
RRRRR
RRRRR
BBBBB
BBBBB
GGGGG
GGGGG
Output
YES
Input
4 3
BRG
BRG
BRG
BRG
Output
YES
Input
6 7
RRRGGGG
RRRGGGG
RRRGGGG
RRRBBBB
RRRBBBB
RRRBBBB
Output
NO
Input
4 4
RRRR
RRRR
BBBB
GGGG
Output
NO
----------------------------------------------------------------------------------------------------
C. Two Seals
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 2
1 2
2 1
Output
4
Input
4 10 9
2 3
1 1
5 10
9 11
Output
56
Input
3 10 10
6 6
7 7
20 5
Output
0
----------------------------------------------------------------------------------------------------
D. Round Subset
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
50 4 20
Output
3
Input
5 3
15 16 3 25 9
Output
3
Input
3 3
9 77 13
Output
0
----------------------------------------------------------------------------------------------------
E. Vasya's Function
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
Output
3
Input
6 3
Output
1
----------------------------------------------------------------------------------------------------
F. Prefix Sums
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
1 1
Output
1
Input
3 6
1 1 1
Output
2
Input
3 1
1 0 1
Output
0
----------------------------------------------------------------------------------------------------
G. Functions On The Segments
time limit per test: 5 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
1
1 2 1 4 5 10
1
1 1 2
Output
13
Input
3
2 5 1 1 1 4
3 6 8 2 5 7
1 3 5 1 4 10
3
1 3 3
2 3 2
1 2 5
Output
19
17
11
----------------------------------------------------------------------------------------------------
