Buggy python submission (verdict: Runtime Error):
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]


class UnionFind:
    def __init__(self, size):
        self.UF = list(range(size))
        self.SIZE = [1] * size  # 0-indexed

    def find(self, x):
        UF = self.UF
        find = self.find
        if UF[x] != x:
            UF[x] = find(UF[x])
        return UF[x]

    def unite(self, x, y):
        is_same = self.is_same
        find = self.find
        SIZE = self.SIZE
        UF = self.UF
        if not is_same(x, y):
            X, Y = find(x), find(y)
            SX, SY = SIZE[X], SIZE[Y]
            if SX > SY:
                m = UF[X] = Y
            else:
                m = UF[Y] = X
            SIZE[m] = SX + SY
            SIZE[X + Y - m] = 0

    def is_same(self, x, y):
        find = self.find
        return find(x) == find(y)

    def scan_uf(self):
        find = self.find
        length = len(self.UF)
        for i in range(length):
            find(i)

    def size(self, x):
        return self.SIZE[self.find(x)]


score = [[0 for _ in range(W)] for _ in range(H)]
UF1 = UnionFind(H * W)
for h in range(H):
    w = 0
    while w < W:
        if S[h][w] == '.':
            w0 = w
            while w < W and S[h][w] == '.':
                UF1.unite(W * h + w, W * h + w0)
                w += 1
        else:
            w += 1
UF2 = UnionFind(H * W)
for w in range(W):
    h = 0
    while h < H:
        if S[h][w] == '.':
            h0 = h
            while h < H and S[h][w] == '.':
                UF2.unite(W * h + w, W * h0 + w)
                h += 1
        else:
            h += 1
ans = -1
for h in range(H):
    for w in range(W):
        ans = max([ans, UF1.size(W * h + w) + UF2.size(W * h + w) - 1])
print(ans)


Fixed submission:
import copy
H, W = [int(_) for _ in input().split()]
S = []
for _ in range(H):
    S += [1 if _ == '.' else 0 for _ in list(input())]
S += [0] * W
SL = copy.copy(S)
SR = copy.copy(S)
SU = copy.copy(S)
SD = copy.copy(S)
for h in range(H):
    for i in range(W * h + 1, W * (h + 1)):
        if SL[i]:
            SL[i] = SL[i - 1] + 1
        else:
            SL[i] = 0
for h in range(H):
    for i in range(W * h - 2, W * (h - 1) - 1, -1):
        if SR[i]:
            SR[i] = SR[i + 1] + 1
        else:
            SR[i] = 0
for w in range(W):
    for i in range(W + w, W * H + w, W):
        if SU[i]:
            SU[i] = SU[i - W] + 1
        else:
            SU[i] = 0
for w in range(W):
    for i in range(W * (H - 2) + w - 1, -1, -W):
        if SD[i]:
            SD[i] = SD[i + W] + 1
        else:
            SD[i] = 0
score = 0
print(max((SL[_] + SR[_] + SU[_] + SD[_] - 3 for _ in range(H * W))))

Buggy python submission (verdict: Runtime Error):
H, W = [int(_) for _ in input().split()]
S = []
for _ in range(H):
    S += [1 if _ == '.' else 0 for _ in list(input())]
S += [0] * W
SL = S.copy()
SR = S.copy()
SU = S.copy()
SD = S.copy()
for h in range(H):
    for i in range(W * h + 1, W * (h + 1)):
        if SL[i]:
            SL[i] = SL[i - 1] + 1
        else:
            SL[i] = 0
for h in range(H):
    for i in range(W * h - 2, W * (h - 1) - 1, -1):
        if SR[i]:
            SR[i] = SR[i + 1] + 1
        else:
            SR[i] = 0
for w in range(W):
    for i in range(W + w, W * H + w, W):
        if SU[i]:
            SU[i] = SU[i - W] + 1
        else:
            SU[i] = 0
for w in range(W):
    for i in range(W * (H - 2) + w - 1, -1, -W):
        if SD[i]:
            SD[i] = SD[i + W] + 1
        else:
            SD[i] = 0
score = 0
print(max((SL[_] + SR[_] + SU[_] + SD[_] - 3 for _ in range(H * W))))


Fixed submission:
import copy
H, W = [int(_) for _ in input().split()]
S = []
for _ in range(H):
    S += [1 if _ == '.' else 0 for _ in list(input())]
S += [0] * W
SL = copy.copy(S)
SR = copy.copy(S)
SU = copy.copy(S)
SD = copy.copy(S)
for h in range(H):
    for i in range(W * h + 1, W * (h + 1)):
        if SL[i]:
            SL[i] = SL[i - 1] + 1
        else:
            SL[i] = 0
for h in range(H):
    for i in range(W * h - 2, W * (h - 1) - 1, -1):
        if SR[i]:
            SR[i] = SR[i + 1] + 1
        else:
            SR[i] = 0
for w in range(W):
    for i in range(W + w, W * H + w, W):
        if SU[i]:
            SU[i] = SU[i - W] + 1
        else:
            SU[i] = 0
for w in range(W):
    for i in range(W * (H - 2) + w - 1, -1, -W):
        if SD[i]:
            SD[i] = SD[i + W] + 1
        else:
            SD[i] = 0
score = 0
print(max((SL[_] + SR[_] + SU[_] + SD[_] - 3 for _ in range(H * W))))

