Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
vert = [[0] * W for _ in range(H)]; hori = [[0] * W for _ in range(H)];
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            hori[i][j] = hori[i][j-1] + 1 if j > 0 else 1
    for j in range(W-2, -1, -1):
        if grid[i][j] == '.' and grid[i][j+1] == '.':
            hori[i][j] = hori[i][j+1] 
for j in range(W):
    for i in range(H):
        if grid[i][j] == '.':
            vert[i][j] = vert[i-1][j] + 1 if i > 0 else 1
    for i in range(H-2, -1, -1):
        if grid[i][j] == '.' and grid[i+1][j] == '.':
            vert[i][j] = vert[i+1][j]
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            ans = max(ans, hori[i][j] + vert[i][j] - 1)
print(ans)

Fixed submission:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
vert = [[0] * W for _ in range(H)]; hori = [[0] * W for _ in range(H)];
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            hori[i][j] = hori[i][j-1] + 1 if j > 0 else 1
    for j in range(W-2, -1, -1):
        if grid[i][j] == '.' and grid[i][j+1] == '.':
            hori[i][j] = hori[i][j+1] 
for j in range(W):
    for i in range(H):
        if grid[i][j] == '.':
            vert[i][j] = vert[i-1][j] + 1 if i > 0 else 1
    for i in range(H-2, -1, -1):
        if grid[i][j] == '.' and grid[i+1][j] == '.':
            vert[i][j] = vert[i+1][j]
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            ans = max(ans, hori[i][j] + vert[i][j] - 1)
print(ans)

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
L = [[0] * W]*H; R = [[0] * W]*H; D = [[0] * W]*H; U = [[0] * W]*H;
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.'
            L[i][j] = L[i][j-1] if j >= 1 else 1
            U[i][j] = U[i-1][j] if i >= 1 else 1
for i in reversed(range(H)):
    for j in reversed(range(W)):
        if grid[i][j] == '.':
            R[i][j] = R[i][j+1] if j <= W-1 else 1
            D[i][j] = D[i+1][j] if i <= H-1 else 1
for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3)
print(ans)

Fixed submission:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
vert = [[0] * W for _ in range(H)]; hori = [[0] * W for _ in range(H)];
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            hori[i][j] = hori[i][j-1] + 1 if j > 0 else 1
    for j in range(W-2, -1, -1):
        if grid[i][j] == '.' and grid[i][j+1] == '.':
            hori[i][j] = hori[i][j+1] 
for j in range(W):
    for i in range(H):
        if grid[i][j] == '.':
            vert[i][j] = vert[i-1][j] + 1 if i > 0 else 1
    for i in range(H-2, -1, -1):
        if grid[i][j] == '.' and grid[i+1][j] == '.':
            vert[i][j] = vert[i+1][j]
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            ans = max(ans, hori[i][j] + vert[i][j] - 1)
print(ans)

Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
L = [[0] * W]*H; R = [[0] * W]*H; D = [[0] * W]*H; U = [[0] * W]*H;
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.'
            L[i][j] = L[i][j-1] if j >= 1 else 1
            U[i][j] = U[i-1][j] if i >= 1 else 1
for i in reversed(range(H)):
    for j in reversed(range(W)):
        if grid[i][j] == '.'
            R[i][j] = R[i][j+1] if j <= W-1 else 1
            D[i][j] = D[i+1][j] if i <= H-1 else 1
for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3)
print(ans)

Fixed submission:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
vert = [[0] * W for _ in range(H)]; hori = [[0] * W for _ in range(H)];
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            hori[i][j] = hori[i][j-1] + 1 if j > 0 else 1
    for j in range(W-2, -1, -1):
        if grid[i][j] == '.' and grid[i][j+1] == '.':
            hori[i][j] = hori[i][j+1] 
for j in range(W):
    for i in range(H):
        if grid[i][j] == '.':
            vert[i][j] = vert[i-1][j] + 1 if i > 0 else 1
    for i in range(H-2, -1, -1):
        if grid[i][j] == '.' and grid[i+1][j] == '.':
            vert[i][j] = vert[i+1][j]
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            ans = max(ans, hori[i][j] + vert[i][j] - 1)
print(ans)