Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
flag = [[False] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        flag[i][j] = s[i][j] == "."
a = [[0] * w for i in range(h)]
for i in range(h):
    count = 0
    for j in range(w):
        if flag[i][j]:
            count += 1
            a[i][j] = count
        else:
            count = 0
for i in range(h - 1, -1, -1):
    m = 0
    for j in range(w - 1, -1, -1):
        if flag[i][j]:
            if m:
                a[i][j] = m
            else:
                m = a[i][j]
        else:
            m = 0
b = [[0] * w for i in range(h)]
for j in range(w):
    count = 0
    for i in range(h):
        if flag[i][j]:
            count += 1
            b[i][j] = count
        else:
            count = 0
for j in range(w - 1, -1, -1):
    m = 0
    for i in range(h - 1, -1, -1):
        if flag[i][j]:
            if m:
                b[i][j] = m
            else:
                m = b[i][j]
        else:
            m = 0
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, a[i][j] + b[i][j] - 1)
print(ans)

Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
hc = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if j > 0:
                hc[i][j] = hc[i][j - 1] + 1
            else:
                hc[i][j] = 1
for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j < w - 1:
                if hc[i][j] < hc[i][j + 1]:
                    hc[i][j] = hc[i][j + 1]
wc = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if j > 0:
                wc[i][j] = wc[i][j - 1] + 1
            else:
                wc[i][j] = 1
for i in range(w):
    for j in range(h - 1, -1, -1):
        if s[j][i] == ".":
            if j < h - 1:
                if wc[i][j] < wc[i][j + 1]:
                    wc[i][j] = wc[i][j + 1]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, hc[i][j] + wc[j][i] - 1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
hc = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            hc[i][j] = hc[i][j - 1] + 1
for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j < w - 1:
                if hc[i][j] < hc[i][j + 1]:
                    hc[i][j] = hc[i][j + 1]
wc = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            wc[i][j] = wc[i][j - 1] + 1
for i in range(w):
    for j in range(h - 1, -1, -1):
        if s[j][i] == ".":
            if j < h - 1:
                if wc[i][j] < wc[i][j + 1]:
                    wc[i][j] = wc[i][j + 1]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, hc[i][j] + wc[j][i] - 1)
print(ans)

Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
hc = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if j > 0:
                hc[i][j] = hc[i][j - 1] + 1
            else:
                hc[i][j] = 1
for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j < w - 1:
                if hc[i][j] < hc[i][j + 1]:
                    hc[i][j] = hc[i][j + 1]
wc = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if j > 0:
                wc[i][j] = wc[i][j - 1] + 1
            else:
                wc[i][j] = 1
for i in range(w):
    for j in range(h - 1, -1, -1):
        if s[j][i] == ".":
            if j < h - 1:
                if wc[i][j] < wc[i][j + 1]:
                    wc[i][j] = wc[i][j + 1]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, hc[i][j] + wc[j][i] - 1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
hc = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            hc[i][j] = hc[i][j - 1] + 1
for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j < w - 1:
                if hc[i][j] < hc[i][j + 1]:
                    hc[i][j] = hc[i][j + 1]
wc = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            wc[i][j] = wc[i][j - 1] + 1
for i in range(w):
    for j in range(h - 1, -1, -1):
        if s[j][i] == ".":
            if j < h - 1:
                if wc[i][j] < wc[i][j + 1]:
                    wc[i][j] = wc[i][j + 1]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, hc[i][j] + wc[j][i] - 1)
print(ans)

Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
hc = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if j > 0:
                hc[i][j] = hc[i][j - 1] + 1
            else:
                hc[i][j] = 1
for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j < w - 1:
                if hc[i][j] < hc[i][j + 1]:
                    hc[i][j] = hc[i][j + 1]
wc = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if j > 0:
                wc[i][j] = wc[i][j - 1] + 1
            else:
                wc[i][j] = 1
for i in range(w):
    for j in range(h - 1, -1, -1):
        if s[j][i] == ".":
            if j < h - 1:
                if wc[i][j] < wc[i][j + 1]:
                    wc[i][j] = wc[i][j + 1]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, hc[i][j] + wc[j][i] - 1)
