Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
field = [list(input()) for _ in range(H)]
#print(field)

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

#print(L)
for h in range(H):
  for w in range(W-1,-1,-1):
    if field[h][w] == "#":
      R[h][w] = 0
    elif w == W-1:
      R[h][w] = 1
    else:
      R[h][w] = R[h][w+1] + 1
#print(R)
for h in range(H-1,-1,-1):
  for w in range(W):
    if field[h][w] == "#":
      D[h][w] = 0
    elif h == H-1:
      D[h][w] = 1
    else:
      D[h][w] = D[h+1][w] + 1
#print(D)     
#print(U)
ans = 0
for h in range(H):
  for w in range(W):
    if field[h][w] == "#":
      L[h][w] = 0
    elif w == 0:
      L[h][w] = 1
    else:
      L[h][w] = L[h][w-1] + 1
    if field[h][w] == "#":
      U[h][w] = 0
    elif h == 0:
      U[h][w] = 1
    else:
      U[h][w] = U[h-1][w] + 1
    ans = max(ans,L[h][w] + R[h][w] + D[h][w] + U[h][w] - 3)

print(ans)

Fixed submission:
H,W = map(int,input().split())
field = [list(input()) for _ in range(H)]
#print(field)

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

#print(L)
for h in range(H):
  for w in range(W-1,-1,-1):
    if field[h][w] == "#":
      R[h][w] = 0
    elif w == W-1:
      R[h][w] = 1
    else:
      R[h][w] = R[h][w+1] + 1
#print(R)
for h in range(H-1,-1,-1):
  for w in range(W):
    if field[h][w] == "#":
      D[h][w] = 0
    elif h == H-1:
      D[h][w] = 1
    else:
      D[h][w] = D[h+1][w] + 1
#print(D)     
#print(U)
ans = 0
for h in range(H):
  for w in range(W):
    if field[h][w] == "#":
      L[h][w] = 0
    elif w == 0:
      L[h][w] = 1
    else:
      L[h][w] = L[h][w-1] + 1
    if field[h][w] == "#":
      U[h][w] = 0
    elif h == 0:
      U[h][w] = 1
    else:
      U[h][w] = U[h-1][w] + 1
    ans = max(ans,L[h][w] + R[h][w] + D[h][w] + U[h][w] - 3)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
field = [list(input()) for _ in range(H)]
#print(field)

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

for h in range(H):
  for w in range(W):
    if field[h][w] == "#":
      L[h][w] = 0
    elif w == 0:
      L[h][w] = 1
    else:
      L[h][w] = L[h][w-1] + 1
#print(L)
for h in range(H):
  for w in range(W-1,-1,-1):
    if field[h][w] == "#":
      R[h][w] = 0
    elif w == W-1:
      R[h][w] = 1
    else:
      R[h][w] = R[h][w+1] + 1
#print(R)
for h in range(H-1,-1,-1):
  for w in range(W):
    if field[h][w] == "#":
      D[h][w] = 0
    elif h == H-1:
      D[h][w] = 1
    else:
      D[h][w] = D[h+1][w] + 1
#print(D)     
for h in range(H):
  for w in range(W):
    if field[h][w] == "#":
      U[h][w] = 0
    elif h == 0:
      U[h][w] = 1
    else:
      U[h][w] = U[h-1][w] + 1
#print(U)
ans = 0
for h in range(H):
  for w in range(W):
    ans = max(ans,L[h][w] + R[h][w] + D[h][w] + U[h][w] - 3)
print(ans)

Fixed submission:
H,W = map(int,input().split())
field = [list(input()) for _ in range(H)]
#print(field)

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

#print(L)
for h in range(H):
  for w in range(W-1,-1,-1):
    if field[h][w] == "#":
      R[h][w] = 0
    elif w == W-1:
      R[h][w] = 1
    else:
      R[h][w] = R[h][w+1] + 1
#print(R)
for h in range(H-1,-1,-1):
  for w in range(W):
    if field[h][w] == "#":
      D[h][w] = 0
    elif h == H-1:
      D[h][w] = 1
    else:
      D[h][w] = D[h+1][w] + 1
#print(D)     
#print(U)
ans = 0
for h in range(H):
  for w in range(W):
    if field[h][w] == "#":
      L[h][w] = 0
    elif w == 0:
      L[h][w] = 1
    else:
      L[h][w] = L[h][w-1] + 1
    if field[h][w] == "#":
      U[h][w] = 0
    elif h == 0:
      U[h][w] = 1
    else:
      U[h][w] = U[h-1][w] + 1
    ans = max(ans,L[h][w] + R[h][w] + D[h][w] + U[h][w] - 3)

print(ans)