Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = int(input())
S = input()
cnt = 0
for i in range(1000):
  hy = i//100
  zyu = (i-hy*100)//10
  ichi = i%10
  cnt_hy = float('inf')
  cnt_zyu = float('inf')
  cnt_ichi = float('inf')
  t = 0
  for j in range(n):
    if t == 0:
      if int(S[j]) == hy:
        cnt_hy = j
        t += 1
    elif t == 1:
      if int(S[j]) == zyu:
        cnt_zyu = j
        t += 1
    elif t == 2:
      if int(S[j]) == ichi:
        cnt_ichi = j
        break
  if cnt_hy < cnt_zyu < cnt_ichi <= n-1:
    cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
S = input()
cnt = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      i_pos = S.find(str(i))
      if i_pos == -1:
        continue
      j_pos = S.find(str(j),i_pos+1)
      if j_pos == -1:
        continue
      k_pos = S.find(str(k),j_pos+1)
      if k_pos == -1:
        continue
      cnt += 1
print(cnt)
### BUGGY CODE ###

# coding:utf-8

N, K = (int(x) for x in input().split())
h = [int(x) for x in input().split()]

inf = 100000000000000
dp = [inf for x in range(N)]

dp[0] = 0
for i in range(0, N):
	for j in range(1, K+1):
		if i + j < N:
			dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])

### FIXED CODE ###

# coding:utf-8

N, K = (int(x) for x in input().split())
h = [int(x) for x in input().split()]

inf = 100000000000000
dp = [inf for x in range(N)]

dp[0] = 0
for i in range(0, N):
	for j in range(1, K+1):
		if i + j < N:
			dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])
### BUGGY CODE ###

def merge(A, left, mid, right):

    n1 = mid-left
    n2 = right-mid
    L = [0 for i in range(n1+1)]
    R = [0 for i in range(n2+1)]
    for i in range(n1):
        L[i] = A[left+i]
    for i in range(n2):
        R[i] = A[mid+i]
    L[n1] = 1000000001
    R[n2] = 1000000001
    i = 0
    j = 0
    #global cnt
    cnt = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
            cnt +=1
        else:
            A[k] = R[j]
            j = j+1
            cnt +=1
    return cnt

def mergeSort(A, left, right):
    if left+1 < right:
         mid = (left+right) // 2
         cnt1 = mergeSort(A, left, mid)
         cnt2 = mergeSort(A, mid, right)
         cnt3 = merge(A, left, mid, right)
         return cnt1+cnt2+cnt3
    else:
        return 0

n = input()
A = list(map(int, input().split()))
cnt = mergeSort(A, 0, len(A))
print(*A)
print(str(cnt))

### FIXED CODE ###

def merge(A, left, mid, right):

    n1 = mid-left
    n2 = right-mid
    #L = [0 for i in range(n1+1)]
    #R = [0 for i in range(n2+1)]
    #for i in range(n1):
    #    L[i] = A[left+i]
    #for i in range(n2):
    #    R[i] = A[mid+i]
    L = A[left:mid]
    R = A[mid:right]
    L.append(float('inf'))
    R.append(float('inf'))
    i = 0
    j = 0
    global cnt

    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
        
        else:
            A[k] = R[j]
            j = j+1
    return cnt

def mergeSort(A, left, right):
    if left+1 < right:
         mid = (left+right) // 2
         mergeSort(A, left, mid)
         mergeSort(A, mid, right)
         merge(A, left, mid, right)
    else:
        return 0

n = input()
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, len(A))
print(*A)
print(str(cnt))
### BUGGY CODE ###

# 解説AC．