print(ans)

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

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
dh = {}
for i in range(h):
    dh[i] = []
    for j in range(w):
        if s[i][j] == "#":
            dh[i].append(j)
dw = {}
for i in range(w):
    dw[i] = []
    for j in range(h):
        if s[j][i] == "#":
            dw[i].append(j)
fw = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if fw[i][j - 1]:
                fw[i][j] = 2
            else:
                fw[i][j] = 1
fh = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if fh[i][j - 1]:
                fh[i][j] = 2
            else:
                fh[i][j] = 1
aw = [[0] * w for i in range(h)]
ah = [[0] * h for i in range(w)]
ans = 0
for i in range(h):
    a = dh[i]
    for j in range(w):
        if s[i][j] == "#":
            continue
        b = dw[j]
        if fw[i][j] == 1:
            c = bisect.bisect_left(a, j)
            if not a:
                wl = w
            else:
                if c == 0:
                    wl = a[0]
                elif c == len(a):
                    wl = w - a[-1] - 1
                else:
                    wl = a[c] - a[c - 1] - 1
        else:
            wl = aw[i][j - 1]
        if fh[j][i] == 1:
            d = bisect.bisect_left(b, i)
            if not b:
                hl = h
            else:
                if d == 0:
                    hl = b[0]
                elif d == len(b):
                    hl = h - b[-1] - 1
                else:
                    hl = b[d] - b[d - 1] - 1
        else:
            hl = ah[j][i - 1]
        aw[i][j] = wl
        ah[j][i] = hl
        ans = max(ans, wl + hl - 1)
print(ans)

Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
hc = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if j > 0:
                hc[i][j] = hc[i][j - 1] + 1
            else:
                hc[i][j] = 1
for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j < w - 1:
                if hc[i][j] < hc[i][j + 1]:
                    hc[i][j] = hc[i][j + 1]
wc = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if j > 0:
                wc[i][j] = wc[i][j - 1] + 1
            else:
                wc[i][j] = 1
for i in range(w):
    for j in range(h - 1, -1, -1):
        if s[j][i] == ".":
            if j < h - 1:
                if wc[i][j] < wc[i][j + 1]:
                    wc[i][j] = wc[i][j + 1]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, hc[i][j] + wc[j][i] - 1)
print(ans)

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

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
dh = {}
for i in range(h):
    dh[i] = []
    for j in range(w):
        if s[i][j] == "#":
            dh[i].append(j)
dw = {}
for i in range(w):
    dw[i] = []
    for j in range(h):
        if s[j][i] == "#":
            dw[i].append(j)
ans = 0
for i in range(h):
    a = dh[i]
    for j in range(w):
        if s[i][j] == "#":
            continue
        b = dw[j]
        c = bisect.bisect_left(a, j)
        if not a:
            wl = w
        else:
            if c == 0:
                wl = a[0]
            elif c == len(a):
                wl = w - a[-1] - 1
            else:
                wl = a[c] - a[c - 1] - 1
        d = bisect.bisect_left(b, i)
        if not b:
            hl = h
        else:
            if d == 0:
                hl = b[0]
            elif d == len(b):
                hl = h - b[-1] - 1
            else:
                hl = b[d] - b[d - 1] - 1
        ans = max(ans, wl + hl - 1)
print(ans)

Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
hc = [[0] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            if j > 0:
                hc[i][j] = hc[i][j - 1] + 1
            else:
                hc[i][j] = 1
for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == ".":
            if j < w - 1:
                if hc[i][j] < hc[i][j + 1]:
                    hc[i][j] = hc[i][j + 1]
wc = [[0] * h for i in range(w)]
for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            if j > 0:
                wc[i][j] = wc[i][j - 1] + 1
            else:
                wc[i][j] = 1
for i in range(w):
    for j in range(h - 1, -1, -1):
        if s[j][i] == ".":
            if j < h - 1:
                if wc[i][j] < wc[i][j + 1]:
                    wc[i][j] = wc[i][j + 1]
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, hc[i][j] + wc[j][i] - 1)
print(ans)