Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
s = [[c for c in input()] for i in range(H)]
s_vrt = [[s[i][j] for i in range(H)] for j in range(W)]

dp_l = [[0 for j in range(W)] for i in range(H)]
dp_r = [[0 for j in range(W)] for i in range(H)]
dp_u = [[0 for j in range(W)] for i in range(H)]
dp_d = [[0 for j in range(W)] for i in range(H)]

for i in range(H):
    cnt = 0
    for j in range(W):
        if s[i][j] == '#':
            cnt = 0
        else:
            dp_l[i][j] = cnt
            cnt += 1

    cnt = 0
    for j in range(W)[::-1]:
        if s[i][j] == '#':
            cnt = 0
        else:
            dp_r[i][j] = cnt
            cnt += 1

for j in range(W):
    cnt = 0
    for i in range(H):
        if s[i][j] == '#':
            cnt = 0
        else:
            dp_d[i][j] = cnt
            cnt += 1

    cnt = 0
    for i in range(H)[::-1]:
        if s[i][j] == '#':
            cnt = 0
        else:
            dp_u[i][j] = cnt
            cnt += 1


count_max = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            continue
        count_max = max(count_max,
            dp_l[i][j]
            + dp_r[i][j]
            + dp_u[i][j]
            + dp_d[i][j]
            + 1)

print(count_max)

Fixed submission:
import numpy as np


H, W = map(int, input().split())
s = np.array([[c for c in input()] for i in range(H)]) == '.'
s_t = s.transpose()

dp_l = np.zeros((W, H), dtype=int)
dp_r = np.zeros((W, H), dtype=int)
dp_u = np.zeros((H, W), dtype=int)
dp_d = np.zeros((H, W), dtype=int)

dp_l[0] = s_t[0]
dp_r[W-1] = s_t[W-1]
dp_u[0] = s[0]
dp_d[H-1] = s[H-1]

for i in range(1, W):
    dp_l[i] = s_t[i] * (dp_l[i-1] + 1)

for i in reversed(range(W-1)):
    dp_r[i] = s_t[i] * (dp_r[i+1] + 1)

for i in range(1, H):
    dp_u[i] = s[i] * (dp_u[i-1] + 1)

for i in reversed(range(H-1)):
    dp_d[i] = s[i] * (dp_d[i+1] + 1)

cnts = dp_l + dp_r + dp_d.transpose() + dp_u.transpose()
print(max(np.amax(cnts, 0)) - 3)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
s = [[c for c in input()] for i in range(H)]
s_vrt = [[s[i][j] for i in range(H)] for j in range(W)]

dp_l = [[0 for j in range(W)] for i in range(H)]
dp_r = [[0 for j in range(W)] for i in range(H)]
dp_u = [[0 for i in range(H)] for j in range(W)]
dp_d = [[0 for i in range(H)] for j in range(W)]


def mark_table_for_dp():
    for i in range(H):
        mark_line_for_dp(s[i], dp_l[i], False)
        mark_line_for_dp(s[i], dp_r[i], True)
    for j in range(W):
        mark_line_for_dp(s_vrt[j], dp_u[j], True)
        mark_line_for_dp(s_vrt[j], dp_d[j], False)



def mark_line_for_dp(line, dp, is_reverse):
    cnt = 0
    r = list(range(len(line)))
    if is_reverse:
        r.reverse()
    for i in r:
        if line[i] == '#':
            cnt = 0
            continue
        dp[i] = cnt
        cnt += 1


mark_table_for_dp()


def count_light_cross(i, j):
    return dp_l[i][j] + dp_r[i][j] + dp_u[j][i] + dp_d[j][i] + 1


count_max = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            continue
        count = count_light_cross(i, j)
        if count_max < count:
            count_max = count

print(count_max)

Fixed submission:
import numpy as np


H, W = map(int, input().split())
s = np.array([[c for c in input()] for i in range(H)]) == '.'
s_t = s.transpose()

dp_l = np.zeros((W, H), dtype=int)
dp_r = np.zeros((W, H), dtype=int)
dp_u = np.zeros((H, W), dtype=int)
dp_d = np.zeros((H, W), dtype=int)

dp_l[0] = s_t[0]
dp_r[W-1] = s_t[W-1]
dp_u[0] = s[0]
dp_d[H-1] = s[H-1]

for i in range(1, W):
    dp_l[i] = s_t[i] * (dp_l[i-1] + 1)

