Harryxun/stf_run huggingface dataset:
class Tree:
  C, RL = {}, {}
  R, N, D, S, P = None, None, None, None, None
  def __init__(s, num):
    s.N = num
  def setC(s, a, b):
    if a in s.C: s.C[a].append(b)
    else: s.C[a] = [b]
    if b in s.C: s.C[b].append(a)
    else: s.C[b] = [a]
  def makeRank(s, root):
    s.R = [0] * s.N
    s.R[root] = 1
    s.RL[1] = [root]
    s.S = {}
    s.P = {}
    F = [root]
    s.D = 2
    while F != []:
      Ft = []
      s.RL[s.D] = []
      for i in F:
        for j in s.C[i]:
          if s.R[j] == 0:
            s.R[j] = s.D
            Ft.append(j)
            s.RL[s.D].append(j)
            if i not in s.S:
              s.S[i] = [j]
            else:
              s.S[i].append(j)
            s.P[j] = i

      s.D += 1
      F = Ft
  def getDeep(s, x):
    ans = 0
    if x in s.S:
      for i in s.S[x]:
        ans = max(ans, s.getDeep(i))
      return ans + 1
    else:
      return 0
  def getParent(s, x, n):
    if n == 0:
      return x
    return s.getParent(s.P[x], n - 1)
    

N, u, v = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N - 1)]

T = Tree(N)
for a, b in AB:
  T.setC(a - 1, b - 1)

T.makeRank(v - 1)
t = (T.R[u - 1] // 2) - 1
f = T.R[u - 1] % 2
k = T.getDeep(T.getParent(u - 1, t))
print(t + k + f)



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

class Tree:
  C, RL = {}, {}
  R, N, D, S, P = None, None, None, None, None
  def __init__(s, num):
    s.N = num
  def setC(s, a, b):
    if a in s.C: s.C[a].append(b)
    else: s.C[a] = [b]
    if b in s.C: s.C[b].append(a)
    else: s.C[b] = [a]
  def makeRank(s, root):
    s.R = [0] * s.N
    s.R[root] = 1
    s.RL[1] = [root]
    s.S = {}
    s.P = {}
    F = [root]
    s.D = 2
    while F != []:
      Ft = []
      s.RL[s.D] = []
      for i in F:
        for j in s.C[i]:
          if s.R[j] == 0:
            s.R[j] = s.D
            Ft.append(j)
            s.RL[s.D].append(j)
            if i not in s.S:
              s.S[i] = [j]
            else:
              s.S[i].append(j)
            s.P[j] = i

      s.D += 1
      F = Ft
  def getDeep(s, x):
    ans = 0
    if x in s.S:
      for i in s.S[x]:
        ans = max(ans, s.getDeep(i))
      return ans + 1
    else:
      return 0
  def getParent(s, x, n):
    if n == 0:
      return x
    return s.getParent(s.P[x], n - 1)
    

N, u, v = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(N - 1)]

T = Tree(N)
for a, b in AB:
  T.setC(a - 1, b - 1)

