Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

row = Counter()
column = Counter()

for j in range(W):
    tmp = set()
    cnt = 0
    for i in range(H):
        if S[i][j] == "#":
            for pi,pj in tmp:
                row[(pi,pj)] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        row[(pi,pj)] = cnt

for i in range(H):
    tmp = set()
    cnt = 0
    for j in range(W):
        if S[i][j] == "#":
            for pi,pj in tmp:
                column[(pi,pj)] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        column[(pi,pj)] = cnt

ans = 0
for i in range(H):
    for j in range(W):
        res = row[(i,j)] + column[(i,j)] - 1
        ans = max(ans,res)

print(ans)

Fixed submission:
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

row = [[0]*W for _ in range(H)]
column = [[0]*W for _ in range(H)]

for j in range(W):
    tmp = set()
    cnt = 0
    for i in range(H):
        if S[i][j] == "#":
            for pi,pj in tmp:
                row[pi][pj] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        row[pi][pj] = cnt

for i in range(H):
    tmp = set()
    cnt = 0
    for j in range(W):
        if S[i][j] == "#":
            for pi,pj in tmp:
                column[pi][pj] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        column[pi][pj] = cnt

ans = 0
for i in range(H):
    for j in range(W):
        res = row[i][j] + column[i][j] - 1
        ans = max(ans,res)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

row = Counter()
column = Counter()

for j in range(W):
    tmp = set()
    cnt = 0
    for i in range(H):
        if S[i][j] == "#":
            for pi,pj in tmp:
                row[(pi,pj)] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        row[(pi,pj)] = cnt

for i in range(H):
    tmp = set()
    cnt = 0
    for j in range(W):
        if S[i][j] == "#":
            for pi,pj in tmp:
                column[(pi,pj)] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        column[(pi,pj)] = cnt

ans = 0
for i in range(H):
    for j in range(W):
        res = row[(i,j)] + column[(i,j)] - 1
        ans = max(ans,res)

print(ans)

Fixed submission:
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

row = [[0]*W for _ in range(H)]
column = [[0]*W for _ in range(H)]

for j in range(W):
    tmp = set()
    cnt = 0
    for i in range(H):
        if S[i][j] == "#":
            for pi,pj in tmp:
                row[pi][pj] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        row[pi][pj] = cnt

for i in range(H):
    tmp = set()
    cnt = 0
    for j in range(W):
        if S[i][j] == "#":
            for pi,pj in tmp:
                column[pi][pj] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        column[pi][pj] = cnt

ans = 0
for i in range(H):
    for j in range(W):
        res = row[i][j] + column[i][j] - 1
        ans = max(ans,res)

print(ans)