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

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = np.zeros((H, W), dtype=int)
trailRight = np.zeros((H, W), dtype=int)
trailUp = np.zeros((H, W), dtype=int)
trailDown = np.zeros((H, W), dtype=int)

for i in range(H):  # 各行について下に見ていく
    for j in range(W):  # その行の各列について右に見ていく
        if S[i][j] == '#':
            pass  # そのマスに置いたとき照らすのは0マス(置けないので)
        else:
            if i == 0 and j == 0:  # 左上
                trailLeft[i][j] = 1
                trailUp[i][j] = 1
            elif i == 0:  # 最上行
                trailLeft[i][j] = trailLeft[i][j - 1] + 1
                trailUp[i][j] = 1
            elif j == 0:  # 最左列
                trailLeft[i][j] = 1
                trailUp[i][j] = trailUp[i - 1][j] + 1
            else:
                trailLeft[i][j] = trailLeft[i][j - 1] + 1
                trailUp[i][j] = trailUp[i - 1][j] + 1

        k = H - i - 1  # H-1 to 0
        l = W - j - 1  # W-1 to 0
        # 左上に見ていく
        if S[k][l] == "#":
            pass
        else:
            if k == H - 1 and l == W - 1:  # 右下
                trailRight[k][l] = 1
                trailDown[k][l] = 1
            elif k == H - 1:  # 最下行
                trailRight[k][l] = trailRight[k][l + 1] + 1
                trailDown[k][l] = 1
            elif l == W - 1:  # 最右列
                trailRight[k][l] = 1
                trailDown[k][l] = trailDown[k + 1][l] + 1
            else:
                trailRight[k][l] = trailRight[k][l + 1] + 1
                trailDown[k][l] = trailDown[k + 1][l] + 1

print(np.max(trailLeft + trailRight + trailUp + trailDown - 3))


Fixed submission:
# can't AC without numpy, Python array handling with for is SLOW
import numpy as np
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))
S = (np.array(S) == ".") * 1

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = np.zeros((H, W), dtype=int)
trailRight = np.zeros((H, W), dtype=int)
trailUp = np.zeros((H, W), dtype=int)
trailDown = np.zeros((H, W), dtype=int)

for i in range(H):
    if i == 0:
        trailUp[i] = S[i]
        trailDown[H - i - 1] = S[H - i - 1] * 1
    else:
        trailUp[i] = (trailUp[i - 1] + 1) * S[i]
        trailDown[H - i - 1] = (trailDown[H - i] + 1) * S[H - i - 1]

for j in range(W):
    if j == 0:
        trailLeft[:, j] = S[:, j]
        trailRight[:, W - j - 1] = S[:, W - j - 1] * 1
    else:
        trailLeft[:, j] = (trailLeft[:, j - 1] + 1) * S[:, j]
        trailRight[:, W - j - 1] = (trailRight[:, W - j] + 1) * S[:, W - j - 1]

print(np.max(trailLeft + trailRight + trailUp + trailDown - 3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
H, W = map(int, input().split())
S = [line.strip("\n") for line in sys.stdin]

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = np.zeros((H, W), dtype=int)
trailRight = np.zeros((H, W), dtype=int)
trailUp = np.zeros((H, W), dtype=int)
trailDown = np.zeros((H, W), dtype=int)

for i in range(H):  # 各行について下に見ていく
    for j in range(W):  # その行の各列について右に見ていく
        if S[i][j] == '#':
            pass  # そのマスに置いたとき照らすのは0マス(置けないので)
        else:
            if i == 0 and j == 0:  # 左上
                trailLeft[i][j] = 1
                trailUp[i][j] = 1
            elif i == 0:  # 最上行
                trailLeft[i][j] = trailLeft[i][j - 1] + 1
                trailUp[i][j] = 1
            elif j == 0:  # 最左列
                trailLeft[i][j] = 1
                trailUp[i][j] = trailUp[i - 1][j] + 1
            else:
                trailLeft[i][j] = trailLeft[i][j - 1] + 1
                trailUp[i][j] = trailUp[i - 1][j] + 1

        k = H - i - 1  # H-1 to 0
        l = W - j - 1  # W-1 to 0
        # 左上に見ていく
        if S[k][l] == "#":
            pass
        else:
            if k == H - 1 and l == W - 1:  # 右下
                trailRight[k][l] = 1
                trailDown[k][l] = 1
            elif k == H - 1:  # 最下行
                trailRight[k][l] = trailRight[k][l + 1] + 1
                trailDown[k][l] = 1
            elif l == W - 1:  # 最右列
                trailRight[k][l] = 1
                trailDown[k][l] = trailDown[k + 1][l] + 1
            else:
                trailRight[k][l] = trailRight[k][l + 1] + 1
                trailDown[k][l] = trailDown[k + 1][l] + 1

print(np.max(trailLeft + trailRight + trailUp + trailDown - 3))


Fixed submission:
# can't AC without numpy, Python array handling with for is SLOW
import numpy as np
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))
S = (np.array(S) == ".") * 1

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = np.zeros((H, W), dtype=int)
trailRight = np.zeros((H, W), dtype=int)
trailUp = np.zeros((H, W), dtype=int)
trailDown = np.zeros((H, W), dtype=int)

