qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
# print(N, xyh)

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            # if h == 0: continue
            # if h + abs(x - cx) + abs(y - cy) != candidate:
            if candidate - abs(x - cx) - abs(y - cy) - h <= 0:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)


Fixed code:
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
# print(N, xyh)

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            _h = candidate - abs(x - cx) - abs(y - cy)
            if h == 0 and _h <= 0: continue
            if not h == _h:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)
Buggy code:
def main():
	n = int(input())
	xi, yi, hi = [0]*n, [0]*n, [0]*n
	stack = []
	result = []
	for i in range(n):
		xi[i], yi[i], hi[i] = map(int, input().split())
		if hi[i] > 0:
			stack = [xi[i], yi[i], hi[i]]
	for i in range(101):
		for j in range(101):
			guess = stack[2] + abs(stack[0]-i) + abs(stack[1]-j)
			is_result = True
			for k in range(n):
				result = guess - abs(xi[k]-i) - abs(yi[k]-j)
				result = max(result, 0)
				if hi[k] != result:
					is_result = False
					break
			if is_result:
				print(str(i)+" "+str(j)+" "+str(v))
				return


if __name__ == '__main__':
    main()

Fixed code:
def main():
	n = int(input())
	xi, yi, hi = [0]*n, [0]*n, [0]*n
	stack = []
	result = []
	for i in range(n):
		xi[i], yi[i], hi[i] = map(int, input().split())
		if hi[i] > 0:
			stack = [xi[i], yi[i], hi[i]]
	for i in range(101):
		for j in range(101):
			guess = stack[2] + abs(stack[0]-i) + abs(stack[1]-j)
			is_result = True
			for k in range(n):
				result = guess - abs(xi[k]-i) - abs(yi[k]-j)
				result = max(result, 0)
				if hi[k] != result:
					is_result = False
					break
			if is_result:
				print(str(i)+" "+str(j)+" "+str(guess))
				return


if __name__ == '__main__':
    main()
Buggy code:
N = int(input())
x = list(0 for i in range(N))
y = list(0 for i in range(N))
h = list(0 for i in range(N))
for i in range(N):
    x[i],y[i],h[i] = (int(i) for i in input().split())

H=-1

for cx in range(101):
    for cy in range(101):
        for i in range(N):
            tmp = h[i]+abs(x[i]-cx)+abs(y[i]-cy)
            if H == -1:
                H = tmp
            elif H != tmp:
                H = -2
            if H == -2:
                break
        if H == -2:
            continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(x[i]-cx)+abs(y[i]-cy)
                if H > dist:
                    H = -2
                    break
        if H == -2:
            continue
        print(cx,cy,H)
        break
    break


Fixed code:
N = int(input())
x = list(0 for i in range(N))
y = list(0 for i in range(N))
h = list(0 for i in range(N))
for i in range(N):
    x[i],y[i],h[i] = (int(i) for i in input().split())


for cx in range(101): 
    for cy in range(101):
        H = -1
        for i in range(N):
            if h[i] > 0:
                tmp = h[i]+abs(x[i]-cx)+abs(y[i]-cy)
                if H == -1:
                    H = tmp
                elif H != tmp:
                    H = -2
                    break
        if H == -2:
            continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(x[i]-cx)+abs(y[i]-cy)
                if H > dist:
                    H = -2
                    break
        if H == -2:
            continue
        print(cx,cy,H)
Buggy code:
n=int(input())
lists=[]
for i in range(n):
    tup=tuple(map(int,input().split()))
    lists.append(tup)
print(lists)
use=()
for some in lists:
    if some[2]==0:
        continue
    else:
        use=some
        break
        
        
ok=True
while ok:
    for i in range(0,101):
        for j in range(0,101):
            height=use[2]+abs(i-use[0])+abs(j-use[1])
            cnt=0
            for inn in lists:
                
                if inn[2]==0:
                    if height>abs(i-use[0])+abs(j-use[1]):
                        continue
                    else:
                        cnt+=1
                elif inn[2]>0:
                    if inn[2]+abs(i-inn[0])+abs(j-inn[1])!=height:
                        continue
                    else:
                        cnt+=1
            if cnt==n:
                ok=False
