Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()

range_W = range(W)
range_H = range(H)
# nomal
L = [[0 for _ in range_W] for _ in range_H]
R = [[0 for _ in range_W] for _ in range_H]
U = [[0 for _ in range_W] for _ in range_H]
D = [[0 for _ in range_W] for _ in range_H]
res = [[0 for _ in range_W] for _ in range_H]
grid = []

append = grid.append
for i in range_H:
    row = list(" ".join(input()).split())
    append(row)

def solve():
    ans = 0
    for i in range_H:
        for j in range_W:
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

if __name__ == "__main__":
    print(solve())


Fixed submission:
import sys, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()


# nomal
# L = [[0 for _ in range(W)] for _ in range(H)]
# R = [[0 for _ in range(W)] for _ in range(H)]
# U = [[0 for _ in range(W)] for _ in range(H)]
# D = [[0 for _ in range(W)] for _ in range(H)]
res = [[0 for _ in range(W)] for _ in range(H)]
grid = []

# numpy
import numpy as np
L, R, U, D = [np.zeros((H, W), int) for _ in range(4)]
grid_np = np.zeros((H,W), int)


for i in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)
    grid_np[i] = np.array(row) == '.'

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

def solve_np():
    ans = 0

    for j in range(W):
        # 本当は意味ない条件分岐
        if j == 0:
            L[:, j] = 1 * grid_np[:, j]
            R[:, -j - 1] = 1 * grid_np[:, -j - 1]
        else:
            L[:, j] = (L[:, j - 1] + 1) * grid_np[:, j]
            R[:, -j - 1] = (R[:, -j] + 1) * grid_np[:, -j - 1]

    for i in range(H):
        if i == 0:
            U[i] = 1 * grid_np[i]
            D[-i -1] = 1 * grid_np[-i -1]
        else:
            U[i] = (U[i - 1] + 1) * grid_np[i]
            D[-i - 1] = (D[-i] + 1) * grid_np[-i - 1]
    ans = np.max((L+R+U+D) -3)
    return ans

if __name__ == "__main__":
    # print(solve())
    print(solve_np())

# if __name__ == "__main__":
#     import timeit
#     loop = 1
#     n = 1000
#     time = timeit.timeit(lambda: solve(), number=loop)
#     print(time/loop)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()


# nomal
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]
res = [[0 for _ in range(W)] for _ in range(H)]
grid = []

append = grid.append
for i in range(H):
    row = list(" ".join(input()).split())
    append(row)

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

if __name__ == "__main__":
    print(solve())


Fixed submission:
import sys, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()


# nomal
# L = [[0 for _ in range(W)] for _ in range(H)]
# R = [[0 for _ in range(W)] for _ in range(H)]
# U = [[0 for _ in range(W)] for _ in range(H)]
# D = [[0 for _ in range(W)] for _ in range(H)]
res = [[0 for _ in range(W)] for _ in range(H)]
grid = []

# numpy
import numpy as np
L, R, U, D = [np.zeros((H, W), int) for _ in range(4)]
grid_np = np.zeros((H,W), int)


for i in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)
    grid_np[i] = np.array(row) == '.'

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

def solve_np():
    ans = 0

    for j in range(W):
        # 本当は意味ない条件分岐
        if j == 0:
            L[:, j] = 1 * grid_np[:, j]
            R[:, -j - 1] = 1 * grid_np[:, -j - 1]
        else:
            L[:, j] = (L[:, j - 1] + 1) * grid_np[:, j]
            R[:, -j - 1] = (R[:, -j] + 1) * grid_np[:, -j - 1]

    for i in range(H):
        if i == 0:
            U[i] = 1 * grid_np[i]
            D[-i -1] = 1 * grid_np[-i -1]
        else:
            U[i] = (U[i - 1] + 1) * grid_np[i]
            D[-i - 1] = (D[-i] + 1) * grid_np[-i - 1]
    ans = np.max((L+R+U+D) -3)
    return ans

if __name__ == "__main__":
    # print(solve())
    print(solve_np())

# if __name__ == "__main__":
#     import timeit
#     loop = 1
#     n = 1000
#     time = timeit.timeit(lambda: solve(), number=loop)
#     print(time/loop)

