Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
H,W = map(int,input().split())
HL=range(H)
WL=range(W)
Gd = [list(input()) for _ in HL]
L=[np.arange(1, W+1)]*H
R=[np.arange(W, 0, -1)]*H
U=[np.arange(H, 0, -1)]*W
D=[np.arange(1, H+1)]*W
L=np.array(L)
R=np.array(R)
U=np.array(U)
D=np.array(D)
def ma():
  for h in HL:
    for w in WL:
      if Gd[h][w]=='#':
        L[h][w:]=L[h][w:]-L[h][w]
      wr=W-w-1
      if Gd[h][wr]=='#':
        R[h][:wr+1]=R[h][:wr+1]-R[h][wr]
  for w in WL:
    for h in HL:
      if Gd[h][w]=='#':
        D[w][h:]=D[w][h:]-D[w][h]
      hr=H-h-1
      if Gd[hr][w]=='#':
        U[w][:hr+1]=U[w][:hr+1]-U[w][hr]
  return np.max(D.T+U.T+L+R-3)
print(ma())

Fixed submission:
import numpy as np
H,W = map(int,input().split())
HL=list(range(H))
WL=list(range(W))
Gd = np.array([list(input()) for _ in HL])
Gd = np.where(Gd=='.', 1, 0)
L=np.zeros((H,W),dtype=np.int64)
R=np.zeros((H,W),dtype=np.int64)
U=np.zeros((H,W),dtype=np.int64)
D=np.zeros((H,W),dtype=np.int64)

for w in WL:
  R[:,w]=(R[:,w-1]+1)*Gd[:,w]
  L[:,-w-1]=(L[:,-w]+1)*Gd[:,-w-1]
for h in HL:
  D[h,:]=(D[h-1,:]+1)*Gd[h,:]
  U[-h-1,:]=(U[-h,:]+1)*Gd[-h-1,:]
