Problem:
 Score: 300 points    Problem Statement  In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had center coordinates  (C_X, C_Y) and height  H . The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0) .  Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:   C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1 .  Additionally, he obtained N pieces of information. The i -th of them is: "the altitude of point (x_i, y_i) is h_i ."   This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.      Constraints   N is an integer between 1 and 100 (inclusive).  x_i and y_i are integers between 0 and 100 (inclusive).  h_i is an integer between 0 and 10^9 (inclusive).  The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.  The center coordinates and the height of the pyramid can be uniquely identified.         Input  Input is given from Standard Input in the following format:  N  x_1  y_1  h_1  x_2  y_2  h_2  x_3  y_3  h_3  :  x_N  y_N  h_N       Output  Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.        Sample Input 1 4
2 3 5
2 1 5
1 2 5
3 2 5      Sample Output 1 2 2 6  In this case, the center coordinates and the height can be identified as (2, 2) and 6 .       Sample Input 2 2
0 0 100
1 1 98      Sample Output 2 0 0 100  In this case, the center coordinates and the height can be identified as (0, 0) and 100 . Note that C_X and C_Y are known to be integers between 0 and 100 .       Sample Input 3 3
99 1 191
100 1 192
99 0 192      Sample Output 3 100 0 193  In this case, the center coordinates and the height can be identified as (100, 0) and 193 .

Solution (Python):
lines = [list(map(int, input().split())) for _ in range(int(input()))]

for cx in range(101):
    for cy in range(101):
        pt = 0
        while lines[pt][2] == 0:
            pt += 1
        x0, y0, h0 = lines[pt]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        flag = True
        for x0, y0, h0 in lines:
            tmp = h0 + abs(cx - x0) + abs(cy - y0)
            if h0 > 0 and tmp != h:
                flag = False
                break
            if h0 == 0:
                if h - abs(cx - x0) - abs(cy - y0) > 0:
                    flag = False
                    break
        if flag:
            print(cx, cy, h)
            exit()

Solution (Python):



n=int(input())

x=[]
y=[]
h=[]

A=[]
for _ in range(n):




    a=[int(i) for i in input().split()]
    A.append(a)

A.sort(key=lambda x:x[2],reverse=True)

ax=-1
ay=-1
ah=-1


zz=101
for i in range(zz):
    for j in range(zz):
        ok=1
        h=abs(A[0][0]-i)+abs(A[0][1]-j)+A[0][2]
        for k in range(n):
            c=abs(A[k][0]-i)+abs(A[k][1]-j)


            if max(h-c,0) != A[k][2]:
                ok=0
                break
        if ok==1:
            ax=i
            ay=j
            ah=h
        if ok==1:
            break
        
    if ok==1:
        break
print(ax,ay,ah)

Solution (Python):
import sys
n = int(input())
ps = [list(map(int, input().split())) for _ in range(n)]

if n == 1:
	
	print(ps[0][0], ps[0][1], ps[0][2])
else:
	for X in range(101):
		for Y in range(101):
			valid = True
			const = -1
			for p in ps:
				x, y, h = p[0], p[1], p[2]
				if h != 0:
					if const < 0:
						const = abs(X - x) + abs(Y - y) + h
					else:
						if abs(X - x) + abs(Y - y) + h != const:
							valid = False
							break
				else:
					if const >= 0:
						if const - abs(X - x) - abs(Y - y) > 0:
							valid = False
							break
			for p in ps:
				x, y, h = p[0], p[1], p[2]
				if h == 0:
					if const >= 0:
						if const - abs(X - x) - abs(Y - y) > 0:
							valid = False
							break

			if valid == True:
				print(X, Y, const)
				sys.exit()

Solution (Python):




def return_H(x, y, h, cx, cy):
    retval_H = h + abs(x - cx) + abs(y - cy)
    return retval_H