for i in reversed(range(W-1)):
    dp_r[i] = s_t[i] * (dp_r[i+1] + 1)

for i in range(1, H):
    dp_u[i] = s[i] * (dp_u[i-1] + 1)

for i in reversed(range(H-1)):
    dp_d[i] = s[i] * (dp_d[i+1] + 1)

cnts = dp_l + dp_r + dp_d.transpose() + dp_u.transpose()
print(max(np.amax(cnts, 0)) - 3)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
s = [[c for c in input()] for i in range(H)]
s_vrt = [[s[i][j] for i in range(H)] for j in range(W)]
# 0: lr, 1: up
memo = [[[-1, -1] for j in range(W)] for i in range(H)]

def count_light_place(i, j):
    line_lr = s[i]
    line_up = s_vrt[j]
    m = memo[i][j]
    c_lr = m[0]
    if c_lr == -1:
        c_lr = count_light_line(j, line_lr)
        memo[i][j][0] = c_lr

    c_up = m[1]
    if c_up == -1:
        c_up = count_light_line(i, line_up)
        memo[i][j][1] = c_up

    return c_lr + c_up - 1

def count_light_line(k, line):
    count = 0
    for dn in reversed(range(k)):
        if line[dn] == '#':
            break
        count += 1
 
    for up in range(k, len(line)):
        if line[up] == '#':
            break
        count += 1
    return count 


count_max = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            continue
        count = count_light_place(i, j)
        if count_max < count:
            count_max = count

print(count_max)

Fixed submission:
import numpy as np


H, W = map(int, input().split())
s = np.array([[c for c in input()] for i in range(H)]) == '.'
s_t = s.transpose()

dp_l = np.zeros((W, H), dtype=int)
dp_r = np.zeros((W, H), dtype=int)
dp_u = np.zeros((H, W), dtype=int)
dp_d = np.zeros((H, W), dtype=int)

dp_l[0] = s_t[0]
dp_r[W-1] = s_t[W-1]
dp_u[0] = s[0]
dp_d[H-1] = s[H-1]

for i in range(1, W):
    dp_l[i] = s_t[i] * (dp_l[i-1] + 1)

for i in reversed(range(W-1)):
    dp_r[i] = s_t[i] * (dp_r[i+1] + 1)

for i in range(1, H):
    dp_u[i] = s[i] * (dp_u[i-1] + 1)

for i in reversed(range(H-1)):
    dp_d[i] = s[i] * (dp_d[i+1] + 1)

cnts = dp_l + dp_r + dp_d.transpose() + dp_u.transpose()
print(max(np.amax(cnts, 0)) - 3)

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
s = [[c for c in input()] for i in range(H)]
s_vrt = [[s[i][j] for i in range(H)] for j in range(W)]

def count_light_place(i, j):
    line_lr = s[i]
    line_up = s_vrt[j]
    return count_light_line(i, line_up) + count_light_line(j, line_lr) - 1


def count_light_line(k, line):
    count = 0
    for dn in reversed(range(k)):
        if line[dn] == '#':
            break
        count += 1
 
    for up in range(k, len(line)):
        if line[up] == '#':
            break
        count += 1
    return count 


count_max = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            continue
        count = count_light_place(i, j)
        if count_max < count:
            count_max = count

print(count_max)

Fixed submission:
import numpy as np


H, W = map(int, input().split())
s = np.array([[c for c in input()] for i in range(H)]) == '.'
s_t = s.transpose()

dp_l = np.zeros((W, H), dtype=int)
dp_r = np.zeros((W, H), dtype=int)
dp_u = np.zeros((H, W), dtype=int)
dp_d = np.zeros((H, W), dtype=int)

dp_l[0] = s_t[0]
dp_r[W-1] = s_t[W-1]
dp_u[0] = s[0]
dp_d[H-1] = s[H-1]

for i in range(1, W):
    dp_l[i] = s_t[i] * (dp_l[i-1] + 1)

for i in reversed(range(W-1)):
    dp_r[i] = s_t[i] * (dp_r[i+1] + 1)

for i in range(1, H):
    dp_u[i] = s[i] * (dp_u[i-1] + 1)

for i in reversed(range(H-1)):
    dp_d[i] = s[i] * (dp_d[i+1] + 1)

cnts = dp_l + dp_r + dp_d.transpose() + dp_u.transpose()
print(max(np.amax(cnts, 0)) - 3)