T.makeRank(v - 1)
t = (T.R[u - 1] // 2) - 1
f = T.R[u - 1] % 2
k = T.getDeep(T.getParent(u - 1, t))
print(t + k + f)
while True:
    t=int(input())
    n=int(input())
    b=0
    if t == 0:
        break
    for i in range(n):
        s,f=map(int,input().split())
        a=f-s
        b+=a
    if t<=b:
        print("OK")
    else:
        print(t-b)


### FIXED CODE ###

while True:
    t=int(input())
    if t == 0:
        break
    n=int(input())
    b=0
    for i in range(n):
        s,f=map(int,input().split())
        a=f-s
        b+=a
    if t<=b:
        print("OK")
    else:
        print(t-b)
N = int(input())
L = input().split()
L = [int(i) for i in L ]
total = 0

L_sort = sorted(L)


def test(total):
	for i in range(N-2):
		for j in range(i+1,N - 1):
							temp_L = L_sort[j + 1:]
							
							#total += len(temp_L[temp_L < L_sort[i]+ L_sort[j]])
							temp_L = [k for k in temp_L if k < L_sort[i]+ L_sort[j]]
							total += len(temp_L)

	return total
						
				  	
print(test(total))


### FIXED CODE ###

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

x = A - (2 * B)

if x >= 0:
	print(x)
elif x < 0:
	print(0)
while 1:
        n = input()
        if n == 0: break
        for i in range(n):
                if i == 0: ns = str(input())
                temp = ''
                count = 1
                for i in range(len(ns)-1):
                        if ns[i] == ns[i+1]:
                                count += 1
                        else:
                                temp += str(count)+ns[i]
                                count = 1
                temp += str(count)+ns[-1]
                ns = temp
        print ns

### FIXED CODE ###

while 1:
        n = input()
        if n == 0: break
        for j in range(n):
                if j == 0: ns = raw_input()
                temp = ''
                count = 1
                for i in range(len(ns)-1):
                        if ns[i] == ns[i+1]:
                                count += 1
                        else:
                                temp += str(count)+ns[i]
                                count = 1
                temp += str(count)+ns[-1]
                ns = temp
        print ns
s = list(map(int,input().split()))
if s[0] <= 1 and s[1] <= 2:
    if s[2] <= 1 and s[3] <= 2:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif s[2] <= 1 and s[3] <= 2:
    print('YYMM')
else:
    print('NA')

### FIXED CODE ###

s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
if s1 == s2 == 0:
    print('NA')
elif s1 <= 12 and s2 <= 12 and s1 >= 1 and s2 >= 1:
    print('AMBIGUOUS')
elif s1 <= 12 and s1 >= 1:
    print('MMYY')
elif s2 <= 12 and s2 >= 1:
    print('YYMM')
else:
    print('NA')
n = int(input())

s = input().split()
color = "Three"

for i in s:
    if i == "Y":
        color = "Four"
        break
print(color)

### FIXED CODE ###

n = int(input())

count = 0

if n <= 2:
    print(count)
else:
    while n >= 3:
        n -= 3
        count += 1
    print(count)
a = raw_input()
x,y = a.split()
n = int(x)
m = int(y)
print n*m + " " + n*2 + m*2

### FIXED CODE ###

x = raw_input().split(" ")
 
a = int(x[0])
b = int(x[1])
 
print str(a*b) + " " + str(2*(a+b))
N = int(input())
W = list(map(int, input().split()))

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)

### FIXED CODE ###

import numpy as np

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

diff = np.abs(np.sum(W[0]) - np.sum(W[0:]))
for i in range(N):
    S_1 = np.sum(W[:i])
    S_2 = np.sum(W[i:])
    if S_1 > S_2:
        if diff > np.abs(S_1 - S_2):
            print(np.abs(S_1 - S_2))
        else:
            print(diff)
        break
    elif S_1 == S_2:
        print(0)
    diff = np.abs(S_1 - S_2)
n,m=map(int,input().split())
w=[0]
if n<100:
    print(w[100])
l=[int(i) for i in input().split()]
d=[0]
for i in l:
    #d.append(i+d[-1])
    d.append((i+d[-1])%m)
d.append(0)
ans=0
for i in range(n):
    for j in range(i+1,n+1):
        p=abs(d[j]-d[i])
        if p%m==0: ans+=1
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
l=[int(i) for i in input().split()]
w=[0]
for i in l:
    w.append((i+w[-1])%m)
ans=0
d={}
for i in w:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
for i in d:
    ans+=d[i]*(d[i]-1)
