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.  



Sample input:
4
2 3 5
2 1 5
1 2 5
3 2 5


Sample output:
2 2 6

Submission status: Runtime Error

Solution code:
N = int(input())
data = [list(map(int,input().split())) for _ in range(N)]
sorted_data = sorted(data,key=lambda x: x[2])

def get_H(x,y,h,Cx,Cy):
    return max(0,h+abs(x-Cx)+abs(y-Cy))
def estimate_H(data,Cx,Cy):
    H = get_H(*data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp = get_H(*cur_data,Cx,Cy)
        if H != tmp:
            break
    else:
        return H
    return None

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(sorted_data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            break

Submission status: Runtime Error

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

sorted_data = sorted(data,key=lambda x: x[2])

def estimate_H(data,Cx,Cy):
    H = get_H(*data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp = get_H(*cur_data,Cx,Cy)
        if H != tmp:
            break
    else:
        return H
    return None
def get_H(x,y,h,Cx,Cy):
    return max(0,h+abs(x-Cx)+abs(y-Cy))

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(sorted_data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            break

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
xyh = []
for _ in range (N):
    xyh.append([int(x) for x in input().split()])

for Cx in range(101):
    for Cy in range (101):
        ls =[]
        for i in range (N):
            x = xyh[i][0]
            y = xyh[i][1]
            h = max(H-abs(x-Cx)-abs(y-Cy),0)
            ls.append([x,y,h])
    if set(ls) == set(xyh):
        ans = [Cx,Cy,h]
    ls = []

print(ans.split())

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
xyh = []
for _ in range (N):
    xyh.append([int(x) for x in input().split()])

for Cx in range(101):
    for Cy in range (101):
        for i in range (N):
            ls = []
            x = xyh[i][0]
            y = xyh[i][1]
            h = max(H-abs(x-Cx)-abs(y-Cy),0)
            ls.append([x,y,h])
        
        if set(ls) == set(xyh):
            ans = [Cx,Cy,h]

print(ans.split())

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
xyh = []
for _ in range (N):
    xyh.append([int(x) for x in input().split()])

for Cx in range(101):
    for Cy in range (101):
        for i in range (N):
            ls = []
            x = xyh[i][0]
            y = xyh[i][1]
            h = max(H-abs(x-Cx)-abs(y-Cy),0)
            ls.append([x,y,h])
        
        if set(ls) == set(xyh)
        ans = [Cx,Cy,h]

print(ans.split())

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())

mappings = []

for i in range(n):
    mapping = [int(i) for i in input().split()]
    mappings.append(mapping)

for cx in range(101):
    for cy in range(101):
        H = -1
        for i in range(n):
            x,y,h = mappings[i]
            if h == 0:
                pass
            else:
                if H == -1:
                    H = h+abs(x-cx)+abs(y-cy)
                elif H!=h+abs(x-cx)+abs(y-cy):
                    break

                if i == len(mappings)-1:
                    ans = (cx,cy,H)

cx,cy,H = ans
print(cx,cy,H)

Submission status: Runtime Error

Solution code:
N = int(input().strip())

points = []

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

for cx in range(0,101):
    for cy in range(0,101):
        H = (points[0][2] + abs(points[0][0] - cx) + abs(points[0][1] - cy))
        if all([points[i][2] == max(H - (abs(points[i][0] - cx) + abs(points[i][1] - cy)),0) for i in range(1,N)]):
            res = [cx,cy,H]
            break


print(res[0],res[1],res[2])

Submission status: Runtime Error

Solution code:
N = int(input().strip())

points = []

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

for cx in range(0,101):
    for cy in range(0,101):
        H = (points[0][2] + abs(points[0][0] - cx) + abs(points[0][1] - cy))
        if all([points[i][2] == H - (abs(points[i][0] - cx) + abs(points[i][1] - cy)) for i in range(1,N)]):
            res = [cx,cy,H]
            break


print(res[0],res[1],res[2])

Submission status: Runtime Error

Solution code:
    n = int(input())
    sols = []
    for i in range(n):
        sols.append([int(i) for i in input().split()])
    if len(sols) == 1:
        print(*sols[0])
 
    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                break

Submission status: Runtime Error

Solution code:
    n = int(input())
    sols = []
    for i in range(n):
        sols.append([int(i) for i in input().split()])
    if len(sols) == 1:
        print(*sols[0])
        return
 
    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                break

Submission status: Runtime Error

Solution code:
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
if n = 1:
    print(a_list[0])
else:
    x_range = range(101)
    y_range = range(101)
    for i in x_range:
        for j in y_range:
            h_list = [abs(a[0]-i)+abs(a[1]-j)+a[2] for a in a_list]
            if (len(set(h_list)) == 1) & (h_list[0] > 0):
                print(i, j, h_list[0])
                break

Submission status: Runtime Error

Solution code:
N=int(input())
li = [list(map(int,input().split())) for i in range(N)]

def solve(li):
    for i in range(101):
        for j in range(101):
            flag=1
            Cx,Cy=i,j
            H_prev=0
            for k in li:
                if k[2]!=0:
                    H_prev=k[2]+abs(k[0]-Cx)+abs(k[1]-Cy)
                    break
            for k in li:
                H=max(k[2]+abs(k[0]-Cx)+abs(k[1]-Cy),0)
                if H_prev != H:
                    flag=0
                    break
                H_prev=H
            if flag==1 and H>=1:
                A=[i,j,H]
                return A
A=solve(li)
print(' '.join(map(str,A)))

Submission status: Runtime Error

Solution code:
N=int(input())
li = [list(map(int,input().split())) for i in range(N)]

def solve(li):
    for i in range(101):
        for j in range(101):
            flag=1
            Cx,Cy=i,j
            H_prev=li[0][2]+abs(li[0][0]-Cx)+abs(li[0][1]-Cy)
            for k in li:
                H=k[2]+abs(k[0]-Cx)+abs(k[1]-Cy)
                if H_prev != H:
                    flag=0
                    break
                H_prev=H
            if flag==1 and H>=1:
                A=[i,j,H]
                return A
A=solve(li)
print(' '.join(map(str,A)))

Submission status: Runtime Error

Solution code:
n = int(input())
XYH = [list(map(int,input().split())) for _ in range(n)]
flag = False
for i in range(101):
    for j in range(101):
        tempH = abs(XYH[0][0] - i) + abs(XYH[0][1] - j) + XYH[0][2] 
        for x,y,h in XYH[1:]:
            if abs(x - i) + abs(y - j) + h != tempH:
                flag = False
                break
            else:
                flag = True
        if flag:
            ans = [i,j,tempH]
            break
    if flag:
        break

print(*ans,sep = " ")

Submission status: Runtime Error

Solution code:
n=int(input())
l=[tuple(map(int,input().split()))for i in range(n)]
l=[i for i in l if i[2]!=0]
s=l[0]
l2=[[x,y,s[2]+abs(x-s[0])+abs(y-s[1])]for y in range(101)for x in range(101)]
for s in l2.copy():
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
print(*l2[0])

Submission status: Runtime Error

Solution code:
n=int(input())
l=[tuple(map(int,input().split()))for i in range(n)]
s=l[0]
l2=[[x,y,s[2]+abs(x-s[0])+abs(y-s[1])]for y in range(101)for x in range(101)]
for s in l2.copy():
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
print(*l2[0])

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
for i in range(n):
    a,b,c=map(int,input().split())
    if c>0:
        l.append([a,b,c])
s=l[0]
l2=[]
for x in range(100):
    for y in range(100):
        l2.append([x,y,s[2]+abs(x-s[0])+abs(y-s[1])])
for s in l2.copy():
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
            
print(*l2[0])

Submission status: Runtime Error

Solution code:
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N

for i in range(N):
	x[i], y[i], h[i] = map(int, input().split())
for cx in range(101):
	for cy in range(101):
		H = abs(x[0]-cx)+abs(y[0]-cy)+h[0]
		for i in range(N):
			# if H != abs(x[i]-cx)+abs(y[i]-cy)+h[i]:
			if h[i] != max(H-abs(x[i]-cx)-abs(y[i]-cy), 0):
				break
			if i == N-1:
				ans = [cx, cy, H]
				break
print(ans[0],ans[1],ans[2])

Submission status: Runtime Error

Solution code:
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N

for i in range(N):
	x[i], y[i], h[i] = map(int, input().split())
for cx in range(101):
	for cy in range(101):
		H = abs(x[0]-cx)+abs(y[0]-cy)+h[0]
		for i in range(N):
			if H != abs(x[i]-cx)+abs(y[i]-cy)+h[i]:
				break
			if i == N-1:
				ans = [cx, cy, H]
				break
print(ans[0],ans[1],ans[2])

Submission status: Runtime Error

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
flag = 0
for x in range(101):
    for y in range(101):
        for i in range(n-1):
            if xyh[i][2] - xyh[i+1][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y) - abs(xyh[i+1][0] - x) - abs(xyh[i+1][1] - y) != 0:
                break
            if i == n-2:
                flag = 1
        if flag == 1:
            ans = [x,y]
            break
    if flag == 1:
        break
ans.append(xyh[0][2] + abs(xyh[0][0] - ans[0]) + abs(xyh[0][1] - ans[1]))
print(str(ans[0])+" "+str(ans[1])+" "+str(ans[2]))

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())
X = []
Y = []
H = []
for i in range(n):
    x,y,h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        ans_h = None
        done = False
        for i in range(n):
            if done == False:
                if ans_h is None:
                    if H[i]!=0:
                        ans_h = abs(X[i]-x)+abs(Y[i]-y)+H[i]
                else:
                    if ans_h-abs(X[i]-x)-abs(Y[i]-y)==H[i]:
                        pass
                    else:
                        done = True
            else:
                break

        if done == False:
            ans = (x,y,ans_h)
x,y,h = ans
print(x,y,h)

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())
X = []
Y = []
H = []
for i in range(n):
    x,y,h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)


