Buggy python submission (verdict: Time Limit Exceeded):
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            if j==0:
                L[i][j]=1
            else:
                L[i][j]=L[i][j-1]+1
for i in range(H):
    for j in range(W-1,-1,-1):
        if S[i][j]==".":
            if j==(W-1):
                R[i][j]=1
            else:
                R[i][j]=R[i][j+1]+1

for j in range(W):
    for i in range(H-1,-1,-1):
        if S[i][j]==".":
            if i==(H-1):
                D[i][j]=1
            else:
                D[i][j]=D[i+1][j]+1

for j in range(W):
    for i in range(H):
        if S[i][j]==".":
            if i==0:
                U[i][j]=1
            else:
                U[i][j]=U[i-1][j]+1
ans=0
X=[[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        X[i][j]=L[i][j]+R[i][j]+D[i][j]+U[i][j]-3
    ans=max(ans,max(X[i]))
print(ans)

Fixed submission:
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            if j==0:
                L[i][j]=1
            else:
                L[i][j]=L[i][j-1]+1
for i in range(H):
    for j in range(W-1,-1,-1):
        if S[i][j]==".":
            if j==(W-1):
                R[i][j]=1
            else:
                R[i][j]=R[i][j+1]+1

for j in range(W):
    for i in range(H-1,-1,-1):
        if S[i][j]==".":
            if i==(H-1):
                D[i][j]=1
            else:
                D[i][j]=D[i+1][j]+1

for j in range(W):
    for i in range(H):
        if S[i][j]==".":
            if i==0:
                U[i][j]=1
            else:
                U[i][j]=U[i-1][j]+1
ans=0
X=[[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        X[i][j]=L[i][j]+R[i][j]+D[i][j]+U[i][j]-3
    ans=max(ans,max(X[i]))
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)
L=[[] for _ in range(H)]
R=[[] for _ in range(H)]
D=[[] for _ in range(H)]
U=[[] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            L[i].append(0)
        if S[i][W-1-j]=="#":
            R[i].append(0)
        else:
            if j==0:
                L[i].append(1)
                R[i].append(1)
            else:
                L[i].append(L[i][j-1]+1)
                R[i].append(R[i][j-1]+1)

for i in range(W):
    for j in range(H):
        if S[j][i]=="#":
            U[j].append(0)
        if S[H-1-j][i]=="#":
            D[j].append(0)
        else:
            if j==0:
                U[j].append(1)
                D[j].append(1)
            else:
                U[j].append(U[j-1][i]+1)
                D[j].append(D[j-1][i]+1)
ans=0

for i in range(H):
    for j in range(W):
        tmp=L[i][j]+R[i][W-1-j]+U[i][j]+D[H-1-i][j]-3
        ans=max(ans,tmp)
print(ans)

Fixed submission:
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            if j==0:
                L[i][j]=1
            else:
                L[i][j]=L[i][j-1]+1
for i in range(H):
    for j in range(W-1,-1,-1):
        if S[i][j]==".":
            if j==(W-1):
                R[i][j]=1
            else:
                R[i][j]=R[i][j+1]+1

for j in range(W):
    for i in range(H-1,-1,-1):
        if S[i][j]==".":
            if i==(H-1):
                D[i][j]=1
            else:
                D[i][j]=D[i+1][j]+1

for j in range(W):
    for i in range(H):
        if S[i][j]==".":
            if i==0:
                U[i][j]=1
            else:
                U[i][j]=U[i-1][j]+1
ans=0
X=[[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        X[i][j]=L[i][j]+R[i][j]+D[i][j]+U[i][j]-3
    ans=max(ans,max(X[i]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)
L=[[] for _ in range(H)]
R=[[] for _ in range(H)]
D=[[] for _ in range(H)]
U=[[] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            L[i].append(0)
        else:
            if j==0:
                L[i].append(1)
            else:
                L[i].append(L[i][j-1]+1)
for i in range(H):
    for j in range(W):
        if S[i][W-1-j]=="#":
            R[i].append(0)
        else:
            if j==0:
                R[i].append(1)
            else:
                R[i].append(R[i][j-1]+1)
for i in range(W):
    for j in range(H):
        if S[j][i]=="#":
            U[j].append(0)
        else:
            if j==0:
                U[j].append(1)
            else:
                U[j].append(U[j-1][i]+1)
for i in range(W):
    for j in range(H):
        if S[H-1-j][i]=="#":
            D[j].append(0)
        else:
            if j==0:
                D[j].append(1)
            else:
                D[j].append(D[j-1][i]+1)
ans=0

for i in range(H):
    for j in range(W):
        tmp=L[i][j]+R[i][W-1-j]+U[i][j]+D[H-1-i][j]-3
        ans=max(ans,tmp)
print(ans)

Fixed submission:
H,W=map(int,input().split())
S=[]
for i in range(H):
    s=input()
    S.append(s)
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            if j==0:
                L[i][j]=1
            else:
                L[i][j]=L[i][j-1]+1
for i in range(H):
    for j in range(W-1,-1,-1):
        if S[i][j]==".":
            if j==(W-1):
                R[i][j]=1
            else:
                R[i][j]=R[i][j+1]+1

for j in range(W):
    for i in range(H-1,-1,-1):
        if S[i][j]==".":
            if i==(H-1):
                D[i][j]=1
            else:
                D[i][j]=D[i+1][j]+1

for j in range(W):
    for i in range(H):
        if S[i][j]==".":
            if i==0:
                U[i][j]=1
            else:
                U[i][j]=U[i-1][j]+1
ans=0
X=[[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        X[i][j]=L[i][j]+R[i][j]+D[i][j]+U[i][j]-3
    ans=max(ans,max(X[i]))
print(ans)