Harryxun/stf_run huggingface dataset:
S = input()
K = int(input())
cnt = 0
for i in range(len(S)-1):
    if S[i]==S[i+1]&&S[i-1]!=S[i]:
        cnt += K
print(cnt)

### FIXED CODE ###

s=input()
k=int(input())
l=len(s)
now=1
seq=[]
re=False
all=False
for i in range(l):
    if s[i%l]==s[(i+1)%l]:
        if i==l-1:
            re=True
            if len(seq)==0:
                all=True
            else:
                first=seq[0]//2
                end=now//2
                seq[0]=(seq[0]+now)
        now+=1
    else:
        seq.append(now)
        now=1
if all:
    ans=len(s)*k//2
else:
    seq=[i//2 for i in seq]
    if re:
        ans=sum(seq)*k-seq[0]+first+end
    else:
        ans=sum(seq)*k

print(ans)
from fractions import Fraction

N, K = map(int, input().split())
ans = 0

flag = True
score = 1
times = 0
while flag:
  times += 1
  score *= 2
  if score >= K:
    flag = False

for i in range(1, N+1):
  ans += Fraction(1, N) * (Fraction(1, 2) ** times)
  times -= 1

print(float(ans))



### FIXED CODE ###

N, K = map(int, input().split())
ans = 0

for i in range(1, N+1):
  tmp = 1 / N
  now = i
  while now < K:
    now *= 2
    tmp /= 2
  ans += tmp
print(ans)
n = int(input())
s = input()
slimes = list(s)
i = 0
while i < n - 1:
  s = slimes[i]
  while s == slimes[i + 1]:
    slimes.pop(i)
    n -= 1
  i += 1
print(n)

### FIXED CODE ###

n = int(input())
s = input()

ans = 1
current = s[0]
for i in range(n):
  if current != s[i]:
    ans += 1 
    current = s[i]
print(str(ans))
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, K = map(int, input().split())
    ans = 0.0
    for i in range(1, N + 1):
        if i < K:
            num = 0
            while i < K:
                i *= 2
                num += 1
            ans += (1 / (2**num)) * (1 / N)

        else:
            ans += 1 / N

    print(f"{ans:.10f}")


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, K = map(int, input().split())
    ans = 0.0
    for i in range(1, N + 1):
        if i < K:
            num = 0
            while i < K:
                i *= 2
                num += 1
            ans += (1 / (2**num)) * (1 / N)

        else:
            ans += 1 / N

    print("{0:.10f}".format(ans))


if __name__ == '__main__':
    main()
N,M=map(int,input().split())
P=[i for i in range(N+1)]
L=[0 for i in range(N+1)]
Q=[]
def find(a):
    if P[a]==a:
        return a
    else:
        return find(P[a])

def union(b,c,d):
    B=find(b)
    C=find(c)
    P[C]=P[B]
    L[c]=L[b]+d

for i in range(M):
    l,r,d=map(int,input().split())
    Q.append([l,r,d])
    union(l,r,d)
#print(P)
#print(L)

for i in Q:
    if L[i[1]]-L[i[0]]==i[2]:
        continue
    else:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())

L=[[]for i in range(N+1)]
D=dict()
for i in range(M):
    l,r,d=map(int,input().split())
    L[l].append([r,d])
    L[r].append([l,-d])
    D[i]=(l,r,d)
    
C=["N" for i in range(N+1)]

def dfs(x):
    for i,j in L[x]:
        if C[i]=="N":
            C[i]=C[x]+j
            dfs(i)

for i in range(1,N+1):
    if C[i]=="N":
        C[i]=0
        dfs(i)
#print(C)
#print(D)
for i in range(M):
    l,r,d=D[i]
    if C[r]-C[l]!=d:
        print("No")
        exit()
print("Yes")
import sys
import numpy as np
from numba import njit

input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
vws = [tuple(map(int, input().split())) for _ in range(N)]
vs, ws = map(lambda ls: np.array(ls, np.int32), zip(*vws))
Q = int(input())
VLs = np.array(list(map(lambda s: tuple(map(int, s.split())), readlines())), np.int32)

n = min(2**10, N)

