Problem p03240 (python)

Fixed submission:
def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(list(map(int, input().split())))

    l.sort(key = lambda x:-x[2])

    for cx in range(0, 101):
        for cy in range(0, 101):
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if i == 0:
                    H = h + abs(x-cx) + abs(y-cy)
                    if H < 1 or H != int(H):
                        break
                    continue
                if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                    break
                if i == n-1:
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(list(map(int, input().split())))

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            ll = []
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h == 0:
                    ll.append(list(x,y,h))
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    if H < 1 or H != int(H):
                        break
                    continue
                if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                    break
                if i == len(l) - 1:
                    for xx,yy,hh, in ll:
                        if hh != max((H - abs(xx-cx) - abs(yy-cy)), 0):
                            break
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(list(map(int, input().split())))

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            ll = []
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h == 0:
                    ll.append(list(x,y,h))
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    if H < 1 or H != int(H):
                        break
                    continue
                if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                    break
                if i == len(l) - 1:
                    for x,y,h in ll:
                        if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                            break
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(list(map(int, input().split())))

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h < 0:
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    continue
                if H < 1 or H != int(H) or (h > 0 and h != H - abs(x-cx) - abs(y-cy) or (h = 0 and h > H - abs(x-cx) - abs(y-cy))):
                    break
                if i == len(l) - 1:
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()