Buggy python submission (verdict: Time Limit Exceeded):
import copy

H, W = map(int, input().split())
grid = [[1 if c == "." else 0 for c in input()] for _ in range(H)]

L = copy.deepcopy(grid)
R = copy.deepcopy(grid)
U = copy.deepcopy(grid)
D = copy.deepcopy(grid)

for i in range(H):
  for j in range(1, W):
    L[i][j] = (L[i][j-1] + 1) * L[i][j]
    R[i][-1-j] = (R[i][-j] + 1) * R[i][-1-j]

for j in range(W):
  for i in range(1, H):
    U[i][j] = (U[i-1][j] + 1) * U[i][j]
    D[-1-i][j] = (D[-i][j] + 1) * D[-1-i][j]

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, 0)

print(ans)


Fixed submission:
import copy

H, W = map(int, input().split())
grid = [[1 if c == "." else 0 for c in input()] for _ in range(H)]

L = copy.deepcopy(grid)
R = copy.deepcopy(grid)
U = copy.deepcopy(grid)
D = copy.deepcopy(grid)

for i in range(H):
  for j in range(1, W):
    L[i][j] = (L[i][j-1] + 1) * L[i][j]
    R[i][-1-j] = (R[i][-j] + 1) * R[i][-1-j]

for j in range(W):
  for i in range(1, H):
    U[i][j] = (U[i-1][j] + 1) * U[i][j]
    D[-1-i][j] = (D[-i][j] + 1) * D[-1-i][j]

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, 0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
H += 2
W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + input() + '#'
grid += '#' * W

HL = [[0]*W for _ in range(H)]
WL = [[0]*H for _ in range(W)]

for i in range(H):
  left = 0
  right = 0
  for j in range(W):
    if grid[W*i+j] == "#":
      left = 0
    else:
      left += 1
      HL[i][j] += left
    if grid[W*(i+1)-1-j] == "#":
      right = 0
    else:
      right += 1
      HL[i][-1-j] += right - 1

for j in range(W):
  left = 0
  right = 0
  for i in range(H):
    if grid[j+i*W] == "#":
      left = 0
    else:
      left += 1
      WL[j][i] += left
    if grid[j+(H-1-i)*W] == "#":
      right = 0
    else:
      right += 1
      WL[j][-1-i] += right - 1

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, HL[i][j] + WL[j][i] - 1, 0)

print(ans)


Fixed submission:
import copy

H, W = map(int, input().split())
grid = [[1 if c == "." else 0 for c in input()] for _ in range(H)]

L = copy.deepcopy(grid)
R = copy.deepcopy(grid)
U = copy.deepcopy(grid)
D = copy.deepcopy(grid)

for i in range(H):
  for j in range(1, W):
    L[i][j] = (L[i][j-1] + 1) * L[i][j]
    R[i][-1-j] = (R[i][-j] + 1) * R[i][-1-j]

for j in range(W):
  for i in range(1, H):
    U[i][j] = (U[i-1][j] + 1) * U[i][j]
    D[-1-i][j] = (D[-i][j] + 1) * D[-1-i][j]

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, 0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
H += 2
W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + input() + '#'
grid += '#' * W

HL = [[0]*W for _ in range(H)]
WL = [[0]*H for _ in range(W)]

for i in range(H):
  left = 0
  right = 0
  for j in range(W):
    if grid[W*i+j] == "#":
      left = 0
    else:
      left += 1
      HL[i][j] += left
    if grid[W*(i+1)-1-j] == "#":
      right = 0
    else:
      right += 1
      HL[i][-1-j] += right - 1

for j in range(W):
  left = 0
  right = 0
  for i in range(H):
    if grid[j+i*W] == "#":
      left = 0
    else:
      left += 1
      WL[j][i] += left
    if grid[j+(H-1-i)*W] == "#":
      right = 0
    else:
      right += 1
      WL[j][-1-i] += right - 1

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, HL[i][j] + WL[j][i] - 1, 0)

print(ans)


Fixed submission:
import copy

H, W = map(int, input().split())
grid = [[1 if c == "." else 0 for c in input()] for _ in range(H)]

L = copy.deepcopy(grid)
R = copy.deepcopy(grid)
U = copy.deepcopy(grid)
D = copy.deepcopy(grid)

