Problem p03240 (python)

Fixed submission:
n=int(input())
xyh=[]

x,y,h=-1,-1,-1
nonzero=-1

for i in range(n):
    xyh.append(list(map(int,input().split())))
    if xyh[i][2] != 0:
        nonzero = i

for px in range(101):
    for py in range(101):
        nh = xyh[nonzero][2]+abs(xyh[nonzero][0]-px)+abs(xyh[nonzero][1]-py)
        ok = True

        for nn in range(n):
            if xyh[nn][2] > 0 and nh != xyh[nn][2]+abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py):
                ok=False
            if xyh[nn][2] == 0 and nh > abs(xyh[nn][0]-px) +abs(xyh[nn][1]-py):
                ok=False
        
        if ok:
            x,y,h = px,py,nh
            print(x,y,h)
            exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]

x,y,k=-1,-1,-1
n=-1
for o in range(n):
    a.append(list(map(int,input().split())))
    if a[o][2] != 0:
        n=o
for i in range(101):
    for j in range(101):
        h=a[n][2]+abs(a[n][0]-i)+abs(a[n][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]

x,y,k=-1,-1,-1
n=-1
for o in range(n):
    a.append(list(map(int,input().split())))
    if a[o][2] != 0:
        n=o
for i in range(101):
    for j in range(101):
        h=a[o][2]+abs(a[o][0]-i)+abs(a[o][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]

x,y,k=-1,-1,-1
n=-1
for _ in range(n):
    a.append(list(map(int,input().split())))
    if a[_][2] != 0:
        n=i
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]

x,y,k=-1,-1,-1

for _ in range(n):
    s=list(map(int,input().split()))
    if s[2] != 0:
        a.append(s)
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]

x,y,k=-1,-1,-1

for _ in range(n):
    s=list(map(int,input().split()))
    if s[2] != 0:
        a.append(s)
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            elif a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for _ in range(n):
    s=list(map(int,input().split()))
    if s[2] != 0:
        a.append(s)
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            elif a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,h = i,j,h
            print(x,y,h)