for x in range(101):
    for y in range(101):
        ans_h = None
        done = False
        for i in range(n):
            if done == False:
                if ans_h is None:
                    if H[i]!=0:
                        ans_h = abs(X[i]-x)+abs(Y[i]-y)+H[i]
                else:
                    if ans_h-abs(X[i]-x)-abs(Y[i]-y)==H[i]:
                        pass
                    else:
                        done = True

        if done == False:
            ans = (x,y,ans_h)
x,y,h = ans
print(x,y,h)

Submission status: Runtime Error

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

for xyh in XYH:
    if xyh[2] > 0:
        XYH_.append(xyh)
# まず中心を求める。
H_ = int(10**9)
Cx, Cy = None, None
for i in range(101):
    cx = i
    for j in range(101):
        cy=j
        test = [H_-abs(x-cx)-abs(y-cy) - h for x, y, h in XYH]
        if all([test[0]==test[i] for i in range(len(test))]):
            Cx=i
            Cy=j
H = XYH_[0][2] + abs(XYH_[0][0]-Cx) + abs(XYH_[0][1]-Cy)
print(Cx, Cy, H)

Submission status: Runtime Error

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

for xyh in XYH:
    if xyh[2] >= 0:
        XYH_.append(xyh)
# まず中心を求める。
H_ = int(10**9)
Cx, Cy = None, None
for i in range(101):
    cx = i
    for j in range(101):
        cy=j
        test = [H_-abs(x-cx)-abs(y-cy) - h for x, y, h in XYH]
        if all([test[0]==test[i] for i in range(len(test))]):
            Cx=i
            Cy=j
