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

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

for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      if j == 0:
        M_W[i][j] = 1
      else:
        M_W[i][j] = M_W[i][j - 1] + 1
    else:
      M_W[i][j] = 0

for i in range(H):
  max_num = 0
  for j in range(W - 1, -1, -1):
    if M_W[i][j] != 0:
      max_num = max(max_num, M_W[i][j])
      M_W[i][j] = max_num
    else:
      max_num = 0

for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      if i == 0:
        M_H[i][j] = 1
      else:
        M_H[i][j] = M_H[i - 1][j] + 1
    else:
      M_H[i][j] = 0

for j in range(W):
  max_num = 0
  for i in range(H - 1, -1, -1):
    if M_H[i][j] != 0:
      max_num = max(max_num, M_H[i][j])
      M_H[i][j] = max_num
    else:
      max_num = 0

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, M_W[i][j] + M_H[i][j] -1)
print(ans)


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

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

for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      if j == 0:
        M_W[i][j] = 1
      else:
        M_W[i][j] = M_W[i][j - 1] + 1
  for j in range(W-2,-1,-1):
    if S[i][j] == '.' and S[i][j+1] == '.':
      M_W[i][j] = M_W[i][j+1]

for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      if i == 0:
        M_H[i][j] = 1
      else:
        M_H[i][j] = M_H[i-1][j] + 1
  for i in range(H-2,-1,-1):
    if S[i][j] == '.' and S[i+1][j] == '.':
      M_H[i][j] = M_H[i+1][j]

#print(M_W)
#print(M_H)

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, M_W[i][j]+M_H[i][j]-1)
print(ans)

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

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

for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      if j == 0:
        M_W[i][j] = 1
      else:
        M_W[i][j] = M_W[i][j - 1] + 1
    else:
      M_W[i][j] = 0

for i in range(H):
  max_num = 0
  for j in range(W - 1, -1, -1):
    if M_W[i][j] != 0:
      max_num = max(max_num, M_W[i][j])
      M_W[i][j] = max_num
    else:
      max_num = 0

for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      if i == 0:
        M_H[i][j] = 1
      else:
        M_H[i][j] = M_H[i - 1][j] + 1
    else:
      M_H[i][j] = 0

for j in range(W):
  max_num = 0
  for i in range(H - 1, -1, -1):
    if M_H[i][j] != 0:
      max_num = max(max_num, M_H[i][j])
      M_H[i][j] = max_num
    else:
      max_num = 0

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, M_W[i][j] + M_H[i][j] -1)
print(ans)


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

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

for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      if j == 0:
        M_W[i][j] = 1
      else:
        M_W[i][j] = M_W[i][j - 1] + 1
  for j in range(W-2,-1,-1):
    if S[i][j] == '.' and S[i][j+1] == '.':
      M_W[i][j] = M_W[i][j+1]

for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      if i == 0:
        M_H[i][j] = 1
      else:
        M_H[i][j] = M_H[i-1][j] + 1
  for i in range(H-2,-1,-1):
    if S[i][j] == '.' and S[i+1][j] == '.':
      M_H[i][j] = M_H[i+1][j]

#print(M_W)
#print(M_H)

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, M_W[i][j]+M_H[i][j]-1)
print(ans)