ans=[i,j,height]
print(*ans)

Fixed code:
n=int(input())
lists=[]
for i in range(n):
    tup=tuple(map(int,input().split()))
    lists.append(tup)

use=()
for some in lists:
    if some[2]==0:
        continue
    else:
        use=some
        break

for i in range(0,101):
    for j in range(0,101):
        height=use[2]+abs(i-use[0])+abs(j-use[1])   
        ok=True
        for inn in lists:
            if inn[2]==0:
                if height>abs(i-inn[0])+abs(j-inn[1]):
                    ok=False
            if inn[2]>0:
                if inn[2]+abs(i-inn[0])+abs(j-inn[1])!=height:
                    ok=False
        if ok:
            ans=[i,j,height]
            print(*ans)
            break
        else:
            continue
Buggy code:
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
for x in range(101):
  for y in range(101):
    for i in d:
      if i[2] > 0:
        H = i[2] + abs(x-i[0]) + abs(y-i[1])
        print(H)
        break
    if all(l[2] == max(H - abs(x-l[0]) - abs(y-l[1]), 0) for l in d):
      print('{} {} {}'.format(x, y, H))
      exit()

Fixed code:
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
for x in range(101):
  for y in range(101):
    for i in d:
      if i[2] > 0:
        H = i[2] + abs(x-i[0]) + abs(y-i[1])
        break
    if all(l[2] == max(H - abs(x-l[0]) - abs(y-l[1]), 0) for l in d):
      print('{} {} {}'.format(x, y, H))
      exit()
Buggy code:
#112
from itertools import product

N=int(input())
px,py,ph=[],[],[]

for _ in range(N):
    x,y,h=map(int,input().split())
    if h!=0:
        px.append(x)
        py.append(y)
        ph.append(h)
        
def Calc_H(Cxi,Cyj,pxi,pyj,hi):
    return hi+abs(Cxi-pxi)+abs(Cyj-pyj)

for Cxi,Cyj in product(range(101),range(101)):
    preH=alc_H(Cxi,Cyj,px[0],py[0],ph[0])
    for i in range(len(ph)):
        nowH=Calc_H(Cxi,Cyj,px[i],py[i],ph[i])
        if nowH!=preH:
            break
        preH=nowH
    else:
        print(Cxi,Cyj,nowH)

Fixed code:
#112
from itertools import product

N=int(input())
px,py,ph=[],[],[]

for _ in range(N):
    x,y,h=map(int,input().split())
    if h!=0:
        px.append(x)
        py.append(y)
        ph.append(h)
        
def Calc_H(Cxi,Cyj,pxi,pyj,hi):
    return hi+abs(Cxi-pxi)+abs(Cyj-pyj)

for Cxi,Cyj in product(range(101),range(101)):

    if len(ph)!=1:
        preH=Calc_H(Cxi,Cyj,px[0],py[0],ph[0])
        for i in range(len(ph)):
            nowH=Calc_H(Cxi,Cyj,px[i],py[i],ph[i])
            if nowH!=preH:
                break
            preH=nowH
        else:
            print(Cxi,Cyj,nowH)
            break
    else:
        print(px[0],py[0],ph[0])
        break
Buggy code:
import sys

def height(a, b, c, d, e):
    return abs(a-d)+abs(b-e)+c

n = int(input())
hint = []
q = 0
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append(c, a, b)
hint.sort(reverse=True)

for i in range(101):
    for j in range(101):
        frag = True
        H = height(hint[0][1], hint[0][2], hint[0][0] i, j)
        for h in hint[1:]:
            if height(h[1], h[2], h[0], i, j) != H:
                frag = False
                break
        if frag:
            print(i, j, H)
            sys.exit()
        