def main(n, l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            retl = []
            maxH = []
            for x, y, h in l:
                if h != 0:
                    retl.append(return_H(x, y, h, cx, cy))
                elif h == 0:
                    maxH.append(return_H(x, y, h, cx, cy))
            if len(maxH) > 0:
                if len(set(retl)) == 1 and retl[0] <= min(maxH):
                    print('{} {} {}'.format(cx, cy, retl[0]))
                    return
            else:
                if len(set(retl)) == 1:
                    print('{} {} {}'.format(cx, cy, retl[0]))
                    return
    
if __name__ == '__main__':
    try:
        n  = int(input().strip())
        l = []
        for i in range(n):
            l.append(list(map(int, input().strip().split(' '))))
        main(n, l)
    except EOFError:
        pass

Solution (Python):
N = int(input())

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

for m in range(N):
    if l[m][2] != 0:
        break

for i in range(0, 101):
    for j in range(0, 101):
        center = [i, j]
        h = l[m][2] + abs(i - l[m][0]) + abs(j - l[m][1])
        

        flag = True

        number = list(range(N))
        number.pop(m)
        for k in number:
            
            
            if max(h - abs(i - l[k][0]) - abs(j - l[k][1]), 0) != l[k][2]:
                flag = False

        if flag:
            print(i, j, h)
            exit()

Solution (Python):
N = int(input())
XYHs = [list(map(int, input().split())) for _ in range(N)]

for Cx in range(100 + 1):
    for Cy in range(100 + 1):
        flg = True
        H = -1
        max_H = float('inf')
        for x, y, h in XYHs:
            CF = abs(x - Cx) + abs(y - Cy)
            if h == 0:
                max_H = min(max_H, CF)
            else:
                t = h + CF
                if H == -1:
                    H = t
                elif H != t:
                    flg = False
                    break
        if flg and H <= max_H:
            print(Cx, Cy, H)
            exit()

Solution (Python):
n = int(input())

xs = []
ys = []
hs = []

for i in range(n):
    x, y, h = list(map(int, input().split()))
    xs.append(x)
    ys.append(y)
    hs.append(h)

count = 0
for h in hs:
    if h != 0:
        count += 1

if count == 1:
    for x, y, h in zip(xs, ys, hs):
        if h != 0:
            print(x, y, h)
            exit(0)

if count == 0:
    pairs = list([(x, y) for x, y in zip(xs, ys)])
    for x1 in range(101):
        for y1 in range(101):
            if (x1, y1) not in pairs:
                print(x1, y1, 1)
                exit(0)

x_cands = []
y_cands = []
for x1 in range(101):
    for y1 in range(101):
        h0 = None
        for x, y, h in zip(xs, ys, hs):
            if h == 0:
                continue
            if h0 is None:
                h0 = abs(x1 - x) + abs(y1 - y) + h
            elif abs(x1 - x) + abs(y1 - y) + h != h0:
                break
        else:
            x_cands.append(x1)
            y_cands.append(y1)

h_cands = []
for xc, yc in zip(x_cands, y_cands):
    for x, y, h in zip(xs, ys, hs):
        if h != 0:
            h_cands.append(h + abs(xc - x) + abs(yc - y))
            break

for xc, yc, hc in zip(x_cands, y_cands, h_cands):
    for x, y, h in zip(xs, ys, hs):
        if h != max(hc - abs(xc - x) - abs(yc - y), 0):
            break
    else:
        print(x_cands[0], y_cands[0], h_cands[0])
        exit(0)

Solution (Python):
N = int(input())

infs = []

for i in range(N):
    infs.append(list(map(int, input().split())))

for i in range(101):
    for j in range(101):
        min_dis = 300
        pre_h = 0
        ans = True
        for k in range(N):
            
            x, y, h = infs[k]
            dx = abs(x - i)
            dy = abs(y - j)
            if min_dis > dx + dy:
                min_dis = dx + dy
                pre_h = h + dx + dy
        for k in range(N):
            
            x, y, h = infs[k]
            dx = abs(x - i)
            dy = abs(y - j)
            if max(pre_h - dx - dy, 0) != h:
                ans = False
                break

        if ans:
            print(i, j, pre_h)
            break

Solution (Python):
from itertools import product

n = int(input())

info = []

for i in range(n):
    info.append(list(map(int,input().split())))

info.sort(reverse=True,key=lambda x:x[2])

for x,y in product(range(101),repeat=2):
    h=-1
    flag=True
    for i in info:
        if h==-1:
            h=abs(i[0]-x)+abs(i[1]-y)+i[2]
        else:
            if i[2] != max(0,h-abs(i[0]-x)-abs(i[1]-y)):
                flag=False
    if flag:
        X=x
        Y=y
        H=h
        break

print(X,Y,H)

Solution (Python):
n = int(raw_input())
pts = [map(int, raw_input().split()) for i in xrange(n)]

for i in xrange(105):
    for j in xrange(105):
        H = 0
        ok = True
        for k in pts:
            if max(H - abs(k[0] - i) - abs(k[1] - j), 0) == k[2]:
                continue
            elif H < 1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                ok = False
        if ok and H > 0:

            for k in pts:
                if max(H - abs(k[0] - i) - abs(k[1] - j), 0) == k[2]:
                    continue
                else:
                    ok = False

            if ok:
                print i, j, H
                exit(0)

Solution (Python):
def is_correct(n, xs, ys, hs, cx, cy):
    h = abs(xs[0] - cx) + abs(ys[0] - cy) + hs[0]
    for i in range(1, n):
        if hs[i] != max(h - abs(xs[i] - cx) - abs(ys[i] - cy), 0):
            return None
    return h


def solve(n, xs, ys, hs):
    for cx in range(101):
        for cy in range(101):
            h = is_correct(n ,xs, ys, hs, cx, cy)
            if h is not None:
                print('{0} {1} {2}'.format(cx, cy, h))
                return


n = int(input())
xs = []
ys = []
hs = []

for i in range(n):
    line = [int(v) for v in input().split()]
    xs.append(line[0])
    ys.append(line[1])
    hs.append(line[2])

maxi = 0
for i in range(n):
    if hs[i] > hs[maxi]:
        maxi = i
hs[0], hs[maxi] = hs[maxi], hs[0]
xs[0], xs[maxi] = xs[maxi], xs[0]
ys[0], ys[maxi] = ys[maxi], ys[0]

solve(n, xs, ys, hs)

Solution (Python):
n = int(input())
p = [[int(i) for i in input().split()] for i in range(n)]
p.sort(key=lambda x: x[2])
a,b,c = p[-1]
f = 0
for cx in range(101):
	for cy in range(101):
		h = c+abs(a-cx)+abs(b-cy)
		if all(k==max(h-abs(i-cx)-abs(j-cy),0) for i,j,k in p): f = 1
		if f: break
	if f: break
print(cx,cy,h)

Solution (Python):





"""
RC112 C
"""

n = int(input())
xyhlist = [tuple(map(int,input().split())) for i in range(n)]
xyhlist0 = []
xyhlist1 = []
for x,y,h in xyhlist:
    if h == 0:
        xyhlist0.append((x,y))
    else:
        xyhlist1.append((x,y,h))

candidate = []
from itertools import product
for x,y in product(range(0,101),range(0,101)):
    test = set(map(lambda t:t[2]+abs(t[0]-x)+abs(t[1]-y),xyhlist1))
    if len(test) == 1:
        candidate.append((x,y,test.pop()))
    elif len(test) == 0:
        candidate.append((x,y,1))

for x,y,h in candidate:
    flag = True
    for x0,y0 in xyhlist0:
        if h-abs(x-x0)- abs(y-y0)>0:
            flag = False
    if flag:
        print(x,y,h)
        exit()

Solution (Python):
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)]
arr.sort(key=lambda l:-l[2])

