Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
grid = [['#' for i in range(w+2)]]
for i in range(h):
  grid.append(['#'] + [s for s in str(input())] + ['#'])
grid.append(['#' for i in range(w+2)])

U = [[0 for j in range(w+2)] for i in range(h+2)]
D = [[0 for j in range(w+2)] for i in range(h+2)]
L = [[0 for j in range(w+2)] for i in range(h+2)]
R = [[0 for j in range(w+2)] for i in range(h+2)]

for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    U[i][j] = U[i-1][j] + 1
    L[i][j] = L[i][j-1] + 1
for i in range(h, 0, -1):
  for j in range(w, 0, -1):
    if grid[i][j] == '#': continue
    D[i][j] = D[i+1][j] + 1
    R[i][j] = R[i][j+1] + 1

ans = 0
for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    cnt = U[i][j] + D[i][j] + L[i][j] + R[i][j] - 3
    ans = max(ans, cnt)
    #print(i, j, cnt)
print(ans)

Fixed submission:
h, w = map(int, input().split())
grid = [['#' for i in range(w+2)]]
for i in range(h):
  grid.append(['#'] + [s for s in str(input())] + ['#'])
grid.append(['#' for i in range(w+2)])

ud = [[0 for j in range(w+2)] for i in range(h+2)]
lr = [[0 for j in range(w+2)] for i in range(h+2)]

for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue

    if ud[i-1][j] > 0:
      ud[i][j] = ud[i-1][j]
    else:
      cnt = 0
      d = i
      while grid[d][j] != '#':
        cnt += 1
        d += 1
      ud[i][j] = cnt

    if lr[i][j-1] > 0:
      lr[i][j] = lr[i][j-1]
    else:
      cnt = 0
      r = j
      while grid[i][r] != '#':
        cnt += 1
        r += 1
      lr[i][j] = cnt

ans = 0
for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    cnt = ud[i][j] + lr[i][j] - 1
    ans = max(ans, cnt)
    #print(i, j, cnt)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
grid = [['#' for i in range(w+2)]]
for i in range(h):
  grid.append(['#'] + [s for s in str(input())] + ['#'])
grid.append(['#' for i in range(w+2)])
#print(grid)
ans = 0
for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    cnt = 1
    u, d = i-1, i+1
    l, r = j-1, j+1
    while True:
      if grid[u][j] == '#': break
      cnt += 1
      u -= 1
    while True:
      if grid[d][j] == '#': break
      cnt += 1
      d += 1
    while True:
      if grid[i][l] == '#': break
      cnt += 1
      l -= 1
    while True:
      if grid[i][r] == '#': break
      cnt += 1
      r += 1
    ans = max(ans, cnt)
    #print(i, j, cnt)
print(ans)

Fixed submission:
h, w = map(int, input().split())
grid = [['#' for i in range(w+2)]]
for i in range(h):
  grid.append(['#'] + [s for s in str(input())] + ['#'])
grid.append(['#' for i in range(w+2)])

ud = [[0 for j in range(w+2)] for i in range(h+2)]
lr = [[0 for j in range(w+2)] for i in range(h+2)]

for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue

    if ud[i-1][j] > 0:
      ud[i][j] = ud[i-1][j]
    else:
      cnt = 0
      d = i
      while grid[d][j] != '#':
        cnt += 1
        d += 1
      ud[i][j] = cnt

    if lr[i][j-1] > 0:
      lr[i][j] = lr[i][j-1]
    else:
      cnt = 0
      r = j
      while grid[i][r] != '#':
        cnt += 1
        r += 1
      lr[i][j] = cnt

ans = 0
for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    cnt = ud[i][j] + lr[i][j] - 1
    ans = max(ans, cnt)
    #print(i, j, cnt)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
grid = [['#' for i in range(w+2)]]
for i in range(h):
  grid.append(['#'] + [s for s in str(input())] + ['#'])
grid.append(['#' for i in range(w+2)])
#print(grid)
ans = 0
for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    cnt = 1
    u, d = i-1, i+1
    l, r = j-1, j+1
    while True:
      if grid[u][j] == '#': break
      cnt += 1
      u -= 1
    while True:
      if grid[d][j] == '#': break
      cnt += 1
      d += 1
    while True:
      if grid[i][l] == '#': break
      cnt += 1
      l -= 1
    while True:
      if grid[i][r] == '#': break
      cnt += 1
      r += 1
    ans = max(ans, cnt)
    #print(i, j, cnt)
print(ans)

Fixed submission:
h, w = map(int, input().split())
grid = [['#' for i in range(w+2)]]
for i in range(h):
  grid.append(['#'] + [s for s in str(input())] + ['#'])
grid.append(['#' for i in range(w+2)])

ud = [[0 for j in range(w+2)] for i in range(h+2)]
lr = [[0 for j in range(w+2)] for i in range(h+2)]

for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue

    if ud[i-1][j] > 0:
      ud[i][j] = ud[i-1][j]
    else:
      cnt = 0
      d = i
      while grid[d][j] != '#':
        cnt += 1
        d += 1
      ud[i][j] = cnt

    if lr[i][j-1] > 0:
      lr[i][j] = lr[i][j-1]
    else:
      cnt = 0
      r = j
      while grid[i][r] != '#':
        cnt += 1
        r += 1
      lr[i][j] = cnt

ans = 0
for i in range(1, h+1):
  for j in range(1, w+1):
    if grid[i][j] == '#': continue
    cnt = ud[i][j] + lr[i][j] - 1
    ans = max(ans, cnt)
    #print(i, j, cnt)
print(ans)