H = XYH_[0][2] + abs(XYH_[0][0]-Cx) + abs(XYH_[0][1]-Cy)
print(Cx, Cy, H)

Submission status: Runtime Error

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

for xyh in XYH:
    if xyh[2] >= 0:
        XYH_.append(xyh)
# まず中心を求める。
H_ = int(10**9)
Cx, Cy = None, None
for i in range(101):
    cx = i
    for j in range(101):
        cy=j
        test = [H_-abs(x-cx)-abs(y-cy) - h for x, y, h in XYH]
        if all([test[0]==test[i] for i in range(len(test))]):
               Cx=i
               Cy=j

H = XYH_[0][2] + abs(XYH_[0][0]-Cx) + abs(XYH_[0][1]-Cy)
print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
H=0
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if a[i][2]!=0:
                if H==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
                for k in range(N):
                    if a[k][2]!=max(H-abs(x-a[k][0])-abs(y-a[k][1]),0):
                        flag=False
print(x,y,H)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if a[i][2]!=0:
                if i==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
                for k in range(N):
                    if a[k][2]!=max(H-abs(x-a[k][0])-abs(y-a[k][1]),0):
                        flag=False
print(x,y,H)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if a[i][2]!=0:
                if i==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
print(x,y,H)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if a[i][0]!=0:
                if i==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
print(x,y,H)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if i==0 or H==0:
                H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
            if a[i][2]!=0 and H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]) and H!=0:
                break
            if i==N-1:
                x=cx
                y=cy
                flag=True
print(x,y,H)

Submission status: Runtime Error

Solution code:
n=int(input())
xyh=[]
h0=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    xyh.append(a)