print(ans//2)
N = int(input())
A = [int(_) for _ in input().split(" ")]
 
ans = sorted(range(1, len(A) + 1), key=lambda x:A[x - 1])
print(*ans)

### FIXED CODE ###

N = int(input())

if N == 1:
    print(1)
elif N % 2 == 1:
    print((N // 2 + 1) / N)
else:
    print(0.5)
A, B, C = map(int, input().split())

if A * B * C == 5 * 5 * 7:
    print('Yes')
else:
    pritn('No')

### FIXED CODE ###

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

if A*B*C == 5*5*7:
    print('YES')
else:
    print('NO')
n,m=map(int,input().split())

a=[1,1]
for i in range(2,10000):
    a.append((a[i-1]+a[i-2])%1000000007)
bad=[]
for i in range(m):
    bad.append(int(input()))
num=[]
before=0
bad_flag=0
# print(bad)
for i in range(len(bad)):
    nxt=bad[i]-before-1
    if nxt==-1:
        bad_flag=1
        break
    num.append(nxt)
    before=bad[i]+1
num.append(n-bad[len(bad)-1]-1)
if bad_flag:
    print(0)
else:
    ans=0
    last=1
    for i in num:
        # print(num,a[i])
        ans=a[i]*last
        last=ans%1000000007
    print(last)
    

### FIXED CODE ###

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

a=[1,1]
for i in range(2,100001):
    a.append((a[i-1]+a[i-2])%1000000007)

bad=[]
for i in range(m):
    bad.append(int(input()))
num=[]
before=0
bad_flag=0

if m!=0:
    for i in range(len(bad)):
        nxt=bad[i]-before-1
        if nxt==-1:
            bad_flag=1
            break
        num.append(nxt)
        before=bad[i]+1
    num.append(n-bad[len(bad)-1]-1)
else:
    num.append(n)
if bad_flag:
    print(0)
else:
    ans=0
    last=1
    for i in num:
        ans=a[i]*last
        last=ans%1000000007
    print(last)
#import matplotlib.pyplot as plt

def main():
    a,b,n = map(int,input().split())
    mx = 0
    for x in range(1,min(a+1,n+1)):
        left = ia*x/b//1
        right = a * x/b//1
        #print("x=",x,"floor(Ax/B)=",int(a*x//b),"A*floor(x/B)=",a * int(x // b),"answer=",left-right)
        #right.append(a * int(x/b))

        mx = max(left-right,mx)
    print(mx)


    #plt.plot(list(range(len(right))),right,label="test")


if __name__ == '__main__':
    main()


### FIXED CODE ###

#import matplotlib.pyplot as plt

def main():
    a,b,n = map(int,input().split())
    x = min(b-1,n)



    print(int(a*x/b) - a * int(x/b))


    #plt.plot(list(range(len(right))),right,label="test")


if __name__ == '__main__':
    main()
n = int(input())

import math

f = math.factorial(n)

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

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return divisors

d = make_divisors(f)

print(len(d))

### FIXED CODE ###

n = int(input())

import math

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

def make_divisors(n):
  divisors = []
  mod = 10**9 + 7
  s = (n**0.5)%mod
  for i in range(1, int(s)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return divisors

p = []
for i in range(1, n+1):
  p += prime_factorize(i)

import collections
pc = collections.Counter(p)

a = 1
for v, c in pc.items():
  a *= c+1

mod = 10**9 +7
print(a%mod)
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,k = map(int,input().split())
ans = []
if b-a + 1<=k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(k):
        ans.append(a+i)
    for i in range(b-k+1,b+1):
        ans.append(i)
    ans = set(ans)
    ans = list(ans)
    ans.sort()
    print(ans)


### FIXED CODE ###

import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

a,b,k = map(int,input().split())
ans = []
if b-a<=k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        ans.append(i)
    for i in range(b-k+1,b+1):
        ans.append(i)
    ans = set(ans)
    ans = list(ans)
    ans.sort()
    for i in range(len(ans)):
        print(ans[i])
n = int(input())
l = [[] for _ in range(n+1)]
s = [0 for _ in range(n+1)]
ll = []
for i in range(n-1):
  ai,bi = map(int,input().split())
  l[ai].append([bi,i])
  l[bi].append([ai,i])
  s[ai] += 1
  s[bi] += 1
mx = 0
for i in range(1,n+1):
  if s[i] > mx:
    mx = s[i]
    mxi = i
print(mx)
ans = [0 for _ in range(n-1)]
def dfs(a,b,c):
  i = 1
  for h,j in l[a]:
    if h != b:
      if i == c:
        i += 1
      ans[j] = i
      dfs(h,a,i)
      i += 1
  return
dfs(mxi,0,0)
for a in ans:
  print(a)

### FIXED CODE ###

import sys
import resource
sys.setrecursionlimit(10**5)
n = int(input())
l = [[] for _ in range(n+1)]
s = [0 for _ in range(n+1)]
ll = []
for i in range(n-1):
  ai,bi = map(int,input().split())
  l[ai].append([bi,i])
  l[bi].append([ai,i])
  s[ai] += 1
  s[bi] += 1
mx = 0
for i in range(1,n+1):
  if s[i] > mx:
    mx = s[i]
    mxi = i
print(mx)
ans = [0 for _ in range(n-1)]
def dfs(a,b,c):
  i = 1
  for h,j in l[a]:
    if h != b:
      if i == c:
        i += 1
      ans[j] = i
      dfs(h,a,i)
      i += 1
  return
dfs(mxi,0,0)
for x in ans:
  print(x)
n=input()
a=0
for i in n:
  a+=int(n[i])
print("Yes") if int(n)//a else print("No")

### FIXED CODE ###

n=input()
a=0
for i in n:
  a+=int(i)
print("Yes") if int(n)%a==0 else print("No")
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

t1 = t.replace("r","P")
t2 = t1.replace("s","R")
t3 = t2.replace("p","S")

# print(t3)
T = list(t3)
# print(T)
minus = 0
ls = ["R","S","P"]
for i in range(k,n):
    if i < n-k:
        tmp = T[i]
        before = T[i-k]
        after = T[i+k]
        if tmp == before:
            ls.remove(tmp)
            if tmp == after:
                T[i] = ls[0]
            else:
                ls.remove(after)
                T[i] = ls[0] 
                ls.append(after)
            ls.append(tmp)
            # if tmp == "R":
            #     minus += r
            # elif tmp == "S":
            #     minus += s
            # else:
            #     minus += p
            if T[i] == "R":
                minus += r
            elif T[i] == "S":
                minus += s
            elif T[i] == "P":
                minus += p
        else:
            pass
    elif i >= n-k:
        tmp = T[i]
        before = T[i-k]
        # after = T[i+k]
        if tmp == before:
            ls.remove(tmp)
            # if tmp == after:
            #     T[i] = ls[0]
            # else:
            #     ls.remove(after)
            #     T[i] = ls[0] 
            #     ls.append(after)
            tmp = ls[0]
            ls.append(tmp)
            # if tmp == "R":
            #     minus += r
            # elif tmp == "S":
            #     minus += s
            # else:
            #     minus += p
            if T[i] == "R":
                minus += r
            elif T[i] == "S":
                minus += s
            elif T[i] == "P":
                minus += p
        else:
            pass

# print(T)
p1 = r * T.count("R")
# print(p1)
p2 = s * T.count("S")
# print(p2)
p3 = p * T.count("P")
# print(p3)
# print(minus)

print(p1+p2+p3-minus)

### FIXED CODE ###

n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

t1 = t.replace("r","P")
t2 = t1.replace("s","R")
t3 = t2.replace("p","S")

# print(t3)
T = list(t3)
# print(T)
minus = 0
ls = ["R","S","P"]
for i in range(k,n):
    if i < n-k:
        tmp = T[i]
        before = T[i-k]
        after = T[i+k]
        if tmp == before:
            ls.remove(tmp)
            if tmp == after:
                T[i] = ls[0]
            else:
                ls.remove(after)
                T[i] = ls[0] 
                ls.append(after)
            ls.append(tmp)
            if T[i] == "R":
                minus += r
            elif T[i] == "S":
                minus += s
            elif T[i] == "P":
                minus += p
        else:
            pass
    elif i >= n-k:
        tmp = T[i]
        before = T[i-k]
        # after = T[i+k]
        if tmp == before:
            ls.remove(tmp)
            T[i] = ls[0]
            ls.append(tmp)
            if T[i] == "R":
                minus += r
            elif T[i] == "S":
                minus += s
            elif T[i] == "P":
                minus += p
        else:
            pass

# print(T)
p1 = r * T.count("R")
# print(p1)
p2 = s * T.count("S")
# print(p2)
p3 = p * T.count("P")
# print(p3)
# print(minus)

print(p1+p2+p3-minus)
N = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 + 7
ans = 1

lst = [0] * 3

for aa in a:
    cnt = 0
    for i, l in enumerate(lst):
        if l == aa:
            cnt += 1
            j = i
    ans *= cnt
    lst[j] += 1
print(ans%MOD)

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 + 7
ans = 1

lst = [0] * 3

for aa in a:
    cnt = 0
    j = -1
    for i, l in enumerate(lst):
        if l == aa:
            cnt += 1
            j = i
    if j == -1:
        ans = 0
        break
    ans *= cnt
    ans %= MOD
    lst[j] += 1

print(ans)
temp=input().split()
H=int(temp[0])
W=int(temp[1])
h=int(temp[2])
w=int(temp[3])

countT=0
ans=[]
if H%h==0 and W%w==0:
	print("No")
else:
	for i in range(H):
		tempAns=[]
		for j in range(W):
			if (i+1)%h==0 and (j+1)%w==0:
				countT-=h*w
				tempAns.append(-1*h*w)
			else:
				tempAns.append(1)
				countT+=1
		ans.append(tempAns)
		print("Yes")
		for i in range(H):
			for j in range(W):
				print(ans[i][j],end="")
				if j!=W-1:
					print(" ",end="")
			print()


### FIXED CODE ###

H,W,h,w=[int(i) for i in input().split()]

if H%h==0 and W%w==0:
        print("No")
elif W%w!=0:
        print("Yes")
        for y in range(H):
                for x in range(W):
                        if x!=0:
                                print(" ",end="")
                        if (x%w)!=(w-1):
                                print(100000,end="")
                        else:
                                print(-100000*(w-1)-1,end="")
                print()
else:
        print("Yes")
        for y in range(H):
                for x in range(W):
                        if x!=0:
                                print(" ",end="")
                        if (y%h)!=(h-1):
                                print(100000,end="")
                        else:
                                print(-100000*(h-1)-1,end="")
                print()
N,A,B= map(int,input().split(' '))
x=A*N
if x>B:
  print(B)
elif x=B:
  print(B)
else ;
  print(x)

### FIXED CODE ###

n,a,b=map(int,input().split())
print(min(n*a,b))
L = set([int(x) for x in stdin.readline().rstrip().split()])
print(sum(L)-max(L))

### FIXED CODE ###

l = list(map(int, input().split()))
print(sum(l)-max(l))
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    count = 0
    B =[]
    for j in range(len(A)):
        if A[j]==i:
            count =+ 1
        else:
            B.append(A[j])
    print(count)
    A = B

### FIXED CODE ###

import math
r = int(input())
print(2*r*math.pi)
import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
b = np.abs(a)
b = sorted(a,reverse = True)
b_k = b[k] 
a_new = [a[i] for i in range(len(a)) if np.abs(a)[i] > b_k]
 
comb = itertools.combinations(a_new,k)  
l = [list(_) for _ in comb]  
A = (functools.reduce(operator.mul,l[_]) for _ in range(len(l)))
l_max = max(A)
waru = 10**9 + 7
print(l_max % waru)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
n, q = map(int, input().split()) # input:"2 2"
s = str(input())
#どこにACがあるかを計算しておいて、あとからL,Rでsplitする
ans=[0]*n
for i in range(n):
  if s[i]=='A' and s[i+1]=='C':
    ans[i]=1
for i in range(q):
  l, r = map(int, input().split()) #ループ内で一行ずつ読み込む
  print(sum(ans[L[i]-1:R[i]-1]))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  if S[i : i + 2] == 'AC':
    t[i + 1] = t[i] + 1
  else:
    t[i + 1] = t[i]
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    b = 4/0
    print "No"


### FIXED CODE ###

N = int(raw_input())
a = [int(i[-2:])for i in raw_input().split(" ")]

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    print "No"
n = int(input())
xyhn = [None] * n
for i in range(n):
    xyhn[i] = list(map(int, input().split(' ')))

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))



### FIXED CODE ###

n = int(input())
xyhn = [None] * n
for i in range(n):
    xyhn[i] = list(map(int, input().split(' ')))

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if xyhn[k][2] > 0 and tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
            if xyhn[k][2] == 0 and abs(cx - xyhn[k][0]) + abs(cy - xyhn[k][1]) < tmp_h:
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))
h, w, m = map(int, input().split())
 