Fixed code:
import sys

def height(a, b, c, d, e):
    return abs(a-d)+abs(b-e)+c

n = int(input())
hint = []
q = 0
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([c, a, b])
hint.sort(reverse=True)

for i in range(101):
    for j in range(101):
        frag = True
        H = height(hint[0][1], hint[0][2], hint[0][0], i, j)
        for h in hint[1:]:
            if h[0] != max(-abs(h[1]-i)-abs(h[2]-j)+H,0):
                frag = False
                break
        if frag:
            print(i, j, H)
            sys.exit()
Buggy code:
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff=min(h)
h=[i-diff for i in h]
def pattern(cx,cy,H):
    for i in range(n):
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Fixed code:
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff = 0
if min(h)>=10:
    diff=min(h)-5
h=[i-diff for i in h]
# print(h)
def pattern(cx,cy,H):
    for i in range(n):
        # print(cx,x[i],cy,y[i],H,h[i],max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()
Buggy code:
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
xyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))
for cx in range(101):
    for cy in range(101):
        flag = 1
        H = None
        maxh = 10**10
        for x, y, h in xyh:
            if h == 0:
                maxh = min(maxh, abs(x - cx) + abs(y - cy))
            else:
                if H is None:
                    H = h + abs(x - cx) + abs(y - cy)
                    if H > maxh:
                        flag = 0
                        break
                else:
                    if H != h + abs(x - cx) + abs(y - cy):
                        flag = 0
                        break
        if flag and H >= maxh:
            print(cx, cy, H)
            sys.exit()
        

Fixed code:
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
xyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))
for cx in range(101):
    for cy in range(101):
        flag = 1
        H = None
        maxh = 10**10
        for x, y, h in xyh:
            if h == 0:
                maxh = min(maxh, abs(x - cx) + abs(y - cy))
            else:
                if H is None:
                    H = h + abs(x - cx) + abs(y - cy)
                    if H > maxh:
                        flag = 0
                        break
                else:
                    if H != h + abs(x - cx) + abs(y - cy):
                        flag = 0
                        break
        if flag and H <= maxh:
            print(cx, cy, H)
            sys.exit()
Buggy code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = N
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = min(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] > 0 and tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                    break
                if(i == N-1 and tmp > 0):
                    print(Cx, Cy, tmp)
                    quit()
                else:
                    print(Cx, Cy, abs(x[k]-Cx)+abs(y[k]-Cy)+1)
main()

Fixed code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = N
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = min(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] != max(tmp-abs(x[i]-Cx)-abs(y[i]-Cy), 0)):
                    break
                if(i == N-1 and tmp > 0):
                    print(Cx, Cy, tmp)
                    quit()               
main()
Buggy code:
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
    break
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break


Fixed code:
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break
Buggy code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    xyh.sort(key=lambda x: x[2], reverse=True)

    for cx in range(101):
        for cy in range(101):
            H = xyh[0][2] - abs(cx - xyh[0][0]) - abs(cy - xyh[0][1])
            b = True
            for x, y, h in xyh:
                if h != H - abs(cx - x) - abs(cy - y):
                    b = False
                    break
            if b:
                print(cx, cy, H)
                exit()


if __name__ == '__main__':
    slove()


Fixed code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    xyh.sort(key=lambda w: w[2], reverse=True)

    for cx in range(101):
        for cy in range(101):
            th = xyh[0][2] + abs(cx - xyh[0][0]) + abs(cy - xyh[0][1])
            b = True
            for x, y, h in xyh:
                if h != max(th - abs(cx - x) - abs(cy - y), 0):
                    b = False
                    break
            if b:
                print(cx, cy, th)
                exit()


if __name__ == '__main__':
    slove()
Buggy code:
n = int(input())
cx,cy = 0,0
list_xyh = []
for i in range(n):
    list_xyh.append(list(map(int, input().split())))
