Codeforces Beta Round 87 (Div. 2 Only)


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

Examples
Input
4
0 3
2 5
4 2
4 0
Output
6
----------------------------------------------------------------------------------------------------
B. Little Pigs and Wolves
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
PPW
W.P
Output
2
Input
3 3
P.W
.P.
W.P
Output
0
----------------------------------------------------------------------------------------------------
C. Party
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
-1
1
2
1
-1
Output
3
----------------------------------------------------------------------------------------------------
D. Lawnmower
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
GWGGW
GGWGG
GWGGG
WGGGG
Output
11
Input
3 3
GWW
WWW
WWG
Output
7
Input
1 1
G
Output
0
----------------------------------------------------------------------------------------------------
E. Plumber
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
13
..
Output
2
Input
3 1
1
4
.
Output
0
Input
2 2
3.
.1
Output
1
----------------------------------------------------------------------------------------------------
