Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = [input() for i in range(H)]

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)]
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            if h==0:D[h][w]=1
            else:D[h][w]=D[h-1][w]+1
            if w==0:R[h][w]=1
            else:R[h][w]=R[h][w-1]+1
for h in range(H-1,-1,-1):
    for w in range(W-1,-1,-1):
        if S[h][w]==".":
            if h==H-1:U[h][w]=1
            else:U[h][w]=U[h+1][w]+1
            if w==W-1:L[h][w]=1
            else:L[h][w]=L[h][w+1]+1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,L[h][w]+R[h][w]+U[h][w]+D[h][w]-3)
print(ans)

Fixed submission:
H,W = map(int,input().split())
S = [input() for i in range(H)]

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)]
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            if h==0:D[h][w]=1
            else:D[h][w]=D[h-1][w]+1
            if w==0:R[h][w]=1
            else:R[h][w]=R[h][w-1]+1
for h in range(H-1,-1,-1):
    for w in range(W-1,-1,-1):
        if S[h][w]==".":
            if h==H-1:U[h][w]=1
            else:U[h][w]=U[h+1][w]+1
            if w==W-1:L[h][w]=1
            else:L[h][w]=L[h][w+1]+1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,L[h][w]+R[h][w]+U[h][w]+D[h][w]-3)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = [input() for i in range(H)]

T = [[0]*W for i in range(H)]
L = [[0]*W for i in range(H)]
for w in range(W):
    a = 0
    cnt = 0
    for h in range(H):
        if S[h][w]==".":
            cnt+=1
        else:
            for ha in range(a,h):
                T[ha][w]=cnt
            a = h+1
            cnt = 0
    if cnt!=0:
        for ha in range(a,H):
            T[ha][w]=cnt
for h in range(H):
    a = 0
    cnt = 0
    for w in range(W):
        if S[h][w]==".":cnt+=1
        else:
            for wa in range(a,w):
                L[h][wa]=cnt
            a = w+1
            cnt = 0
    if cnt!=0:
        for wa in range(a,W):
            L[h][wa]=cnt

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,T[h][w]+L[h][w]-1)
print(ans)

Fixed submission:
H,W = map(int,input().split())
S = [input() for i in range(H)]

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)]
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            if h==0:D[h][w]=1
            else:D[h][w]=D[h-1][w]+1
            if w==0:R[h][w]=1
            else:R[h][w]=R[h][w-1]+1
for h in range(H-1,-1,-1):
    for w in range(W-1,-1,-1):
        if S[h][w]==".":
            if h==H-1:U[h][w]=1
            else:U[h][w]=U[h+1][w]+1
            if w==W-1:L[h][w]=1
            else:L[h][w]=L[h][w+1]+1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,L[h][w]+R[h][w]+U[h][w]+D[h][w]-3)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = [input() for i in range(H)]
ans = 0
def f(h,w):
    global H,W,S
    cnt = 1
    for ha in range(h-1,-1,-1):
        if S[ha][w]=="#":break
        cnt+=1
    for hb in range(h+1,H):
        if S[hb][w]=="#":break
        cnt+=1
    for wa in range(w-1,-1,-1):
        if S[h][wa]=="#":break
        cnt+=1
    for wb in range(w+1,W):
        if S[h][wb]=="#":break
        cnt+=1
    return cnt
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            ans = max(ans,f(h,w))
print(ans)

Fixed submission:
H,W = map(int,input().split())
S = [input() for i in range(H)]

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)]
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            if h==0:D[h][w]=1
            else:D[h][w]=D[h-1][w]+1
            if w==0:R[h][w]=1
            else:R[h][w]=R[h][w-1]+1
for h in range(H-1,-1,-1):
    for w in range(W-1,-1,-1):
        if S[h][w]==".":
            if h==H-1:U[h][w]=1
            else:U[h][w]=U[h+1][w]+1
            if w==W-1:L[h][w]=1
            else:L[h][w]=L[h][w+1]+1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,L[h][w]+R[h][w]+U[h][w]+D[h][w]-3)
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]
ans = [[0 for i in range(W)] for j in range(H)]
def f(h,w,x):
  global H,W,S,ans
  if h<0 or h>=H or w<0 or w>=W or S[h][w]=="#":
    return
  ans[h][w]+=1
  if x==0:
    f(h-1,w,1)
    f(h+1,w,2)
    f(h,w-1,3)
    f(h,w+1,4)
  elif x==1:
    f(h-1,w,1)
  elif x==2:
    f(h+1,w,2)
  elif x==3:
    f(h,w-1,3)
  elif x==4:
    f(h,w+1,4)
for h in range(H):
  for w in range(W):
    if S[h][w]=="#":
      continue
    f(h,w,0)
a = 0
for h in ans:
  a = max(a,max(h))
print(a)

Fixed submission:
H,W = map(int,input().split())
S = [input() for i in range(H)]

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)]
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            if h==0:D[h][w]=1
            else:D[h][w]=D[h-1][w]+1
            if w==0:R[h][w]=1
            else:R[h][w]=R[h][w-1]+1
for h in range(H-1,-1,-1):
    for w in range(W-1,-1,-1):
        if S[h][w]==".":
            if h==H-1:U[h][w]=1
            else:U[h][w]=U[h+1][w]+1
            if w==W-1:L[h][w]=1
            else:L[h][w]=L[h][w+1]+1

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,L[h][w]+R[h][w]+U[h][w]+D[h][w]-3)
print(ans)