Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[0 for w in range(W + 2)] for h in range(H + 2)]
R = [[0 for w in range(W + 2)] for h in range(H + 2)]
D = [[0 for w in range(W + 2)] for h in range(H + 2)]
U = [[0 for w in range(W + 2)] for h in range(H + 2)] 
ans = 0
for i in range(H):
  S[i] = input()
  for j in range(W):
    if S[i][j] == '.':
      L[i + 1][j + 1] = L[i + 1][j] + 1
    if S[i][W - 1 - j] == '.':
      R[i + 1][W - j] = R[i + 1][W - j + 1] + 1
for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      U[i + 1][j + 1] = U[i][j + 1] + 1
    if S[H - 1 - i][j] == '.':
      D[H - i][j + 1] = D[H + 1 - i][j + 1] + 1
for i in range(1, H + 1):
  for j in range(1, W + 1):
    ans = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, ans)
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[0 for w in range(W + 2)] for h in range(H + 2)]
R = [[0 for w in range(W + 2)] for h in range(H + 2)]
D = [[0 for w in range(W + 2)] for h in range(H + 2)]
U = [[0 for w in range(W + 2)] for h in range(H + 2)] 
ans = 0
for i in range(H):
  S[i] = input()
  for j in range(W):
    if S[i][j] == '.':
      L[i + 1][j + 1] = L[i + 1][j] + 1
    if S[i][W - 1 - j] == '.':
      R[i + 1][W - j] = R[i + 1][W - j + 1] + 1
for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      U[i + 1][j + 1] = U[i][j + 1] + 1
    if S[H - 1 - i][j] == '.':
      D[H - i][j + 1] = D[H + 1 - i][j + 1] + 1
for i in range(1, H + 1):
  for j in range(1, W + 1):
    ans = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[[0, 0] for w in range(W + 2)] for h in range(H + 2)]
ans = 0
for i in range(H):
  S[i] = input()
  for j in range(W):
    if S[i][j] == '.':
      if L[i + 1][j][0] == 0:
        k = j
        while k < W and S[i][k] == '.':
          L[i + 1][j + 1][0] += 1
          k += 1
      else:
        L[i + 1][j + 1][0] = L[i + 1][j][0]
for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      if L[i][j + 1][1] == 0:
        k = i
        while k < H and S[k][j] == '.':
          L[i + 1][j + 1][1] += 1
          k += 1
        ans = max(sum(L[i + 1][j + 1]) - 1, ans)
      else:
        L[i + 1][j + 1][1] = L[i][j + 1][1]
        ans = max(sum(L[i + 1][j + 1]) - 1, ans)
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[0 for w in range(W + 2)] for h in range(H + 2)]
R = [[0 for w in range(W + 2)] for h in range(H + 2)]
D = [[0 for w in range(W + 2)] for h in range(H + 2)]
U = [[0 for w in range(W + 2)] for h in range(H + 2)] 
ans = 0
for i in range(H):
  S[i] = input()
  for j in range(W):
    if S[i][j] == '.':
      L[i + 1][j + 1] = L[i + 1][j] + 1
    if S[i][W - 1 - j] == '.':
      R[i + 1][W - j] = R[i + 1][W - j + 1] + 1
for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      U[i + 1][j + 1] = U[i][j + 1] + 1
    if S[H - 1 - i][j] == '.':
      D[H - i][j + 1] = D[H + 1 - i][j + 1] + 1
for i in range(1, H + 1):
  for j in range(1, W + 1):
    ans = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[[0, 0] for w in range(W + 1)] for h in range(H + 1)]
for i in range(H):
  S[i] = input()
  l = 0
  for j in range(W):
    if S[i][j] == '#':
      L[i][j - l][0] = l
      L[i][j][0] = -l
      l = 0
    else:
      l += 1
  L[i][W - l][0] = l
  L[i][W][0] = -l
for j in range(W):
  u = 0
  for i in range(H):
    if S[i][j] == '#':
      L[i - u][j][1] = u
      L[i][j][1] = -u
      u = 0
    else:
      u += 1
  L[H - u][j][1] = u
  L[H][j][1] = -u
for i in range(H):
  for j in range(1, W):
    L[i][j][0] += L[i][j - 1][0]
for j in range(W):
  for i in range(1, H):
    L[i][j][1] += L[i - 1][j][1]
ans = 0
for i in range(H):
  for j in range(W):
    ans = max(sum(L[i][j]) - 1, ans)
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[0 for w in range(W + 2)] for h in range(H + 2)]
R = [[0 for w in range(W + 2)] for h in range(H + 2)]
D = [[0 for w in range(W + 2)] for h in range(H + 2)]
U = [[0 for w in range(W + 2)] for h in range(H + 2)] 
ans = 0
for i in range(H):
  S[i] = input()
  for j in range(W):
    if S[i][j] == '.':
      L[i + 1][j + 1] = L[i + 1][j] + 1
    if S[i][W - 1 - j] == '.':
      R[i + 1][W - j] = R[i + 1][W - j + 1] + 1
for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      U[i + 1][j + 1] = U[i][j + 1] + 1
    if S[H - 1 - i][j] == '.':
      D[H - i][j + 1] = D[H + 1 - i][j + 1] + 1
for i in range(1, H + 1):
  for j in range(1, W + 1):
    ans = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[[0, 0] for w in range(W + 1)] for h in range(H + 1)]
for i in range(H):
  S[i] = input()
  l = 0
  for j in range(W):
    if S[i][j] == '#':
      L[i][j - l][0] = l
      L[i][j][0] = -l
      l = 0
    else:
      l += 1
  L[i][W - l][0] = l
  L[i][W][0] = -l
for j in range(W):
  u = 0
  for i in range(H):
    if S[i][j] == '#':
      L[i - u][j][1] = u
      L[i][j][1] = -u
      u = 0
    else:
      u += 1
  L[H - u][j][1] = u
  L[H][j][1] = -u
for i in range(H):
  for j in range(1, W):
    L[i][j][0] += L[i][j - 1][0]
for j in range(W):
  for i in range(1, H):
    L[i][j][1] += L[i - 1][j][1]
ans = 0
for i in range(H):
  for j in range(W):
    ans = max(sum(L[i][j]) - 1, ans)
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[0 for w in range(W + 2)] for h in range(H + 2)]
R = [[0 for w in range(W + 2)] for h in range(H + 2)]
D = [[0 for w in range(W + 2)] for h in range(H + 2)]
U = [[0 for w in range(W + 2)] for h in range(H + 2)] 
ans = 0
for i in range(H):
  S[i] = input()
  for j in range(W):
    if S[i][j] == '.':
      L[i + 1][j + 1] = L[i + 1][j] + 1
    if S[i][W - 1 - j] == '.':
      R[i + 1][W - j] = R[i + 1][W - j + 1] + 1
for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      U[i + 1][j + 1] = U[i][j + 1] + 1
    if S[H - 1 - i][j] == '.':
      D[H - i][j + 1] = D[H + 1 - i][j + 1] + 1
for i in range(1, H + 1):
  for j in range(1, W + 1):
    ans = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, ans)
print(ans)