Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**5)

def d(tree, array, v):
  next_v = tree.get(v)
  
  for nv, nd in next_v:
    if array[nv] == -1:
      array[nv] = array[v] + nd
      d(tree, array, nv)
  

n = int(input())
tree = {}

for i in range(n-1):
  a,b,c = map(int, input().split())
  a -= 1
  b -= 1
  
  array = tree.get(a, [])
  array.append((b,c))
  tree[a] = array
  
  array = tree.get(b, [])
  array.append((a,c))
  tree[b] = array
  
q,k = map(int, input().split())
k -= 1

array = [-1] * n
array[k] = 0

d(tree, array, k)

ans = []
for i in range(q):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  
  ans.append(array[x] + array[y])
  
for i in range(len(ans)):
  print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

def d(tree, array, v):
  next_v = tree.get(v)
  
  for nv, nd in next_v:
    if array[nv] == -1:
      array[nv] = array[v] + nd
      d(tree, array, nv)
  

n = int(input())
tree = {}

for i in range(n-1):
  a,b,c = map(int, input().split())
  a -= 1
  b -= 1
  
  array = tree.get(a, [])
  array.append((b,c))
  tree[a] = array
  
  array = tree.get(b, [])
  array.append((a,c))
  tree[b] = array
  
q,k = map(int, input().split())
k -= 1

array = [-1] * n
array[k] = 0

d(tree, array, k)

ans = []
for i in range(q):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  
  ans.append(array[x] + array[y])
  
for i in range(len(ans)):
  print(ans[i])
A,B = map(int, input().split())

print(6-(A+B))

### FIXED CODE ###

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

print(6-(A+B))
int(input())
A:str = input().split()
if A.count('Y')>0:
    print("Four")
else:
    print("Three")


### FIXED CODE ###

int(input())
A = input().split()
if A.count('Y')>0:
    print("Four")
else:
    print("Three")
#Input
l_A =  [[0 for i in range(3)] for j in range(3)]

def detect_BINGO(l_Atf):
    #print(l_Atf)
    #横
    for i in range(3):
        f_detect = True
        for j in range(3):
            #print(f_detect, l_Atf[i][j])
            f_detect = f_detect and l_Atf[i][j]
        if(f_detect):
            #print("横" + str(i))
            return True
    #縦
    for i in range(3):
        f_detect = True
        for j in range(3):
            f_detect = f_detect and l_Atf[j][i]
        if(f_detect):
            #print("縦" + str(i))
            return True
    #斜
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][i]
    if(f_detect):
        #print("斜＼")
        return True
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[3-1-i][3-1-i]
    if(f_detect):
        #print("斜／")
        return True
    
    #BINGOなし
    return False

#Process
l_Atf = [[False for i in range(3)] for j in range(3)]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if(l_A[j][k] == b):
                l_Atf[j][k] = True
    #print(l_Atf)

#   print(l_Atf)
f_bingo = detect_BINGO(l_Atf)

#Output
if(f_bingo):
    print("Yes")
else:
    print("no")


### FIXED CODE ###

#Input
l_A =  [[0 for i in range(3)] for j in range(3)]
l_A[0] = list(map(int, input().split()))
l_A[1] = list(map(int, input().split()))
l_A[2] = list(map(int, input().split()))

def detect_BINGO(l_Atf):
    #print(l_Atf)
    #横
    for i in range(3):
        f_detect = True
        for j in range(3):
            #print(f_detect, l_Atf[i][j])
            f_detect = f_detect and l_Atf[i][j]
        if(f_detect):
            #print("横" + str(i))
            return True
    #縦
    for i in range(3):
        f_detect = True
        for j in range(3):
            f_detect = f_detect and l_Atf[j][i]
        if(f_detect):
            #print("縦" + str(i))
            return True
    #斜
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][i]
    if(f_detect):
        #print("斜＼")
        return True
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][3-1-i]
    if(f_detect):
        #print("斜／")
        return True
    
    #BINGOなし
    return False

#Process
l_Atf = [[False for i in range(3)] for j in range(3)]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if(l_A[j][k] == b):
                l_Atf[j][k] = True
    #print(l_Atf)

