Buggy python submission (verdict: Time Limit Exceeded):
H,W=map(int,input().split())

L=[[0]*W for i in range(H)]
R=[[0]*W for i in range(H)]
U=[[0]*W for i in range(H)]
D=[[0]*W for i in range(H)]

cntr=0
cntd=[0]*W
for i in range(H):
    temp=input()
    for j in range(W):
        if temp[j]!="#":
            if j==0:
                L[i][j]=1
            else:
                L[i][j]=L[i][j-1]+1
            cntr+=1
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j]=U[i-1][j]+1
            cntd[j]+=1
        else:
            for k in range(cntr):
                R[i][j-1-k]=k+1
            cntr=0
            for k in range(cntd[j]):
                D[i-1-k][j]=k+1
            cntd[j]=0
    if cntr!=0:
        for k in range(cntr):
            R[i][W - 1 - k] = k + 1
        cntr=0
for i in range(W):
    if cntd[i]!=0:
        for k in range(cntd[i]):
            D[H-1-k][i]=k+1

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








Fixed submission:
H,W=map(int,input().split())

s=[[0]*W for i in range(H)]

for i in range(H):
    cnt = 0
    temp=input()

    for j in range(W):
        if temp[j]!="#":
            cnt+=1
        else:
            if j==0:
                continue
            else:
                for k in range(cnt):
                    s[i][j-(1+k)]=cnt
                cnt=0
    if cnt!=0:
        for k in range(cnt):
            s[i][W-1 - k] = cnt
        cnt = 0

ans=[]
mx=0
for i in range(W):
    cnt=0
    for j in range(H):
        if s[j][i]!=0:
            cnt+=1
            mx=max(mx,s[j][i])
        else:
            if j==0:
                continue
            else:
                ans.append(mx+cnt-1)
                cnt=0
                mx=0
    if cnt!=0:
        ans.append(mx+cnt-1)
        mx=0
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
H,W=map(int,input().split())

s=[[0]*W for i in range(H)]

for i in range(H):
    cnt = 0
    temp=input()

    for j in range(W):
        if temp[j]!="#":
            cnt+=1
        else:
            if j==0:
                continue
            else:
                for k in range(cnt):
                    s[i][j-(1+k)]=cnt
                cnt=0
    if cnt!=0:
        for k in range(cnt):
            s[i][W-1 - k] = cnt
        cnt = 0

ans=[]
mx=0
for i in range(W):
    cnt=0
    for j in range(H):
        if s[j][i]!=0:
            cnt+=1
            mx=max(mx,s[j][i])
        else:
            if j==0:
                continue
            else:
                ans.append(mx+cnt-1)
                cnt=0
                mx=0
    if cnt!=0:
        ans.append(mx+cnt-1)
        mx=0
print(max(ans))



Fixed submission:
H,W=map(int,input().split())

s=[[0]*W for i in range(H)]

for i in range(H):
    cnt = 0
    temp=input()

    for j in range(W):
        if temp[j]!="#":
            cnt+=1
        else:
            if j==0:
                continue
            else:
                for k in range(cnt):
                    s[i][j-(1+k)]=cnt
                cnt=0
    if cnt!=0:
        for k in range(cnt):
            s[i][W-1 - k] = cnt
        cnt = 0

ans=[]
mx=0
for i in range(W):
    cnt=0
    for j in range(H):
        if s[j][i]!=0:
            cnt+=1
            mx=max(mx,s[j][i])
        else:
            if j==0:
                continue
            else:
                ans.append(mx+cnt-1)
                cnt=0
                mx=0
    if cnt!=0:
        ans.append(mx+cnt-1)
        mx=0
print(max(ans))