Buggy python submission (verdict: Time Limit Exceeded):
import re
h,w = map(int, input().split())
m=[]
d = [[0]*w for _ in range(h)]
u = [[0]*w for _ in range(h)]
for _ in range(h):
  t=[]
  for i in re.split("(#)", input()):
    if not i == "#":
      t.extend([len(i)]*len(i))
    else:
      t.append(0)
  m.append(t)

for i in range(w):
  for j in range(h):
    if m[j][i] == 0:
      d[j][i] = 0
    else:
      if j != 0:
        d[j][i] = d[j-1][i] + 1
      else:
        d[j][i] = 1

    if m[h-1-j][i] == 0:
      u[h-1-j][i] = 0
    else:
      if h-1-j == h-1:
        u[h-1-j][i] = 1
      else:
        u[h-1-j][i] = u[h-j][i] + 1
ans=0
for i in range(w):
  for j in range(h):
    ans = max(ans, u[j][i]+d[j][i]+m[j][i])
print(ans - 2)

Fixed submission:
import re
h,w = map(int, input().split())
m=[]
d = [[0]*w for _ in range(h)]
u = [[0]*w for _ in range(h)]
for _ in range(h):
  t=[]
  for i in re.split("(#)", input()):
    if not i == "#":
      t.extend([len(i)]*len(i))
    else:
      t.append(0)
  m.append(t)

for i in range(w):
  for j in range(h):
    if m[j][i] == 0:
      d[j][i] = 0
    else:
      if j != 0:
        d[j][i] = d[j-1][i] + 1
      else:
        d[j][i] = 1

    if m[h-1-j][i] == 0:
      u[h-1-j][i] = 0
    else:
      if h-1-j == h-1:
        u[h-1-j][i] = 1
      else:
        u[h-1-j][i] = u[h-j][i] + 1
ans=0
for i in range(w):
  for j in range(h):
    ans = max(ans, u[j][i]+d[j][i]+m[j][i])
print(ans - 2)

Buggy python submission (verdict: Time Limit Exceeded):
import re
h,w = map(int, input().split())
m = []
for _ in range(h):
  t=[]
  
  for i in re.split("(#)", input()):
    if not i == "#":
      t.extend([len(i)-1]*len(i))
    else:
      t.append(-1)
  m.append(t)

ans=0
tate=[]
for i in range(w):
  temp = []
  cnt = 0
  for j in range(h):
    if m[j][i] == -1:
      if cnt == 0:
        temp.extend([-1])
      else:
        temp.extend([cnt-1]*(cnt))
        temp.extend([-1])
      cnt = 0
    else:
      cnt += 1
  else:
    if cnt > 0:
      temp.extend([cnt-1]*(cnt))
  tate.append(temp)
ans=0
for i in range(w):
  for j in range(h):
    if m[j][i] == -1:
      continue
    ans = max(ans,tate[i][j] + m[j][i])
print(ans + 1)

Fixed submission:
import re
h,w = map(int, input().split())
m=[]
d = [[0]*w for _ in range(h)]
u = [[0]*w for _ in range(h)]
for _ in range(h):
  t=[]
  for i in re.split("(#)", input()):
    if not i == "#":
      t.extend([len(i)]*len(i))
    else:
      t.append(0)
  m.append(t)

for i in range(w):
  for j in range(h):
    if m[j][i] == 0:
      d[j][i] = 0
    else:
      if j != 0:
        d[j][i] = d[j-1][i] + 1
      else:
        d[j][i] = 1

    if m[h-1-j][i] == 0:
      u[h-1-j][i] = 0
    else:
      if h-1-j == h-1:
        u[h-1-j][i] = 1
      else:
        u[h-1-j][i] = u[h-j][i] + 1
ans=0
for i in range(w):
  for j in range(h):
    ans = max(ans, u[j][i]+d[j][i]+m[j][i])
print(ans - 2)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int, input().split())
maze=[]
for _ in range(h):
  maze.append(input())

light_w=[[0]*w for _ in range(h)]
light_h=[[0]*w for _ in range(h)]

for i in range(w):
  cnt_up = 0
  cnt_down = 0
  for j in range(h):
    if maze[j][i] == "#":
      cnt_up=0
    else:
      light_w[j][i] += cnt_up
      cnt_up+=1

    if maze[h-j-1][i] == "#":
      cnt_down=0
    else:
      light_w[h-j-1][i] += cnt_down
      cnt_down+=1

for i in range(h):
  cnt_right = 0
  cnt_left = 0
  for j in range(w):
    if maze[i][j] == "#":
      cnt_left=0
    else:
      light_h[i][j] += cnt_left
      cnt_left+=1

    if maze[i][w-j-1] == "#":
      cnt_right=0
    else:
      light_h[i][w-j-1] += cnt_right
      cnt_right+=1
ans=0
for i in range(h):
  for j in range(w):
    ans=max(ans,light_h[i][j]+light_w[i][j])
print(ans+1)

Fixed submission:
import re
h,w = map(int, input().split())
m=[]
d = [[0]*w for _ in range(h)]
u = [[0]*w for _ in range(h)]
for _ in range(h):
  t=[]
  for i in re.split("(#)", input()):
    if not i == "#":
      t.extend([len(i)]*len(i))
    else:
      t.append(0)
  m.append(t)

for i in range(w):
  for j in range(h):
    if m[j][i] == 0:
      d[j][i] = 0
    else:
      if j != 0:
        d[j][i] = d[j-1][i] + 1
      else:
        d[j][i] = 1

    if m[h-1-j][i] == 0:
      u[h-1-j][i] = 0
    else:
      if h-1-j == h-1:
        u[h-1-j][i] = 1
      else:
        u[h-1-j][i] = u[h-j][i] + 1
ans=0
for i in range(w):
  for j in range(h):
    ans = max(ans, u[j][i]+d[j][i]+m[j][i])
print(ans - 2)