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

l=[[0]*W for _ in range(H)]
r=[[0]*W for _ in range(H)]
u=[[0]*W for _ in range(H)]
d=[[0]*W for _ in range(H)]

for j in range(H):
  for i in range(W):
    if field[j][i]==".":
      if i==0:
        l[j][i]=1
      else:
        l[j][i]=l[j][i-1]+1
      if j==0:
        u[j][i]=1
      else:
        u[j][i]=u[j-1][i]+1
        

for j in reversed(range(H)):
  for i in reversed(range(W)):
    if field[j][i]==".":
      if i==W-1:
        r[j][i]=1
      else:
        r[j][i]=r[j][i+1]+1
      if j==H-1:
        d[j][i]=1
      else:
        d[j][i]=d[j+1][i]+1

A=[]
for j in range(H):
  for i in range(W):
    A.append(l[j][i]+r[j][i]+d[j][i]+u[j][i]-3)

print(max(A))

Fixed submission:
H,W=map(int,input().split())
field=[list(input()) for _ in range(H)]

l=[[0]*W for _ in range(H)]
r=[[0]*W for _ in range(H)]
u=[[0]*W for _ in range(H)]
d=[[0]*W for _ in range(H)]

for j in range(H):
  for i in range(W):
    if field[j][i]==".":
      if i==0:
        l[j][i]=1
      else:
        l[j][i]=l[j][i-1]+1
      if j==0:
        u[j][i]=1
      else:
        u[j][i]=u[j-1][i]+1
        

for j in reversed(range(H)):
  for i in reversed(range(W)):
    if field[j][i]==".":
      if i==W-1:
        r[j][i]=1
      else:
        r[j][i]=r[j][i+1]+1
      if j==H-1:
        d[j][i]=1
      else:
        d[j][i]=d[j+1][i]+1

A=[]
for j in range(H):
  for i in range(W):
    A.append(l[j][i]+r[j][i]+d[j][i]+u[j][i]-3)

print(max(A))

Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
field=[]
for i in range(H):
  field.append(list(input()))

l=[[[-1,-1] for _ in range(W)] for _ in range(H)]

def xp(x,y):
  global xn
  if x>=W:
    pass
  elif field[y][x]=="#":
    l[y][x][0]=0
  else:
    xn+=1
    xp(x+1,y)
    l[y][x][0]=xn


def yp(x,y):
  global yn
  if y>=H:
    pass
  elif field[y][x]=="#":
    l[y][x][1]=0
  else:
    yn+=1
    yp(x,y+1)
    l[y][x][1]=yn


for j in range(H):
  for i in range(W):
    xn=0
    yn=0
    if l[j][i][0]==-1:
      xp(i,j)
    if l[j][i][1]==-1:
      yp(i,j)

print(max([max([i[0]+i[1]-1 for i in j]) for j in l]))

Fixed submission:
H,W=map(int,input().split())
field=[list(input()) for _ in range(H)]

l=[[0]*W for _ in range(H)]
r=[[0]*W for _ in range(H)]
u=[[0]*W for _ in range(H)]
d=[[0]*W for _ in range(H)]

for j in range(H):
  for i in range(W):
    if field[j][i]==".":
      if i==0:
        l[j][i]=1
      else:
        l[j][i]=l[j][i-1]+1
      if j==0:
        u[j][i]=1
      else:
        u[j][i]=u[j-1][i]+1
        

for j in reversed(range(H)):
  for i in reversed(range(W)):
    if field[j][i]==".":
      if i==W-1:
        r[j][i]=1
      else:
        r[j][i]=r[j][i+1]+1
      if j==H-1:
        d[j][i]=1
      else:
        d[j][i]=d[j+1][i]+1

A=[]
for j in range(H):
  for i in range(W):
    A.append(l[j][i]+r[j][i]+d[j][i]+u[j][i]-3)

print(max(A))

Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
field=[]
for i in range(H):
  field.append(list(input()))

l=[[[-1,-1] for _ in range(W)] for _ in range(H)]

def xp(x,y):
  global xn
  if x>=W:
    pass
  elif field[y][x]=="#":
    l[y][x][0]=0
  else:
    xn+=1
    xp(x+1,y)
    l[y][x][0]=xn


def yp(x,y):
  global yn
  if y>=H:
    pass
  elif field[y][x]=="#":
    l[y][x][1]=0
  else:
    yn+=1
    yp(x,y+1)
    l[y][x][1]=yn


for j in range(H):
  for i in range(W):
    xn=0
    yn=0
    if l[j][i][0]==-1:
      xp(i,j)
    if l[j][i][1]==-1:
      yp(i,j)

print(max([max([i[0]+i[1]-1 for i in j]) for j in l]))

Fixed submission:
H,W=map(int,input().split())
field=[list(input()) for _ in range(H)]

l=[[0]*W for _ in range(H)]
r=[[0]*W for _ in range(H)]
u=[[0]*W for _ in range(H)]
d=[[0]*W for _ in range(H)]

for j in range(H):
  for i in range(W):
    if field[j][i]==".":
      if i==0:
        l[j][i]=1
      else:
        l[j][i]=l[j][i-1]+1
      if j==0:
        u[j][i]=1
      else:
        u[j][i]=u[j-1][i]+1
        

for j in reversed(range(H)):
  for i in reversed(range(W)):
    if field[j][i]==".":
      if i==W-1:
        r[j][i]=1
      else:
        r[j][i]=r[j][i+1]+1
      if j==H-1:
        d[j][i]=1
      else:
        d[j][i]=d[j+1][i]+1

A=[]
for j in range(H):
  for i in range(W):
    A.append(l[j][i]+r[j][i]+d[j][i]+u[j][i]-3)

print(max(A))