Codeforces Round 219 (Div. 2)


A. Collecting Beats is Fun
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
.135
1247
3468
5789
Output
YES
Input
5
..1.
1111
..1.
..1.
Output
YES
Input
1
....
12.1
.2..
.2..
Output
NO
----------------------------------------------------------------------------------------------------
B. Making Sequences is Fun
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
9 1 1
Output
9
Input
77 7 7
Output
7
Input
114 5 14
Output
6
Input
1 1 2
Output
0
----------------------------------------------------------------------------------------------------
C. Counting Kangaroos is Fun
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
2
5
7
6
9
8
4
2
Output
5
Input
8
9
1
6
2
6
5
8
3
Output
5
----------------------------------------------------------------------------------------------------
D. Counting Rectangles is Fun
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5 5
00101
00000
00001
01000
00001
1 2 2 4
4 5 4 5
1 2 5 2
2 2 4 5
4 2 5 3
Output
10
1
7
34
5
Input
4 7 5
0000100
0000010
0011000
0000000
1 7 2 7
3 1 3 1
2 3 4 5
1 2 2 7
2 2 4 7
Output
3
1
16
27
52
----------------------------------------------------------------------------------------------------
E. Watching Fireworks is Fun
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
50 3 1
49 1 1
26 1 4
6 1 10
Output
-31
Input
10 2 1
1 1000 4
9 1000 4
Output
1992
----------------------------------------------------------------------------------------------------