print(list_xyh)
for cx in range(0,101):
    for cy in range(0,101):
        H = abs(cx - list_xyh[0][0]) + abs(cy - list_xyh[0][1]) + list_xyh[0][2]
        for i in range(n):
            if list_xyh[i][2] != 0:
                if H - list_xyh[i][2] == abs(cx - list_xyh[i][0]) + abs(cy - list_xyh[i][1]):
                    continue
                else:
                    break
        else:
            print(cx,cy,H)
            break
    else:
        continue
    break


Fixed code:
n = int(input())
cx,cy = 0,0
list_xyh = []
for i in range(n):
    list_xyh.append(list(map(int, input().split())))
for cx in range(0,101):
    for cy in range(0,101):
        for i in range(n):
            if list_xyh[i][2] != 0:
                H = abs(cx - list_xyh[i][0]) + abs(cy - list_xyh[i][1]) + list_xyh[i][2]
                break
        for i in range(n):
            if max(H - abs(cx - list_xyh[i][0]) - abs(cy - list_xyh[i][1]),0) == list_xyh[i][2]:
                continue
            else:
                break
        else:
            print(cx,cy,H)
            break
    else:
        continue
    break
Buggy code:
N = int(input())
data = []
for _ in range(N):
    x, y, h = map(int,input().split())
    data.append([h, x, y])
data.sort(reverse=True)
end = False
for x in range(101):
    if end:
        break
    for y in range(101):
        xi, yi, hi = data[0]
        H = hi + abs(x - xi) + abs(y - yi)
        for i in range(1, N):
            xi, yi, hi = data[i]
            if max(H - abs(x - xi) - abs(y - yi), 0) != hi:
                break
            if i == N - 1:
                print(x, y, H)
                end = True
                break

Fixed code:
N = int(input())
data = []
for _ in range(N):
    x, y, h = map(int,input().split())
    data.append([h, x, y])
data.sort(reverse=True)
end = False
for x in range(101):
    if end:
        break
    for y in range(101):
        if end:
            break
        hi, xi, yi = data[0]
        H = hi + abs(x - xi) + abs(y - yi)
        for i in range(1, N):
            hi, xi, yi = data[i]
            if max(H - abs(x - xi) - abs(y - yi), 0) != hi:
                break
            if i == N - 1:
                print(x, y, H)
                end = True
                break
Buggy code:
N=int(input())
X=[0]*N
Y=[0]*N
H=[0]*N
import sys
for i in range(N):
    X[i],Y[i],H[i]=map(int,input().split())
for x in range(100+1):
    for y in range(100+1):
        for i in range(0,N):
            
            if H[i]>0:
                assume_h = H[i] + abs(x-X[i]) + abs(y-Y[i])
                target = i
                break
                
        for i in range(N):
            #print(x,y,i)
            #print(H[i] + abs(x-X[i]) + abs(y-Y[i]))
            if H[i]  != min(assume_h - abs(x-X[i]) - abs(y-Y[i]), 0):
                break
        else:
            print(x,y,assume_h)
            sys.exit()

Fixed code:
N=int(input())
X=[0]*N
Y=[0]*N
H=[0]*N
import sys
for i in range(N):
    X[i],Y[i],H[i]=map(int,input().split())
for x in range(100+1):
    for y in range(100+1):
        for i in range(0,N):
            
            if H[i]>0:
                assume_h = H[i] + abs(x-X[i]) + abs(y-Y[i])
                target = i
                break
                
        for i in range(N):
            #print(x,y,i)
            #print(H[i] + abs(x-X[i]) + abs(y-Y[i]))
            if H[i]  != max(assume_h - abs(x-X[i]) - abs(y-Y[i]), 0):
                break
        else:
            print(x,y,assume_h)
            sys.exit()
Buggy code:
i = lambda: list(map(int, input().split()))
N, = i()
M = [i() for j in range(N)]
H = 0
for k in range(101):
    if M[i][2] != 0:
        H = abs(M[0][0] - Cx) + abs(M[0][1] - Cy) + M[0][2]
        break
