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

H,W = map(int,input().split())
grids = [[s for s in sys.stdin.readline()] for _ in range(H)]

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

row_cnt = [[0 for _ in range(W)]for _ in range(H)]
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      row_cnt[j][i] = 0
      for ii in range(prvii,i):
        row_cnt[j][ii] = tmp_cnt
      prvii = i+1
      tmp_cnt = 0
  for ii in range(prvii,W):
    row_cnt[j][ii] = tmp_cnt

print(max([row_cnt[j][i]+col_cnt[j][i]-1 for i in range(W) for j in range(H)]))

Fixed submission:
import sys

H,W = map(int,input().split())
grids = [[s for s in sys.stdin.readline()] for _ in range(H)]

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

ans = -float('inf')
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      for ii in range(prvii,i):
        ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)
      prvii = i+1
      tmp_cnt = 0

  for ii in range(prvii,W):
    ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)

print(ans)

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

H,W = map(int,input().split())
grids = [[s for s in sys.stdin.readline()] for _ in range(H)]

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

row_cnt = [[0 for _ in range(W)]for _ in range(H)]
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      row_cnt[j][i] = 0
      for ii in range(prvii,i):
        row_cnt[j][ii] = tmp_cnt
      prvii = i+1
      tmp_cnt = 0
  for ii in range(prvii,W):
    row_cnt[j][ii] = tmp_cnt

print(max([row_cnt[j][i]+col_cnt[j][i]-1 for i in range(W) for j in range(H)]))

Fixed submission:
import sys

H,W = map(int,input().split())
grids = [[s for s in sys.stdin.readline()] for _ in range(H)]

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

ans = -float('inf')
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      for ii in range(prvii,i):
        ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)
      prvii = i+1
      tmp_cnt = 0

  for ii in range(prvii,W):
    ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)

print(ans)

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

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

row_cnt = [[0 for _ in range(W)]for _ in range(H)]
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      row_cnt[j][i] = 0
      for ii in range(prvii,i):
        row_cnt[j][ii] = tmp_cnt
      prvii = i+1
      tmp_cnt = 0
  for ii in range(prvii,W):
    row_cnt[j][ii] = tmp_cnt

print(max([row_cnt[j][i]+col_cnt[j][i]-1 for i in range(W) for j in range(H)]))

Fixed submission:
import sys

H,W = map(int,input().split())
grids = [[s for s in sys.stdin.readline()] for _ in range(H)]

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

ans = -float('inf')
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      for ii in range(prvii,i):
        ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)
      prvii = i+1
      tmp_cnt = 0

  for ii in range(prvii,W):
    ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)

print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import groupby

H, W = map(int,input().split())
S = []

max_row_range = [[None, None], [None, None]]
max_row_num = -float('inf')
for j in range(H):
  row = [0 if s=='.' else 1 for s in input()]
  S.append(row)
  
  i = 0
  for key, value in groupby(row):
    value_len = len(list(value))
    if key == 0 and max_row_num < value_len:
      max_row_range = [[i,j],[i+value_len,j]]
      max_row_num = value_len
    i += value_len

max_col_range = [[None, None], [None, None]]
max_col_num = -float('inf')
for i, col in enumerate(zip(*S)):
  if i < max_row_range[0][0] or i < max_row_range[0][1]: continue 
    
  j = 0
  for key, value in groupby(col):
    value_len = len(list(value))
    if key == 0 and max_col_num < value_len:
      max_col_range = [[i,j],[i+value_len,j]]
      max_col_num = value_len
    j += value_len
    
print(max_row_range[1][0]-max_row_range[0][0]+max_col_range[1][0]-max_col_range[0][0]-1)

Fixed submission:
import sys

H,W = map(int,input().split())
grids = [[s for s in sys.stdin.readline()] for _ in range(H)]

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

ans = -float('inf')
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      for ii in range(prvii,i):
        ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)
      prvii = i+1
      tmp_cnt = 0

  for ii in range(prvii,W):
    ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w  = map(int, input().split())
