Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))

#l,r,u,d = [[[0 for w in range(W)] for h in range(H)] for _ in range(4)]
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for h in range(H):
  for w in range(W):
    s = S[h][w]
    l[h][w] = (l[h][w-1]+1)*S[h][w]
    r[h][-w-1] = (r[h][-w]+1)*S[h][-w-1]
    u[h][w] = (u[h-1][w]+1)*S[h][w]
    d[-h-1][w] = (d[-h][w]+1)*S[-h-1][w]
  
#ans = 0
#for h in range(H):
#  for w in range(W):
#    tmp =(l[h][w]+r[h][w]+u[h][w]+d[h][w]-3)*S[h][w]
#    ans = max(ans, tmp)
ans = np.max((l+r+u+d-3)*S)

print(ans)
    




Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))

l,r,u,d = [[[0 for w in range(W)] for h in range(H)] for _ in range(4)]


for h in range(H):
  for w in range(W):
    s = S[h][w]
    l[h][w] = (l[h][w-1]+1)*S[h][w]
    r[h][-w-1] = (r[h][-w]+1)*S[h][-w-1]
    u[h][w] = (u[h-1][w]+1)*S[h][w]
    d[-h-1][w] = (d[-h][w]+1)*S[-h-1][w]
  
ans = 0
for h in range(H):
  for w in range(W):
    tmp =(l[h][w]+r[h][w]+u[h][w]+d[h][w]-3)*S[h][w]
    ans = max(ans, tmp)
    
print(ans)
    




Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)

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

import numpy as np
a = np.zeros([H,W],dtype=int)
b = np.zeros([H,W],dtype=int)
c = np.zeros([H,W],dtype=int)
d = np.zeros([H,W],dtype=int)

for h in range(H):
  for w in range(W):
    if S[h][w]=="#":
      a[h,w]=0
    elif w == 0:
      a[h,w]=1
    else: 
      a[h,w] = a[h,w-1] + 1

for h in range(H):
  for w in range(W):
    w = W-w-1
    if S[h][w]=="#":
      b[h,w]=0
    elif w == W-1:
      b[h,w]=1
    else: 
      b[h,w] = b[h,w+1] + 1
      
for w in range(W):
  for h in range(H):
    if S[h][w]=="#":
      c[h,w]=0
    elif h == 0:
      c[h,w]=1
    else: 
      c[h,w] = c[h-1,w] + 1
      
for w in range(W):
  for h in range(H):
    h = H-h-1
    
    if S[h][w]=="#":
      d[h,w]=0
    elif h == H-1:
      d[h,w]=1
    else: 
      d[h,w] = d[h+1,w] + 1
      
print((a+b+c+d).max()-3)

Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = [int(i) for i in input().split(" ")]
S = []
for i in range(H):
  S.append(input())
  
import numpy as np

r_lens = []
for s in S:
  counts = [len(block) for block in s.split("#")]
  
  r_len = []
  for c in counts:
    r_len+=[c]*c
    r_len+=[0]
  r_len.pop()
  r_lens.append(r_len)
r_lens = np.array(r_lens)

S2 = [""]*W
for h in range(H):
  for w in range(W):
    S2[w] += S[h][w]
    
c_lens = []
for s in S2:
  counts = [len(block) for block in s.split("#")]
  
  c_len = []
  for c in counts:
    c_len+=[c]*c
    c_len+=[0]
  c_len.pop()
  c_lens.append(c_len)
c_lens = np.array(c_lens)

print((r_lens+c_lens.T-1).max())

Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)

Buggy python submission (verdict: Runtime Error):
H, W = [int(i) for i in input().split(" ")]
S = []
for i in range(H):
  S.append(input())
  
import numpy as np

r_lens = []
for s in S:
  counts = [len(block) for block in s.split("#")]
  
  r_len = []
  for c in counts:
    r_len+=[c]*c
    r_len+=[0]
  r_lens.append(r_len)
r_lens = np.array(r_lens)

S2 = [""]*W
for h in range(H):
  for w in range(W):
    S2[w] += S[h][w]
    
c_lens = []
for s in S2:
  counts = [len(block) for block in s.split("#")]
  
  c_len = []
  for c in counts:
    c_len+=[c]*c
    c_len+=[0]
  c_lens.append(c_len)
