Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
m = [[0] * W for _ in range(H)]
for h in range(H):
    i = None
    for j in range(W + 1):
        if j < W and S[h][j] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[h][k] += j - i
                i = None
for w in range(W):
    i = None
    for j in range(H + 1):
        if j < H and S[j][w] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[k][w] += j - i
                i = None
ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        ans = max(ans, m[h][w] - 1)
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
m = [[0] * W for _ in range(H)]
for h in range(H):
    i = None
    for j in range(W + 1):
        if j < W and S[h][j] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[h][k] += j - i
                i = None
for w in range(W):
    i = None
    for j in range(H + 1):
        if j < H and S[j][w] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[k][w] += j - i
                i = None
ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        ans = max(ans, m[h][w] - 1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
m = [[[0, 0] for _ in range(W)] for _ in range(H)]
for h in range(H):
    i = None
    for j in range(W + 1):
        if j < W and S[h][j] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[h][k][0] = j - i
                i = None
for w in range(W):
    i = None
    for j in range(H + 1):
        if j < H and S[j][w] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[k][w][1] = j - i
                i = None
ans = 0
for h in range(H):
    for w in range(W):
        if m[h][w][0] == 0 or m[h][w][1] == 0:
            continue
        ans = max(ans, m[h][w][0] + m[h][w][1] - 1)
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
m = [[0] * W for _ in range(H)]
for h in range(H):
    i = None
    for j in range(W + 1):
        if j < W and S[h][j] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[h][k] += j - i
                i = None
for w in range(W):
    i = None
    for j in range(H + 1):
        if j < H and S[j][w] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[k][w] += j - i
                i = None
ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        ans = max(ans, m[h][w] - 1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
m = [[[0, 0] for _ in range(W)] for _ in range(H)]
for h in range(H):
    i = None
    for j in range(W + 1):
        if j < W and S[h][j] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[h][k][0] = j - i
                i = None
for w in range(W):
    i = None
    for j in range(H + 1):
        if j < H and S[j][w] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[k][w][1] = j - i
                i = None
ans = 0
for h in range(H):
    for w in range(W):
        if m[h][w][0] == 0 or m[h][w][1] == 0:
            continue
        ans = max(ans, m[h][w][0] + m[h][w][1] - 1)
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
m = [[0] * W for _ in range(H)]
for h in range(H):
    i = None
    for j in range(W + 1):
        if j < W and S[h][j] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[h][k] += j - i
                i = None
for w in range(W):
    i = None
    for j in range(H + 1):
        if j < H and S[j][w] == ".":
            if i is None:
                i = j
        else:
            if i is not None:
                for k in range(i, j):
                    m[k][w] += j - i
                i = None
ans = 0
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        ans = max(ans, m[h][w] - 1)
print(ans)