mp = []
hp = [0] * h
wp = [0] * w
 
for i in range(m):
    l = list(map(int, input().split()))
    mp.append(l)
    hp[l[0]-1] += 1
    wp[l[1]-1] += 1
 
maxhp = max(hp)
maxwp = max(wp)
hpdex = [i for i, x in enumerate(hp) if x == maxhp]
wpdex = [i for i, x in enumerate(wp) if x == maxwp]
 
for i in range(len(hpdex)):
    for j in range(len(wpdex)):
        if [hpdex[i] + 1, wpdex[j] + 1] not in mp:
            print(maxhp + maxwp)
            exit()
 
print(maxhp + maxwp - 1)


### FIXED CODE ###


n, x, t = map(int, input().split())
if n % x == 0:
    print(n // x * t)
else:
    print((n // x + 1) * t)
n = int(input())
f = list(map(int, input().split()))

def dp(i, cur):
  if i==n-1:
    return cur
  if i == n-2:
    cur += abs(f[i] - f[i+1])
    return dp(i+1, cur)
  else:
    return min(dp(i+1, cur + abs(f[i] - f[i+1])), dp(i+2, cur + abs(f[i] - f[i+2])))
print(dp(0, 0))

### FIXED CODE ###

n = int(input())
arr = list(map(int, input().split()))
if n == 2:
    print(abs(arr[0] - arr[1]))
    exit()
dp = [10 ** 9 for _ in range(n)]
dp[0] = abs(arr[0] - arr[1])
dp[1] = min(abs(arr[2] - arr[0]), abs(arr[2] - arr[1]) + dp[0])

for i in range(3, n):
    dp[i - 1] = min(
        abs(arr[i] - arr[i - 1]) + dp[i - 2], abs(arr[i] - arr[i - 2]) + dp[i - 3]
    )

# dp[2] = min(abs(arr[3] - arr[2]) + dp[1], abs(arr[3] - arr[1]) + dp[0])
# dp[3] = min(abs(arr[4] - arr[3]) + dp[2], abs(arr[4] - arr[2]) + dp[1])
# dp[4] = min(abs(arr[5] - arr[4]) + dp[3], abs(arr[5] - arr[3]) + dp[2])

print(dp[-2])