Buggy python submission (verdict: Time Limit Exceeded):
import sys, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

H, W = read_int()
grid = []
import numpy as np
L = np.zeros((H, W), int)
R = np.zeros((H, W), int)
U = np.zeros((H, W), int)
D = np.zeros((H, W), int)
res = np.zeros((H, W), int)
# L = [[0 for _ in range(W)] for _ in range(H)]
# R = [[0 for _ in range(W)] for _ in range(H)]
# U = [[0 for _ in range(W)] for _ in range(H)]
# D = [[0 for _ in range(W)] for _ in range(H)]
# res = [[0 for _ in range(W)] for _ in range(H)]

for _ in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)

# r = []
# heapq.heapify(r)
# for i in range(H * W):
#     heapq.heappush(r, 0)
# r = [3 for i in range(H*W)]
def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == "#":
                L[i][j] = U[i][j] = 0
            else:
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)
                # r[i* W + j] -= L[i][j] + U[i][j]

            if grid[H - i - 1][W - j - 1] == "#":
                R[H - i - 1][W - j - 1] = D[H - i - 1][W - j - 1] = 0
            else:
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

if __name__ == "__main__":
    print(solve())



Fixed submission:
import sys, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()


# nomal
# L = [[0 for _ in range(W)] for _ in range(H)]
# R = [[0 for _ in range(W)] for _ in range(H)]
# U = [[0 for _ in range(W)] for _ in range(H)]
# D = [[0 for _ in range(W)] for _ in range(H)]
res = [[0 for _ in range(W)] for _ in range(H)]
grid = []

# numpy
import numpy as np
L, R, U, D = [np.zeros((H, W), int) for _ in range(4)]
grid_np = np.zeros((H,W), int)


for i in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)
    grid_np[i] = np.array(row) == '.'

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

def solve_np():
    ans = 0

    for j in range(W):
        # 本当は意味ない条件分岐
        if j == 0:
            L[:, j] = 1 * grid_np[:, j]
            R[:, -j - 1] = 1 * grid_np[:, -j - 1]
        else:
            L[:, j] = (L[:, j - 1] + 1) * grid_np[:, j]
            R[:, -j - 1] = (R[:, -j] + 1) * grid_np[:, -j - 1]

    for i in range(H):
        if i == 0:
            U[i] = 1 * grid_np[i]
            D[-i -1] = 1 * grid_np[-i -1]
        else:
            U[i] = (U[i - 1] + 1) * grid_np[i]
            D[-i - 1] = (D[-i] + 1) * grid_np[-i - 1]
    ans = np.max((L+R+U+D) -3)
    return ans

if __name__ == "__main__":
    # print(solve())
    print(solve_np())

# if __name__ == "__main__":
#     import timeit
#     loop = 1
#     n = 1000
#     time = timeit.timeit(lambda: solve(), number=loop)
#     print(time/loop)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

H, W = read_int()
grid = []
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]

for _ in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)

res = [[-3 for _ in range(W)] for _ in range(H)]

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == "#":
                L[i][j] = U[i][j] = 0
            else:
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
            res[i][j] += L[i][j] + U[i][j]
            ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == "#":
                R[H - i - 1][W - j - 1] = D[H - i - 1][W - j - 1] = 0
            else:
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
            res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
            ans = max(res[H - i - 1][W - j - 1], ans)
    return ans

if __name__ == "__main__":
    print(solve())



Fixed submission:
import sys, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()


# nomal
# L = [[0 for _ in range(W)] for _ in range(H)]
# R = [[0 for _ in range(W)] for _ in range(H)]
# U = [[0 for _ in range(W)] for _ in range(H)]
# D = [[0 for _ in range(W)] for _ in range(H)]
res = [[0 for _ in range(W)] for _ in range(H)]
grid = []

# numpy
import numpy as np
L, R, U, D = [np.zeros((H, W), int) for _ in range(4)]
grid_np = np.zeros((H,W), int)


for i in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)
    grid_np[i] = np.array(row) == '.'

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

