Buggy python submission (verdict: Runtime Error):
from collections import deque

h, w = list(map(int, input().split()))

s = [list(input()) for _ in range(h)]

y = [[0] * w for _ in range(h)]
q = deque([])
c = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1
        
        if s[i][j] == "#" or j == w-1:
            while len(q) > 0:
                x, y = q.pop()
                y[x][y] = c
            c = 0



m = 0

c = 0
for j in range(w):
    for i in range(h):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1

        if s[i][j] == "#" or i == h-1:
            while len(q) > 0:
                x, y = q.pop()
                m = max(m, y[x][y] + c - 1)
            c = 0
print(m)


Fixed submission:
from collections import deque

h, w = list(map(int, input().split()))

s = [list(input()) for _ in range(h)]

yo = [[0] * w for _ in range(h)]
q = deque([])
c = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1
        
        if s[i][j] == "#" or j == w-1:
            while len(q) > 0:
                x, y = q.pop()
                yo[x][y] = c
            c = 0



m = 0

c = 0
for j in range(w):
    for i in range(h):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1

        if s[i][j] == "#" or i == h-1:
            while len(q) > 0:
                x, y = q.pop()
                m = max(m, yo[x][y] + c - 1)
            c = 0
print(m)

Buggy python submission (verdict: Runtime Error):
from itertools import *
from collections import *
h,w=map(int,input().split())
s=[[False]*w for i in range(h)]
for i in range(h):
    t=list(input())
    for j in range(w):
        
        if t[j]==".":
            s[i][j]=True
def dp(i,j):
    if s[i][j]:
        return l(i,j)+r(i,j)+d(i,j)+u(i,j)-6
    else:
        return 0
def l(i,j):
    if s[i][j]:
        if j==0:
            return 1
        else:
            return l(i,j-1)+1
    else:
        return 0
def r(i,j):
    if s[i][j]:
        if j==w-1:
            return 1
        else:
            return l(i,j+1)+1
    else:
        return 0
def d(i,j):
    if s[i][j]:
        if i==h-1:
            return 1
        else:
            return d(i+1,j)+1
    else:
        return 0
def u(i,j):
    if s[i][j]:
        if i==0:
            return 1
        else:
            return u(i-1,j)+1
    else:
        return 0
ans=0
for i in range(h):
    for j in range(w):
        if dp(i,j)>ans:
            ans=dp(i,j)
print(ans)

Fixed submission:
from collections import deque

h, w = list(map(int, input().split()))

s = [list(input()) for _ in range(h)]

yo = [[0] * w for _ in range(h)]
q = deque([])
c = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1
        
        if s[i][j] == "#" or j == w-1:
            while len(q) > 0:
                x, y = q.pop()
                yo[x][y] = c
            c = 0



m = 0

c = 0
for j in range(w):
    for i in range(h):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1

        if s[i][j] == "#" or i == h-1:
            while len(q) > 0:
                x, y = q.pop()
                m = max(m, yo[x][y] + c - 1)
            c = 0
print(m)

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[]
d=[]
for i in range(h):
    s.append(list(input()))
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            d.append((i,j))
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            l,r=-1,w-1
            t,u=-1,h-1
            tmp=0
            for x,y in d:
                if x==i:
                    if l<y<j:
                        l=y
                    if j<y<r:
                        r=y
                if y==j:
                    if t<x<i:
                        t=x
                    if i<x<u:
                        u=x
            tmp=r-l+u-t-1
            if tmp>ans:
                ans=tmp
print(ans)
            

Fixed submission:
from collections import deque

h, w = list(map(int, input().split()))

s = [list(input()) for _ in range(h)]

yo = [[0] * w for _ in range(h)]
q = deque([])
c = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1
        
        if s[i][j] == "#" or j == w-1:
            while len(q) > 0:
                x, y = q.pop()
                yo[x][y] = c
            c = 0



m = 0

c = 0
for j in range(w):
    for i in range(h):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1

        if s[i][j] == "#" or i == h-1:
            while len(q) > 0:
                x, y = q.pop()
                m = max(m, yo[x][y] + c - 1)
            c = 0
print(m)