for i in range(H):
    if i == 0:
        trailUp[i] = S[i]
        trailDown[H - i - 1] = S[H - i - 1] * 1
    else:
        trailUp[i] = (trailUp[i - 1] + 1) * S[i]
        trailDown[H - i - 1] = (trailDown[H - i] + 1) * S[H - i - 1]

for j in range(W):
    if j == 0:
        trailLeft[:, j] = S[:, j]
        trailRight[:, W - j - 1] = S[:, W - j - 1] * 1
    else:
        trailLeft[:, j] = (trailLeft[:, j - 1] + 1) * S[:, j]
        trailRight[:, W - j - 1] = (trailRight[:, W - j] + 1) * S[:, W - j - 1]

print(np.max(trailLeft + trailRight + trailUp + trailDown - 3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
H, W = map(int, input().split())
S = [line.strip("\n") for line in sys.stdin]

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = [[0] * W for _ in range(H)]
trailRight = [[0] * W for _ in range(H)]
trailUp = [[0] * W for _ in range(H)]
trailDown = [[0] * W for _ in range(H)]

for i in range(H):  # 各行について下に見ていく
    for j in range(W):  # その行の各列について右に見ていく
        if S[i][j] == '#':
            pass  # そのマスに置いたとき照らすのは0マス(置けないので)
        else:
            if i == 0 and j == 0:  # 左上
                trailLeft[i][j] = 1
                trailUp[i][j] = 1
            elif i == 0:  # 最上行
                trailLeft[i][j] = trailLeft[i][j - 1] + 1
                trailUp[i][j] = 1
            elif j == 0:  # 最左列
                trailLeft[i][j] = 1
                trailUp[i][j] = trailUp[i - 1][j] + 1
            else:
                trailLeft[i][j] = trailLeft[i][j - 1] + 1
                trailUp[i][j] = trailUp[i - 1][j] + 1

        k = H - i - 1  # H-1 to 0
        l = W - j - 1  # W-1 to 0
        # 左上に見ていく
        if S[k][l] == "#":
            pass
        else:
            if k == H - 1 and l == W - 1:  # 右下
                trailRight[k][l] = 1
                trailDown[k][l] = 1
            elif k == H - 1:  # 最下行
                trailRight[k][l] = trailRight[k][l + 1] + 1
                trailDown[k][l] = 1
            elif l == W - 1:  # 最右列
                trailRight[k][l] = 1
                trailDown[k][l] = trailDown[k + 1][l] + 1
            else:
                trailRight[k][l] = trailRight[k][l + 1] + 1
                trailDown[k][l] = trailDown[k + 1][l] + 1

ans = 0
for i in range(H):  # 各行について下に見ていく
    for j in range(W):  # その行の各列について右に見ていく
        ans = max(ans, trailLeft[i][j] + trailRight[i][j] + trailUp[i][j] + trailDown[i][j] - 3)

print(ans)


Fixed submission:
# can't AC without numpy, Python array handling with for is SLOW
import numpy as np
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))
S = (np.array(S) == ".") * 1

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = np.zeros((H, W), dtype=int)
trailRight = np.zeros((H, W), dtype=int)
trailUp = np.zeros((H, W), dtype=int)
trailDown = np.zeros((H, W), dtype=int)

for i in range(H):
    if i == 0:
        trailUp[i] = S[i]
        trailDown[H - i - 1] = S[H - i - 1] * 1
    else:
        trailUp[i] = (trailUp[i - 1] + 1) * S[i]
        trailDown[H - i - 1] = (trailDown[H - i] + 1) * S[H - i - 1]

for j in range(W):
    if j == 0:
        trailLeft[:, j] = S[:, j]
        trailRight[:, W - j - 1] = S[:, W - j - 1] * 1
    else:
        trailLeft[:, j] = (trailLeft[:, j - 1] + 1) * S[:, j]
        trailRight[:, W - j - 1] = (trailRight[:, W - j] + 1) * S[:, W - j - 1]