def solve_np():
    ans = 0

    for j in range(W):
        # 本当は意味ない条件分岐
        if j == 0:
            L[:, j] = 1 * grid_np[:, j]
            R[:, -j - 1] = 1 * grid_np[:, -j - 1]
        else:
            L[:, j] = (L[:, j - 1] + 1) * grid_np[:, j]
            R[:, -j - 1] = (R[:, -j] + 1) * grid_np[:, -j - 1]

    for i in range(H):
        if i == 0:
            U[i] = 1 * grid_np[i]
            D[-i -1] = 1 * grid_np[-i -1]
        else:
            U[i] = (U[i - 1] + 1) * grid_np[i]
            D[-i - 1] = (D[-i] + 1) * grid_np[-i - 1]
    ans = np.max((L+R+U+D) -3)
    return ans

if __name__ == "__main__":
    # print(solve())
    print(solve_np())

# if __name__ == "__main__":
#     import timeit
#     loop = 1
#     n = 1000
#     time = timeit.timeit(lambda: solve(), number=loop)
#     print(time/loop)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

H, W = read_int()
grid = []
L = [[0 for _ in range(W)] for _ in range(H)]
R = [[0 for _ in range(W)] for _ in range(H)]
U = [[0 for _ in range(W)] for _ in range(H)]
D = [[0 for _ in range(W)] for _ in range(H)]

for _ in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)

res = [[0 for _ in range(W)] for _ in range(H)]
def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == "#":
                L[i][j] = U[i][j] = 0
            else:
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1

            if grid[H - i - 1][W - j - 1] == "#":
                R[H - i - 1][W - j - 1] = D[H - i - 1][W - j - 1] = 0
            else:
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1

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

    return ans

if __name__ == "__main__":
    print(solve())



Fixed submission:
import sys, math, heapq
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
H, W = read_int()


# nomal
# L = [[0 for _ in range(W)] for _ in range(H)]
# R = [[0 for _ in range(W)] for _ in range(H)]
# U = [[0 for _ in range(W)] for _ in range(H)]
# D = [[0 for _ in range(W)] for _ in range(H)]
res = [[0 for _ in range(W)] for _ in range(H)]
grid = []

# numpy
import numpy as np
L, R, U, D = [np.zeros((H, W), int) for _ in range(4)]
grid_np = np.zeros((H,W), int)


for i in range(H):
    row = list(" ".join(input()).split())
    grid.append(row)
    grid_np[i] = np.array(row) == '.'

def solve():
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                L[i][j] = 1 if j == 0 else L[i][j - 1] + 1
                U[i][j] = 1 if i == 0 else U[i - 1][j] + 1
                res[i][j] += L[i][j] + U[i][j]
                ans = max(res[i][j], ans)

            if grid[H - i - 1][W - j - 1] == ".":
                R[H - i - 1][W - j - 1] = 1 if j == 0 else R[H - i - 1][W - j] + 1
                D[H - i - 1][W - j - 1] = 1 if i == 0 else D[H - i][W - j - 1] + 1
                res[H - i - 1][W - j - 1] += R[H - i - 1][W - j - 1] + D[H - i - 1][W - j - 1]
                ans = max(res[H - i - 1][W - j - 1], ans)
    return ans - 3

def solve_np():
    ans = 0

    for j in range(W):
        # 本当は意味ない条件分岐
        if j == 0:
            L[:, j] = 1 * grid_np[:, j]
            R[:, -j - 1] = 1 * grid_np[:, -j - 1]
        else:
            L[:, j] = (L[:, j - 1] + 1) * grid_np[:, j]
            R[:, -j - 1] = (R[:, -j] + 1) * grid_np[:, -j - 1]

    for i in range(H):
        if i == 0:
            U[i] = 1 * grid_np[i]
            D[-i -1] = 1 * grid_np[-i -1]
        else:
            U[i] = (U[i - 1] + 1) * grid_np[i]
            D[-i - 1] = (D[-i] + 1) * grid_np[-i - 1]
    ans = np.max((L+R+U+D) -3)
    return ans

if __name__ == "__main__":
    # print(solve())
    print(solve_np())

# if __name__ == "__main__":
#     import timeit
#     loop = 1
#     n = 1000
#     time = timeit.timeit(lambda: solve(), number=loop)
#     print(time/loop)