for x in range(101):
    for y in range(101):
        p=0
        l=max(0,xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1]))
        for i in range(n):
            if xyh[i][2]==0:
                if l>abs(x-xyh[i][0])+abs(y-xyh[i][1]:
                    p=1
                    break
                else:
                    continue
            if l==max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1])):
                l=max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]))
            else:
                p=1
                break
        if p==0:
            print(x,y,l)
            import sys
            sys.exit()

Submission status: Runtime Error

Solution code:
n=int(input())
xyh=[]
for i in range(n):
    a=[int(j) for j in input().split()]
    if a[2]!=0:
        xyh.append(a)

for x in range(101):
    for y in range(101):
        p=0
        l=max(0,xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1]))
        for i in range(n):
            if l==max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1])):
                l=max(0,xyh[i][2]+abs(x-xyh[i][0])+abs(y-xyh[i][1]))
            else:
                p=1
                break
        if p==0:
            print(x,y,l)
            import sys
            sys.exit()

Submission status: Runtime Error

Solution code:
n = int(input())
e = sorted([[int(i) for i in input().split()] for i in range(n)], key=lambda x:x[2])[::-1]

def f():
    for x in range(101):
        for y in range(101):
            flg = True
            H = e[0][2] + abs(x-e[0][0]) + abs(y-e[0][1])
            for e_ in e:
                if (e_[2] == 0) and  H > abs(x-e_[0]) + abs(y-e_[1]):
                    flg = False
                    break
                if H != e_[2] + abs(x-e_[0]) + abs(y-e_[1]):
                    flg = False
                    break
            if flg:
                return (x, y, H)
result = f()
print("{} {} {}".format(result[0], result[1], result[2]) )

Submission status: Runtime Error

Solution code:
n = int(input())
e = sorted([[int(i) for i in input().split()] for i in range(n)], key=lambda x:x[2])[::-1]

def f():
    for x in range(101):
        for y in range(101):
            flg = True
            H = e[0][2] + abs(x-e[0][0]) + abs(y-e[0][1])
            for e_ in e:
                if H != e_[2] + abs(x-e_[0]) + abs(y-e_[1]):
                    flg = False
                    break
            if flg:
                return (x, y, H)
result = f()
print("{} {} {}".format(result[0], result[1], result[2]) )

Submission status: Runtime Error

Solution code:
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

def f():
    for x in range(101):
        for y in range(101):
            flg = True
            H = e[0][2] + abs(x-e[0][0]) + abs(y-e[0][1])
            for e_ in e:
                if H != e_[2] + abs(x-e_[0]) + abs(y-e_[1]):
                    flg = False
                    break
            if flg:
                return (x, y, H)
result = f()
print("{} {} {}".format(result[0], result[1], result[2]) )

Submission status: Runtime Error

Solution code:
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

def f():
    for x in range(101):
        for y in range(101):
            flg = True
            H = e[0][2] + abs(x-e[0][0]) + abs(y-e[0][1])
            if len(e) > 1:
                for e_ in e[1:]:
                    if H != e_[2] + abs(x-e_[0]) + abs(y-e_[1]):
                        flg = False
                        break
            if flg:
                return (x, y, H)
result = f()
print("{} {} {}".format(result[0], result[1], result[2]) )

Submission status: Runtime Error

Solution code:
n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

def f():
    for x in range(101):
        for y in range(101):
            flg = True
            H = e[0][2] + abs(x-e[0][0]) + abs(y-e[0][1])
            for e_ in e[1:]:
                if H != e_[2] + abs(x-e_[0]) + abs(y-e_[1]):
                    flg = False
                    break
            if flg:
                return (x, y, H)
result = f()
print("{} {} {}".format(result[0], result[1], result[2]) )

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
data = np.zeros((N,3))
for i in range(N):
    data[i] = np.array(input().split())

# data = np.array([[2,3,5],[2,1,5],[1,2,0],[3,2,5]])

for n in range(10201):
    C_x = n // 101
    C_y = n % 101
    flg = True
    unsetflg = True
    for i,(x,y,h) in enumerate(data):
        if unsetflg and h>=1:
            H = abs(x-C_x)+abs(y-C_y)+h
            unsetflg = False
        else
            if h>=1 and H != abs(x-C_x)+abs(y-C_y)+h:
                flg = False
                break 
    if flg:
        print(C_x,C_y,int(H))
        break

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())

    xn = []
    yn = []
    hn = []

    for i in range(N):
        xi, yi, hi = map(int, input().split())
        if hi:
            xn.append(xi)
            yn.append(yi)
            hn.append(hi)

    if N == 1:
        print(xn[0], yn[0], hn[0])
        return

    for Cx in range(101):
        for Cy in range(101):

            last = None

            for i in range(N):
                H = abs(xn[i] - Cx) + abs(yn[i] - Cy) + hn[i]

                if H < 0:
                    continue
                if last:
                    if (last != H):
                        break

                last = H
            else:
                print(Cx, Cy, H)
                return