f_bingo = detect_BINGO(l_Atf)

#Output
if(f_bingo):
    print("Yes")
else:
    print("No")
import sys
input = sys.stdin.readline

@njit
def main():
    N = int(input())
    Answer = 0

    for i in range(1,N+1):
        cnt = N // i
        num = cnt * (cnt + 1) >> 1
        num *= i
        Answer += num

print(Answer)
main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
Answer = 0

for i in range(1,N+1):
    cnt = N // i
    num = cnt * (cnt + 1) >> 1
    num *= i
    Answer += num

print(Answer)
def min(a,i)
for t in range(0, i)
  if a[0] > a[t]:
    a[0] = a[t]
  return a[0]

def max(a,i)
for t in range(0, i)
  if a[0] < a[t]:
    a[0] = a[t]
  return a[0]

def sum(a,i)
for t in range(1, i)
  a[0] += a[t]
  return a[0]

i = int(raw_input().split())
a = map(int, raw_input().split())
print "min(a,i) max(a,i) sum(a,i)"

### FIXED CODE ###

def min(a,i):
  x = a[0]
  for t in range(0, i):
    if x > a[t]:
      x = a[t]
  return x

def max(a,i):
  y = a[0]
  for t in range(0, i):
    if y < a[t]:
      y = a[t]
  return y

def sum(a,i):
  s = 0
  for t in range(0, i):
    s += a[t]
  return s

i = int(raw_input())
a = map(int, raw_input().split())
print "%d %d %d" % (min(a,i), max(a,i), sum(a,i))
A, B, H, M = map(int, input().split())

m_theta = (M/60)*2*pi
h_theta = 1/12*(H + M/60) * 2* pi
mh_theta = abs(m_theta - h_theta)

x = A**2 + B**2 - 2*A*B*cos(mh_theta)
x = sqrt(x)
print(x)


### FIXED CODE ###

import math
from math import cos,pi,sqrt,radians

A, B, H, M = map(float, input().split())

m_theta = (M/60.0)*2*pi
h_theta = 1/12.0*(H + M/60.0) * 2* pi
mh_theta = abs(m_theta - h_theta)

x = A**2 + B**2 - 2*A*B*cos(mh_theta)
x = sqrt(x)
print(x)
import sys
import numpy as np
a=[int(x)for x in list(sys.argv[1])]+[-1]
print(str(a[0]+0if(np.trim_zeros(np.diff(a))[0]<0)else 1)*3)


### FIXED CODE ###

