Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W = IL()
grid = [[i for i in S()] for i in range(H)]
cntH = [[0 for i in range(W)] for i in range(H)]
cntW = [[0 for i in range(W)] for i in range(H)]

for h in range(H):
  cnt = 0
  for w in range(W):
    if grid[h][w] == "#":
      cnt = 0
    else:
      cnt += 1
      cntW[h][w] = cnt

for h in range(H-1,-1,-1):
  cnt = 0
  for w in range(W-1,-1,-1):
    if grid[h][w] == "#":
      cnt = 0
    elif cnt == 0:
      cnt = cntW[h][w]
    else:
      cntW[h][w] = cnt

for w in range(W):
  cnt = 0
  for h in range(H):
    if grid[h][w] == "#":
      cnt = 0
    else:
      cnt += 1
      cntH[h][w] = cnt

for w in range(W-1,-1,-1):
  cnt = 0
  for h in range(H-1,-1,-1):
    if grid[h][w] == "#":
      cnt = 0
    elif cnt == 0:
      cnt = cntH[h][w]
    else:
      cntH[h][w] = cnt

ans = 0
for h in range(H):
  for w in range(W):
    ans = max(ans,cntW[h][w]+cntH[h][w])

print(ans-1)

Fixed submission:
H,W = list(map(int,input().split()))
grid = [[i for i in input()] for i in range(H)]
cntH = [[0 for i in range(W)] for i in range(H)]
cntW = [[0 for i in range(W)] for i in range(H)]

for h in range(H):
  cnt = 0
  for w in range(W):
    if grid[h][w] == "#":
      cnt = 0
    else:
      cnt += 1
      cntW[h][w] = cnt

for h in range(H-1,-1,-1):
  cnt = 0
  for w in range(W-1,-1,-1):
    if grid[h][w] == "#":
      cnt = 0
    elif cnt == 0:
      cnt = cntW[h][w]
    else:
      cntW[h][w] = cnt

for w in range(W):
  cnt = 0
  for h in range(H):
    if grid[h][w] == "#":
      cnt = 0
    else:
      cnt += 1
      cntH[h][w] = cnt

for w in range(W-1,-1,-1):
  cnt = 0
  for h in range(H-1,-1,-1):
    if grid[h][w] == "#":
      cnt = 0
    elif cnt == 0:
      cnt = cntH[h][w]
    else:
      cntH[h][w] = cnt

ans = 0
for h in range(H):
  for w in range(W):
    ans = max(ans,cntW[h][w]+cntH[h][w])

print(ans-1)

Buggy python submission (verdict: Runtime Error):
def tamiL(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiL(x-1,y,n+1)
    else:
      return n
  else:
    return n

def tamiR(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiR(x+1,y,n+1)
    else:
      return n
  else:
    return n

def tamiU(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiU(x,y-1,n+1)
    else:
      return n
  else:
    return n

def tamiD(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiD(x,y+1,n+1)
    else:
      return n
  else:
    return n

H,W = list(map(int,input().split()))
grid = [[i for i in input()] for i in range(H)]

ans = 0
for i in range(H):
  for j in range(W):
    if grid[i][j] == ".":
      cnt = 0
      cnt += tamiL(j-1,i,0)
      cnt += tamiR(j+1,i,0)
      cnt += tamiU(j,i-1,0)
      cnt += tamiD(j,i+1,0)
      ans = max(ans,cnt+1)

print(ans)

Fixed submission:
H,W = list(map(int,input().split()))
grid = [[i for i in input()] for i in range(H)]
cntH = [[0 for i in range(W)] for i in range(H)]
cntW = [[0 for i in range(W)] for i in range(H)]

for h in range(H):
  cnt = 0
  for w in range(W):
    if grid[h][w] == "#":
      cnt = 0
    else:
      cnt += 1
      cntW[h][w] = cnt

for h in range(H-1,-1,-1):
  cnt = 0
  for w in range(W-1,-1,-1):
    if grid[h][w] == "#":
      cnt = 0
    elif cnt == 0:
      cnt = cntW[h][w]
    else:
      cntW[h][w] = cnt

for w in range(W):
  cnt = 0
  for h in range(H):
    if grid[h][w] == "#":
      cnt = 0
    else:
      cnt += 1
      cntH[h][w] = cnt

for w in range(W-1,-1,-1):
  cnt = 0
  for h in range(H-1,-1,-1):
    if grid[h][w] == "#":
      cnt = 0
    elif cnt == 0:
      cnt = cntH[h][w]
    else:
      cntH[h][w] = cnt

ans = 0
for h in range(H):
  for w in range(W):
    ans = max(ans,cntW[h][w]+cntH[h][w])

print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tamiL(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiL(x-1,y,n+1)
    else:
      return n
  else:
    return n

def tamiR(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiR(x+1,y,n+1)
    else:
      return n
  else:
    return n

def tamiU(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiU(x,y-1,n+1)
    else:
      return n
  else:
    return n

def tamiD(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiD(x,y+1,n+1)
    else:
      return n
  else:
    return n

H,W = IL()
grid = [[i for i in S()] for i in range(H)]

ans = 0
for i in range(H):
  for j in range(W):
    if grid[i][j] == ".":
      cnt = 0
      cnt += tamiL(j-1,i,0)
      cnt += tamiR(j+1,i,0)
      cnt += tamiU(j,i-1,0)
      cnt += tamiD(j,i+1,0)
      ans = max(ans,cnt+1)

print(ans)

Fixed submission:
H,W = list(map(int,input().split()))
grid = [[i for i in input()] for i in range(H)]
cntH = [[0 for i in range(W)] for i in range(H)]
cntW = [[0 for i in range(W)] for i in range(H)]

for h in range(H):
  cnt = 0
  for w in range(W):
    if grid[h][w] == "#":
      cnt = 0
    else:
      cnt += 1
      cntW[h][w] = cnt

for h in range(H-1,-1,-1):
  cnt = 0
  for w in range(W-1,-1,-1):
    if grid[h][w] == "#":
      cnt = 0
    elif cnt == 0:
      cnt = cntW[h][w]
    else:
      cntW[h][w] = cnt

for w in range(W):
  cnt = 0
  for h in range(H):
    if grid[h][w] == "#":
      cnt = 0
    else:
      cnt += 1
      cntH[h][w] = cnt

for w in range(W-1,-1,-1):
  cnt = 0
  for h in range(H-1,-1,-1):
    if grid[h][w] == "#":
      cnt = 0
    elif cnt == 0:
      cnt = cntH[h][w]
    else:
      cntH[h][w] = cnt

ans = 0
for h in range(H):
  for w in range(W):
    ans = max(ans,cntW[h][w]+cntH[h][w])

print(ans-1)