for i in range(H):
  for j in range(1, W):
    L[i][j] = (L[i][j-1] + 1) * L[i][j]
    R[i][-1-j] = (R[i][-j] + 1) * R[i][-1-j]

for j in range(W):
  for i in range(1, H):
    U[i][j] = (U[i-1][j] + 1) * U[i][j]
    D[-1-i][j] = (D[-i][j] + 1) * D[-1-i][j]

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, 0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
H += 2
W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + input() + '#'
grid += '#' * W

HL = [[0]*W for _ in range(H)]
WL = [[0]*H for _ in range(W)]

for i in range(H):
  temp = grid[W*i:W*(i+1)]
  left = 0
  right = 0
  for j in range(W):
    if temp[j] == "#":
      left = 0
    else:
      left += 1
      HL[i][j] += left
    if temp[-1-j] == "#":
      right = 0
    else:
      right += 1
      HL[i][-1-j] += right - 1

for j in range(W):
  temp = grid[j::W]
  left = 0
  right = 0
  for i in range(H):
    if temp[i] == "#":
      left = 0
    else:
      left += 1
      WL[j][i] += left
    if temp[-1-i] == "#":
      right = 0
    else:
      right += 1
      WL[j][-1-i] += right - 1

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, HL[i][j] + WL[j][i] - 1, 0)

print(ans)


Fixed submission:
import copy

H, W = map(int, input().split())
grid = [[1 if c == "." else 0 for c in input()] for _ in range(H)]

L = copy.deepcopy(grid)
R = copy.deepcopy(grid)
U = copy.deepcopy(grid)
D = copy.deepcopy(grid)

for i in range(H):
  for j in range(1, W):
    L[i][j] = (L[i][j-1] + 1) * L[i][j]
    R[i][-1-j] = (R[i][-j] + 1) * R[i][-1-j]

for j in range(W):
  for i in range(1, H):
    U[i][j] = (U[i-1][j] + 1) * U[i][j]
    D[-1-i][j] = (D[-i][j] + 1) * D[-1-i][j]

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, 0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
H += 2
W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + input() + '#'
grid += '#' * W

def dfs(start):
    move_list = [-1, 1, W, -W]
    L = 1
    for move in move_list:
      v = start
      cnt = 0
      while grid[v] == ".":
        v += move
        if grid[v] != "#":
          cnt += 1
      L += cnt
    return L

ans = max(dfs(v) for v in range(H*W) if grid[v] != "#")
print(ans)

Fixed submission:
import copy

H, W = map(int, input().split())
grid = [[1 if c == "." else 0 for c in input()] for _ in range(H)]

L = copy.deepcopy(grid)
R = copy.deepcopy(grid)
U = copy.deepcopy(grid)
D = copy.deepcopy(grid)

for i in range(H):
  for j in range(1, W):
    L[i][j] = (L[i][j-1] + 1) * L[i][j]
    R[i][-1-j] = (R[i][-j] + 1) * R[i][-1-j]

for j in range(W):
  for i in range(1, H):
    U[i][j] = (U[i-1][j] + 1) * U[i][j]
    D[-1-i][j] = (D[-i][j] + 1) * D[-1-i][j]

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, 0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
H += 2
W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + input() + '#'
grid += '#' * W

def dfs(start):
    move_list = [-1, 1, W, -W]
    L = 1
    for move in move_list:
      v = start
      cnt = 0
      while grid[v] == ".":
        v += move
        if grid[v] != "#":
          cnt += 1
      L += cnt
    return L

ans = max(dfs(v) for v in range(H*W) if grid[v] != "#")
print(ans)

Fixed submission:
import copy

H, W = map(int, input().split())
grid = [[1 if c == "." else 0 for c in input()] for _ in range(H)]

L = copy.deepcopy(grid)
R = copy.deepcopy(grid)
U = copy.deepcopy(grid)
D = copy.deepcopy(grid)

for i in range(H):
  for j in range(1, W):
    L[i][j] = (L[i][j-1] + 1) * L[i][j]
    R[i][-1-j] = (R[i][-j] + 1) * R[i][-1-j]

for j in range(W):
  for i in range(1, H):
    U[i][j] = (U[i-1][j] + 1) * U[i][j]
    D[-1-i][j] = (D[-i][j] + 1) * D[-1-i][j]

ans = 0

for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, 0)

print(ans)