Buggy python submission (verdict: Runtime Error):

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    if i == H-1 or S[i+1][j] == '#':
        vertical[i][j] = current
        return current
    vertical[i][j] = search_vertical(i+1, j, current+1)
    return vertical[i][j]

def search_horizontal(i, j, current):
    if j == W-1 or S[i][j+1] == '#':
        horizontal[i][j] = current
        return current
    horizontal[i][j] = search_horizontal(i, j+1, current+1)
    return horizontal[i][j]

res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

print(res)


Fixed submission:

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    i2 = i

    while not (i2 == H-1 or S[i2+1][j] == '#'):
        i2 += 1
        current += 1

    for i3 in range(i, i2+1):
        vertical[i3][j] = current

def search_horizontal(i, j, current):
    j2 = j

    while  not (j2 == W-1 or S[i][j2+1] == '#'):
        j2 += 1
        current += 1

    for j3 in range(j, j2+1):
        horizontal[i][j3] = current


res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

# print(vertical)
print(res)

Buggy python submission (verdict: Runtime Error):

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = list(input())
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    if i == H-1 or S[i+1][j] == '#':
        vertical[i][j] = current
        return current
    vertical[i][j] = search_vertical(i+1, j, current+1)
    return vertical[i][j]

def search_horizontal(i, j, current):
    if j == W-1 or S[i][j+1] == '#':
        horizontal[i][j] = current
        return current
    horizontal[i][j] = search_horizontal(i, j+1, current+1)
    return horizontal[i][j]

for i in range(H):
    for j in range(W):
        if vertical[i][j] == -1 and S[i][j] == '.':
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1 and S[i][j] == '.':
            search_horizontal(i, j, 1)


print(max(vertical[i][j] + horizontal[i][j] -1 for i in range(H) for j in range(W)))


Fixed submission:

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    i2 = i

    while not (i2 == H-1 or S[i2+1][j] == '#'):
        i2 += 1
        current += 1

    for i3 in range(i, i2+1):
        vertical[i3][j] = current

def search_horizontal(i, j, current):
    j2 = j

    while  not (j2 == W-1 or S[i][j2+1] == '#'):
        j2 += 1
        current += 1

    for j3 in range(j, j2+1):
        horizontal[i][j3] = current


res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

# print(vertical)
print(res)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = list(input())
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    if i == H-1 or S[i+1][j] == '#':
        vertical[i][j] = current
        return current
    vertical[i][j] = search_vertical(i+1, j, current+1)
    return vertical[i][j]

def search_horizontal(i, j, current):
    if j == W-1 or S[i][j+1] == '#':
        horizontal[i][j] = current
        return current
    horizontal[i][j] = search_horizontal(i, j+1, current+1)
    return horizontal[i][j]

for i in range(H):
    for j in range(W):
        if vertical[i][j] == -1 and S[i][j] == '.':
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1 and S[i][j] == '.':
            search_horizontal(i, j, 1)


print(max(vertical[i][j] + horizontal[i][j] -1 for i in range(H) for j in range(W)))


Fixed submission:

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    i2 = i

    while not (i2 == H-1 or S[i2+1][j] == '#'):
        i2 += 1
        current += 1

    for i3 in range(i, i2+1):
        vertical[i3][j] = current

def search_horizontal(i, j, current):
    j2 = j

    while  not (j2 == W-1 or S[i][j2+1] == '#'):
        j2 += 1
        current += 1

    for j3 in range(j, j2+1):
        horizontal[i][j3] = current


res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

# print(vertical)
print(res)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = list(input())
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    if i == H-1 or S[i+1][j] == '#':
        vertical[i][j] = current
        return current
    vertical[i][j] = search_vertical(i+1, j, current+1)
    return vertical[i][j]

def search_horizontal(i, j, current):
    if j == W-1 or S[i][j+1] == '#':
        horizontal[i][j] = current
        return current
    horizontal[i][j] = search_horizontal(i, j+1, current+1)
    return horizontal[i][j]

for i in range(H):
    for j in range(W):
        if vertical[i][j] == -1 and S[i][j] == '.':
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1 and S[i][j] == '.':
            search_horizontal(i, j, 1)


print(max(vertical[i][j] + horizontal[i][j] -1 for i in range(H) for j in range(W)))


Fixed submission:

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    i2 = i

    while not (i2 == H-1 or S[i2+1][j] == '#'):
        i2 += 1
        current += 1

    for i3 in range(i, i2+1):
        vertical[i3][j] = current

def search_horizontal(i, j, current):
    j2 = j

    while  not (j2 == W-1 or S[i][j2+1] == '#'):
        j2 += 1
        current += 1

    for j3 in range(j, j2+1):
        horizontal[i][j3] = current


res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

# print(vertical)
print(res)