Problem p03240 (python)

Fixed submission:
N=int(input().strip())
xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    xyh.append([xi,yi,hi])
    if hi>=1:
        xyhset=[xi,yi,hi]
        
for nx in range(101):
    for ny in range(101):
        He = xyhset[2]+abs(xyhset[0]-nx)+abs(xyhset[1]-ny)
        He=max(0,He)
        flag=True
        for i in range(N):
            h=He-abs(xyh[i][0]-nx)-abs(xyh[i][1]-ny)
            h=max(0,h)
            if xyh[i][2]!=h:
                flag=False
        if flag:
            ax=nx
            ay=ny
            ah=He

print("{} {} {}".format(ax,ay,ah))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().strip().split())

for i in range(M//N,0,-1):
    if M%i==0:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xtst=xi
        ytst=yi
        htst=hi
    xyh.append([xi,yi,hi])

for ny in range(101):
    for nx in range(101):
        nh=abs(xtst-nx)+abs(ytst-ny)+htst
        nh=max(nh,0)
        fl=True
        for lis in xyh:
                if lis[2]!=max(0,nh-abs(lis[0]-nx)+abs(lis[1]-ny)):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

Buggy submission (verdict: Runtime Error):
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xtst=xi
        ytst=yi
        htst=hi
    xyh.append([xi,yi,hi])

for ny in range(101):
    for nx in range(101):
        nh=abs(xtst-nx)+abs(ytst-ny)+htst
        nh=max(nh,0)
        fl=True
        for lis in xyh:
                if lis[2]!=max(0,nh-abs(lis[0]-nx)+abs(lis[1]-ny)):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

Buggy submission (verdict: Runtime Error):
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
nh=0
for ny in range(101):
    if fl:
        break
    for nx in range(101):
        if fl:
            break
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(N):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
                    break
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

Buggy submission (verdict: Runtime Error):
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
nh=0
for ny in range(101):
    if fl:
        break
    for nx in range(101):
        if fl:
            break
        for i in range(len(xyh)):
            if i==0:
                nh=abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]
        #        print(abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2])
            elif i==len(xyh)-1:
                if nh!=abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]:
                    break
                else:
                    fl=True
                    ax=nx
                    ay=ny
                    ah=nh
                    break
            else:
                if nh!=abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]:
                    break

print("{} {} {}".format(ax,ay,ah))