Buggy python submission (verdict: Time Limit Exceeded):
H, W = list(map(int, input().split()))
S = []
for i in range(H):
  S.append(input())
  
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 i in range(H):
  work = 0
  for j in range(W):
    if S[i][j] == '#':
      work = 0
    else:
      work += 1
    R[i][j] = work
    
for i in range(H):
  work = 0
  for j in range(W-1,-1,-1):
    if S[i][j] == '#':
      work = 0
    else:
      work += 1
    L[i][j] = work
    
for i in range(W):
  work = 0
  for j in range(H):
    if S[j][i] == '#':
      work = 0
    else:
      work += 1
    D[j][i] = work
    
for i in range(W):
  work = 0
  for j in range(H-1,-1,-1):
    if S[j][i] == '#':
      work = 0
    else:
      work += 1
    U[j][i] = work
    
ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)
    
print(ans)

Fixed submission:
H, W = list(map(int, input().split()))
S = []
for i in range(H):
  S.append(input())
  
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 i in range(H):
  work = 0
  for j in range(W):
    if S[i][j] == '#':
      work = 0
    else:
      work += 1
    R[i][j] = work
    
for i in range(H):
  work = 0
  for j in range(W-1,-1,-1):
    if S[i][j] == '#':
      work = 0
    else:
      work += 1
    L[i][j] = work
    
for i in range(W):
  work = 0
  for j in range(H):
    if S[j][i] == '#':
      work = 0
    else:
      work += 1
    D[j][i] = work
    
for i in range(W):
  work = 0
  for j in range(H-1,-1,-1):
    if S[j][i] == '#':
      work = 0
    else:
      work += 1
    U[j][i] = work
    
ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)
    
print(ans)

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

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


for i in range(H):
  work = 0
  fj = 0
  for j in range(W+1):
    if j == W or S[i][j] == '#':
      for k in range(fj,j):
        A[i][k] += work
      work = 0
      fj = j + 1
    else:
      work += 1
      
for i in range(W):
  work = 0
  fj = 0
  for j in range(H+1):
    if j == H or S[j][i] == '#':
      for k in range(fj,j):
        A[k][i] += work
      work = 0
      fj = j + 1
    else:
      work += 1

ans = 0
for i in range(H):
  #print(A[i])
  ans = max(ans, max(A[i]))
  
print(ans-1)

Fixed submission:
H, W = list(map(int, input().split()))
S = []
for i in range(H):
  S.append(input())
  
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 i in range(H):
  work = 0
  for j in range(W):
    if S[i][j] == '#':
      work = 0
    else:
      work += 1
    R[i][j] = work
    
for i in range(H):
  work = 0
  for j in range(W-1,-1,-1):
    if S[i][j] == '#':
      work = 0
    else:
      work += 1
    L[i][j] = work
    
for i in range(W):
  work = 0
  for j in range(H):
    if S[j][i] == '#':
      work = 0
    else:
      work += 1
    D[j][i] = work
    
for i in range(W):
  work = 0
  for j in range(H-1,-1,-1):
    if S[j][i] == '#':
      work = 0
    else:
      work += 1
    U[j][i] = work
    
ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3)
    
print(ans)