Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, raw_input().split())
S = [[0 if c == "." else 1 for c in raw_input()] for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]

for i in xrange(h):
    ps = 0
    for j in xrange(w):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            L[i][j] = ps

for j in xrange(w):
    ps = 0
    for i in xrange(h):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            U[i][j] = ps

for i in xrange(h-1, -1, -1):
    ps = 0
    for j in xrange(w-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            R[i][j] = ps
for j in xrange(w-1, -1, -1):
    ps = 0
    for i in xrange(h-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            D[i][j] = ps
maxLight = 0
for i in xrange(h):
    for j in xrange(w):
        maxLight = max(maxLight, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print maxLight


Fixed submission:
h, w = map(int, raw_input().split())
S = [[0 if c == "." else 1 for c in raw_input()] for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]

for i in xrange(h):
    ps = 0
    for j in xrange(w):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            L[i][j] = ps

for j in xrange(w):
    ps = 0
    for i in xrange(h):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            U[i][j] = ps

for i in xrange(h-1, -1, -1):
    ps = 0
    for j in xrange(w-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            R[i][j] = ps
for j in xrange(w-1, -1, -1):
    ps = 0
    for i in xrange(h-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            D[i][j] = ps
maxLight = 0
for i in xrange(h):
    for j in xrange(w):
        maxLight = max(maxLight, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print maxLight

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, raw_input().split())
S = [raw_input() for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]

for i in range(h):
    ps = 0
    s = S[i]
    for j in range(w):
        if s[j] == "#":
            ps = 0
        else:
            ps += 1
            L[i][j] = ps

for j in range(w):
    ps = 0
    for i in range(h):
        if S[i][j] == "#":
            ps = 0
        else:
            ps += 1
            U[i][j] = ps

for i in range(h-1, -1, -1):
    ps = 0
    for j in range(w-1, -1, -1):
        if S[i][j] == "#":
            ps = 0
        else:
            ps += 1
            R[i][j] = ps
for j in range(w-1, -1, -1):
    ps = 0
    for i in range(h-1, -1, -1):
        if S[i][j] == "#":
            ps = 0
        else:
            ps += 1
            D[i][j] = ps
maxLight = 0
for i in range(h):
    for j in range(w):
        maxLight = max(maxLight, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print maxLight


Fixed submission:
h, w = map(int, raw_input().split())
S = [[0 if c == "." else 1 for c in raw_input()] for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]

for i in xrange(h):
    ps = 0
    for j in xrange(w):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            L[i][j] = ps

for j in xrange(w):
    ps = 0
    for i in xrange(h):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            U[i][j] = ps

for i in xrange(h-1, -1, -1):
    ps = 0
    for j in xrange(w-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            R[i][j] = ps
for j in xrange(w-1, -1, -1):
    ps = 0
    for i in xrange(h-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            D[i][j] = ps
maxLight = 0
for i in xrange(h):
    for j in xrange(w):
        maxLight = max(maxLight, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print maxLight

Buggy python submission (verdict: Runtime Error):
h, w = map(int, raw_input().split())
S = [raw_input() for i in range(h)]
Gh = [[0]*w for i in range(h)]
Gw = [[0]*w for i in range(w)]

for i in range(h):
    ps = 0
    s = S[i]
    for j in range(w):
        if s[j] == "#":
            ps = 0
        else:
            ps += 1
            Gh[i][j] = ps

for j in range(w):
    ps = 0
    for i in range(h):
        if S[i][j] == "#":
            ps = 0
        else:
            ps += 1
            Gw[i][j] = ps

for i in range(h-1, -1, -1):
    ps = 0
    for j in range(w-1, -1, -1):
        if S[i][j] == "#":
            ps = 0
        else:
            ps = max(ps, Gh[i][j])
            Gh[i][j] = ps
for j in range(w-1, -1, -1):
    ps = 0
    for i in range(h-1, -1, -1):
        if S[i][j] == "#":
            ps = 0
        else:
            ps = max(ps, Gw[i][j])
            Gw[i][j] = ps
maxLight = 0
for i in range(h):
    for j in range(w):
        maxLight = max(maxLight, Gh[i][j] + Gw[i][j]-1)
print maxLight


Fixed submission:
h, w = map(int, raw_input().split())
S = [[0 if c == "." else 1 for c in raw_input()] for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]

for i in xrange(h):
    ps = 0
    for j in xrange(w):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            L[i][j] = ps

for j in xrange(w):
    ps = 0
    for i in xrange(h):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            U[i][j] = ps

for i in xrange(h-1, -1, -1):
    ps = 0
    for j in xrange(w-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            R[i][j] = ps
for j in xrange(w-1, -1, -1):
    ps = 0
    for i in xrange(h-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            D[i][j] = ps
maxLight = 0
for i in xrange(h):
    for j in xrange(w):
        maxLight = max(maxLight, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print maxLight

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, raw_input().split())
S = [[c for c in raw_input()] for i in range(h)]
Gh = [[0]*w for i in range(h)]
Gw = [[0]*w for i in range(h)]

for i in range(h):
    ps = 0
    s = S[i]
    for j in range(w):
        if w == j or s[j] == "#":
            ps = 0
        else:
            ps += 1
            Gh[i][j] = ps

for j in range(w):
    ps = 0
    for i in range(h):
        if i == h or S[i][j] == "#":
            ps = 0
        else:
            ps += 1
            Gw[i][j] = ps

for i in range(h-1, -1, -1):
    ps = 0
    for j in range(w-1, -1, -1):
        if S[i][j] == "#":
            ps = 0
        else:
            ps = max(ps, Gh[i][j])
            Gh[i][j] = ps
for j in range(w-1, -1, -1):
    ps = 0
    for i in range(h-1, -1, -1):
        if S[i][j] == "#":
            ps = 0
        else:
            ps = max(ps, Gw[i][j])
            Gw[i][j] = ps
maxLight = 0
for i in range(h):
    for j in range(w):
        maxLight = max(maxLight, Gh[i][j] + Gw[i][j]-1)
print maxLight


Fixed submission:
h, w = map(int, raw_input().split())
S = [[0 if c == "." else 1 for c in raw_input()] for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]

for i in xrange(h):
    ps = 0
    for j in xrange(w):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            L[i][j] = ps

for j in xrange(w):
    ps = 0
    for i in xrange(h):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            U[i][j] = ps

for i in xrange(h-1, -1, -1):
    ps = 0
    for j in xrange(w-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            R[i][j] = ps
for j in xrange(w-1, -1, -1):
    ps = 0
    for i in xrange(h-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            D[i][j] = ps
maxLight = 0
for i in xrange(h):
    for j in xrange(w):
        maxLight = max(maxLight, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print maxLight

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, raw_input().split())
S = [[c for c in raw_input()] for i in range(h)]
Gh = [[0]*w for i in range(h)]
Gw = [[0]*w for i in range(h)]

for i in range(h):
    ps = 0
    leftObstacle = -1
    s = S[i]
    for j in range(w+1):
        if w == j or s[j] == "#":
            for k in range(leftObstacle + 1, j):
                Gh[i][k] = ps
            ps = 0
            leftObstacle = j
        else:
            ps += 1

for j in range(w):
    ps = 0
    upObstacle = -1
    for i in range(h+1):
        if i == h or S[i][j] == "#":
            for k in range(upObstacle+1, i):
                Gw[k][j] = ps
            ps = 0
            upObstacle = i
        else:
            ps += 1
maxLight = 0
for i in range(h):
    for j in range(w):
        maxLight = max(maxLight, Gh[i][j] + Gw[i][j]-1)
print maxLight

Fixed submission:
h, w = map(int, raw_input().split())
S = [[0 if c == "." else 1 for c in raw_input()] for i in range(h)]
L = [[0]*w for i in range(h)]
R = [[0]*w for i in range(h)]
U = [[0]*w for i in range(h)]
D = [[0]*w for i in range(h)]

for i in xrange(h):
    ps = 0
    for j in xrange(w):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            L[i][j] = ps

for j in xrange(w):
    ps = 0
    for i in xrange(h):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            U[i][j] = ps

for i in xrange(h-1, -1, -1):
    ps = 0
    for j in xrange(w-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            R[i][j] = ps
for j in xrange(w-1, -1, -1):
    ps = 0
    for i in xrange(h-1, -1, -1):
        if S[i][j] == 1:
            ps = 0
        else:
            ps += 1
            D[i][j] = ps
maxLight = 0
for i in xrange(h):
    for j in xrange(w):
        maxLight = max(maxLight, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print maxLight