c_lens = np.array(c_lens)

print((r_lens+c_lens+1).max())

Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)

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

import numpy as np
mat = np.full([H,W,2], -1)
  
def calc_c(S,r,c):
  count = 0
  c1 = c
  while True:
    c1 -= 1
    if c1 >=0 and S[r][c1]==".":
      count += 1
    else: break
      
  c1 = c
  while True:
    c1 += 1
    if c1 <W and S[r][c1]==".":
      count += 1
    else: break
  
  c1 = c
  while True:
    c1 += 1
    if c1 <W and S[r][c1]==".":
      mat[r,c1,1] = count
    else: break
  return count

def calc_r(S,r,c):
  count = 0
  r1 = r
  while True:
    r1 -= 1
    if r1 >= 0 and S[r1][c]==".":
      count += 1
    else: break
      
  r1 = r
  while True:
    r1 += 1
    if r1 < H and S[r1][c]==".":
      count += 1
    else: break
   
  r1 = r
  while True:
    r1 += 1
    if r1 < H and S[r1][c]==".":
      mat[r1,c,0]=count
    else: break
  return count

ans = 0
  
for r in range(H):
  for c in range(W):
    target = S[r][c]
    if target == "#":
      continue
      
    rc, cc = mat[r,c]
    if rc == -1:
    	rc = calc_r(S,r,c)
    if cc == -1:
    	cc = calc_c(S,r,c)
        
    ans = max(rc+cc+1, ans) 

print(int(ans))

Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)

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

import numpy as np
mat = np.full([H,W,2], -1)
  
def calc_c(S,r,c):
  count = 0
  c1 = c
  while True:
    c1 -= 1
    if c1 >=0 and S[r][c1]==".":
      count += 1
    else: break
      
  c1 = c
  while True:
    c1 += 1
    if c1 <W and S[r][c1]==".":
      count += 1
    else: break
      
  mat[r,c]=count
  return count

def calc_r(S,r,c):
  count = 0
  r1 = r
  while True:
    r1 -= 1
    if r1 >= 0 and S[r1][c]==".":
      count += 1
    else: break
      
  r1 = r
  while True:
    r1 += 1
    if r1 < H and S[r1][c]==".":
      count += 1
    else: break
   
  mat[r,c]=count
  return count

ans = 0
  
for r in range(H):
  for c in range(W):
    target = S[r][c]
    if target == "#":
      continue
      
    rc, cc = mat[r,c]
    if rc == -1:
    	rc = calc_r(S,r,c)
    if cc == -1:
    	cc = calc_c(S,r,c)
        
    ans = max(rc+cc+1, ans) 

print(ans)

Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)

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

def calc_len(S,r,c):
  count = 1
  
  c1 = c
  while True:
    c1 -= 1
    if c1 >=0 and S[r][c1]==".":
      count += 1
    else: break
      
  c1 = c
  while True:
    c1 += 1
    if c1 <W and S[r][c1]==".":
      count += 1
    else: break
      
  r1 = r
  while True:
    r1 -= 1
    if r1 >= 0 and S[r1][c]==".":
      count += 1
    else: break
      
  r1 = r
  while True:
    r1 += 1
    if r1 < H and S[r1][c]==".":
      count += 1
    else: break
   
  return count

ans = 0
  
for r in range(H):
  for c in range(W):
    target = S[r][c]
    if target == "#":
      continue
    count = calc_len(S,r,c)
    ans = max(count, ans) 

print(ans)

Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = []
for h in range(H):
  S.append(list(map(lambda s:0 if s=='#' else 1, input())))
S = np.array(S)
 
l,r,u,d = [np.zeros([H,W], dtype=int) for _ in range(4)]

for w in range(W):
  l[:,w] = (l[:,w-1]+1)*S[:,w]
  r[:,-w-1] = (r[:,-w]+1)*S[:,-w-1]

for h in range(H):
  u[h] = (u[h-1]+1)*S[h]
  d[-h-1] = (d[-h]+1)*S[-h-1]
  
ans = np.max((l+r+u+d-3)*S)

print(ans)