import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline()[0:3])]+[-1]
print(str(a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*3)
N,M = [int(i) for i in input().split(" ")]
check_list = []

for _ in range(M):
    check_list.append([int(i) for i in input().split(" ")])

for i in range(10 ** (N + 1)):
    i = str(i)
    for j in check_list:
        if i[j[0] - 1] != str(j[1]):
            break
        else:
            continue
    else:
        print(i)
        break
else:
    print(-1)

### FIXED CODE ###

N,M = [int(i) for i in input().split(" ")]
check_list = []

for _ in range(M):
    check_list.append([int(i) for i in input().split(" ")])

for i in range(10 ** N):
    i = str(i)
    if len(i) != N:
        continue

    for j in check_list:
        if i[j[0] - 1] != str(j[1]):
            break
        else:
            continue
    else:
        print(i)
        break
else:
    print(-1)
n,m=map(int,input().split())
x=[]
for _ in range(n):
    x.append([])

for _ in range(m):
    s,c=map(int,input().split())
    x[s-1].append(c)
ans=''
for i in range(n):
    if len(set(x[i]))>=2:
        ans='-1'
        break
    if len(x[i])==0 and i==0:
        ans='1'
    if len(x[i])==0 and i!=0:
        ans='0'
    ans+=str(x[i][0])
print(int(ans))

### FIXED CODE ###

n,m=map(int,input().split())
a=[]
for _ in range(m):
    s,c=map(int,input().split())
    a.append([s,c])

ans=-1
if n==1:
    for i in range(10):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
else:
    for i in range(10**(n-1),10**n):
        x=str(i)
        c=0
        for j in range(m):
            if x[a[j][0]-1] == str(a[j][1]):
                c+=1          
        if c==m:
            ans=i
            break
print(ans)
n,m=map(int,input().split())
a=[]
b=[]
z=[]
x=[]
for i in range(n):
    a+=[[int(i) for i in input().split()]]
for i in range(m):
    b+=[[int(i) for i in input().split()]]
for i in range(n):
    for j in range(m):
        z+=[a[i][j]*b[j][0]]
    x+=[sum(z)]
    z=0
for i in range(m):
    print(x[m])

### FIXED CODE ###

n,m=map(int,input().split())
a=[]
b=[]
z=[]
x=[]
for i in range(n):
    a+=[[int(i) for i in input().split()]]
for i in range(m):
    b+=[[int(i) for i in input().split()]]
for i in range(n):
    for j in range(m):
        z+=[a[i][j]*b[j][0]]
    x+=[sum(z)]
    z=[]
for i in range(n):
    print(x[i])
#!/snap/bin/pypy3

MEMO = dict()

def search(n, data):
    global MEMO
    
    if n in MEMO:
        return MEMO[n]
    else:
        startfrom_n = [element[1] for element in data if element[0] == n]
        if not startfrom_n:
            MEMO[n] = 0
            return 0

        MEMO[n] = max(search(i, data) for i in startfrom_n) + 1
        return MEMO[n]


def main():
    N, M = map(int, input().split())
    data = [tuple(map(int, input().split())) for _ in range(M)]


    print(max(search(n, data) for n in range(1, N+1)))



if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/python3
import sys

MEMO = dict()

def search(n, data):
    global MEMO

    if n in MEMO:
        return MEMO[n]
    else:
        if not n in data:
            MEMO[n] = 0
            return 0

        MEMO[n] = max(search(i, data) for i in data[n]) + 1
        return MEMO[n]


def main():
    # sys.setrecursionlimit(65535)
    sys.setrecursionlimit(10**9)
    N, M = map(int, input().split())
    data = dict()
    for _ in range(M):
        x, y = map(int, input().split())
        if x not in data:
            data[x] = [y]
        else:
            data[x].append(y)

    print(max(search(n, data) for n in range(1, N+1)))



if __name__ == '__main__':
    main()
print(int(__file__[4])/2)

### FIXED CODE ###

_=int(input());c=0
for i in 'i¥½ÃÉ':
  if (_ < ord(i)):
    print(c)
    break
  c+=1
r = int(input(""))
g = int(input(""))
b = int(input(""))

r = r * 100
g = g * 10
b = b * 1

d = r + g + b
if d % 4 == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

r, g, b = map(str, input().split())
ans = r + g + b
# print(ans)
ans_i = int(ans)
 
if ans_i % 4 == 0:
    print('YES')
else:
    print('NO')
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
A_array = [input()[:-1] for s in range(H)]

ans_array = [[10000] * W for i in range(H)]
# print(ans_array)

for i, A in enumerate(A_array):
    black_index = [i for i, x in enumerate(A) if x == "#"]
    # print(black_index)
    for black in black_index:
        ans_array = [[
            min(ans_array[h][w],
                abs(h - i) + abs(w - black)) for w in range(W)
        ] for h in range(H)]
print(max([max(ans_array[i]) for i in range(H)]))

### FIXED CODE ###

from scipy import ndimage
import numpy as np
import sys
input = sys.stdin.readline

H, W = map(int, input().split())

A_array = np.array(
    [[0 if s == "#" else 1 for s in input()[:-1]] for i in range(H)])
# print(A_array)


# print(A_array)
b = ndimage.morphology.distance_transform_cdt(
    A_array, metric="taxicab")
print(np.max(b))
# -*- coding: utf-8 -*-

def solve():
    return str(int.__sub__(*map(int, input().split()),)+1)

if __name__ == '__main__':
    print(solve())


### FIXED CODE ###

# -*- coding: utf-8 -*-

def solve():
  N, K = map(int, input().split())
  return str(N-K+1)

if __name__ == '__main__':
    print(solve())
x,y,z,w = map(int,input().split())
a = z-x
b = w-y
print(str(z-b)+" "+str(w+a)+" "+str(x-b)+" "+str(y+a))

### FIXED CODE ###

k = int(input())
odd = 0
even = 0
if k%2==0:
    odd = k//2
    even = k//2
else:
    odd = k//2+1
    even = k//2
print(odd*even)
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
bcs = [list(map(int, input().split())) for i in range(M)]
"""
10 3
1 8 5 7 100 4 52 33 13 5
3 10
4 30
1 4
"""


# In[14]:


def binary_search(nbs, tar):
    #print(nbs, tar)
    ln = 0
    rn = len(nbs)-1
    t = int(len(nbs)/2)
    
    while ln < rn:
        comp = nbs[t]
        if tar >= comp and tar<nbs[t+1]:
            break
        elif tar >= comp: # 今の値がtar以下であれば、
            ln = t + 1 # 左端をt+1に更新
        elif tar < comp: # 今の値が
            rn = t - 1 # 右端をt-1に更新
        t = int((ln+rn)/2)
    return t


# In[16]:


sbcs = sorted(bcs, key=lambda x:x[1], reverse=True)
nb = 0
sA = sorted(A)
for i in range(M):
    if nb >= N: # nbがN以上になれば、終了
        break
    
    B, C = sbcs[i]
    las = nb+B-1
    las = las if las <N else N-1
    if sA[nb] >= C: # もしnb個目がC以上であれば、終了
        break
    elif sA[nb+B-1] <= C: #もしB個目が、C以下なら、B個目までをCにする
        sA[nb:nb+B] = [C]*B
        nb += B
    else: #nb個目がC未満で、nb+B-1個目がCより大きければ
        t = binary_search(sA[nb:nb+B], C) 
        t = t if nb+t < N else N-nb-1
        sA[nb:nb+t+1] = [C]*(t+1)
        nb += t+1
    
print(sum(sA))


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[1]:


import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
bcs = [list(map(int, input().split())) for i in range(M)]


# In[14]:


"""
def binary_search(nbs, tar):
    #print(nbs, tar)
    ln = 0
    rn = len(nbs)-1
    t = int(len(nbs)/2)
    
    while ln < rn:
        comp = nbs[t]
        if tar >= comp and tar<nbs[t+1]:
            break
        elif tar >= comp: # 今の値がtar以下であれば、
            ln = t + 1 # 左端をt+1に更新
        elif tar < comp: # 今の値がtarより大きければ、
            rn = t - 1 # 右端をt-1に更新
        t = int((ln+rn)/2)
    return t
"""


# In[16]:


sbcs = sorted(bcs, key=lambda x:x[1], reverse=True)
sA = sorted(A)

nb = 0
ans = 0
is_finish = False

for i in range(M):
    B, C = sbcs[i]
    
    for j in range(B):
        if nb < N and sA[nb] < C:
            ans += C
            nb += 1
        else:
            is_finish = True
            break
    
    if is_finish:
        break

if nb < N:
    ans += sum(sA[nb:])

print(ans)
        
"""
    if nb >= N: # nbがN以上になれば、終了
        break
    
    B, C = sbcs[i]
    las = nb+B-1
    las = las if las <N else N-1
    if sA[nb] >= C: # もしnb個目がC以上であれば、終了
        break
    elif sA[nb+B-1] <= C: #もしB個目が、C以下なら、B個目までをCにする
        sA[nb:nb+B] = [C]*B
        nb += B
    else: #nb個目がC未満で、nb+B-1個目がCより大きければ
        t = binary_search(sA[nb:nb+B], C) 
        t = t if nb+t < N else N-nb-1
        sA[nb:nb+t+1] = [C]*(t+1)
        nb += t+1
    
print(sum(sA))
"""


# In[ ]:
print(input.replace("?", "D"))

### FIXED CODE ###

print(input().replace("?", "D"))
N = int(input())
array = []

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  print(_input)
  array.append((int(_input[0]), int(_input[1], int(_input[2]))))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)