for cx in range(101):
  for cy in range(101):
    ch = None
    for x, y, h in arr:
      t = h + abs(cx-x) + abs(cy-y)
      if h > 0:
        if ch is not None and t != ch:
          break
        ch = t
      else:
        if t < ch:
          break
    else:
      print(cx, cy, ch)
      exit()

Solution (Python):
N = int(input())
d = [[int(j) for j in input().split()] for i in range(N)]
ind = float('inf')
for i, (x,y,h) in enumerate(d):
    if h != 0:
        ind = i
        break

for cx in range(0, 101):
    for cy in range(0, 101):
        x,y,h = d[ind]
        H = h + abs(x - cx) + abs(y - cy)
        l = [h == max(H - abs(x - cx) - abs(y - cy), 0) for j,(x,y,h) in enumerate(d) if j != ind]
        if all(l):
            print(cx,cy,H)
            exit()

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

for i in range(101):
    for j in range(101):
        H = -1
        tmp = []
        for l in xyh:
            if l[2]==0:
                tmp.append([l[0],l[1]])
                continue
            h = l[2] + abs(i-l[0]) + abs(j-l[1])
            if H!=-1:
                if H!=h:
                    break
            else:
                H = h
        else:
            if H>=1:
                flag = True
                for mmm in tmp:
                    hhh = H - abs(mmm[0]-i) - abs(mmm[1]-j)
                    if hhh>0:
                        flag = False
                        break
                if flag:
                    print(i,j,H)
                    exit()