slist = [input() for i in range(h)]
## 1.横→縦
# 横方向maxとなるj
max_empty_yoko = 0
max_idx_yoko = [None, None, None] #[istart, iend, j]
for j, s in enumerate(slist):
  tmp_max_empty = 0
  tmp_max_idxj =[None, None, None]
  for index in range(len(s)):
    if s[index] == '.':
      if tmp_max_empty == 0:
        tmp_max_idxj[0] = index
      tmp_max_empty += 1
    else:
      if max_empty_yoko < tmp_max_empty:
        max_empty_yoko = tmp_max_empty
        max_idx_yoko[0] = tmp_max_idxj[0]
        max_idx_yoko[1] = index-1
        max_idx_yoko[2] = j
      tmp_max_empty = 0
      tmp_max_idxj = [None, None, None]
        

  if max_empty_yoko < tmp_max_empty:
    max_empty_yoko = tmp_max_empty
    max_idx_yoko[0] = tmp_max_idxj[0]
    max_idx_yoko[1] = index-1
    max_idx_yoko[2] = j

max_empty_tate = 0
max_idx_tate = [None, None, None]
for i in range(max_idx_yoko[0],max_idx_yoko[1]):
  tmp_max_empty = 0
  tmp_max_idxi = [None, None, None]
  for j in range(h):
    if slist[j][i] == '.':
      if tmp_max_empty == 0:
        tmp_max_idxi[0] = j
      tmp_max_empty += 1
    else:
      if max_empty_tate < tmp_max_empty:
        max_empty_tate = tmp_max_empty
        max_idx_tate[0] = tmp_max_idxi[0]
        max_idx_tate[1] = j-1
        max_idx_tate[2] = i
      tmp_max_empty = 0
      tmp_max_idxi = [None, None, None]

  if max_empty_tate < tmp_max_empty:
    max_empty_tate = tmp_max_empty
    max_idx_tate[0] = tmp_max_idxi[0]
    max_idx_tate[1] = j
    max_idx_tate[2] = i

# ans1
ans1 = max_empty_yoko+max_empty_tate-1

## 2.縦→横
# 縦方向maxとなるi
max_empty_tate = 0
max_idx_tate = [None, None, None]
for i in range(w):
  tmp_max_empty = 0
  tmp_max_idxi = [None, None, None]
  for j in range(h):
    if slist[j][i] == '.':
      if tmp_max_empty == 0:
        tmp_max_idxi[0] = j
      tmp_max_empty += 1
    else:
      if max_empty_tate < tmp_max_empty:
        max_empty_tate = tmp_max_empty
        max_idx_tate[0] = tmp_max_idxi[0]
        max_idx_tate[1] = j-1
        max_idx_tate[2] = i
      tmp_max_empty = 0
      tmp_max_idxi = [None, None, None]

  if max_empty_tate < tmp_max_empty:
    max_empty_tate = tmp_max_empty
    max_idx_tate[0] = tmp_max_idxi[0]
    max_idx_tate[1] = j
    max_idx_tate[2] = i

# 横方向maxとなるj
max_empty_yoko = 0
max_idx_yoko = [None, None, None] #[istart, iend, j]
for j, s in enumerate(slist):
  if j < max_idx_tate[0] and  max_idx_tate[1] < j:
    continue
  tmp_max_empty = 0
  tmp_max_idxj =[None, None, None]
  for index in range(len(s)):
    if s[index] == '.':
      if tmp_max_empty == 0:
        tmp_max_idxj[0] = index
      tmp_max_empty += 1
    else:
      if max_empty_yoko < tmp_max_empty:
        max_empty_yoko = tmp_max_empty
        max_idx_yoko[0] = tmp_max_idxj[0]
        max_idx_yoko[1] = index-1
        max_idx_yoko[2] = j
      tmp_max_empty = 0
      tmp_max_idxj = [None, None, None]
        

  if max_empty_yoko < tmp_max_empty:
    max_empty_yoko = tmp_max_empty
    max_idx_yoko[0] = tmp_max_idxj[0]
    max_idx_yoko[1] = index-1
    max_idx_yoko[2] = j
# ans2
ans2 = max_empty_yoko+max_empty_tate-1

## ans
print(max(ans1,ans2))

Fixed submission:
import sys

H,W = map(int,input().split())
grids = [[s for s in sys.stdin.readline()] for _ in range(H)]

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

ans = -float('inf')
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      for ii in range(prvii,i):
        ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)
      prvii = i+1
      tmp_cnt = 0

  for ii in range(prvii,W):
    ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)

print(ans)