Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
S = [input() for i in range(h)]

A = [[0 for i in range(w)] for j in range(h)]

a = -1
b = -1
for i in range(h):
    a = -1
    for j in range(w):
        if S[i][j] == "#":
            if a != -1:
                for k in range(a,j):
                    A[i][k] += j-a
                a = -1
        else:
            if a == -1:
                a = j
                #print(j)
    if a != -1:
        for k in range(a,j+1):
            A[i][k] += j+1-a

for i in range(w):
    a = -1
    for j in range(h):
        if S[j][i] == "#":
            if a != -1:
                for k in range(a,j):
                    A[k][i] += j-a
                a = -1
        else:
            if a == -1:
                a = j
    if a != -1:
        for k in range(a,j+1):
            A[k][i] += j+1-a
#print(A)

ans = 0
for i in range(h):
    ans = max(ans, max(A[i]))

print(ans-1)

Fixed submission:
h,w = map(int,input().split())
S = [input() for i in range(h)]

A = [[0 for i in range(w)] for j in range(h)]

a = -1
b = -1
for i in range(h):
    a = -1
    for j in range(w):
        if S[i][j] == "#":
            if a != -1:
                for k in range(a,j):
                    A[i][k] += j-a
                a = -1
        else:
            if a == -1:
                a = j
                #print(j)
    if a != -1:
        for k in range(a,j+1):
            A[i][k] += j+1-a

for i in range(w):
    a = -1
    for j in range(h):
        if S[j][i] == "#":
            if a != -1:
                for k in range(a,j):
                    A[k][i] += j-a
                a = -1
        else:
            if a == -1:
                a = j
    if a != -1:
        for k in range(a,j+1):
            A[k][i] += j+1-a
#print(A)

ans = 0
for i in range(h):
    ans = max(ans, max(A[i]))

print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
S = [input() for i in range(h)]

A = [[[0,0] for i in range(w)] for j in range(h)]

a = -1
b = -1
for i in range(h):
    a = -1
    for j in range(w):
        if S[i][j] == "#":
            if a != -1:
                for k in range(a,j):
                    A[i][k][0] = j-a
                a = -1
        else:
            if a == -1:
                a = j
                #print(j)
    if a != -1:
        for k in range(a,j+1):
            A[i][k][0] = j+1-a

for i in range(w):
    a = -1
    for j in range(h):
        if S[j][i] == "#":
            if a != -1:
                for k in range(a,j):
                    A[k][i][1] = j-a
                a = -1
        else:
            if a == -1:
                a = j
    if a != -1:
        for k in range(a,j+1):
            A[k][i][1] = j+1-a
#print(A)

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, A[i][j][0] + A[i][j][1])

print(ans-1)

Fixed submission:
h,w = map(int,input().split())
S = [input() for i in range(h)]

A = [[0 for i in range(w)] for j in range(h)]

a = -1
b = -1
for i in range(h):
    a = -1
    for j in range(w):
        if S[i][j] == "#":
            if a != -1:
                for k in range(a,j):
                    A[i][k] += j-a
                a = -1
        else:
            if a == -1:
                a = j
                #print(j)
    if a != -1:
        for k in range(a,j+1):
            A[i][k] += j+1-a

for i in range(w):
    a = -1
    for j in range(h):
        if S[j][i] == "#":
            if a != -1:
                for k in range(a,j):
                    A[k][i] += j-a
                a = -1
        else:
            if a == -1:
                a = j
    if a != -1:
        for k in range(a,j+1):
            A[k][i] += j+1-a
#print(A)

ans = 0
for i in range(h):
    ans = max(ans, max(A[i]))

print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
S = [input() for i in range(h)]

A = [[[0,0] for i in range(w)] for j in range(h)]

a = -1
b = -1
for i in range(h):
    a = -1
    for j in range(w):
        if S[i][j] == "#":
            if a != -1:
                for k in range(a,j):
                    A[i][k][0] = j-a
                a = -1
        else:
            if a == -1:
                a = j
                #print(j)
    if a != -1:
        for k in range(a,j+1):
            A[i][k][0] = j+1-a

for i in range(w):
    a = -1
    for j in range(h):
        if S[j][i] == "#":
            if a != -1:
                for k in range(a,j):
                    A[k][i][1] = j-a
                a = -1
        else:
            if a == -1:
                a = j
    if a != -1:
        for k in range(a,j+1):
            A[k][i][1] = j+1-a
#print(A)

ans = 0
for i in range(h):
    for j in range(w):
        su = sum(A[i][j])
        ans = max(ans, su)

print(ans-1)

Fixed submission:
h,w = map(int,input().split())
S = [input() for i in range(h)]

A = [[0 for i in range(w)] for j in range(h)]

a = -1
b = -1
for i in range(h):
    a = -1
    for j in range(w):
        if S[i][j] == "#":
            if a != -1:
                for k in range(a,j):
                    A[i][k] += j-a
                a = -1
        else:
            if a == -1:
                a = j
                #print(j)
    if a != -1:
        for k in range(a,j+1):
            A[i][k] += j+1-a

for i in range(w):
    a = -1
    for j in range(h):
        if S[j][i] == "#":
            if a != -1:
                for k in range(a,j):
                    A[k][i] += j-a
                a = -1
        else:
            if a == -1:
                a = j
    if a != -1:
        for k in range(a,j+1):
            A[k][i] += j+1-a
#print(A)

ans = 0
for i in range(h):
    ans = max(ans, max(A[i]))

print(ans-1)