Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
s=[input() for i in range(h)]
c=[[[0,0] for i in range(w)] for i in range(h)]
t=0
for H in range(h):
    for W in range(w):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                c[H][W-l][0]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[H][-l][0]=t
    t=0    
for W in range(w):
    for H in range(h):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                c[H-l][W][1]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[-l][W][1]=t
    t=0
ans=0
for i in c:
    for j in i:
        ans=max(sum(j),ans)
print(max(ans-1,0))

Fixed submission:
h,w=map(int,input().split())
s=[input() for i in range(h)]
c=[[0 for i in range(w)] for i in range(h)]
t=0
for H in range(h):
    for W in range(w):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                c[H][W-l]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[H][-l]=t
    t=0
ans=0
for W in range(w):
    for H in range(h):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                ans=max(c[H-l][W]+t,ans)
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        ans=max(c[-l][W]+t,ans)
    t=0
print(max(ans-1,0))

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
s=[input() for i in range(h)]
c=[[[0,0] for i in range(w)] for i in range(h)]
t=0
for H,i in enumerate(s):
    for W,j in enumerate(i):
        if(j=="#"):
            for l in range(1,t+1):
                c[H][W-l][0]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[H][-l][0]=t
    t=0    
for W in range(w):
    for H in range(h):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                c[H-l][W][1]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[-l][W][1]=t
    t=0
ans=0
for i in c:
    for j in i:
        ans=max(sum(j),ans)
print(max(ans-1,0))

Fixed submission:
h,w=map(int,input().split())
s=[input() for i in range(h)]
c=[[0 for i in range(w)] for i in range(h)]
t=0
for H in range(h):
    for W in range(w):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                c[H][W-l]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[H][-l]=t
    t=0
ans=0
for W in range(w):
    for H in range(h):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                ans=max(c[H-l][W]+t,ans)
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        ans=max(c[-l][W]+t,ans)
    t=0
print(max(ans-1,0))

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
s=[input() for i in range(h)]
c=[[[0,0] for i in range(w)] for i in range(h)]
t=0
for H,i in enumerate(s):
    for W,j in enumerate(i):
        if(j=="#"):
            for l in range(1,t+1):
                c[H][W-l][0]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[H][-l][0]=t
    t=0    
for W in range(w):
    for H in range(h):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                c[H-l][W][1]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[-l][W][1]=t
    t=0
ans=0
for i in c:
    for j in i:
        ans=max(sum(j),ans)
print(max(ans-1,0))

Fixed submission:
h,w=map(int,input().split())
s=[input() for i in range(h)]
c=[[0 for i in range(w)] for i in range(h)]
t=0
for H in range(h):
    for W in range(w):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                c[H][W-l]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[H][-l]=t
    t=0
ans=0
for W in range(w):
    for H in range(h):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                ans=max(c[H-l][W]+t,ans)
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        ans=max(c[-l][W]+t,ans)
    t=0
print(max(ans-1,0))