def main():
    N, M = map(int, input().split(" "))
    result = 1
    for i in range(2, M // N + 1):
        if M % i == 0:
            result = i
    print(result)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N, M = map(int, input().split(" "))
    for i in range(M // N, 0, -1):
        if M % i == 0 and i <= M / N:
            print(i)
            break


if __name__ == '__main__':
    main()
### BUGGY CODE ###

data = [str(i+1)*4 for i in range(9)]
while True:
    n = raw_input()
    if n == '0000': 
        break
    elif n in data:
        print 'NA'
        continue
    c = 0
    while n != '6174':
        L = int(''.join(sorted(list(n), key=int, reverse=True)))
        S = int(''.join(sorted(list(n), key=int)))
        n = str(L-S)
        c += 1
    else:
        print c

### FIXED CODE ###

data = [str(i+1)*4 for i in range(9)]
while True:
    n = raw_input()
    if n == '0000': 
        break
    elif n in data:
        print 'NA'
        continue
    c = 0
    while n != '6174':
        L = int(''.join(sorted(n, reverse=True)))
        S = int(''.join(sorted(n)))
        n = str(L-S).zfill(4)
        c += 1
    else:
        print c
### BUGGY CODE ###

from collections import deque

N, *A = map(int, open(0).read().split())
V = N * (N - 1) // 2

serial = [[0 for _ in range(N)] for _ in range(N)]
k = 0
for i in range(N):
    for j in range(i + 1, N):
        serial[i][j] = serial[j][i] = k
        k += 1

G = [[] for _ in range(V)]
deg = [0] * V
for s, a in zip(serial, zip(*[iter(A)] * (N - 1))):
    for j in range(N - 2):
        G[s[a[j] - 1]].append(s[a[j + 1] - 1])
        deg[s[a[j + 1] - 1]] += 1

Q = deque((k, 1) for k, v in enumerate(deg) if v == 0)

ans = 0
cnt = len(Q)
while Q:
    v, ans = Q.popleft()
    for t in G[v]:
        deg[t] -= 1
        if deg[t] == 0:
            Q.append((t, ans + 1))
            cnt += 1

if cnt != V:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import time
start = time.time()

import sys
input = sys.stdin.readline

N = int(input())
A = [[int(i) - 1 for i in input().split()] for _ in range(N)]

cur = [0] * N

max_pairs = N * (N - 1)

pairs = 0
cnt = 1
for _ in range(max_pairs // 2):
    visited = [False] * N
    for i, a in enumerate(A):
        if cur[i] >= N - 1:
            continue
        p = a[cur[i]]
        if A[p][cur[p]] == i:
            # print(cnt, p + 1, A[p][cur[p]] + 1, i + 1)
            visited[i] = True
            visited[a[cur[i]]] = True
            pairs += 1

    # print(pairs)
    if pairs == max_pairs:
        break
    if pairs > max_pairs:
        print(-1)
        quit()

    update = False
    for i, v in enumerate(visited):
        if v:
            cur[i] += 1
            update = True

    if not update:
        print(-1)
        quit()

    if time.time() - start > 1.8:
        print(N * (N - 1) // 2)
        exit()

    cnt += 1

print(cnt)
### BUGGY CODE ###

def main():
    n = int(input())
    a = sorted(tuple(map(int, input().split())))

    ans = [0] * n
    for i in range(len(a) - 1):
        if ans[i] == 1:
            continue
        for j in range(i + 1, len(a)):
            if a[i] == a[j]:
                ans[i] = 1
                ans[j] = 1
            else:
                if a[j] % a[i] == 0:
                    ans[j] = 1
    print(n - sum(ans))


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    a = tuple(map(int, input().split()))

    ans = 0
    mx = max(a) + 1
    dp = [0] * mx
    for i in a:
        for j in range(i, mx, i):
            dp[j] += 1
    for i in a:
        if dp[i] == 1:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, w = map(int, input().split())

ws = [0] * n
vs = [0] * n

for i in range(n):
  a, b = map(int, input().split())
  ws[i] = a
  vs[i] = b
  
dp = [0] * (w + 1)

for i in range(n):
  for j in range(w, -1, -1):
    if j + ws[i] <= w:
      dp[j + ws[i]] = max(dp[j + ws[i]], dp[j] + vs[i])
      
print(dp[w])

### FIXED CODE ###

n, w = map(int, input().split())

ws = [0] * n
vs = [0] * n

for i in range(n):
  a, b = map(int, input().split())
  ws[i] = a
  vs[i] = b
  
dp = [0] * (w + 1)

for i in range(n):
  for j in range(w, -1, -1):
    if j + ws[i] <= w:
      dp[j + ws[i]] = max(dp[j + ws[i]], dp[j] + vs[i])
      
print(dp[w])
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt_list = []
b = set(a)
for s in b:
    cnt_list.append(a.count(s))
cnt_list = sorted(cnt_list)

print(sum(cnt_list[:len(cnt_list) - k]))

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt_list = [0]*(n+1)
for i in range(n):
    cnt_list[a[i]] += 1
cnt_list.sort()
print(sum(cnt_list[:len(cnt_list) - k]))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
i = 0
while i<N:
    print(A.count(i+1))
    i+=1

### FIXED CODE ###

import collections
 
N = int(input())
A = list(map(int, input().split()))
 
c = collections.Counter(A)
 
for i in range(1, N+1):
    print(c[i])
### BUGGY CODE ###

N = int(input())
num_list = list(map(int, input().split()))

length = N
amount = 0
for i in range(length-1):
  for j in range(i+1, length):
    num1 = num_list[i]
    num2 = num_list[j]
    bit_num1 = format(num1, "b")
    bit_num2 = format(num2, "b")
    length_num1 = len(bit_num1)
    length_num2 = len(bit_num2)
    max_length = max(length_num1, length_num2)
    bit_num1 = bit_num1.zfill(max_length)
    bit_num2 = bit_num2.zfill(max_length)       
    num = ""
    for k in range(1, max_length+1):
      if int(bit_num1[-k]) and not int(bit_num2[-k]):
        num = "1" + num
      elif not int(bit_num1[-k]) and int(bit_num2[-k]):
        num = "1" + num
      else:
        num = "0" + num
    amount += int(num, 2)

L = 10**9 + 7
print(amount % L)

### FIXED CODE ###

import numpy as np
N = int(input())
num_list = np.array(input().split(), dtype="int")

max_num = max(num_list)
max_bit_num = format(max_num, "b")
max_bit_num_length = len(max_bit_num)
ans = 0
radix = 1
for i in range(max_bit_num_length):
  new_num_list = (num_list >> i) & 1
  one_amount = np.count_nonzero(new_num_list == 1)
  zero_amount = len(num_list) - one_amount
  ans += (one_amount*zero_amount)*radix
  radix *= 2
print(ans%(10**9+7))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)

n, q = map(int, sys.stdin.readline().split())

graph = [[] for _ in range(n+1)] 
for i in range(1, n):
  a, b = map(int, sys.stdin.readline().split())
  graph[a].append(b)
  graph[b].append(a)

point = [0]*(n+1)
for i in range(q):
  p, x = map(int, sys.stdin.readline().split())
  point[p] += x

seen = [False]*(n+1)
counter = [0]*(n+1)
sum_point = 0

def dfs(v):
  
  global graph
  global seen
  global sum_point
  global counter
  
  seen[v] = True
  sum_point += point[v]
  
  for next_v in graph[v]:
    
    if seen[next_v]: 
      continue
    dfs(next_v)
  
  counter[v] = sum_point
  sum_point -= point[v]

dfs(1)
print(*counter[1::])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n, q = map(int, sys.stdin.readline().split())

graph = [[] for _ in range(n+1)] 
for i in range(1, n):
  a, b = map(int, sys.stdin.readline().split())
  graph[a].append(b)
  graph[b].append(a)

point = [0]*(n+1)
for i in range(q):
  p, x = map(int, sys.stdin.readline().split())
  point[p] += x

seen = [False]*(n+1)
counter = [0]*(n+1)
sum_point = 0

def dfs(v):
  
  global graph
  global seen
  global sum_point
  global counter
  
  seen[v] = True
  sum_point += point[v]
  
  for next_v in graph[v]:
    
    if seen[next_v]: 
      continue
    dfs(next_v)
  
  counter[v] = sum_point
  sum_point -= point[v]

dfs(1)
print(*counter[1::])
### BUGGY CODE ###

from bisect import bisect_left
from operator import itemgetter

n, q = map(int, input().split())
stx = [tuple(int(x) for x in input().split()) for _ in range(n)]
d = [int(input()) for _ in range(q)]

ans = [-1] * q

stx.sort(reverse=True, key=itemgetter(2))

for s, t, x in stx:
    L = bisect_left(d, s-x)
    R = bisect_left(d, t-x)
    for i in range(L, R):
        ans[i] = x

for x in ans:
    print(x)

### FIXED CODE ###

from bisect import bisect_left
from operator import itemgetter

n, q = map(int, input().split())
stx = [tuple(int(x) for x in input().split()) for _ in range(n)]
d = [int(input()) for _ in range(q)]

ans = [-1] * q
skip = [-1] * q

stx.sort(key=itemgetter(2))

for s, t, x in stx:
    L = bisect_left(d, s-x)
    R = bisect_left(d, t-x)
    while L < R:
        if skip[L] == -1:
            ans[L] = x
            skip[L] = R
            L += 1
        else:
            L = skip[L]

for x in ans:
    print(x)
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]

ans = a[0]
for i in range(1,n):
    ans *= a[i]

if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]
lim = 10**18
flag = True

ans = a[0]

if a.count(0) >= 1:
    ans = 0
else:
    for i in range(1,n):
        ans *= a[i]
        if ans > lim:
            flag = False
            break
            
if flag:
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

n=int(input())
x=input()
chk=0
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk+=2**i
d={}
ans=[]
for i,j in enumerate(x[::-1]):
    if j=="1":
        t=chk-2**i
    else:
        t=chk+2**i
    s=t
    cnt=0
    while t:
        pc=bin(t)[2:].count("1")
        t%=pc
        cnt+=1
        if t in d:
            cnt+=d[t]
            break
    if s not in d:
        d[s]=cnt
    ans.append(cnt)
for i in ans[::-1]:
    print(i)

### FIXED CODE ###

n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(0)
    exit()
elif b==1:
    for i in range(n):
        if i==n-1: print(2)
        elif x[i]=="0": print(1)
        else: print(0)
    exit()
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        if b>1: chk2+=pow(2,i,b-1)
        else: chk2=0
l=[]
for i,j in enumerate(x[::-1]):
    if b: a1=pow(2,i,b+1)
    else: a1=1
    if b>1: a2=pow(2,i,b-1)
    else: a2=1
    if j=="0":
        t=chk1+a1
    else:
        if b>1: t=chk2+b-1-a2
        else: t=0
    ans,f=0,1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,X,Y=map(int,input().split())
E=[[] for i in range(N+1)]
for i in range(1,N):
    E[i].append(i+1)
    E[i+1].append(i)
E[X].append(Y)
E[Y].append(X)

ANS=[0]*(N+1)
from collections import deque
for i in range(1,N+1):
    Q=deque()
    Q.append(i)
    D=[-1]*(N+1)
    D[i]=0
    
    while Q:
        x=Q.popleft()
        for to in E[x]:
            if D[to]==-1:
                D[to]=D[x]+1
                Q.append(to)
                ANS[D[to]]+=1
    #print(D)
for i in range(1,N):
    print(ANS[i]//2)
    


### FIXED CODE ###

import sys
input = sys.stdin.readline

N,X,Y=map(int,input().split())
E=[[] for i in range(N+1)]
for i in range(1,N):
    E[i].append(i+1)
    E[i+1].append(i)
E[X].append(Y)
E[Y].append(X)

ANS=[0]*(N+1)
from collections import deque
for i in range(1,N+1):
    Q=deque()
    Q.append(i)
    D=[-1]*(N+1)
    D[i]=0
    
    while Q:
        x=Q.popleft()
        for to in E[x]:
            if D[to]==-1:
                D[to]=D[x]+1
                Q.append(to)
                ANS[D[to]]+=1
    #print(D)
for i in range(1,N):
    print(ANS[i]//2)
### BUGGY CODE ###

S = input()
q = int(input())
Q = list()
for i in range(q):
    Q.append(list(map(str, input().split())))

flag = False
for i in range(q):
    if Q[i][0] == '1':
        flag = not flag
    elif (Q[i][1] == '1' and flag) or (Q[i][1] == '2' and not flag):
        S += Q[i][2]
    else:
        S = Q[i][2] + S

if flag:
    S = reversed(S)
print(''.join(S))


### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())

flag = False
for _ in range(Q):
    q = input()
    if q[0] == '1':
        flag = not flag
    else:
        _, f, c = q.split()
        if flag:
            if f == '2':
                S.appendleft(c)
            else:
                S.append(c)
        else:
            if f == '1':
                S.appendleft(c)
            else:
                S.append(c)

if flag:
    S.reverse()
print(''.join(S))
### BUGGY CODE ###

import bisect
n=int(input())
seq= [int(input()) for i in range(n)]

# dp[k]:最適に部分列を繋げた時の集合
dp = [seq[0]]

for i in range(1,len(seq)):
    if seq[i] <= dp[0]:
        dp.insert(0,seq[i])

    else:
        dp[bisect.bisect_left(dp, seq[i])-1] = seq[i]

print(len(dp))

### FIXED CODE ###

import collections
from collections import deque
import bisect

n=int(input())
a=list(int(input()) for i in range(n))
b=deque()
b.append(-1)


for i in range(n):
    if a[i]>b[0]:
        x=bisect.bisect_right(b,a[i]-1)
        b[x-1]=a[i]
    else:
        b.appendleft(a[i])
print(len(b))
### BUGGY CODE ###

num = int(input())

count = 0
for nn1 in range(1, num + 1):
  for nn2 in range(1, num + 1):
    n1 = str(nn1).lstrip('0')
    n2 = str(nn2).lstrip('0')
    if n1[0] == n2[-1] and n2[0] == n1[-1]:
      count += 1
      
print(count)

### FIXED CODE ###

import collections

num = int(input())
count = 0
ll = []
lr = []
for nn1 in range(1, num + 1):
  left = (str(nn1).lstrip('0')[0])
  right = (str(nn1)[-1])
  ll.append(left + '+' + right)
  lr.append(right + '+' + left)

c = collections.Counter(lr)

for i in range(num):
  count += int(c[ll[i]])

print(count)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
op = [list(map(int, input().split())) for _ in range(m)]
op.sort(key=lambda x: x[1], reverse=True)
a.sort()

idx = 0
for b, c in op:
    for i in range(b):
        if idx < n and a[idx] < c:
            a[idx] = c
            idx += 1
        if idx >= n:
            break
    if idx >= n:
        break


print(sum(a))


### FIXED CODE ###

from operator import itemgetter
n, m = map(int, input().split())
a = list(map(int, input().split()))
op = [list(map(int, input().split())) for _ in range(m)]
op.sort(key=itemgetter(1), reverse=True)
a.sort()

idx = 0
ans = 0
for i in range(n):
    if idx < m and op[idx][1] > a[i]:
        ans += op[idx][1]
    else:
        ans += a[i]

    if idx < m and op[idx][0] > 1:
        op[idx][0] -= 1
    else:
        idx += 1


print(ans)
### BUGGY CODE ###

import sys
input= sys.stdin.readline

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(M-N+1):
  if M%(N+i)==0:
    print(M//(N+i))
    exit()

### FIXED CODE ###

import sys
input= sys.stdin.readline

N,M = map(int,input().split())
g=M//N#最大公約数になる可能性のある最大値
for i in range(g):
  if M%(g-i)==0:
    print(g-i)
    exit()
  if M%(N+i)==0:
    print(M//(N+i))
    exit()
### BUGGY CODE ###

def main():
    import sys
    N = int(input())
    left = 0
    right = N - 1
    table = ["?"]*N

    for i in range(21):
        c = (left + right) // 2
        if table[c] == "?":
            print(c)
            sys.stdin.flush()
            s = input()
            if s == "Vacant":
                return
            table[c] = s
        if table[left] == "?":
            print(left)
            sys.stdin.flush()
            le = input()
            if le == "Vacant":
                return
            table[left] = le
        if table[right] == "?":
            print(right)
            sys.stdin.flush()
            ri = input()
            if ri == "Vacant":
                return
            table[right] = ri
        if table[left] != table[c]:
            right = c
        elif table[right] != table[c]:
            left = c
        else:
            raise Exception


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    N = int(input())
    left = 0
    right = N
    table = ["?"]*N
    print(left)
    sys.stdin.flush()
    le = input()
    if le == "Vacant":
        return
    table[left] = le

    for i in range(20):
        c = (left + right) // 2
        print(c)
        sys.stdin.flush()
        s = input()
        if s == "Vacant":
            return
        table[c] = s
        if (c - left) % 2 == 0 and table[left] == table[c]:
            left = c
        elif (c - left) % 2 == 1 and table[left] != table[c]:
            left = c
        else:
            right = c


if __name__ == '__main__':
    main()
### BUGGY CODE ###

from itertools import accumulate

def solve():
    def getNums(Ss):
        lenS = len(Ss)
        nums = [0] * lenS
        Ss += '#'
        num = -1
        for i, S in enumerate(Ss):
            if S == '.':
                num += 1
            else:
                if num > 0:
                    nums[i-(num+1)] = num
                    if i < lenS:
                        nums[i] = -num
                num = -1
        return accumulate(nums)


    H, W = map(int, input().split())
    Sss = [input() for _ in range(H)]

    numHss = [list(getNums(Ss)) for Ss in Sss]
    Sss_tr = list(map(''.join, zip(*Sss))) # 転置
    numVss_tr = [getNums(Ss) for Ss in Sss_tr]
    numVss = list(map(list, zip(*numVss_tr))) # 転置

    ans = 0
    for i in range(H):
        for j in range(W):
            num = numHss[i][j] + numVss[i][j] + 1
            if num > ans:
                ans = num

    print(ans)

solve()


### FIXED CODE ###

from itertools import accumulate

def getNums(Ss):
    lenS = len(Ss)
    nums = [0] * lenS
    Ss += '#'
    num = -1
    for i, S in enumerate(Ss):
        if S == '.':
            num += 1
        else:
            if num > 0:
                nums[i-(num+1)] = num
                if i < lenS:
                    nums[i] = -num
            num = -1
    return accumulate(nums)


H, W = map(int, input().split())
Sss = [input() for _ in range(H)]

numHss = [list(getNums(Ss)) for Ss in Sss]
Sss_tr = list(map(''.join, zip(*Sss))) # 転置
numVss_tr = [getNums(Ss) for Ss in Sss_tr]
numVss = list(map(list, zip(*numVss_tr))) # 転置

ans = 0
for i in range(H):
    for j in range(W):
        num = numHss[i][j] + numVss[i][j] + 1
        if num > ans:
            ans = num

print(ans)
### BUGGY CODE ###

N = int(input())

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

'''
def calcCenterHeight(X, Y, Cx, Cy, Ch):
    return Ch + abs(X - Cx) + abs(Y - Cy)
'''


def calcCenterHeight(X, Y, Cx, Cy, Ch):
    s = set()
    H = Ch + abs(X - Cx) + abs(Y - Cy)
    s.add(H)
    if Ch == 0:
        for h in range(0, H):
            s.add(h)
    return s


from functools import reduce

for X in range(0, 101):
    for Y in range(0, 101):
        s = [calcCenterHeight(X, Y, Cx, Cy, Ch) for Cx, Cy, Ch in list]
        a = reduce(lambda a, b: a & b, s)
        # print(X, Y, s, a)
        if len(a) == 1:
            print(X, Y, a.pop())
            exit


### FIXED CODE ###

import sys

N = int(input())

list = []
for i in range(0, N):
    x, y, h = [int(x) for x in input().split()]
    list.append((x, y, h))
    # if (h != 0):
    # list.append((x, y, h))

for X in range(0, 101):
    for Y in range(0, 101):
        b = True
        H = 0
        for Cx, Cy, Ch in list:
            if Ch != 0:
                H = Ch + abs(X - Cx) + abs(Y - Cy)
        for Cx, Cy, Ch in list:
            h = max(H - abs(X - Cx) - abs(Y - Cy), 0)
            if Ch != h:
                b = False
        if b == True:
            print(X, Y, H)
            sys.exit(0)