for Cx in range(101):
    for Cy in range(101):
        if all([False for d in M if H != abs(d[0] - Cx) + abs(d[1] - Cy) + d[2]]):
            print(Cx, Cy, H)

Fixed code:
i = lambda: list(map(int, input().split()))
N, = i()
M = [i() for j in range(N)]
k = -1
for k in range(len(M)):
    if M[k][2] > 0:
        break
for Cx in range(101):
    for Cy in range(101):
        H = abs(M[k][0] - Cx) + abs(M[k][1] - Cy) + M[k][2]
        if all([False for d in M if d[2] != max(H - abs(d[0] - Cx) - abs(d[1] - Cy), 0)]):
            print(Cx, Cy, H)
            break
Buggy code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    temp = [int(_) for _ in input().split(' ')]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])

for cx in range(101):
    for cy in range(101):
        ch = -1
        correctness = True
        for i in range(n):
            if ch > 0:
                if h[i] != max(ch - abs(cx - x[i]) - abs(cy - y[i]), 0):
                    correctness = False
            if h[i] > 0:
                ch = h[i] + abs(cx - x[i]) + abs(cy - y[i])
        if correctness:
            print(ch)


Fixed code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    temp = [int(_) for _ in input().split(' ')]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])

for cx in range(101):
    for cy in range(101):
        correctness = True
        for i in range(n):
            if h[i] > 0:
                ch = h[i] + abs(cx - x[i]) + abs(cy - y[i])
        for i in range(n):
            if h[i] != max(ch - abs(cx - x[i]) - abs(cy - y[i]), 0):
                correctness = False
        if correctness:
            print('{0} {1} {2}'.format(cx, cy, ch))
Buggy code:
def main():
    N = int(input())
    points = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        points.append((x, y, h))
        if h >= 1:
            hint = (x, y, h)

    for px in range(1, 101):
        for py in range(1, 101):
            H = hint[2] + abs(px-hint[0]) + abs(py-hint[1])
            clearflag = True
            for point in points:
                x, y, h = point
                val = max([H - abs(px-x) - abs(py-y), 0])
                if val != h:
                    clearflag = False

            if clearflag:
                print(px, py, H)
                return
if __name__ == '__main__':
    main()

Fixed code:
def main():
    N = int(input())
    points = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        points.append((x, y, h))
        if h >= 1:
            hint = (x, y, h)

    for px in range(101):
        for py in range(101):
            H = hint[2] + abs(px-hint[0]) + abs(py-hint[1])
            clearflag = True
            for point in points:
                x, y, h = point
                val = max([H - abs(px-x) - abs(py-y), 0])
                if val != h:
                    clearflag = False

            if clearflag:
                print(px, py, H)
                return
if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
lst = []
for _ in range(n):
  x, y, h = map(int, input().split())
  if h:
  lst.append(x, y, h)
if len(lst) == 1:
  print(*lst)
  quit()
for cx in range(101):
  for cy in range(101):
    a = True
    preh = abs(lst[0][0] - cx) + abs(lst[0][1] - cy) +lst[0][2]
    for x, y, h in lst[1:]:
      H = abs(x - cx) + abs(y - cy) + h
      if H != preh:
        a = False
        break
    if a:
      print(cx, cy, H)
      quit()
    

Fixed code:
n = int(input())
lst = []
for _ in range(n):
  x, y, h = map(int, input().split())
  if h != 0:
    lst.append([x, y, h])
if len(lst) == 1:
  print(*lst[0])
  quit()
for cx in range(101):
  for cy in range(101):
    a = True
    preh = abs(lst[0][0] - cx) + abs(lst[0][1] - cy) +lst[0][2]
    for x, y, h in lst[1:]:
      H = abs(x - cx) + abs(y - cy) + h
      if H != preh:
        a = False
        break
    if a:
      print(cx, cy, H)
      quit()