Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np


def read():
    return sys.stdin.readline().rstrip()


def main():
    h, w = map(int, read().split())
    s = np.array([[i == "." for i in read()] for _ in range(h)], dtype=int)
    left = s.copy()
    right = s.copy
    up = s.copy
    down = s.copy
    for i in range(w - 1):
        left[:, i + 1] = (left[:, i] + 1) * s[:, i + 1]
        right[:, -i - 2] = (right[:, -i - 1] + 1) * s[:, -i - 2]
    for i in range(h - 1):
        up[i + 1] = (up[i] + 1) * s[i + 1]
        down[-i - 2] = (down[-i - 1] + 1) * s[-i - 2]
    print((left + right + up + down).max() - 3)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

if __name__ == '__main__':
    main()

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


def read():
    return sys.stdin.readline().rstrip()


def main():
    h, w = map(int, read().split())
    s = [[False] * w] + [[False] + [i == "." for i in read()] + [False] for _ in range(h)] + [[False] * w]
    left = [[0] * (w + 2) for _ in range(h + 2)]
    right = [[0] * (w + 2) for _ in range(h + 2)]
    up = [[0] * (w + 2) for _ in range(h + 2)]
    down = [[0] * (w + 2) for _ in range(h + 2)]
    for y in range(1, h + 1):
        for x in range(1, w + 1):
            if s[y][x]:
                left[y][x] = left[y][x - 1] + 1
                up[y][x] = up[y - 1][x] + 1
            if s[-y - 1][-x - 1]:
                right[-y - 1][-x - 1] = right[-y - 1][-x] + 1
                down[-y - 1][-x - 1] = down[-y][-x - 1] + 1
    c = 0
    for y in range(1, h + 1):
        for x in range(1, w + 1):
            if s[y][x]:
                c = max(left[y][x] + right[y][x] + up[y][x] + down[y][x], c)
    print(c - 3)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

if __name__ == '__main__':
    main()

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


def read():
    return sys.stdin.readline().rstrip()


def main():
    h, w = map(int, read().split())
    s = ["#" * w] + ["w" + read() + "w" for _ in range(h)] + ["w" * w]
    left = [[0] * (w + 2) for _ in range(h + 2)]
    right = [[0] * (w + 2) for _ in range(h + 2)]
    up = [[0] * (w + 2) for _ in range(h + 2)]
    down = [[0] * (w + 2) for _ in range(h + 2)]
    for y in range(1, h + 1):
        for x in range(1, w + 1):
            if s[y][x] == ".":
                left[y][x] = left[y][x - 1] + 1
                up[y][x] = up[y - 1][x] + 1
            if s[-y - 1][-x - 1] == ".":
                right[-y - 1][-x - 1] = right[-y - 1][-x] + 1
                down[-y - 1][-x - 1] = down[-y][-x - 1] + 1
    c = 0
    for y in range(1, h + 1):
        for x in range(1, w + 1):
            if s[y][x] == ".":
                c = max(left[y][x] + right[y][x] + up[y][x] + down[y][x], c)
    print(c - 3)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    l = np.zeros((h, w), dtype=int)
    r = np.zeros((h, w), dtype=int)
    u = np.zeros((h, w), dtype=int)
    d = np.zeros((h, w), dtype=int)
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                l[i][j] = l[i][j - 1] + 1 if j > 0 else 1
                u[i][j] = u[i - 1][j] + 1 if i > 0 else 1
            if s[h - 1 - i][w - 1 - j] == ".":
                r[h - 1 - i][w - 1 - j] = r[h - 1 - i][w - j] + 1 if j > 0 else 1
                d[h - 1 - i][w - 1 - j] = d[h - i][w - 1 - j] + 1 if i > 0 else 1
    print((l + r + u + d).max() - 3)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

if __name__ == '__main__':
    main()

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

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) 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 i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                l[i][j] = l[i][j - 1] + 1 if j > 0 else 1
                u[i][j] = u[i - 1][j] + 1 if i > 0 else 1
            if s[h - 1 - i][w - 1 - j] == ".":
                r[h - 1 - i][w - 1 - j] = r[h - 1 - i][w - j] + 1 if j > 0 else 1
                d[h - 1 - i][w - 1 - j] = d[h - i][w - 1 - j] + 1 if i > 0 else 1
    ans = 0
    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)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

if __name__ == '__main__':
    main()

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

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def read():
    return sys.stdin.readline().rstrip()

def main():
    h, w = map(int, read().split())
    s = [list(read()) for _ in range(h)]
    row = [[0 for _ in range(w)] for _ in range(h)]
    col = [[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        c = 0
        for j in range(w):
            if s[i][j] == "#":
                for k in range(j - c, j):
                    row[i][k] = c
                c = 0
            else:
                c += 1
        for k in range(w - c, w):
            row[i][k] = c
    for i in range(w):
        c = 0
        for j in range(h):
            if s[j][i] == "#":
                for k in range(j - c, j):
                    col[k][i] = c
                c = 0
            else:
                c += 1
        for k in range(h - c, h):
            col[k][i] = c
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(row[i][j] + col[i][j], ans)
    print(ans - 1)

if __name__ == '__main__':
    main()