@njit("i4[:, :](i4, i4[:], i4[:])", cache = True)
def precompute(n, vs, ws):
    dp = np.zeros((n, 10**5+1), np.int32)
    dp[0, ws[0]:] = vs[0]
    for i in range(1, n):
        v = vs[i]
        w = ws[i]
        dp[i] = dp[(i-1)//2]
        dp[i, w:] = np.maximum(dp[(i-1)//2, :-w]+v, dp[i, w:])
    return dp

@njit("i4(i4[:], i4[:], i4, i4[:])", cache = True)
def func(vs_part, ws_part, L, dp_):
    bits = np.arange(1 << len(vs_part))
    values = np.zeros_like(bits, np.int32)
    weights = np.zeros_like(bits, np.int32)
    for i in range(len(vs_part)):
        indices = np.nonzero(np.bitwise_and(bits, 1<<i))
        values[indices] += vs_part[i]
        weights[indices] += ws_part[i]

    mask = (weights <= L)     
    return np.amax(dp_[L - weights[mask]] + values[mask])

#@njit("(i4, i4[:], i4[:], i4[:, :])", cache = True)
def main(n, vs, ws, VLs):
    dp = precompute(n, vs, ws)

    for V, L in VLs:
        V -= 1
        if V < n:
            print(dp[V, L])
        else:
            Vs = []
            while V >= n:
                Vs.append(V)
                V = (V-1) // 2
            Vs_arr = np.array(Vs)
            vs_part = vs[Vs_arr]
            ws_part = ws[Vs_arr]
            ans = func(vs_part, ws_part, L, dp[V])
            print(ans)

main(N, vs, ws, VLs)

### FIXED CODE ###

import sys
import numpy as np
from numba import njit

input = sys.stdin.buffer.readline

N = int(input())
vws = [tuple(map(int, input().split())) for _ in range(N)]

n = min(2**11, N)
vws_arr = np.array(vws, np.int32)

dp = np.zeros((n, 10**5+1), np.int32)
for i in range(n):
    v, w = vws[i]
    dp[i] = dp[(i-1)//2]
    dp[i, w:] = np.maximum(dp[(i-1)//2, :-w]+v, dp[i, w:])


@njit("i4(i4[::1], i4[::1], i4, i4[::1])", cache = True)
def func(vs, ws, L, dp_):
    values = np.zeros(1 << len(vs), np.int32)
    weights = np.zeros(1 << len(vs), np.int32)
    for i in range(len(vs)):
        for bits in range(1 << len(vs)):
            if bits & (1 << i):
                values[bits] += vs[i]
                weights[bits] += ws[i]
    ret = 0
    for v, w in zip(values, weights):
        if w <= L:
            ret = max(dp_[L - w] + v, ret)
    return ret

Q = int(input())
for _ in range(Q):
    V, L = map(int, input().split())
    V -= 1
    if V < n:
        print(dp[V, L])
    else:
        Vs = []
        while V >= n:
            Vs.append(V)
            V = (V-1) // 2
        vs = vws_arr[Vs, 0]
        ws = vws_arr[Vs, 1]
        print(func(vs, ws, L, dp[V]))
N, K = map(int, input().split())
H = map(int, input().split())

H.sorted(reverse=True)

if K >= N:
    print(0)
else:
    for i in range(K):
        print(sum(H[K:]))


### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort(reverse=True)

if K >= N:
    print(0)
else:
    print(sum(H[K:]))
import copy
h,w =map(int,input().split())

s = [[]*w for _ in range(h)]
white =0
for i in range(h):
    t = input()
    for j in range(w):
        if t[j] == ".":
            white += 1
            s[i].append(10**5)
        elif t[j] == "#":
            s[i].append(t[j])
now = [0,0]
steps =[]
steps.append(now)
direction = []
s[0][0] =0
a = [2]
while len(steps) >0:
    now = copy.copy(steps[0])
    if s[now[0]][now[1]] =="#":
        continue
    for k in [[0,1],[1,0],[-1,0],[0,-1]]:
        if now[0] + k[0] >=0 and now[0] + k[0] < h:
            now[0] += k[0]
            if now[1] + k[1] >=0 and now[1] + k[1] <w:
                if s[now[0]][now[1]] =="#":
                    continue
                else:
                    now[1] += k[1]
                    if s[now[0]][now[1]] == 10**5:
                        if not [now[0],now[1]] in steps:
                            steps.append([now[0],now[1]])
            else:
                continue
        else:
            continue
    if s[steps[0][0]][steps[0][1]] ==0:
        steps.pop(0)
        continue
    elif s[steps[0][0]][steps[0][1]] >10**4:
        direction =[]
        for l in [[0,1],[1,0],[-1,0],[0,-1]]:
            if steps[0][0]+l[0]>=0 and steps[0][0]+l[0]<h and steps[0][1]+l[1]< w and steps[0][1]+l[1] >=0 and s[steps[0][0]+l[0]][steps[0][1]+l[1]] != "#":
                direction.append(s[steps[0][0]+l[0]][steps[0][1]+l[1]])
        s[steps[0][0]][steps[0][1]] = min(direction)+1
    steps.pop(0)

if s[h-1][w-1] == "#" or s[h-1][w-1] == 10**4:
    print(-1)
else:
    print(white-1 - s[h-1][w-1])









### FIXED CODE ###

import copy
h,w =map(int,input().split())

s = [[]*w for _ in range(h)]
white =0
for i in range(h):
    t = input()
    for j in range(w):
        if t[j] == ".":
            white += 1
            s[i].append(10**5)
        elif t[j] == "#":
            s[i].append(t[j])
now = [0,0]
steps =[]
steps.append(now)
direction = []
s[0][0] =0
a = [2]
while len(steps) >0:
    now = copy.copy(steps[0])
    if s[now[0]][now[1]] =="#":
        continue
    for k in [[0,1],[1,0],[-1,0],[0,-1]]:
        now = copy.copy(steps[0])
        if now[0] + k[0] >=0 and now[0] + k[0] < h:
            now[0] += k[0]
            if now[1] + k[1] >=0 and now[1] + k[1] <w:
                now[1] += k[1]
                if s[now[0]][now[1]] == 10**5:
                    if not [now[0],now[1]] in steps:
                        steps.append([now[0],now[1]])
            else:
                continue
        else:
            continue
    # if s[steps[0][0]][steps[0][1]] ==0:
    #     steps.pop(0)
    #     continue
    if s[steps[0][0]][steps[0][1]] >10**4:
        direction =[]
        for l in [[0,1],[1,0],[-1,0],[0,-1]]:
            if steps[0][0]+l[0]>=0 and steps[0][0]+l[0]<h and steps[0][1]+l[1]< w and steps[0][1]+l[1] >=0 and s[steps[0][0]+l[0]][steps[0][1]+l[1]] != "#":
                s[steps[0][0]][steps[0][1]]=min(s[steps[0][0]+l[0]][steps[0][1]+l[1]]+1,s[steps[0][0]][steps[0][1]])
    steps.pop(0)
if s[h-1][w-1] == "#" or s[h-1][w-1] == 10**5:
    print(-1)
else:
    print(white-1 - s[h-1][w-1])
import math

A, B = input().split()

A = int(A)
B = int(B)


def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

### FIXED CODE ###

import operator
import functools

A, B = input().split()

A = int(A)
B = int(B)

value = []

count = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

primeA = prime_factorize(A)

primeB = prime_factorize(B)


for i in range(len(primeA)):
    for j in range(len(primeB)):
        if primeA[i] == primeB[j]:
            value.append(primeA[i])
            primeA[i] = 1
            primeB[j] = 1
            break
        else:
            continue

value = value + primeA + primeB

result = functools.reduce(operator.mul, value)

print(result)
while(1):
  count = int(raw_input())
  if count == 0: break
  previous_cube = [1, 2, 3, 4, 5, 6]
  operation = {'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left':[1, 4, 2, 5, 3, 6]}
  sum = 1
  for i in xrange(count):
    new_cube = []
    for e in xrange(5):
      new_cube.append(previous_cube[operation[raw_input().strip()][e]])
    sum += new_cube[0]
    previous_cube = new_cube
  print sum

### FIXED CODE ###

while 1:
  n = input()
  if n == 0:  break
  d = range(1, 7)
  ans = 1
  for i in range(n):
    c = raw_input()[0]
    if c == 'N': S = [1,5,2,3,0,4]
    elif c == "S": S = [4,0,2,3,5,1]
    elif c == "E": S = [3,1,0,5,4,2]
    elif c == "W": S = [2,1,5,0,4,3]
    elif c == "R": S = [0,2,4,1,3,5]
    elif c == "L": S = [0,3,1,4,2,5]
    d = [d[s] for s in S]
    ans += d[0]
  print ans
A,B=map(int,input().split())
C = (B - A )*( B - A + 1 )/ 2 - B 
print(C)

### FIXED CODE ###

N = int(input())
if N <= 999:
    print("ABC")
else:
    print("ABD")
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return






def main():
    N,Q = list(map(int,input().split()))
    adjl = [[] for _ in range(N)]
    for _ in  range(N-1):
        a, b = list(map(lambda x: int(x)-1,input().split()))
        adjl[a].append(b)
        adjl[b].append(a)
    res = [0]*N
    for _ in  range(Q):
        p, x = list(map(lambda x: int(x),input().split()))
        res[p-1] += x
    def dfs(n, parent = None):
        if parent != None:
            res[n] += res[parent]
        for neigh in adjl[n]:
            if neigh == parent:
                continue
            else:
                dfs(neigh,n)
    dfs(0)
    for _ in range(N):
        print(res[_],end=" ")
    print()





if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import exit, stderr, stdin, setrecursionlimit
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N, Q = list(map(int,input().split()))
    adjl = [[] for _ in range(N+1)]
    for _ in  range(N-1):
        a, b = list(map(lambda x: int(x),input().split()))
        adjl[a].append(b)
        adjl[b].append(a)
    res = [0]*(N+1)
    # print(adjl)
    for _ in  range(Q):
        p, x = list(map(lambda x: int(x),input().split()))
        res[p] += x
    # def dfs(n, parent = None):
    #     if parent != None:
    #         res[n] += res[parent]
    #     for neigh in adjl[n]:
    #         if neigh == parent:
    #             continue
    #         else:
    #             dfs(neigh,n)
    # dfs(0)
    q = [(1,0)]
    while q:
        x, parent = q.pop()
        res[x] += res[parent]
        for neigh in adjl[x]:
            if neigh != parent:
                q.append((neigh,x))

    print(' '.join(map(str,res[1:])))





if __name__ == "__main__":
    main()
import sys
n = int(input())
w = []
for i in range(n):
  word = input()
  if word in w:
    print('No')
    sys.exit()
cur = w[0][-1]
for x in w[1:]:
  if cur != x[0]:
    print('No')
    sys.exit()
  cur = x[-1]
print('Yes')

### FIXED CODE ###

import sys
n = int(input())
w = []
for i in range(n):
  word = input()
  if word in w:
    print('No')
    sys.exit()
  w.append(word)
cur = w[0][-1]
for x in w[1:]:
  if cur != x[0]:
    print('No')
    sys.exit()
  cur = x[-1]
print('Yes')
from math import gcd
n = int(input())
t_list = [int(input()) for i in range(n)]
ans = t_list[0]
for i in range(1,n):
    ans = ans * t_list[i] // gcd(ans,t_list[i])
print(ans)

### FIXED CODE ###

from fractions import gcd
n = int(input())
t_list = [int(input()) for i in range(n)]
ans = t_list[0]
for i in range(1,n):
    ans = ans * t_list[i] // gcd(ans,t_list[i])
print(ans)
int(input()) = N
for a in range(1,10):
  for b in range(a,10):
  if N==a*b:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")
while True :
	x,y = map(int,raw_input.split())
	if x==0 and y==0 :
		break
	else :
		if x<y :
			print '%d %d' %(x,y)
		else :
			print '%d %d' %(y,x)

### FIXED CODE ###

while True :
	x,y = map(int,raw_input().split())
	if x==0 and y==0 :
		break
	else :
		if x<y :
			print'%d %d' %(x,y)
		else :
			print'%d %d' %(y,x)
if S == "Sunny": return "Cloudy"
if S == "Cloudy": return "Rainy"
if S == "Rainy": return "Sunny"

### FIXED CODE ###

S = input()
if S == "Sunny": print("Cloudy")
if S == "Cloudy": print("Rainy")
if S == "Rainy": print("Sunny")
num = (10 ** 9) + 7

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

prime_upper = int(m ** (1/2) + 10)
prime_dict = {}

check = [False] * prime_upper
prime = [2]

while m % 2 == 0:
    m //= 2
    if not 2 in prime_dict.keys():
        prime_dict[2] = 0
    prime_dict[2] += 1

for j in range(2, prime_upper, 2):
    check[j] = True

for i in range(3, prime_upper, 2):
    if not check[i]:
        prime.append(i)
        while m % i == 0:
            m //= i
            if not i in prime_dict.keys():
                prime_dict[i] = 0
            prime_dict[i] += 1

        for j in range(i, prime_upper, i):
            check[j] = True

value_max = max(prime_dict.values())
com2 = [[0] * (value_max + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, value_max + 1):
        if i == 1:
            com2[i][j] = 1
        elif j == 1:
            com2[i][j] = i
        else:
            com2[i][j] = (com2[i][j - 1] + com2[i - 1][j]) % num
if m != 1:
    ans = n
else:
    ans = 1
for key, value in prime_dict.items():
    ans = (ans * com2[n][value]) % num

print(ans)

### FIXED CODE ###

num = (10 ** 9) + 7

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

if m == 1:
    print(1)
    exit()

prime_upper = int(m ** (1/2) + 50)
prime_dict = {}

check = [False] * prime_upper
prime = [2]

while m % 2 == 0:
    m //= 2
    if not 2 in prime_dict.keys():
        prime_dict[2] = 0
    prime_dict[2] += 1

for j in range(2, prime_upper, 2):
    check[j] = True

for i in range(3, prime_upper, 2):
    if not check[i]:
        prime.append(i)
        while m % i == 0:
            m //= i
            if not i in prime_dict.keys():
                prime_dict[i] = 0
            prime_dict[i] += 1

        for j in range(i, prime_upper, i):
            check[j] = True

if len(prime_dict.values()) != 0:
    value_max = max(prime_dict.values())
    com2 = [[0] * (value_max + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(1, value_max + 1):
            if i == 1:
                com2[i][j] = 1
            elif j == 1:
                com2[i][j] = i
            else:
                com2[i][j] = (com2[i][j - 1] + com2[i - 1][j]) % num
    if m != 1:
        ans = n
    else:
        ans = 1
    for key, value in prime_dict.items():
        ans = (ans * com2[n][value]) % num
    print(ans)
else:
    print(n)
def solve():
    N = int(input())
    X = input()
    X_10 = int(X,2)

    r = X.count("1")
    r0 = r-1
    r1 = r+1
    ans = []
    
    s1 = X_10 % r1 
    s0 = X_10 % r0 
    for i in range(N):
        if X[i] == '0':
            ans.append(f((s1 + pow(2,N-1-i)) % r1))
        else:
            if r == 1:
                ans.append(0)
            else:
                ans.append(f((s0 - pow(2,N-1-i)) % r0))
    
    print(*ans, sep='\n')

def f(N):
    cnt = 1
    while N != 0:
        N = N % popcount(N)
        cnt += 1
    
    return cnt

def popcount(N):
    b = bin(N)
    cnt = 0
    for i in range(2,len(b)):
        if b[i] == '1':
            cnt += 1

    return cnt

if __name__ == '__main__':
    solve()

### FIXED CODE ###

def solve():
    N = int(input())
    X = input()
    X_10 = int(X,2)

    r = X.count("1")
    r0 = r-1
    r1 = r+1
    ans = []
    
    s0 = X_10 % r0 if r != 1 else None
    s1 = X_10 % r1 

    for i in range(N):
        if X[i] == '0':
            ans.append(f((s1 + pow(2,N-1-i,r1)) % r1))
        else:
            if r0 == 0:
                ans.append(0)
            else:
                ans.append(f((s0 - pow(2,N-1-i,r0)) % r0))
    
    print(*ans, sep='\n')

def f(N):
    cnt = 1
    while N != 0:
        N = N % popcount(N)
        cnt += 1
    
    return cnt

def popcount(N):
    b = bin(N)
    cnt = 0
    for i in range(2,len(b)):
        if b[i] == '1':
            cnt += 1

    return cnt

if __name__ == '__main__':
    solve()
a = input()
b = input()

print a * b ,
print ' '  ,
print 2 * ( a + b ) 

### FIXED CODE ###

a,b = map( int , raw_input().split() )

ans1 = a * b
ans2 = 2 * ( a + b )

print ans1 , ans2
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)


cxyl = []
for i in range(101):
    for j in range(101):
        cxyl.append((i,j))
cxy = set(cxyl)
hd = {}
for i in range(n):
    for c in list(cxy):
        if h[i] == 0:
            if 1 > abs(x[i]-c[0]) + abs(y[i]-c[1]):
                cxy.remove(c)
                continue
        else:
            H = abs(x[i]-c[0]) + abs(y[i]-c[1]) + h[i]
            if H < 1:
                cxy.remove(c)
                continue
            if c in hd:
                if hd[c] != H:
                    cxy.remove(c)
                    continue
            else:
                hd[c] = H
if len(cxy) != 1:
    raise ValueError
ret = cxy.pop()
print(str(ret[0]) + ' ' + str(ret[1]) + ' ' + str(hd[ret]))


### FIXED CODE ###

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)


cxyl = []
for i in range(101):
    for j in range(101):
        cxyl.append((i,j))
cxy = set(cxyl)
hd = {}
hzero = set([])
for i in range(n):
    for c in list(cxy):
        H = abs(x[i]-c[0]) + abs(y[i]-c[1]) + h[i]
        if h[i] == 0:
            hzero.add((x[i],y[i]))
            if 1 > H:
                cxy.remove(c)
                continue
        else:
            if c in hd:
                if hd[c] != H:
                    cxy.remove(c)
                    continue
            else:
                hd[c] = H

for xy in list(hzero):
    xi = xy[0]
    yi = xy[1]
    for c in list(cxy):
        H = abs(xi-c[0]) + abs(yi-c[1])
        if hd[c] - H > 0:
            cxy.remove(c)

ret = cxy.pop()
print(str(ret[0]) + ' ' + str(ret[1]) + ' ' + str(hd[ret]))