main()

Submission status: Runtime Error

Solution code:
import numpy as np
# N = int(input())
# data = np.zeros((N,3))
# for i in range(N):
#     data[i] = np.array(input().split())

data = np.array([[2,3,5],[2,1,5],[1,2,5],[3,2,5]])

for n in range(10201):
    C_x = n // 101
    C_y = n % 101
    flg = True
    unsetflg = True
    for i,(x,y,h) in enumerate(data):
        if unsetflg
        	if h>0:
            	H = abs(x-C_x)+abs(y-C_y)+h
            	unsetflg = False
        elif h>0:
            if H != abs(x-C_x)+abs(y-C_y)+h:
                flg = False
                break 
    if flg:
        print(C_x,C_y,int(H))
        break

Submission status: Runtime Error

Solution code:
def pyramid(N: int, info: list) -> tuple:
    """
    """
    _info = sorted(info, reverse=True)
    x, y, h = _info[0]
    candidtes = [
        (cx, cy, h + abs(cx - x) + abs(cy - y))
        for cx in range(100+1)
        for cy in range(100+1)]

    for x, y, h in _info[1:]:
        temp = []
        for cx, cy, H in candidtes:
            th = max(H - abs(cx - x)-abs(cy - y), 0)
            if th == h:
                temp.append((cx, cy, H))

        candidtes = temp

    return candidtes[0]

if __name__ == "__main__":
    N = int(input())
    info = [
        tuple(int(s) for s in input().split())
        for _ in range(N)]
    cx, cy, h = pyramid(N, info)
    print(cx, cy, h)

Submission status: Runtime Error

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]<l[B][2]:
    A,B=B,A
  if l[A][2]>l[B][2]:
    if l[B][2]==0:
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap<=abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
    else:
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap==abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
  
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  s=t[:]
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Runtime Error

Solution code:
import sympy

Submission status: Runtime Error

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=set(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=set()
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.add((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.add((X,Y))
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.add((X,Y))
  else:
    t=s.copy()
    if (l[A][0],l[A][1]) in t:
      t.remove((l[A][0],l[A][1]))
    if (l[B][0],l[B][1]) in t:
      t.remove((l[B][0],l[B][1]))    

  s=t.copy()
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Runtime Error

Solution code:
n = int(input())
info = [tuple(map(int, input().split()))]
nonzeroinfo = []
for x, y, h in info:
    if h > 0:
        nonzeroinfo.append((x, y, h))
zeroinfo = []
for x, y, h in info:
    if h == 0:
        zeroinfo.append((x, y, h))
def checknonzero(x, y, h):
    for a, b, c in nonzeroinfo:
        if h != abs(x-a) + abs(y-b) + c:
            return False
    return True
def checkzero(x, y, h):
    for a, b, _ in zeroinfo:
        if abs(x-a) + abs(y-b) < h:
            return False
    return True
for x in range(101):
    for y in range(101):
        x1, y1, h1 = nonzeroinfo[0]
        h = abs(x-x1) + abs(y-y1) + h1
        ret1 = checknonzero(x, y, h)
        ret2 = checkzero(x, y, h)
        if ret1 and ret2:
            print(x, y, h)
            exit()

Submission status: Runtime Error

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  else:
    t=[:]
  s=t[:]
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Runtime Error

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  s=t[:]
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Runtime Error

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  else:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  s=t[:]
if len(s)!=1:
  nya-n
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Runtime Error

Solution code:
import sys
N = int(input())
a = [list(map(int, input().split())) for l in range(N)]

if N == 1:
    print(a[0], a[1], a[2])

if len(a) == a[2].count(0):
    print(5050 - sum(a[0]), 5050 - sum(a[1]), 1)

for i in range (101):
    for j in range (101):
        H = []
        for k in range (N):
            if a[k][2] != 0:
                H.append(a[k][2] + abs(a[k][0] - i) + abs(a[k][1] - j))
                #print(H)
        if len(H) == H.count(H[0]):
            print(i, j, H[0])
            sys.exit()