Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = list(input()) + ['#']
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)


Fixed submission:
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = list(input()) + ['#']
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
                

for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
        height[j] = 0 

print(ans)


Fixed submission:
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = []
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = list(input()) + [0]
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                s = s[:(j-length)] + [length]*length + s[j:]
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                height[j] = 0 
    S.append(s)

for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
        height[j] = 0 

print(ans)


Fixed submission:
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = []
height, ans = [0] * (W+1), 0
for i in range(H):
    s = list(input()) + [0]
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            s[j] = 0
            if length > 0:
                s = s[:(j-length)] + [length]*length + s[j:]
                length = 0
            if height[j] > 0:
                temp = max(S[i - k - 1][j] for k in range(height[j])) + height[j] - 1
                if ans < temp:
                    ans = temp
                height[j] = 0 
    S.append(s)

for j in range(W):
    if height[j] > 0:
        temp = max(S[i - k - 1][j] for k in range(height[j])) + height[j] - 1
        if ans < temp:
            ans = temp

print(ans)

Fixed submission:
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = []
heigth = [0] * (W+1)
for i in range(H):
    s = list(input()) + [0]
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            heigth[j] += 1
        else:
            s[j] = 0
            if length > 0:
                s = s[:(j-length)] + [length]*length + s[j:]
                length = 0
            if heigth[j] > 0:
                for k in range(heigth[j]):
                    S[i - k - 1][j] += heigth[j] - 1
                heigth[j] = 0 
    S.append(s)

for j in range(W):
    if heigth[j] > 0:
        for k in range(heigth[j]):
            S[i - k][j] += heigth[j] - 1

print(max([max(S[i]) for i in range(H)]))

Fixed submission:
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = []
for i in range(H):
    S += [['#'] + list(input()) + ['#']]
S = [['#' for i in range(W+2)]] + S + [['#' for i in range(W+2)]]

ans,v = 0,[0 for i in range(W)]
for i in range(1,W+1):
    k = 1
    while S[k][i] == '.':
        k += 1
    v[i-1] = k - 1

for i in range(1,H+1):
    j,dot = 1,0
    while j < W+1:
        while S[i][j] == '.':
                dot += 1
                j += 1
        for k in range(j-dot,j):
            if ans < dot + v[k-1]:    ans = dot + v[k-1]

        dot = 0
        k = i+1
        if j < W+1:
            while S[k][j] == '.':
                k += 1
            v[j-1] = k - i - 1
            j += 1 
print(ans-1)    



Fixed submission:
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = []
for i in range(H):
    S += [['#'] + list(input()) + ['#']]
S = [['#' for i in range(W+2)]] + S + [['#' for i in range(W+2)]]

ans,v = 0,[0 for i in range(W)]
for i in range(1,W+1):
    k = 1
    while S[k][i] == '.':
        k += 1
    v[i-1] = k - 1

for i in range(1,H+1):
    dot = 1
    while S[i][dot] == '.':
            dot += 1
    dot -= 1
    for j in range(1,W+1):
        if S[i][j] == '#':
            k = j+1
            while S[i][k] == '.':
                k += 1
            dot = k - j - 1

            k = i+1
            while S[k][j] == '.':
                k += 1
            v[j-1] = k - i - 1 
        else:
            if ans < dot + v[j-1]:    ans = dot + v[j-1]
print(ans-1)    



Fixed submission:
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = input() + '#'
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                width_max[j], height[j] = 0, 0
for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
print(ans)