Harryxun/stf_run huggingface dataset:
import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
'''
ans = 0
for i in range(N):
    pA = A[i] * A[i+1:]
    ans += pA.sum()

print(int(ans % (1e9+7)))
'''
a = np.tile(A,(N, 1))
a = a * a.T

a_diag = np.diag(a).sum()
a = ((a.sum()-a_diag)/2)
#print(a/10e9+7)
print(int(np.mod(a, 10**9+7)))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
D = 1000000007


ans = 0
B = [0] * (N + 1)

for i in range(N-1, -1, -1):
    B[i] = (B[i+1] + A[i]) % D

for i in range(0, N-1):
    ans += (A[i] * B[i+1]) % D

print(int(ans % D))
N,M=map(int,input().split())
list=[[] for j in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  list[a-1]+="Y"
  list[b-1]+="Y"
for i in range(M):
  print(len(list[i]))

### FIXED CODE ###

N,M=map(int,input().split())
list=[[] for j in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  list[a-1]+="Y"
  list[b-1]+="Y"
for i in range(N):
  print(len(list[i]))
(a, b) = [int(x) for x in input().split()]

x = a // b
y = a % b
z = a / b

print('{1} {2} {3:6f}'.format(x, y, z));

### FIXED CODE ###

(a, b) = [int(i) for i in input().split()]
d = int (a / b)
r = a % b
f = a / b
print('%s %s %.5f' % (d, r, f))
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
a=[1]*(m+1)
for i in range(n):
    b=a[:]
    k=0
    for j in range(m):
        b[j]=(k+b[j])%(10**9+7)
        if s[i]==t[j]:
            k=(k+a[j])%(10**9+7)
    b[-1]=(k+b[-1])%(10**9+7)
    a=b[:]
print(a[-1]%(10**9+7))
~                                             

### FIXED CODE ###

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [1] * (M+1)
dpleft = [0] * (M)
MOD = 10 ** 9 + 7
ndp = [1] * (M+1)
for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            ndp[m+1] = ndp[m] + dp[m+1]
            dpleft[m] = dp[m+1]
        else:
            ndp[m+1] = ndp[m] + dpleft[m]
    dp = ndp[:]
print(dp[-1] % MOD)
n=int(input())
s,t=str(input().split())
for i in range(n):
    print(s[i], end='')
    print(t[i], end='')

### FIXED CODE ###

n=int(input())
s,t=input().split(' ')
for i in range(n):
    print(s[i], end='')
    print(t[i], end='')
az = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
sum_az = [0 for x in range(26)]

while True:
    x = raw_input()
    if not x:
        break
    x.lower()
    for i in range(26):
        for j in range(len(x)):
            if x[j] == az[i]:
                sum_az[i] += 1


for i in range(26):
    print ("%s : %d" % (az[i], sum_az[i]))
                

### FIXED CODE ###

import sys
az =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
sum_az = [0 for x in range(26)]

for x in sys.stdin.read().lower():
    for i in range(26):
        if x == az[i]:
            sum_az[i] += 1


for i in range(26):
    print ("%s : %d" % (az[i], sum_az[i]))
s=input()


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

### FIXED CODE ###

s=input()
 
 
if s=="Sunny":
  print("Cloudy")
elif s=="Cloudy":
  print("Rainy")
elif s=="Rainy":
  print("Sunny")
a[0],a[1],a[2] = map(int, raw_input().split())


print a[0],a[1],a[2]

### FIXED CODE ###

a,b,c = sorted(map(int, raw_input().split()))
print a,b,c
# from math import gcd
import math
N = int(input())
A = list(map(int,input().split()))
# N=3
# A=[12 ,15 ,18]
l=[0]*N
r=[0]*N
l[0]=A[0]
r[0]=A[N-1]
for i in range(1,N-1):
    l[i]=math.gcd(l[i-1],A[i])
    r[i]=math.gcd(r[i-1],A[N-1-i])    
gcdlist = [1,l[N-2],r[N-2]]
for i in range(N-2):
    gcdlist.append(math.gcd(l[i],r[N-3-i]))
# print(gcdlist)
print(max(gcdlist))

### FIXED CODE ###

from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
# N=3
# A=[12 ,15 ,18]
l=[0]*N
r=[0]*N
l[0]=A[0]
r[0]=A[N-1]
for i in range(1,N-1):
    l[i]=gcd(l[i-1],A[i])
    r[i]=gcd(r[i-1],A[N-1-i])    
gcdlist = [1,l[N-2],r[N-2]]
for i in range(N-2):
    gcdlist.append(gcd(l[i],r[N-3-i]))
#print(gcdlist)
print(max(gcdlist))
import math
n, m = [int(i) for i in input().split()]
p = [0 for i in range(n + 1)]
for _ in range(m):
    p[int(input())] = 1
    
a = []
a.append(1)
if p[1] == 1:
    a.append(0)
else:
    a.append(1)
for i in range(2, n + 1):
    if p[i] == 1:
        a.append(0)
    else:
        a.append((a[i - 2] + a[i - 1]) % 1000000007)
    
print(a[n])

### FIXED CODE ###

p = (int(i) for i in input().split())
p = sorted(p)
print(p[0] + p[1])
N = int(input())
B = list(map(int, input().split()))

B.sort()
A=[]
A.append([B[0]])

for i in range(N):
    if i>0 && i < N-1 :
        A.append(min(B[i-1],B[i],B[i+1]))
    if i == N-1:
        A.append(B[N-1])
print(sum(A))

### FIXED CODE ###

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

A=[]
A.append(B[0])
for i in range(0,N-2):
    if i>=1 & i < N-2:
      A.append(min(B[i],B[i+1]))
      
A.append(B[-1])
print(sum(A))
x = input()

if s.is_super:
  print("A")
else:
  print("a")

### FIXED CODE ###

x = input()

if x in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
  print('a')
else:
  print('A')
a,b=map(int,input().split())
if a=b:
  print("H")
else:
  print("D")
  

### FIXED CODE ###

a,b=input().split()
if a==b:
  print("H")
else:
  print("D")
n = int(input())

l = [input() for _ in range(4)]

count = len(set(l))
flag = True
for i in range(len(l) -1 ):
    if l[i][len(l[i]) -1] != l[i+1][0]:
        flag = False
        break

if flag and count == n:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())

l = [input() for _ in range(n)]

count = len(set(l))
flag = True
for i in range(len(l) -1 ):
    if l[i][len(l[i]) -1] != l[i+1][0]:
        flag = False
        break

if flag and count == n:
    print("Yes")
else:
    print("No")
x = int(input())
 
if 400 < = x and x <= 599:
  print(8)
elif x <= 799:
  print(7)
elif x <= 999:
  print(6)
elif x <= 1199:
  print(5)
elif x <= 1399:
  print(4)
elif x <= 1599:
  print(3)
elif x <= 1799:
  print(2)
else:
  print(1)

### FIXED CODE ###

x = int(input())
 
if 400 <= x and x <= 599:
  print(8)
elif x <= 799:
  print(7)
elif x <= 999:
  print(6)
elif x <= 1199:
  print(5)
elif x <= 1399:
  print(4)
elif x <= 1599:
  print(3)
elif x <= 1799:
  print(2)
else:
  print(1)
n=int(input())
a=int(input())
b=int(input())

if n==1:
  print('Hello World')
elif n==2:
  print(a+b)

### FIXED CODE ###

n=int(input())

if n==1:
  print('Hello World')
elif n==2:
  a=int(input())
  b=int(input())
  print(a+b)
N, W = map(int, input().split())

Ws = []
Vs = []

for _ in range(N):
  w, v = map(int, input().split())
  Ws.append(w)
  Vs.append(v)

Ans = [[0 for _ in range(N * max(Vs))+1] for _ in range(N)]

Ans[0][Vs[0]] = Ws[0]

for i in range(1, N):
  for v in range(N*max(Vs)+1):
    if v-Vs[i] >= 0:
      Ans[i][v] = max(Ans[i-1][v-Vs[i]] + Ws[i], Ans[i-1][v], Ans[i][v])
    else:
      Ans[i][v] = max(Ans[i-1][v], Ans[i][v])

AnsW = Ans[N-1]
AnsW.sorted()
for i in range(len(AnsW)-1):
  if AnsW[i+1] > W:
    print(AnsW[i])
    break

### FIXED CODE ###

import sys
import pdb
input = sys.stdin.readline

N, W = map(int, input().split())
ws = [0]
vs = [0]

for _ in range(N):
  w, v = map(int, input().split())
  ws.append(w)
  vs.append(v)

inf = 2e11
V = int(sum(vs))   # N * max(vs)
# V = int(100 * 1e3)   # N * max(vs)
# Weight[i番目までの品番][価値j]
Weight = [[inf for _ in range(V+1)] for __ in range(N+1)]

if ws[1] <= W:
  Weight[1][vs[1]] = ws[1]
  value_max = vs[1]
else:
  value_max = 0

for _ in range(N+1):
  Weight[_][0] = 0

# pdb.set_trace()

for num in range(2, N+1):
  for value in range(1, V+1):
    if value >= vs[num]:   # 新しい品物を入れられるとき
      Weight[num][value] = min(Weight[num][value], Weight[num-1][value], Weight[num-1][value-vs[num]] + ws[num])
      if Weight[num][value] <= W:
        value_max = max(value_max, value)
      else:
        Weight[num][value] = inf
    else:   # 新しい品物を入れられないとき
      # 重さを変えることはできない
      Weight[num][value] = Weight[num-1][value]
      # Weight[num][value] = max(Weight[num][value], Weight[num-1][value])

# print(Weight)
print(value_max)
import sys
a=[map(int,i.split())for i in sys.stdin]
print(*sorted(a,reverse=True)[:3],sep='\n')


### FIXED CODE ###

a=[int(input()) for i in range(10)]
a.sort(reverse=True)
for i, iv in enumerate(a):
	print(iv)
	if i >= 2:
		break
s=input()
cnt=0
for i range(1,len(s)):
  if s[i]!=s[i-1]:
    cnt+=1
print(cnt)

### FIXED CODE ###

s=input()
cnt=0
for i in range(1,len(s)):
  if s[i]!=s[i-1]:
    cnt+=1
print(cnt)
import itertools

H,W,K = map(int, input().split())
p = 1000000007

if K - 1 > H:
    print(0)
    exit(0)

R = []
for r in itertools.product( [0,1], repeat=(W-1) ):
    if 1 not in list(map(lambda i : r[i]*r[i+1], range(len(r)-1)) ):
        R.append(r)


M = [ (
    len( list( filter( lambda r:r[0]==0, R) ) ),
    len( list( filter( lambda r:r[0]==1, R) ) ),
    0
) ]
for c in range(1,W-1):
    M.append((
        len( list( filter( lambda r:r[c]==0 and r[c-1]==0, R) ) ),
        len( list( filter( lambda r:r[c]==1, R) ) ),
        len( list( filter( lambda r:r[c-1]==1, R) ) )
    ))
M.append((
    len( list( filter( lambda r:r[W-2]==0, R) ) ),
    0,
    len( list( filter( lambda r:r[W-2]==1, R) ) )
))

count = [1] + [0]*(W-1)
for h in range(H):
    count_ = [0] * W
    for num,c in zip(count, range(len(count))):
        for m,n in zip(M[c], [0,+1,-1]):
            if c+n >= 0 and c+n < W:
                count_[c+n] += num * m
    count = count_
        
print(count_[K-1]%p)    
    


### FIXED CODE ###

import itertools

H,W,K = map(int, input().split())
p = 1000000007

if K - 1 > H:
    print(0)
    exit(0)
if W == 1:
    print(1)
    exit(0)

R = []
for r in itertools.product( [0,1], repeat=(W-1) ):
    if 1 not in list(map(lambda i : r[i]*r[i+1], range(len(r)-1)) ):
        R.append(r)


M = [ (
    len( list( filter( lambda r:r[0]==0, R) ) ),
    len( list( filter( lambda r:r[0]==1, R) ) ),
    0
) ]
for c in range(1,W-1):
    M.append((
        len( list( filter( lambda r:r[c]==0 and r[c-1]==0, R) ) ),
        len( list( filter( lambda r:r[c]==1, R) ) ),
        len( list( filter( lambda r:r[c-1]==1, R) ) )
    ))
M.append((
    len( list( filter( lambda r:r[W-2]==0, R) ) ),
    0,
    len( list( filter( lambda r:r[W-2]==1, R) ) )
))

count = [1] + [0]*(W-1)
for h in range(H):
    count_ = [0] * W
    for num,c in zip(count, range(len(count))):
        for m,n in zip(M[c], [0,+1,-1]):
            if c+n >= 0 and c+n < W:
                count_[c+n] += num * m
    count = count_
        
print(count_[K-1]%p)
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break
  else:
	ans = abs(s2-s1)

print(ans)

### FIXED CODE ###

n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break
  else:
    ans = abs(s2-s1)

print(ans)
A = int(input())
B = int(input())
C = A*B
print(C)

### FIXED CODE ###

x, y = map(int, input().split())
print(x*y)
N=int(input().rstrip().split())
An=list(map(int, input().rstrip().split()))
cnt=0
while True:
    if len(list(filter(lambda a:(a+1)%2, An))) < len(An):
        break
    An=list(map(lambda a:int(a/2), An))
    cnt+=1
print(cnt)


### FIXED CODE ###

N=int(input())
An=list(map(int, input().rstrip().split()))
cnt=0
while True:
    if len(list(filter(lambda a:(a+1)%2, An))) < len(An):
        break
    An=list(map(lambda a:int(a/2), An))
    cnt+=1
print(cnt)
l = list(map(int, input().split()))
area = l[0] * l[1]
perimeter = l[0] * 2 + l[1] * 2
print('{0} {1}.format(area, perimeter))



### FIXED CODE ###

l = list(map(int, input().split()))
area = l[0] * l[1]
perimeter = l[0] * 2 + l[1] * 2
print('{0} {1}'.format(area, perimeter))
# -*- coding: utf-8 -*-
import itertools

def comb1(n, r):
    if n == 0 or r == 0: return 1
    return comb1(n, r-1) * (n-r+1) / r

a = int(input())
# スペース区切りの整数の入力
m_members = []
a_members = []
r_members = []
c_members = []
h_members = []

for i in range(a):
    member = input()
    if(member[0:1] == 'M'):
        m_members.append(member)
    elif(member[0:1] == 'A'):
        a_members.append(member)
    elif(member[0:1] == 'R'):
        r_members.append(member)
    elif(member[0:1] == 'C'):
        c_members.append(member)
    elif(member[0:1] == 'H'):
        h_members.append(member)

member_info = []
count = 0
result = 0

if(len(m_members) != 0):
    member_info.append(len(m_members))
    count += 1
if(len(a_members) != 0):
    member_info.append(len(a_members))
    count += 1
if(len(r_members) != 0):
    member_info.append(len(r_members))
    count += 1
if(len(c_members) != 0):
    member_info.append(len(c_members))
    count += 1
if(len(h_members) != 0):
    member_info.append(len(h_members))
    count += 1

if(count >= 3):
    for i in (list(itertools.combinations(member_info, 3))):
        result += i[0] * i[1] * i[2]
    print(result)
else:
    print(0)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
# 出力
print(int(a/3))
n,m = map(int,input().split())
x = list(map(int,input().split()))
t_3 = max(x) - min(x)
t = []
t_2 = 0
x.sort()
if m == 1:
    print(0)
    exit()

for i in range(m-1):
    t.append(x[i+1]-x[i])

t.sort(reverse=True)
for i in range(n-1):
    t_2 += t[i]

print(t_3-t_2)


### FIXED CODE ###

n,m = map(int,input().split())
x = list(map(int,input().split()))
t_3 = max(x) - min(x)
t = []
t_2 = 0
x.sort()
if m == 1:
    print(0)
    exit()

for i in range(m-1):
    t.append(x[i+1]-x[i])

t.sort(reverse=True)
pp = min(n-1,m-1)
for i in range(pp):
    t_2 += t[i]

print(t_3-t_2)
N,L=map(int,input().split())
S=[input() for n in range(N)]
for num in range(L):
    ans1=S[num]
    for num2 in range(L):

        ans2=S[num2]
        for i in range(L):
            if ans1[i]>ans2[i]:
                True
            else :
                S[num],S[num2]=S[num2],S[num]
print("".join(S))

### FIXED CODE ###

N,L=map(int,input().split())
S=[input() for n in range(N)]
S=sorted(S)
"""for num in range(L):
    ans1=S[num]
    for num2 in range(L):

        ans2=S[num2]
        for i in range(L):
            if ans1[i]>ans2[i]:
                break
            elif ans1[i]==ans2[i]:
                continue
            else :
                S[num],S[num2]=S[num2],S[num]
                break
"""
print("".join(S))
H,N = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b =map(int,input().split())
    A.append(a)
    B.append(b)

G = [0]*(H+1)

@jit
def func()
    for i in range(1,N+1):
        for j in range(1,H+1):
            if i == 1:
                if j-A[i-1]<0:
                    G[j] = B[i-1]
                else:
                    G[j] = G[j-A[i-1]]+B[i-1]
            elif j-A[i-1]<0:
                G[j] = min(G[j], B[i-1])
            else:
                G[j] = min(G[j], G[j-A[i-1]]+B[i-1])
        return G[H]
        
print(func())

### FIXED CODE ###

H,N = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b =map(int,input().split())
    A.append(a)
    B.append(b)

G = [0]*(H+1)

for i in range(1,N+1):
    for j in range(1,H+1):
        if i == 1:
            if j-A[i-1]<0:
                G[j] = B[i-1]
            else:
                G[j] = G[j-A[i-1]]+B[i-1]
        elif j-A[i-1]<0:
            G[j] = min(G[j], B[i-1])
        else:
            G[j] = min(G[j], G[j-A[i-1]]+B[i-1])
        
print(G[H])
n, m = [int(item) for item in input().split()]
a, b = [], []
for i in range(n):
  a.append(input())
for j in range(m):
  b.append(input())

ans = [0] * (n-m)
for i in range(n):
  for j in range(n-m):
    if a[i][j:j+m] == b[i]:
      ans[j] += 1
      if ans[j] >= m:
        print("Yes")
        exit()
    else:
      ans[n-m] = 0
print("No")

### FIXED CODE ###

n, m = [int(item) for item in input().split()]
a, b = [], []
for i in range(n):
    a.append(input().rstrip())
for i in range(m):
    b.append(input().rstrip())

for i in range(n-m+1):
    for j in range(n-m+1):
        ans = True
        for k in range(m):
            for l in range(m):
                if not a[i+k][j+l] == b[k][l]:
                    ans = False
                    break
        if ans:
            print("Yes")
            exit()
print("No")
N = int(input())
a = [map(int, input().split()) for _ in range(N)]
a = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += a[i]
  else:
    Bob += a[i]
print(Alice - Bob)
  


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
a = sorted(a)[::-1]
Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += a[i]
  else:
    Bob += a[i]
print(Alice - Bob)
N = int(input())
S = input()

for i in range(N//2):
  if S[i] != S[-i-1]:
    key += 1
    
if key >= 1:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

N = int(input())
S = input()
key = 0
 
if N%2 == 1:
  key += 1
else:
  for i in range(N//2):
    if S[i] != S[(N//2)+i]:
      key += 1
    
if key >= 1:
  print('No')
else:
  print('Yes')
S = input()
K = input() 
if S[int(K)-1] == '1':
    ans = 1
else:
    for i in range(len(S)):
        if S[i] != '1':
            ans = int(S[i])
            break
print(ans)

### FIXED CODE ###

S = input()
K = input() 
ans = 1
if not all([i == '1' for i in S[:int(K)]]):
    for i in range(len(S)):
        if S[i] != '1':
            ans = int(S[i])
            break
print(ans)
from math import gcd
N=int(input())
A=list(map(int,input().split()))
g=gcd(A[0],A[1])
for i in range(2,N):
        g=gcd(g,A[i])
print(g)

### FIXED CODE ###

from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
g=gcd(A[0],A[1])
for i in range(2,N):
        g=gcd(g,A[i])
print(g)
import sys
from functools32 import lru_cache
from collections import OrderedDict

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)


class Graph():
    def __init__(self):
        self.adjacency_dict = {}
        self.counter_dict = OrderedDict()

    def add_vertex(self, v):
        self.adjacency_dict[v] = []
        self.counter_dict[v] = 0

    def add_edge(self, v1, v2):
        self.adjacency_dict[v1].append(v2)
        self.adjacency_dict[v2].append(v1)

    def add_count(self, v, count):
        self.counter_dict[v] += count

    @lru_cache
    def dfs(self, v, pv):
        for nv in self.adjacency_dict[v]:
            if nv != pv:
                self.counter_dict[nv] += self.counter_dict[v]
                self.dfs(nv, v)

    def print_counters(self):
        print(*self.counter_dict.values())


def main():
    n, q = map(int, input().split())
    tree = Graph()
    for v in range(1, n+1):
        tree.add_vertex(v)
    for _ in range(n-1):
        a, b = map(int, input().split())
        tree.add_edge(a, b)
    for _ in range(q):
        p, x = map(int, input().split())
        tree.add_count(p, x)
    tree.dfs(1, 0)
    tree.print_counters()


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import OrderedDict

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)


class Graph():
    def __init__(self):
        self.adjacency_dict = {}
        self.counter_dict = OrderedDict()

    def add_vertex(self, v):
        self.adjacency_dict[v] = set()
        self.counter_dict[v] = 0

    def add_edge(self, v1, v2):
        self.adjacency_dict[v1].add(v2)
        self.adjacency_dict[v2].add(v1)

    def add_count(self, v, count):
        self.counter_dict[v] += count

    def dfs_stack(self, start):
        stack = [start]
        visited = set()

        parent_vertex = 0
        while stack:
            current_vertex = stack.pop()
            visited.add(current_vertex)
            for v in self.adjacency_dict[current_vertex]:
                if v not in visited and v != parent_vertex:
                    self.counter_dict[v] += self.counter_dict[current_vertex]
                    stack.append(v)
            parent_vertex = current_vertex

    def dfs_rec(self, v, pv):
        for nv in self.adjacency_dict[v]:
            if nv != pv:
                self.counter_dict[nv] += self.counter_dict[v]
                self.dfs_rec(nv, v)

    def print_counters(self):
        print(*self.counter_dict.values())


def main():
    n, q = map(int, input().split())
    tree = Graph()
    for v in range(1, n+1):
        tree.add_vertex(v)
    for _ in range(n-1):
        a, b = map(int, input().split())
        tree.add_edge(a, b)
    for _ in range(q):
        p, x = map(int, input().split())
        tree.add_count(p, x)
    tree.dfs_stack(1)
    # tree.dfs_rec(1, 0)
    tree.print_counters()


if __name__ == "__main__":
    main()
a=map(int,input().split())
a.sort()
print(min((abs(a[0]-a[1])+abs(a[1]-a[2])),(abs(a[2]-a[1])+abs(a[1]-a[0]))))

### FIXED CODE ###

a=list(map(int,input().split()))
a.sort()
print(min((abs(a[0]-a[1])+abs(a[1]-a[2])),(abs(a[2]-a[1])+abs(a[1]-a[0]))))
n, k = map(int, input().split())
li = list(map(int, input().split()))
 
check = [0] * (n)
res = []
next = 0
 
for i in range(n):
    if check[next] == 0:
        check[next] = 1
        next = li[next]-1
    elif check[next] == 1:
        check[next] += 1
        res.append(next+1)
        next = li[next]-1
    else:
        cnt = len(res)
        k -= check.count(1)
        amari = k%cnt
        print(res[amari])
        break
else:
	amari=k%n
    ans=li[amari-1]
	print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
li = list(map(int, input().split()))
 
check = [0] * (n+10)
res = []
next = 0
 
for i in range(k):
    if check[next] == 0:
        check[next] = 1
        next = li[next]-1
    elif check[next] == 1:
        check[next] += 1
        res.append(next+1)
        next = li[next]-1
    else:
        cnt = len(res)
        k -= check.count(1)
        amari = k%cnt
        print(res[amari])
        break
else:
    print(next+1)