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

for w in range(W):
    for h in range(H):
        if grid[h][w] == '#':
            U[h][w] = 0
        elif h == 0:
            U[h][w] = 1
        else:
            U[h][w] = U[h-1][w] + 1

for w in range(W-1,-1,-1):
    for h in range(H):
        if grid[h][w] == '#':
            R[h][w] = 0
        elif w == W-1:
            R[h][w] = 1
        else:
            R[h][w] = R[h][w+1] + 1

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

Fixed submission:
import numpy as np
h, w = map(int, input().split())
table = np.array([list(input())for _ in range(h)]) == '.'
 
d = np.zeros((h, w), dtype = int)
u = np.zeros((h, w), dtype = int)
r = np.zeros((h, w), dtype = int)
l = np.zeros((h, w), dtype = int)

for i in range(h):
    d[i] = (d[i-1]+1) * table[i]
    u[-i-1] = (u[-i]+1) * table[-i-1]

for i in range(w):
    r[:, i] = (r[:, i-1]+1) * table[:, i]
    l[:, -i-1] = (l[:, -i]+1) * table[:, -i-1]
print(np.max(d+u+r+l)-3)

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

for w in range(W):
    for h in range(H):
        if grid[h][w] == '#':
            U[h][w] = 0
        elif h == 0:
            U[h][w] = 1
        else:
            U[h][w] = U[h-1][w] + 1

for w in range(W-1,-1,-1):
    for h in range(H):
        if grid[h][w] == '#':
            R[h][w] = 0
        elif w == W-1:
            R[h][w] = 1
        else:
            R[h][w] = R[h][w+1] + 1

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

Fixed submission:
import numpy as np
h, w = map(int, input().split())
table = np.array([list(input())for _ in range(h)]) == '.'
 
d = np.zeros((h, w), dtype = int)
u = np.zeros((h, w), dtype = int)
r = np.zeros((h, w), dtype = int)
l = np.zeros((h, w), dtype = int)

for i in range(h):
    d[i] = (d[i-1]+1) * table[i]
    u[-i-1] = (u[-i]+1) * table[-i-1]

for i in range(w):
    r[:, i] = (r[:, i-1]+1) * table[:, i]
    l[:, -i-1] = (l[:, -i]+1) * table[:, -i-1]
print(np.max(d+u+r+l)-3)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
# dir: 0 -> start
# dir: 1 -> right
# dir: 2 -> down
# dir: 3 -> left
# dir: 4 -> up
import sys
sys.setrecursionlimit(10**9)
grid = [list(input()) for _ in range(H)]


def dfs(grid,y,x,dir):
    global num_l
    if not (0 <= x < W and 0 <= y < H):
        return
    if grid[y][x] == '#':
        return
    num_l += 1
    if dir == 0:
        dfs(grid, y, x+1, 1)
        dfs(grid, y+1, x, 2)
        dfs(grid, y, x-1, 3)
        dfs(grid, y-1, x, 4)
    elif dir == 1:
        dfs(grid, y, x + 1, 1)
    elif dir == 2:
        dfs(grid, y+1, x, 2)
    elif dir == 3:
        dfs(grid, y, x-1, 3)
    elif dir == 4:
        dfs(grid, y-1, x, 4)

ans = 0
for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            num_l = 0
            dfs(grid, h, w, 0)
            ans = max(ans,num_l)
print(ans)

Fixed submission:
import numpy as np
h, w = map(int, input().split())
table = np.array([list(input())for _ in range(h)]) == '.'
 
d = np.zeros((h, w), dtype = int)
u = np.zeros((h, w), dtype = int)
r = np.zeros((h, w), dtype = int)
l = np.zeros((h, w), dtype = int)

for i in range(h):
    d[i] = (d[i-1]+1) * table[i]
    u[-i-1] = (u[-i]+1) * table[-i-1]

for i in range(w):
    r[:, i] = (r[:, i-1]+1) * table[:, i]
    l[:, -i-1] = (l[:, -i]+1) * table[:, -i-1]
print(np.max(d+u+r+l)-3)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
# dir: 0 -> start
# dir: 1 -> right
# dir: 2 -> down
# dir: 3 -> left
# dir: 4 -> up
import sys
sys.setrecursionlimit(10**9)
grid = [list(input()) for _ in range(H)]


def dfs(grid,y,x,dir):
    global num_l
    if not (0 <= x < W and 0 <= y < H):
        return
    if grid[y][x] == '#':
        return
    num_l += 1
    if dir == 0:
        dfs(grid, y, x+1, 1)
        dfs(grid, y+1, x, 2)
        dfs(grid, y, x-1, 3)
        dfs(grid, y-1, x, 4)
    elif dir == 1:
        dfs(grid, y, x + 1, 1)
    elif dir == 2:
        dfs(grid, y+1, x, 2)
    elif dir == 3:
        dfs(grid, y, x-1, 3)
    elif dir == 4:
        dfs(grid, y-1, x, 4)

ans = 0
for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            num_l = 0
            dfs(grid, h, w, 0)
            ans = max(ans,num_l)
print(ans)

Fixed submission:
import numpy as np
h, w = map(int, input().split())
table = np.array([list(input())for _ in range(h)]) == '.'
 
d = np.zeros((h, w), dtype = int)
u = np.zeros((h, w), dtype = int)
r = np.zeros((h, w), dtype = int)
l = np.zeros((h, w), dtype = int)

for i in range(h):
    d[i] = (d[i-1]+1) * table[i]
    u[-i-1] = (u[-i]+1) * table[-i-1]

for i in range(w):
    r[:, i] = (r[:, i-1]+1) * table[:, i]
    l[:, -i-1] = (l[:, -i]+1) * table[:, -i-1]
print(np.max(d+u+r+l)-3)

Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
# dir: 0 -> start
# dir: 1 -> right
# dir: 2 -> down
# dir: 3 -> left
# dir: 4 -> up

grid = [list(input()) for _ in range(H)]


def dfs(grid,y,x,dir):
    global num_l
    if not (0 <= x < W and 0 <= y < H):
        return
    if grid[y][x] == '#':
        return
    num_l += 1
    if dir == 0:
        dfs(grid, y, x+1, 1)
        dfs(grid, y+1, x, 2)
        dfs(grid, y, x-1, 3)
        dfs(grid, y-1, x, 4)
    elif dir == 1:
        dfs(grid, y, x + 1, 1)
    elif dir == 2:
        dfs(grid, y+1, x, 2)
    elif dir == 3:
        dfs(grid, y, x-1, 3)
    elif dir == 4:
        dfs(grid, y-1, x, 4)

ans = 0
for h in range(H):
    for w in range(W):
        if grid[h][w] == '.':
            num_l = 0
            dfs(grid, h, w, 0)
            ans = max(ans,num_l)
print(ans)

Fixed submission:
import numpy as np
h, w = map(int, input().split())
table = np.array([list(input())for _ in range(h)]) == '.'
 
d = np.zeros((h, w), dtype = int)
u = np.zeros((h, w), dtype = int)
r = np.zeros((h, w), dtype = int)
l = np.zeros((h, w), dtype = int)

for i in range(h):
    d[i] = (d[i-1]+1) * table[i]
    u[-i-1] = (u[-i]+1) * table[-i-1]

for i in range(w):
    r[:, i] = (r[:, i-1]+1) * table[:, i]
    l[:, -i-1] = (l[:, -i]+1) * table[:, -i-1]
print(np.max(d+u+r+l)-3)