### FIXED CODE ###

N = int(input())
array = []

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  array.append((int(_input[0]), int(_input[1]), int(_input[2])))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)
import math

c  = input();

for var in range(0, int(c)) :
	n1 = input();
	n2 = input();
	sum = int(n1) + int(n2);

	if int(math.log10(sum)) + 1 > 80 :
		print("overflow");
	else :
		print(sum);

### FIXED CODE ###

for _ in range(int(input())) :
    n = int(input()) + int(input())
    if (n >= 10 ** 80) :
        print("overflow")
    else :
        print(n)
base = raw_input()


def toggleUpLo(char):
    if char.isupper():
        return char.lower()
    else:
        return char.upper()

new_str = [toggleUpLo(c) for c in base]
print(''.join(new_str)

### FIXED CODE ###

base = raw_input()


def toggleUpLo(char):
    if char.isupper():
        return char.lower()
    else:
        return char.upper()

new_str = [toggleUpLo(c) for c in base]
print(''.join(new_str))
a,b,c = map(int,input().split())
def newton_root(n):
    x = n/2.
    f = lambda x: x**2 - n
    f_prime = lambda x: 2*x
    while abs(f(x)) > 1e-4:
        x -= f(x)/f_prime(x)
                        % x = (x+n/x)/2
    return x
print(newton_root(1004))

### FIXED CODE ###

from decimal import *
import sys
a,b,c = map(int,input().split())
getcontext().prec = 500
if a + b >= c:
  print('No')
  sys.exit(0)
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
  print('Yes')
  sys.exit(0)
print('No')
S = input()
T = input()

for i in range(len(S)-len(T)+1):
    ok = False
    for j in range(len(T)):
        if S[i+j]!=T[j] and S[i+j]!='?':
            break
    else:
        S = S[:i] + T + S[i+len(T):]
        ok = True
        break

if ok:
    print(S.replace('?', 'a'))
else:
    print("UNRESTORABLE")


### FIXED CODE ###

S = input()
T = input()

if len(T) > len(S):
    print("UNRESTORABLE")
    exit()

ans = []

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if S[i+j]!=T[j] and S[i+j]!='?':
            break
    else:
        ans.append((S[:i] + T + S[i+len(T):]).replace('?', 'a'))

if len(ans) == 0:
    print("UNRESTORABLE")
else:
    ans.sort()
    print(ans[0])
A,B = map(int,input().split())

target = list()

target.append(A+B)
target.append(A-B)
target.append(A*B)

print(map(target))


### FIXED CODE ###

A,B = map(int,input().split())

target = list()

target.append(A+B)
target.append(A-B)
target.append(A*B)

print(max(target))
N=int(input())
x=[0]
y=[0]

for i in range(1,N):
  t,x_tmp,y_tmp=map(int,input().split())
  x.append(x_tmp)
  y.append(y_tmp)
  d=abs(x[i-1]-x[i])+abs(y[i-1]-y[i])
  if d>t or d%2!=t%2:
    print("No")
    flag=0
    break
  else:
    flag=1
    
if flag==1:
  print("Yes")

### FIXED CODE ###

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

N=a*b

if N%2==0:
  print("Even")
else:
  print("Odd")
n=int(input())
r=0
b=0
for i in range(n):
 t=int(input())
 if i==0!=t or b+1<t:print(-1);exit()
 elif b>=t:r+=b
 b=t
print(r+b)

### FIXED CODE ###

a,b,c,k=map(int,input().split())
print(a-b if k%2==0 else b-a)
h,w = map(int, input().split())

if w % 2 == 1:
    idle = int((w - 1) / 2)
    can = w - idle
    second = can - 1
    num = can + second
else:
    idle = int(w / 2)
    num = idle * 2
    
if h % 2 == 1:
    row = int(h // 2)
    print(num * row + can)
else:
    row = int(h / 2)
    print(num * row)

### FIXED CODE ###

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

if w == 1 or h == 1:
    print(1)
    exit()
    
if w == 2 and h == 2:
    print(2)
    exit()

if w % 2 == 1:
    idle = int((w - 1) / 2)
    can = w - idle
    second = can - 1
    num = can + second
elif w % 2 == 1 and h == 1:
    idle = int((w - 1) / 2)
    can = w - idle
    print(can)
    exit()
elif w % 2 == 0 and h == 1:
    print(1)
    exit()
else:
    idle = int(w / 2)
    num = idle * 2

if h % 2 == 1 and w % 2 == 0:
    print(int((w / 2) * h))
    exit()

if h % 2 == 1:
    row = int(h // 2)
    print(num * row + can)
else:
    row = int(h / 2)
    print(num * row)
import numpy as np
n = int(input())
h = list(map(int,input().split(' ')))
h_d = np.diff(h)

ans = 0
ans_a = [0]
first_h_d = h_d[0]

#print(h_d)
for i in h_d:
  if first_h_d <= i and  h_d[0]<= 0 :
    ans+=1
    first_h_d = i
  else:
    ans_a.append(ans)
    ans = 0
    first_h_d = i

print(max(ans_a))

### FIXED CODE ###

#import numpy as np
n = int(input())
h = list(map(int,input().split(' ')))
#h_d = np.diff(h)

ans = 0
ans_a = [0]
#first_h_d = h_d[0]
first_h = h[0]
#print(h_d)
for i in h[1:]:
  #print(first_h,i,first_h >= i)
  if first_h >= i:
    ans+=1
    first_h = i
  else:
    ans_a.append(ans)
 #   print(ans)
    ans = 0
    first_h = i

ans_a.append(ans)

print(max(ans_a))
s = input()

if s = "Rainy":
  print("Sunny")
elif s = "Sunny":
  print("Cloudy")
else:
  print("Rainy")

### FIXED CODE ###

s = input()

if s == "Rainy":
  print("Sunny")
elif s == "Sunny":
  print("Cloudy")
else:
  print("Rainy")
s = list(input())
k = int(input())

cnt = 0
c = 0
if s[0] == s[-1]:
  if s[-1] == s[-2]: cnt +=1
  else: c +=1
  s[-1] = ""

for i in range(len(s)-1):
  if s[i] == s[i+1]:
    s[i+1] = ""
    cnt += 1
print(k*cnt + (k-1)*c)

### FIXED CODE ###

s = list(input())
k = int(input())

if len(set(s)) == 1:
    print((len(s)*k)//2)
    exit()

def n_change(sss):
    s = sss.copy()
    x = 0
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            s[i] = "X"
            x += 1
    return x

print(n_change(s) + (k-1) * (n_change(2*s) - n_change(s)))
if A >= B+2:
    n = 2*A - 1
elif A <= B-2:
    n = 2*B - 1
else:
    n = A+B
    
print(n)

### FIXED CODE ###

A,B = map(int, input().split())

if A >= B+2:
    n = 2*A - 1
elif A <= B-2:
    n = 2*B - 1
else:
    n = A+B
    
print(n)
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

for i in range(101):  # x座標
    for j in range(101):  # y座標
        tmp_h = abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
        cnt = 0
        for k in range(N):
            if tmp_h == abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]:
                cnt += 1
        if cnt == N:
            ans_x = i
            ans_y = j
            ans_h = tmp_h
            break
print(ans_x, ans_y, ans_h)
            

### FIXED CODE ###

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

for i in range(N):
    if xyh[i][2] != 0:
        x = xyh[i][0]
        y = xyh[i][1]
        h = xyh[i][2]

for i in range(101):  # x座標
    for j in range(101):  # y座標
        tmp_h = abs(x-i)+abs(y-j)+h
        cnt = 0
        for k in range(N):
            if xyh[k][2] == max(0,tmp_h-abs(xyh[k][0]-i)-abs(xyh[k][1]-j)):
                cnt += 1
        if cnt == N:
            ans_x = i
            ans_y = j
            ans_h = tmp_h
            break
print(ans_x, ans_y, ans_h)