Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
h+=2
w+=2
s=[]
l=[[0 for i in range(w)]for j in range(h)]
yl=[[]for j in range(h)]
tl=[[]for j in range(w)]
s.append(["#"]*w)
for i in range(h-2):
    a=input()
    s.append("#"+a+"#")
s.append(["#"]*w)

for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            yl[i].append(j)
            tl[j].append(i)
ans=0
import bisect
for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j]!="#":
            n=bisect.bisect(yl[i],j)
            m=bisect.bisect(tl[j],i)
            p=0
            p+=yl[i][n]-yl[i][n-1]+tl[j][m]-tl[j][m-1]-3
            
            ans=max(ans,p)
                
        
print(ans)
    








Fixed submission:
h,w=map(int,input().split())
s=[]
l=[[0 for i in range(w)]for j in range(h)]
 
for i in range(h):
    a=input()
    s.append(a)

yoko=[[0 for j in range(w)] for j in range(h)]
tate=[[0 for j in range(w)] for j in range(h)]

for i in range(h):
    p=0
    for j in range(w):
        if s[i][j]=="#" or j==w-1:
            if s[i][j]==".":
                for k in range(p):
                    yoko[i][j-k-1]+=p+1
                yoko[i][j]+=p+1
            else:
                for k in range(p):
                    yoko[i][j-k-1]+=p
            p=0
        elif s[i][j]==".":
            p+=1
for i in range(w):
    p=0
    for j in range(h):
        if s[j][i]=="#" or j==h-1:
            if s[j][i]==".":
                for k in range(p):
                    tate[j-k-1][i]+=p+1
                yoko[j][i]+=p+1
            else:
                for k in range(p):
                    tate[j-k-1][i]+=p
            p=0
        elif s[j][i]==".":
            p+=1
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,yoko[i][j]+tate[i][j]-1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
h+=2
w+=2
s=[]
l=[[0 for i in range(w)]for j in range(h)]
s.append(["#"]*w)
for i in range(h-2):
    a=input()
    s.append("#"+a+"#")
s.append(["#"]*w)

yl=[[]for j in range(h)]
tl=[[]for j in range(w)]
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            yl[i].append(j)
            tl[j].append(i)
ans=0
import bisect
for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j]!="#":
            n=bisect.bisect(yl[i],j)
            m=bisect.bisect(tl[j],i)
            p=0
            p+=yl[i][n]-yl[i][n-1]+tl[j][m]-tl[j][m-1]-3
            
            ans=max(ans,p)
                
        
print(ans)

Fixed submission:
h,w=map(int,input().split())
s=[]
l=[[0 for i in range(w)]for j in range(h)]
 
for i in range(h):
    a=input()
    s.append(a)

yoko=[[0 for j in range(w)] for j in range(h)]
tate=[[0 for j in range(w)] for j in range(h)]

for i in range(h):
    p=0
    for j in range(w):
        if s[i][j]=="#" or j==w-1:
            if s[i][j]==".":
                for k in range(p):
                    yoko[i][j-k-1]+=p+1
                yoko[i][j]+=p+1
            else:
                for k in range(p):
                    yoko[i][j-k-1]+=p
            p=0
        elif s[i][j]==".":
            p+=1
for i in range(w):
    p=0
    for j in range(h):
        if s[j][i]=="#" or j==h-1:
            if s[j][i]==".":
                for k in range(p):
                    tate[j-k-1][i]+=p+1
                yoko[j][i]+=p+1
            else:
                for k in range(p):
                    tate[j-k-1][i]+=p
            p=0
        elif s[j][i]==".":
            p+=1
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,yoko[i][j]+tate[i][j]-1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
h+=2
w+=2
s=[]
l=[[0 for i in range(w)]for j in range(h)]
s.append(["#" for i in range(w)])
for i in range(h-2):
    a=input()
    s.append("#"+a+"#")
s.append(["#" for i in range(w)])

yl=[[]for j in range(h)]
tl=[[]for j in range(w)]
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            yl[i].append(j)
            tl[j].append(i)
ans=0
import bisect
for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j]!="#":
            n=bisect.bisect(yl[i],j)
            m=bisect.bisect(tl[j],i)
            p=0
            if yl[i][n-1]!=yl[i][-1]:
                p+=yl[i][n]-yl[i][n-1]-1
            elif j<yl[i][0]:
                p+=yl[i][0]
            else:
                p+=len(yl[i])-yl[i][-1]-1
                
            if tl[j][m-1]!=tl[j][-1]:
                p+=tl[j][m]-tl[j][m-1]-2
            elif i<tl[j][0]:
                p+=tl[j][0]-1
            else:
                p+=len(tl[j])-tl[j][-1]-2
            
            ans=max(ans,p)
                
        
print(ans)

Fixed submission:
h,w=map(int,input().split())
s=[]
l=[[0 for i in range(w)]for j in range(h)]
 
for i in range(h):
    a=input()
    s.append(a)

yoko=[[0 for j in range(w)] for j in range(h)]
tate=[[0 for j in range(w)] for j in range(h)]

for i in range(h):
    p=0
    for j in range(w):
        if s[i][j]=="#" or j==w-1:
            if s[i][j]==".":
                for k in range(p):
                    yoko[i][j-k-1]+=p+1
                yoko[i][j]+=p+1
            else:
                for k in range(p):
                    yoko[i][j-k-1]+=p
            p=0
        elif s[i][j]==".":
            p+=1
for i in range(w):
    p=0
    for j in range(h):
        if s[j][i]=="#" or j==h-1:
            if s[j][i]==".":
                for k in range(p):
                    tate[j-k-1][i]+=p+1
                yoko[j][i]+=p+1
            else:
                for k in range(p):
                    tate[j-k-1][i]+=p
            p=0
        elif s[j][i]==".":
            p+=1
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,yoko[i][j]+tate[i][j]-1)

print(ans)