Solution (Python):
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
hs=[xyh[i][-1] for i in range(n)]
mh=max(hs)
if mh==0:
    mh=1
for cx in range(101):
    for cy in range(101):
        for h in range(mh,mh+101):
            j=True
            for i in range(n):
                if max(h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:
                    j=False
            if j:
                print(cx,cy,h)
                break

Solution (Python):
def main():
    n = int(input())
    cor = [tuple(map(int, input().split())) for i in range(n)]

    cor.sort(reverse=True, key=lambda tup: tup[2])

    for i in range(101):
        for j in range(101):
            if cor[0][2]:
                h = cor[0][2] + abs(i-cor[0][0]) + abs(j-cor[0][1])
            else:
                h = 1

            for x, y, hi in cor:
                if max(h-abs(i-x)-abs(j-y), 0) != hi:
                    break

            else:
                print(i, j, h)
                exit()


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
data = [list(map(int, input().split())) for i in range(n)]

flag = 0
for i in range(n):
    if data[i][2] > 0:
        flag = 1
        break

if flag == 0:
    print(data[0][0], data[0][1], 0)
else:
    for cx in range(0, 101):
        for cy in range(0, 101):
            for i in range(n):
                if data[i][2] > 0:
                    H = abs(data[i][0]-cx) + abs(data[i][1]-cy) + data[i][2]
            check = 0
            for i in range(n):
                if data[i][2] != max(0, H - abs(data[i][0]-cx) - abs(data[i][1]-cy)):
                    check = 1
            if check == 0:
                print(cx, cy, H)
                exit()

Solution (Python):
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    s=input().split()
    x.append(int(s[0]))
    y.append(int(s[1]))
    h.append(int(s[2]))
for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if h[i]>0:
                hh=h[i]+abs(cx-x[i])+abs(cy-y[i])
                break
        flag=True
        for i in range(n):
            if h[i]!=max(0,hh-abs(cx-x[i])-abs(cy-y[i])):
                flag=False
                break
        if flag:
            print(cx,cy,hh)

Solution (Python):
n = int(input())

x = []
y = []
h = []
for i in range(n):
    xi, yi, hi = map(int, input().split())
    x.append(xi)
    y.append(yi)
    h.append(hi)

isOk = False
i = 0
j = 0
constant = -1

for i in range(101):
    for j in range(101):

        constant = -1
        for k in range(n):
            if h[k] != 0:
                temp = h[k] + abs(i - x[k]) + abs(j - y[k])

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:

            for p in range(n):
                if h[p] == 0 and constant - abs(i - x[p]) - abs(j - y[p]) > 0:
                    break
            else:
                isOk = True
                break
        
    if isOk:
        break

print(i, j, constant)

Solution (Python):
from itertools import product

N = int(input())

xs = []
ys = []
hs = []

sampleX = -1
sampleY = -1
sampleH = 0

for n in range(N):
  x,y,h = map(int, input().split())
  xs.append(x)
  ys.append(y)
  hs.append(h)

  if h is not 0:
    sampleX = x
    sampleY = y
    sampleH = h

for cx, cy in product(range(101), range(101)):
  H = sampleH + abs(sampleX - cx) + abs(sampleY - cy)
  for x,y,h in zip(xs,ys,hs):
    if not max(H - abs(x-cx) - abs(y-cy), 0) == h:
      break
  else:
    print(cx, cy, H)
    break
else:
  raise "hoge"

Solution (Python):
N=int(input().strip())
xyh=[]
for i in range(N):
    xyh.append(list(map(int, input().strip().split())))
xyh=sorted(xyh, key=lambda x:-x[2])

for cx in range(101):
    for cy in range(101):
        flag=True
        Hcand=-1
        for x,y,h in xyh:
            if h==0 and H>0:
                if H-abs(x-cx)-abs(y-cy)>0:
                    flag=False
                    break
            else:
                H= h+abs(x-cx)+abs(y-cy)
                if Hcand==-1:
                    Hcand=H
                else:
                    if Hcand!=H:
                        flag=False
                        break
        if flag:
            break
    if flag:
        break
print("{} {} {}".format(cx,cy,H))

Solution (Python):
import sys
fin = sys.stdin.readline
from collections import deque
N = int(fin())
info_list = [[int(elem) for elem in fin().split(' ')] for _ in range(N)]
assert len(info_list[0]) == 3

for cx in range(101):
    for cy in range(101):
        H = None
        queue = deque(info_list)
        while queue:
            x, y, h = queue.popleft()
            if H is None and h != 0:
                H = abs(x - cx) + abs(y - cy) + h
                queue.append([x, y, h])
                continue
            elif H is None and h == 0:
                queue.append([x, y, h])
                continue
            elif H is not None:
                if h != max(H - abs(x - cx) - abs(y - cy), 0):
                    queue.append([x, y, h])
                    break
        if len(queue) != 0:
            continue
        else:
            print("{} {} {}".format(cx, cy, H))
            exit(0)

Solution (Python):
N = int(input())
x = []
y = []
h = []

for i in range(N):
    xi, yi, hi = map(int, input().split(" "))
    x.append(xi)
    y.append(yi)
    h.append(hi)

for Cx in range(101):
    for Cy in range(101):
        for i in range(N):
            if h[i] != 0:
                H = h[i] + abs(Cx - x[i]) + abs(Cy - y[i])
                break
        
        for i in range(N):
            if h[i] != max(H - (abs(Cx - x[i]) + abs(Cy - y[i])), 0):
                break
        else:
            print (Cx, Cy, H)
            break

Solution (Python):
iipt=lambda:int(input())
miipt=lambda:map(int,input().split(" "))
N=iipt()
l=[];
x0,y0,h0=0,0,0
for i in range(N):
    l.append(list(miipt()))
    if l[i][2]:
        x0,y0,h0=l[i]
for cx in range(0,101):
    for cy in range(0,101):
        H=h0+abs(x0-cx)+abs(y0-cy)
        f=False
        for x,y,h in l:
            if h!=max(H-abs(x-cx)-abs(y-cy),0):
                f=True
                break
        if not f:
            print(cx,cy,H)

Solution (Python):




N = int(input())
x_list = [0]*N
y_list = [0]*N
h_list = [0]*N

for i in range(N):
    x, y, h = map(int, input().split())
    x_list[i] = x
    y_list[i] = y
    h_list[i] = h
    

done = False
for CX in range(101):
    for CY in range(101):
        for i in range(N):
            if h_list[i] > 0:
                H = h_list[i] + abs(CX - x_list[i]) + abs(CY - y_list[i])
                break
        done = True
        for i in range(N):
            if h_list[i] != max(0, H - abs(CX - x_list[i]) - abs(CY - y_list[i])):
                done = False
                break
        if done:
            break
    if done:
        break
print(" ".join([str(CX), str(CY), str(H)]))

Solution (Python):
N= int(input())
X=[]
Y=[]
H=[]
f=0
for i in range(N):
    x, y, h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
for CX in range(0,101):
    for CY in range(0, 101):
        for i in range(N):
            if H[i]>0:
                CH=abs(X[i]-CX)+abs(Y[i]-CY)+H[i]
                break
        for i in range(N):
            if max(0,CH-abs(X[i]-CX)-abs(Y[i]-CY))!=H[i]:
                break
            if i==N-1:
                f=1
                break
        if f==1:
            break
    if f==1:
        break
print(str(CX)+" "+str(CY)+" "+str(CH))

Solution (Python):
import sys

N=int(input())
XYH=[list(map(int,input().split())) for i in range(N)]

for i in range(101):
    for j in range(101):
        LIST=[]
        for xyh in XYH:
            if xyh[2]==0:
                continue
            else:
                LIST.append(abs(i-xyh[0])+abs(j-xyh[1])+xyh[2])

        if min(LIST)==max(LIST):
            i0,j0,h0=i,j,LIST[0]
        else:
            continue


        CHECK=1


        for xyh in XYH:
            if xyh[2]==0:
                if abs(i0-xyh[0])+abs(j0-xyh[1])<h0:
                    CHECK=0

        if CHECK==1:
            print(i0,j0,h0)

Solution (Python):
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[j]
for cx in range(101):
    for cy in range(101):
        H = A[2] + abs( A[0] - cx) + abs( A[1] - cy)
        Flag = True
        for i in range(N):
            if max( H - abs(X[i][0]-cx) - abs(X[i][1] - cy), 0) != X[i][2]:
                Flag = False
                break
        if Flag:
            print('{} {} {}'.format(cx, cy, H))
            break
    if Flag:
        break

Solution (Python):
import sys
N = int(raw_input())
arr = []
must = -1
for i in range(N):
    arr.append(list(map(int,raw_input().split())))
    if arr[i][2]:
        must = i
for i in range(101):
    for j in range(101):
        if must!=-1:
            h = arr[must][2]+abs(arr[must][0]-i)+abs(arr[must][1]-j)
            v = 1
            for k in range(N):
                if arr[k][2]:
                    if arr[k][2]+abs(arr[k][0]-i)+abs(arr[k][1]-j)!=h:
                        v = 0
                else:
                    if abs(arr[k][0]-i)+abs(arr[k][1]-j)<h:
                        v = 0
            if v:
                print i,j,h
                sys.exit()
        else:
            v = 1
            for k in range(N):
                if arr[k][0]==i and arr[k][1]==j:
                    v = 0
            if v:
                print i,j,1
                sys.exit()

Solution (Python):
def inpl(): return list(map(int, input().split()))

import numpy as np

N = int(input())
X = np.zeros(N, dtype=np.int64)
Y = np.zeros(N, dtype=np.int64)
H = np.zeros(N, dtype=np.int64)

Q = sorted([inpl() for _ in range(N)], key=lambda x: x[2], reverse=True)

for i, q in enumerate(Q):
    X[i], Y[i], H[i] = q

assert H[0] > 0

for cx in range(101):
    for cy in range(101):
        cH = H[0] + np.abs(X[0] - cx) + np.abs(Y[0] - cy)
        if np.all(H == np.maximum(cH - np.abs(X - cx) - np.abs(Y - cy), 0)):
            print(cx, cy, cH)

Solution (Python):
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,zz = map(int,input().split())	
    x.append(xx)
    y.append(yy)
    h.append(zz)
kk = h.index(max(h))
k= 0
for i in range(101):
    for j in range(101):
        ass = h[kk]+abs(x[kk]-i)+abs(y[kk]-j)
        for r in range(n):
            if h[r] == 0:
                if ass -abs(x[r]-i)-abs(y[r]-j) > 0:
                    ass = -1
            else:
                if ass != abs(x[r]-i)+abs(y[r]-j)+h[r]:
                    ass = -1
        
        if ass != -1:
            print(str(i)+' '+str(j)+ ' '+ str(ass))
            break

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N = input()
ls = []

for i in range(N):
    x, y, h = map(int, raw_input().split())
    ls.append((x, y, h))
    if h > 0:
        stand = x, y, h

for cx in range(101):
    for cy in range(101):
        x, y, h = stand
        H = h + abs(x - cx) + abs(y - cy)
        flag = True
        for x, y, h in ls:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                flag = False
                break
        if flag:
            print cx, cy, H
            exit()

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
xyh = []

bes = -1
for i in range(n):
    xyh.append(na())
    if xyh[-1][2] > 0:
        bes = len(xyh)-1

bx = -1
by = -1
bh = -1
for x in range(101):
    for y in range(101):
        if bh >= 0: continue
        h = abs(xyh[bes][0] - x) + abs(xyh[bes][1] - y) + xyh[bes][2]
        ok = True
        for u in xyh:
            if max(h-abs(u[0]-x)-abs(u[1]-y), 0) != u[2]:
                ok = False
                break
        if ok:
            bx, by, bh = x, y, h

print(bx, by, bh)