Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

H, W = map(int, input().split())

grid = []

count_w = [[0] * W for _ in range(H)]
count_h = [[0] * W for _ in range(H)]

for _ in range(H):
  grid.append([x for x in input()])
  

for h in range(H):
  r = 0
  count = 0
  for l in range(W):
    while r < W and grid[h][r] == '.':
      r += 1
      count += 1
    count_w[h][l] = count
    if r == l:
      r += 1
      count = 0
      
for w in range(W):
  r = 0
  count = 0
  for l in range(H):
    while r < H and grid[r][w] == '.':
      r += 1
      count += 1
    count_h[l][w] = count
    if r == l:
      r += 1
      count = 0

print(max(
  count_h[h][w] + count_w[h][w] - 1
  for w in range(W)
  for h in range(H)      
))


Fixed submission:
import sys

input = sys.stdin.readline

H, W = map(int, input().split())

grid = []

count_w = [[0] * W for _ in range(H)]
count_h = [[0] * W for _ in range(H)]

for _ in range(H):
  grid.append([x for x in input()])
  

for h in range(H):
  r = 0
  count = 0
  for l in range(W):
    while r < W and grid[h][r] == '.':
      r += 1
      count += 1
    count_w[h][l] = count
    if r == l:
      r += 1
      count = 0
      
for w in range(W):
  r = 0
  count = 0
  for l in range(H):
    while r < H and grid[r][w] == '.':
      r += 1
      count += 1
    count_h[l][w] = count
    if r == l:
      r += 1
      count = 0

answer = 0

for h in range(H):
  for w in range(W):
    answer = max(answer, count_h[h][w] + count_w[h][w] - 1)

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())

grid = []

count_w = [[0] * W for _ in range(H)]
count_h = [[0] * W for _ in range(H)]

for _ in range(H):
  grid.append([x for x in input()])
  

for h in range(H):
  r = 0
  count = 0
  for l in range(W):
    while r < W and grid[h][r] == '.':
      r += 1
      count += 1
    count_w[h][l] = count
    if r == l:
      r += 1
      count = 0
      
for w in range(W):
  r = 0
  count = 0
  for l in range(H):
    while r < H and grid[r][w] == '.':
      r += 1
      count += 1
    count_h[l][w] = count
    if r == l:
      r += 1
      count = 0

print(max(
  count_h[h][w] + count_w[h][w] - 1
  for w in range(W)
  for h in range(H)      
))


Fixed submission:
import sys

input = sys.stdin.readline

H, W = map(int, input().split())

grid = []

count_w = [[0] * W for _ in range(H)]
count_h = [[0] * W for _ in range(H)]

for _ in range(H):
  grid.append([x for x in input()])
  

for h in range(H):
  r = 0
  count = 0
  for l in range(W):
    while r < W and grid[h][r] == '.':
      r += 1
      count += 1
    count_w[h][l] = count
    if r == l:
      r += 1
      count = 0
      
for w in range(W):
  r = 0
  count = 0
  for l in range(H):
    while r < H and grid[r][w] == '.':
      r += 1
      count += 1
    count_h[l][w] = count
    if r == l:
      r += 1
      count = 0

answer = 0

for h in range(H):
  for w in range(W):
    answer = max(answer, count_h[h][w] + count_w[h][w] - 1)

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())

grid = []

count_w = [[0] * W for _ in range(H)]
count_h = [[0] * W for _ in range(H)]

for _ in range(H):
  grid.append([x for x in input()])
  

for i in range(H):
  for j in range(W):
    if grid[i][j] == '#':
      count_w[i][j] = 0
      continue
    if j == 0 or grid[i][j - 1] == '#':  # カウントスタート
      count = 0
      k = j
      while k < W and grid[i][k] == '.':
        k += 1
        count += 1
      count_w[i][j] = count      
    else:
      count_w[i][j] = count_w[i][j - 1]  # 左隣と同じ
    
for h in range(H):
  for w in range(W):
    if grid[h][w] == '#':
      count_w[h][w] = 0
      continue
    if w == 0 or grid[h][w - 1] == '#':  # カウントスタート
      count = 0
      k = w
      while k < W and grid[h][k] == '.':
        k += 1
        count += 1
      count_w[h][w] = count      
    else:
      count_w[h][w] = count_w[h][w - 1]  # 左隣と同じ  

for w in range(W):
  for h in range(H):
    if grid[h][w] == '#':
      count_h[h][w] = 0
      continue
    if h == 0 or grid[h - 1][w] == '#':  # カウントスタート
      count = 0
      k = h
      while k < H and grid[k][w] == '.':
        k += 1
        count += 1
      count_h[h][w] = count      
    else:
      count_h[h][w] = count_h[h - 1][w]  # 上と同じ        

print(max(
  count_h[h][w] + count_w[h][w] - 1
  for w in range(W)
  for h in range(H)      
))


Fixed submission:
import sys

input = sys.stdin.readline

H, W = map(int, input().split())

grid = []

count_w = [[0] * W for _ in range(H)]
count_h = [[0] * W for _ in range(H)]

for _ in range(H):
  grid.append([x for x in input()])
  

for h in range(H):
  r = 0
  count = 0
  for l in range(W):
    while r < W and grid[h][r] == '.':
      r += 1
      count += 1
    count_w[h][l] = count
    if r == l:
      r += 1
      count = 0
      
for w in range(W):
  r = 0
  count = 0
  for l in range(H):
    while r < H and grid[r][w] == '.':
      r += 1
      count += 1
    count_h[l][w] = count
    if r == l:
      r += 1
      count = 0

answer = 0

for h in range(H):
  for w in range(W):
    answer = max(answer, count_h[h][w] + count_w[h][w] - 1)

print(answer)