Buggy python submission (verdict: Time Limit Exceeded):
H, W = [int(_) for _ in input().split()]
S = []
for _ in range(H):
    S += [1 if _ == '.' else 0 for _ in list(input())]
S += [0] * W
SL = S.copy()
SR = S.copy()
SU = S.copy()
SD = S.copy()
for h in range(H):
    for i in range(W * h + 1, W * (h + 1)):
        if SL[i]:
            SL[i] = SL[i - 1] + 1
        else:
            SL[i] = 0
for h in range(H):
    for i in range(W * h - 2, W * (h - 1) - 1, -1):
        if SR[i]:
            SR[i] = SR[i + 1] + 1
        else:
            SR[i] = 0
for w in range(W):
    for i in range(W + w, W * H + w, W):
        if SU[i]:
            SU[i] = SU[i - W] + 1
        else:
            SU[i] = 0
for w in range(W):
    for i in range(W * (H - 2) + w - 1, -1, -W):
        if SD[i]:
            SD[i] = SD[i + W] + 1
        else:
            SD[i] = 0
score = 0
print(max((SL[_] + SR[_] + SU[_] + SD[_] - 3 for _ in range(H * W))))


Fixed submission:
import copy
H, W = [int(_) for _ in input().split()]
S = []
for _ in range(H):
    S += [1 if _ == '.' else 0 for _ in list(input())]
S += [0] * W
SL = copy.copy(S)
SR = copy.copy(S)
SU = copy.copy(S)
SD = copy.copy(S)
for h in range(H):
    for i in range(W * h + 1, W * (h + 1)):
        if SL[i]:
            SL[i] = SL[i - 1] + 1
        else:
            SL[i] = 0
for h in range(H):
    for i in range(W * h - 2, W * (h - 1) - 1, -1):
        if SR[i]:
            SR[i] = SR[i + 1] + 1
        else:
            SR[i] = 0
for w in range(W):
    for i in range(W + w, W * H + w, W):
        if SU[i]:
            SU[i] = SU[i - W] + 1
        else:
            SU[i] = 0
for w in range(W):
    for i in range(W * (H - 2) + w - 1, -1, -W):
        if SD[i]:
            SD[i] = SD[i + W] + 1
        else:
            SD[i] = 0
score = 0
print(max((SL[_] + SR[_] + SU[_] + SD[_] - 3 for _ in range(H * W))))

Buggy python submission (verdict: Runtime Error):
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]


class UnionFind:
    def __init__(self, size):
        self.UF = list(range(size))
        self.SIZE = [1] * size  # 0-indexed

    def find(self, x):
        UF = self.UF
        find = self.find
        if UF[x] != x:
            UF[x] = find(UF[x])
        return UF[x]

    def unite(self, x, y):
        is_same = self.is_same
        find = self.find
        SIZE = self.SIZE
        UF = self.UF
        if not is_same(x, y):
            X, Y = find(x), find(y)
            SX, SY = SIZE[X], SIZE[Y]
            if SX > SY:
                m = UF[X] = Y
            else:
                m = UF[Y] = X
            SIZE[m] = SX + SY
            SIZE[X + Y - m] = 0

    def is_same(self, x, y):
        find = self.find
        return find(x) == find(y)

    def scan_uf(self):
        find = self.find
        length = len(self.UF)
        for i in range(length):
            find(i)

    def size(self, x):
        return self.SIZE[self.find(x)]


score = [[0 for _ in range(W)] for _ in range(H)]
UF1 = UnionFind(H * W)
for h in range(H):
    w = 0
    while w < W:
        if S[h][w] == '.':
            w0 = w
            while w < W and S[h][w] == '.':
                UF1.unite(W * h + w, W * h + w0)
                w += 1
        else:
            w += 1
UF2 = UnionFind(H * W)
for w in range(W):
    h = 0
    while h < H:
        if S[h][w] == '.':
            h0 = h
            while h < H and S[h][w] == '.':
                UF2.unite(W * h + w, W * h0 + w)
                h += 1
        else:
            h += 1
ans = -1
for h in range(H):
    for w in range(W):
        ans = max([ans, UF1.size(W * h + w) + UF2.size(W * h + w) - 1])
print(ans)


Fixed submission:
import copy
H, W = [int(_) for _ in input().split()]
S = []
for _ in range(H):
    S += [1 if _ == '.' else 0 for _ in list(input())]
S += [0] * W
SL = copy.copy(S)
SR = copy.copy(S)
SU = copy.copy(S)
SD = copy.copy(S)
for h in range(H):
    for i in range(W * h + 1, W * (h + 1)):
        if SL[i]:
            SL[i] = SL[i - 1] + 1
        else:
            SL[i] = 0
for h in range(H):
    for i in range(W * h - 2, W * (h - 1) - 1, -1):
        if SR[i]:
            SR[i] = SR[i + 1] + 1
        else:
            SR[i] = 0
for w in range(W):
    for i in range(W + w, W * H + w, W):
        if SU[i]:
            SU[i] = SU[i - W] + 1
        else:
            SU[i] = 0
for w in range(W):
    for i in range(W * (H - 2) + w - 1, -1, -W):
        if SD[i]:
            SD[i] = SD[i + W] + 1
        else:
            SD[i] = 0
score = 0
print(max((SL[_] + SR[_] + SU[_] + SD[_] - 3 for _ in range(H * W))))