print(np.max(trailLeft + trailRight + trailUp + trailDown - 3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
H, W = map(int, input().split())
S = [line.strip("\n") for line in sys.stdin]
transposeS = ["" for _ in range(W)]

rowRunLength = [[0] * W for _ in range(H)]
columnRunLength = [[0] * H for _ in range(W)]


for rowNum, elem in enumerate(S):
    previousObstacleIndex = -1
    lightCount = 0
    for colNum, char in enumerate(elem):
        if char == "#":
            rowRunLength[rowNum][colNum] = 0
            for i in range(previousObstacleIndex + 1, colNum):
                rowRunLength[rowNum][i] = lightCount
            previousObstacleIndex = colNum
            lightCount = 0
        else:
            lightCount += 1
    else:
        for i in range(previousObstacleIndex + 1, W):
            rowRunLength[rowNum][i] = lightCount

for i in range(W):
    for j in range(H):
        transposeS[i] += S[j][i]

for rowNum, elem in enumerate(transposeS):
    previousObstacleIndex = -1
    lightCount = 0
    for colNum, char in enumerate(elem):
        if char == "#":
            columnRunLength[rowNum][colNum] = 0
            for i in range(previousObstacleIndex + 1, colNum):
                columnRunLength[rowNum][i] = lightCount
            previousObstacleIndex = colNum
            lightCount = 0
        else:
            lightCount += 1
    else:
        for i in range(previousObstacleIndex + 1, H):
            columnRunLength[rowNum][i] = lightCount

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, rowRunLength[i][j] + columnRunLength[j][i] - 1)

print(ans)


Fixed submission:
# can't AC without numpy, Python array handling with for is SLOW
import numpy as np
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))
S = (np.array(S) == ".") * 1

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = np.zeros((H, W), dtype=int)
trailRight = np.zeros((H, W), dtype=int)
trailUp = np.zeros((H, W), dtype=int)
trailDown = np.zeros((H, W), dtype=int)

for i in range(H):
    if i == 0:
        trailUp[i] = S[i]
        trailDown[H - i - 1] = S[H - i - 1] * 1
    else:
        trailUp[i] = (trailUp[i - 1] + 1) * S[i]
        trailDown[H - i - 1] = (trailDown[H - i] + 1) * S[H - i - 1]

for j in range(W):
    if j == 0:
        trailLeft[:, j] = S[:, j]
        trailRight[:, W - j - 1] = S[:, W - j - 1] * 1
    else:
        trailLeft[:, j] = (trailLeft[:, j - 1] + 1) * S[:, j]
        trailRight[:, W - j - 1] = (trailRight[:, W - j] + 1) * S[:, W - j - 1]

print(np.max(trailLeft + trailRight + trailUp + trailDown - 3))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
H, W = map(int, input().split())
S = [line.strip("\n") for line in sys.stdin]
transposeS = ["" for _ in range(W)]

rowRunLength = [[None] * W for _ in range(H)]
columnRunLength = [[None] * H for _ in range(W)]


for idx, elem in enumerate(S):
    previousObstacleIndex = -1

    while previousObstacleIndex != W:
        obstacleIndex = elem.find("#", previousObstacleIndex + 1)
        if obstacleIndex == -1:
            obstacleIndex = W
        else:
            rowRunLength[idx][obstacleIndex] = 0
        for lightenedIndex in range(previousObstacleIndex + 1, obstacleIndex):
            rowRunLength[idx][lightenedIndex] = obstacleIndex - previousObstacleIndex - 1
        previousObstacleIndex = obstacleIndex

for i in range(W):
    for j in range(H):
        transposeS[i] += S[j][i]

for idx, elem in enumerate(transposeS):
    previousObstacleIndex = -1

    while previousObstacleIndex != H:
        obstacleIndex = elem.find("#", previousObstacleIndex + 1)
        if obstacleIndex == -1:
            obstacleIndex = H
        else:
            columnRunLength[idx][obstacleIndex] = 0
        for lightenedIndex in range(previousObstacleIndex + 1, obstacleIndex):
            columnRunLength[idx][lightenedIndex] = obstacleIndex - previousObstacleIndex - 1
        previousObstacleIndex = obstacleIndex

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, rowRunLength[i][j] + columnRunLength[j][i] - 1)

print(ans)


Fixed submission:
# can't AC without numpy, Python array handling with for is SLOW
import numpy as np
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))
S = (np.array(S) == ".") * 1

# i行j列に置いたとき上下左右の方向それぞれに光の軌跡が何マス伸びるか(自マスを含む)
trailLeft = np.zeros((H, W), dtype=int)
trailRight = np.zeros((H, W), dtype=int)
trailUp = np.zeros((H, W), dtype=int)
trailDown = np.zeros((H, W), dtype=int)

for i in range(H):
    if i == 0:
        trailUp[i] = S[i]
        trailDown[H - i - 1] = S[H - i - 1] * 1
    else:
        trailUp[i] = (trailUp[i - 1] + 1) * S[i]
        trailDown[H - i - 1] = (trailDown[H - i] + 1) * S[H - i - 1]

for j in range(W):
    if j == 0:
        trailLeft[:, j] = S[:, j]
        trailRight[:, W - j - 1] = S[:, W - j - 1] * 1
    else:
        trailLeft[:, j] = (trailLeft[:, j - 1] + 1) * S[:, j]
        trailRight[:, W - j - 1] = (trailRight[:, W - j] + 1) * S[:, W - j - 1]

print(np.max(trailLeft + trailRight + trailUp + trailDown - 3))