print(np.max(D+U+L+R-3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
H,W = map(int,input().split())
Gd = [list(input()) for _ in range(H)]
L=[np.arange(1, W+1)]*H
R=[np.arange(W, 0, -1)]*H
U=[np.arange(H, 0, -1)]*W
D=[np.arange(1, H+1)]*W
L=np.array(L)
R=np.array(R)
U=np.array(U)
D=np.array(D)
HL=range(H)
WL=range(W)
for h in HL:
  for w in WL:
    if Gd[h][w]=='#':
      L[h][w:]=L[h][w:]-L[h][w]
    wr=W-w-1
    if Gd[h][wr]=='#':
      R[h][:wr+1]=R[h][:wr+1]-R[h][wr]
for w in WL:
  for h in HL:
    if Gd[h][w]=='#':
      D[w][h:]=D[w][h:]-D[w][h]
    hr=H-h-1
    if Gd[hr][w]=='#':
      U[w][:hr+1]=U[w][:hr+1]-U[w][hr]
print(np.max(D.T+U.T+L+R-3))

Fixed submission:
import numpy as np
H,W = map(int,input().split())
HL=list(range(H))
WL=list(range(W))
Gd = np.array([list(input()) for _ in HL])
Gd = np.where(Gd=='.', 1, 0)
L=np.zeros((H,W),dtype=np.int64)
R=np.zeros((H,W),dtype=np.int64)
U=np.zeros((H,W),dtype=np.int64)
D=np.zeros((H,W),dtype=np.int64)

for w in WL:
  R[:,w]=(R[:,w-1]+1)*Gd[:,w]
  L[:,-w-1]=(L[:,-w]+1)*Gd[:,-w-1]
for h in HL:
  D[h,:]=(D[h-1,:]+1)*Gd[h,:]
  U[-h-1,:]=(U[-h,:]+1)*Gd[-h-1,:]
print(np.max(D+U+L+R-3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
H,W = map(int,input().split())
Gd,L,R,U,D=[None]*H,[None]*H,[None]*H,[None]*H,[None]*H
for _ in range(H):
  Gd[_] = list(input())
  L[_], R[_], D[_], U[_] = [0]*W, [0]*W, [0]*W, [0]*W
L=np.array(L)
R=np.array(R)
U=np.array(U)
D=np.array(D)
HL=range(H)
WL=range(W)
def ma():
  for h in HL:
    for w in WL:
      if Gd[h][w]=='#':
        R[h][w]=0
      else:
        if w==0:
          R[h][w]=1
        else:
          R[h][w]=R[h][w-1]+1
      wr=W-w-1
      if Gd[h][wr]=='#':
        L[h][wr]=0
      else:
        if w==0:
          L[h][wr]=1
        else:
          L[h][wr]=L[h][wr+1]+1

  for w in WL:
    for h in HL:
      if Gd[h][w]=='#':
        D[h][w]=0
      else:
        if h==0:
          D[h][w]=1
        else:
          D[h][w]=D[h-1][w]+1
      hr=H-h-1
      if Gd[hr][w]=='#':
        U[hr][w]=0
      else:
        if h==0:
          U[hr][w]=1
        else:
          U[hr][w]=U[hr+1][w]+1
  return np.max(D+U+L+R-3)
print(ma())

Fixed submission:
import numpy as np
H,W = map(int,input().split())
HL=list(range(H))
WL=list(range(W))
Gd = np.array([list(input()) for _ in HL])
Gd = np.where(Gd=='.', 1, 0)
L=np.zeros((H,W),dtype=np.int64)
R=np.zeros((H,W),dtype=np.int64)
U=np.zeros((H,W),dtype=np.int64)
D=np.zeros((H,W),dtype=np.int64)

for w in WL:
  R[:,w]=(R[:,w-1]+1)*Gd[:,w]
  L[:,-w-1]=(L[:,-w]+1)*Gd[:,-w-1]
for h in HL:
  D[h,:]=(D[h-1,:]+1)*Gd[h,:]
  U[-h-1,:]=(U[-h,:]+1)*Gd[-h-1,:]
print(np.max(D+U+L+R-3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
H,W = map(int,input().split())
Gd,L,R,U,D=[None]*H,[None]*H,[None]*H,[None]*H,[None]*H
for _ in range(H):
  Gd[_] = list(input())
  L[_], R[_], D[_], U[_] = [0]*W, [0]*W, [0]*W, [0]*W
L=np.array(L)
R=np.array(R)
U=np.array(U)
D=np.array(D)
def ma():
  for h in range(H):
    for w in range(W):
      if Gd[h][w]=='#':
        R[h][w]=0
      else:
        if w==0:
          R[h][w]=1
        else:
          R[h][w]=R[h][w-1]+1
      wr=W-w-1
      if Gd[h][wr]=='#':
        L[h][wr]=0
      else:
        if w==0:
          L[h][wr]=1
        else:
          L[h][wr]=L[h][wr+1]+1

  for w in range(W):
    for h in range(H):
      if Gd[h][w]=='#':
        D[h][w]=0
      else:
        if h==0:
          D[h][w]=1
        else:
          D[h][w]=D[h-1][w]+1
      hr=H-h-1
      if Gd[hr][w]=='#':
        U[hr][w]=0
      else:
        if h==0:
          U[hr][w]=1
        else:
          U[hr][w]=U[hr+1][w]+1
  return np.max(D+U+L+R-3)
print(ma())

Fixed submission:
import numpy as np
H,W = map(int,input().split())
HL=list(range(H))
WL=list(range(W))
Gd = np.array([list(input()) for _ in HL])
Gd = np.where(Gd=='.', 1, 0)
L=np.zeros((H,W),dtype=np.int64)
R=np.zeros((H,W),dtype=np.int64)
U=np.zeros((H,W),dtype=np.int64)
D=np.zeros((H,W),dtype=np.int64)

for w in WL:
  R[:,w]=(R[:,w-1]+1)*Gd[:,w]
  L[:,-w-1]=(L[:,-w]+1)*Gd[:,-w-1]
for h in HL:
  D[h,:]=(D[h-1,:]+1)*Gd[h,:]
  U[-h-1,:]=(U[-h,:]+1)*Gd[-h-1,:]
print(np.max(D+U+L+R-3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np
H,W = map(int,input().split())
Gd,L,R,U,D=[None]*H,[None]*H,[None]*H,[None]*H,[None]*H
for _ in range(H):
  Gd[_] = list(input())
  L[_], R[_], D[_], U[_] = [0]*W, [0]*W, [0]*W, [0]*W
L=np.array(L)
R=np.array(R)
U=np.array(U)
D=np.array(D)

for h in range(H):
  for w in range(W):
    if Gd[h][w]=='#':
      R[h][w]=0
    else:
      if w==0:
        R[h][w]=1
      else:
        R[h][w]=R[h][w-1]+1
    wr=W-w-1
    if Gd[h][wr]=='#':
      L[h][wr]=0
    else:
      if w==0:
        L[h][wr]=1
      else:
        L[h][wr]=L[h][wr+1]+1

for w in range(W):
  for h in range(H):
    if Gd[h][w]=='#':
      D[h][w]=0
    else:
      if h==0:
        D[h][w]=1
      else:
        D[h][w]=D[h-1][w]+1
    hr=H-h-1
    if Gd[hr][w]=='#':
      U[hr][w]=0
    else:
      if h==0:
        U[hr][w]=1
      else:
        U[hr][w]=U[hr+1][w]+1
ret = np.max(D+U+L+R-3)
print(ret)

Fixed submission:
import numpy as np
H,W = map(int,input().split())
HL=list(range(H))
WL=list(range(W))
Gd = np.array([list(input()) for _ in HL])
Gd = np.where(Gd=='.', 1, 0)
L=np.zeros((H,W),dtype=np.int64)
R=np.zeros((H,W),dtype=np.int64)
U=np.zeros((H,W),dtype=np.int64)
D=np.zeros((H,W),dtype=np.int64)

for w in WL:
  R[:,w]=(R[:,w-1]+1)*Gd[:,w]
  L[:,-w-1]=(L[:,-w]+1)*Gd[:,-w-1]
for h in HL:
  D[h,:]=(D[h-1,:]+1)*Gd[h,:]
  U[-h-1,:]=(U[-h,:]+1)*Gd[-h-1,:]
print(np.max(D+U+L+R-3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
Gd,L,R,U,D=[None]*H,[None]*H,[None]*H,[None]*H,[None]*H
for _ in range(H):
  Gd[_] = list(input())
  L[_], R[_], D[_], U[_] = [0]*W, [0]*W, [0]*W, [0]*W
for h in range(H):
  for w in range(W):
    if Gd[h][w]=='#':
      R[h][w]=0
    else:
      if w==0:
        R[h][w]=1
      else:
        R[h][w]=R[h][w-1]+1
    wr=W-w-1
    if Gd[h][wr]=='#':
      L[h][wr]=0
    else:
      if w==0:
        L[h][wr]=1
      else:
        L[h][wr]=L[h][wr+1]+1

for w in range(W):
  for h in range(H):
    if Gd[h][w]=='#':
      D[h][w]=0
    else:
      if h==0:
        D[h][w]=1
      else:
        D[h][w]=D[h-1][w]+1
    hr=H-h-1
    if Gd[hr][w]=='#':
      U[hr][w]=0
    else:
      if h==0:
        U[hr][w]=1
      else:
        U[hr][w]=U[hr+1][w]+1
ret = 0
for w in range(W):
  for h in range(H):
    ret = max(ret, D[h][w]+U[h][w]+R[h][w]+L[h][w]-3)
print(ret)

Fixed submission:
import numpy as np
H,W = map(int,input().split())
HL=list(range(H))
WL=list(range(W))
Gd = np.array([list(input()) for _ in HL])
Gd = np.where(Gd=='.', 1, 0)
L=np.zeros((H,W),dtype=np.int64)
R=np.zeros((H,W),dtype=np.int64)
U=np.zeros((H,W),dtype=np.int64)
D=np.zeros((H,W),dtype=np.int64)

for w in WL:
  R[:,w]=(R[:,w-1]+1)*Gd[:,w]
  L[:,-w-1]=(L[:,-w]+1)*Gd[:,-w-1]
for h in HL:
  D[h,:]=(D[h-1,:]+1)*Gd[h,:]
  U[-h-1,:]=(U[-h,:]+1)*Gd[-h-1,:]
print(np.max(D+U+L+R-3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
H,W = map(int,input().split())
Gd = [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 h in range(H):
  for w in range(W):
    if Gd[h][w]=='#':
      R[h][w]=0
    else:
      if w==0:
        R[h][w]=1
      else:
        R[h][w]=R[h][w-1]+1
    wr=W-w-1
    if Gd[h][wr]=='#':
      L[h][wr]=0
    else:
      if w==0:
        L[h][wr]=1
      else:
        L[h][wr]=L[h][wr+1]+1

for w in range(W):
  for h in range(H):
    if Gd[h][w]=='#':
      D[h][w]=0
    else:
      if h==0:
        D[h][w]=1
      else:
        D[h][w]=D[h-1][w]+1
    hr=H-h-1
    if Gd[hr][w]=='#':
      U[hr][w]=0
    else:
      if h==0:
        U[hr][w]=1
      else:
        U[hr][w]=U[hr+1][w]+1
ret = 0
for w in range(W):
  for h in range(H):
    ret = max(ret, D[h][w]+U[h][w]+R[h][w]+L[h][w]-3)
print(ret)

Fixed submission:
import numpy as np
H,W = map(int,input().split())
HL=list(range(H))
WL=list(range(W))
Gd = np.array([list(input()) for _ in HL])
Gd = np.where(Gd=='.', 1, 0)
L=np.zeros((H,W),dtype=np.int64)
R=np.zeros((H,W),dtype=np.int64)
U=np.zeros((H,W),dtype=np.int64)
D=np.zeros((H,W),dtype=np.int64)

for w in WL:
  R[:,w]=(R[:,w-1]+1)*Gd[:,w]
  L[:,-w-1]=(L[:,-w]+1)*Gd[:,-w-1]
for h in HL:
  D[h,:]=(D[h-1,:]+1)*Gd[h,:]
  U[-h-1,:]=(U[-h,:]+1)*Gd[-h-1,:]
print(np.max(D+U+L+R-3))

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
Gd = [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 h in range(H):
  for w in range(W):
    if Gd[h][w]=='#':
      R[h][w]=0
    else:
      if w==0:
        R[h][w]=1
      else:
        R[h][w]=R[h][w-1]+1
    wr=W-w-1
    if Gd[h][wr]=='#':
      L[h][wr]=0
    else:
      if w==0:
        L[h][wr]=1
      else:
        L[h][wr]=L[h][wr+1]+1

for w in range(W):
  for h in range(H):
    if Gd[h][w]=='#':
      D[h][w]=0
    else:
      if h==0:
        D[h][w]=1
      else:
        D[h][w]=D[h-1][w]+1
    hr=H-h-1
    if Gd[hr][w]=='#':
      U[hr][w]=0
    else:
      if h==0:
        U[hr][w]=1
      else:
        U[hr][w]=U[hr+1][w]+1
ret = 0
for w in range(W):
  for h in range(H):
    ret = max(ret, D[h][w]+U[h][w]+R[h][w]+L[h][w]-3)
print(ret)

Fixed submission:
import numpy as np
H,W = map(int,input().split())
HL=list(range(H))
WL=list(range(W))
Gd = np.array([list(input()) for _ in HL])
Gd = np.where(Gd=='.', 1, 0)
L=np.zeros((H,W),dtype=np.int64)
R=np.zeros((H,W),dtype=np.int64)
U=np.zeros((H,W),dtype=np.int64)
D=np.zeros((H,W),dtype=np.int64)

for w in WL:
  R[:,w]=(R[:,w-1]+1)*Gd[:,w]
  L[:,-w-1]=(L[:,-w]+1)*Gd[:,-w-1]
for h in HL:
  D[h,:]=(D[h-1,:]+1)*Gd[h,:]
  U[-h-1,:]=(U[-h,:]+1)*Gd[-h-1,:]
print(np.max(D+U+L+R-3))