Harryxun/stf_run huggingface dataset:
n = int(input())
a = list(map(int,input().split()))
b = a
#1 = plus
cp = 0
cm = 0
sumscp = 0
sumscm = 0

for i in range(len(a)):
    
    if i % 2 == 0:
        while sumscp + a[i] < 1:
            a[i] = a[i] + 1
            cp = cp + 1
        sumscp = sumscp + a[i]
    else:
        while sums + a[i] > -1:
            a[i] = a[i] - 1
            cp = cp + 1
        sumscp = sumscp + a[i]
        
for i in range(len(b)):
    
    if i % 2 == 0:
        while sumscm + b[i] > -1:
            b[i] = b[i] - 1
            cm = cm + 1
        sumscm = sumscm + b[i]
    else:
        while sumscm + a[i] < 1:
            b[i] = b[i] + 1
            cm = cm + 1
        sumscm = sumscm + b[i]
    
print(min(cp,cm))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
sums = 0
count = 0
for i in range(n):
    sums = sums + a[i]
    if i % 2 ==0 :
        if sums > 0:
            None
        else:
            count = count + 1 -sums
            sums = 1
    else:
        if sums < 0:
            None
        else:
            count = count + 1 + sums
            sums = -1
            
count2 = 0
sums2 = 0
for i in range(n):
    sums2 = sums2 + a[i]
    if i % 2 ==1 :
        if sums2 > 0:
            None
        else:
            count2 = count2 + 1 -sums2
            sums2 = 1
    else:
        if sums2 < 0:
            None
        else:
            count2 = count2 + 1 + sums2
            sums2 = -1
            
print(min(count,count2))
import math
A ,B = list(map(int,input().split()))

def problem_koganemaru(A,B):  
  for price in range(10000):
    if math.ceil(price*0.08) == A and math.ceil(price*0.1) == B:
      return price
  return -1

print(problem_koganemru(A,B))

### FIXED CODE ###

import math
A ,B = list(map(int,input().split()))
 
def problem_koganemaru(A,B):  
  for price in range(10000):
    if math.floor(price*0.08) == A and math.floor(price*0.1) == B:
      return price
  return -1
 
print(problem_koganemaru(A,B))
from bisect import bisect_left

n, m, q = map(int, input().split())
LR = [0]*m
for i in range(m):
    LR[i] = list(map(int, input().split()))
P = [0]*q
Q = [0]*q
for i in range(q):
    P[i], Q[i] = map(int, input().split())

LR.sort(key=lambda x: (x[0], x[1]))
L = list(map(lambda x: x[0], LR))
#print(LR)

C = [[0]*(m+1) for _ in range(m+1)]
for i in range(1,m+1):
    l = bisect_left(L, i)
    r = bisect_left(L, i+1)-1
    R2 = list(map(lambda x: x[1], LR[l:r+1]))
    #print(l, r, R2)
    for j in range(i,m+1):
        C[i][j] = bisect_left(R2, j+1)
    #print(i, C[i])

for i in range(q):
    ans = 0
    for j in range(P[i], Q[i]+1):
        ans += C[j][Q[i]]
    print(ans)


### FIXED CODE ###

from bisect import bisect_left
 
n, m, q = map(int, input().split())
LR = [0]*m
for i in range(m):
    LR[i] = list(map(int, input().split()))
P = [0]*q
Q = [0]*q
for i in range(q):
    P[i], Q[i] = map(int, input().split())
 
LR.sort(key=lambda x: (x[0], x[1]))
L = list(map(lambda x: x[0], LR))
#print(LR)
 
C = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    l = bisect_left(L, i)
    r = bisect_left(L, i+1)-1
    R2 = list(map(lambda x: x[1], LR[l:r+1]))
    #print(l, r, R2)
    for j in range(i,n+1):
        C[i][j] = bisect_left(R2, j+1)
    #print(i, C[i])
 
for i in range(q):
    ans = 0
    for j in range(P[i], Q[i]+1):
        ans += C[j][Q[i]]
    print(ans)
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = input()
N = int(N)
a=list(map(int,input().split()))
m = lcm(*a)
print(m)
x = 0
for j in range(N):
  x += (m-1) % a[j]
print(x)




### FIXED CODE ###

import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = input()
N = int(N)
a = list(map(int,input().split()))
m = lcm(*a)
x = 0
for j in range(N):
  x += (m-1) % a[j]
print(x)
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def mfact():
    f = [1]
    for i in range(1, 20000):
        f.append(f[-1] * i % MOD)
    return f

def inv(x):
    res = 1
    k = MOD - 2
    y = x
    while (k):
        if(k % 2 == 1):
            res = (res * y) % MOD
        y = (y ** 2) % MOD
        k = k // 2
    return res

def comb(n, k, f):
    if n < k or n < 0 or k < 0:
        return 0
    a = f[n]
    b = f[n-k]
    c = f[k]
    bc = (b * c) % MOD
    return (a * inv(bc)) % MOD

def solve(N: int, M: int, K: int):
    ans = 0
    for i in range(N):
        for j in range(M):
            a = j * (j+1) // 2
            b = (M-1-j) * (M-1-j+1) // 2
            ans += (a+b) * i + M * (i*(i+1)//2) + a
            ans %= MOD
    f = mfact()
    ans *= comb(N*M-2, K-2, f)
    ans %= MOD
    print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, M, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def mfact():
    f = [1]
    for i in range(1, 200007):
        f.append(f[-1] * i % MOD)
    return f

def inv(x):
    res = 1
    k = MOD - 2
    y = x
    while (k):
        if(k % 2 == 1):
            res = (res * y) % MOD
        y = (y ** 2) % MOD
        k = k // 2
    return res

def comb(n, k, f):
    a = f[n]
    b = f[n-k]
    c = f[k]
    bc = (b * c) % MOD
    return (a * inv(bc)) % MOD

def solve(N: int, M: int, K: int):
    ans = 0
    for i in range(N):
        for j in range(M):
            a = j * (j+1) // 2
            b = (M-1-j) * (M-1-j+1) // 2
            ans += (a+b) * i + M * (i*(i+1)//2) + a
            ans %= MOD
    f = mfact()
    ans *= comb(N*M-2, K-2, f)
    ans %= MOD
    print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, M, K)

if __name__ == '__main__':
    main()
import sys

input = sys.stdin.readline

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

sc = []
dic = dict()
for _ in range(M):
    sc.append(list(map(int, input().split())))

sc.sort(key=lambda x:x[1])
sc.sort(key=lambda x:x[0])

if sc[-1][0] > N:
    print(-1)
    exit()

for i in range(M):
    if sc[i][0] not in dic.keys():
        dic[sc[i][0]] = [sc[i][1]]
    elif sc[i][1] not in dic[sc[i][0]]:
        dic[sc[i][0]].append(sc[i][1])

for value in dic.values():
    if len(value) > 1:
        print(-1)
        exit()

if N == 1:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(0)
        exit()
else:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(-1)
        exit()

ans = ['a'] * N

for i in range(M):
    ans[sc[i][0]-1] = sc[i][1] 

if ans[0] == 'a':
    ans[0] = 1
for i in range(len(ans)):
    if ans[i] == 'a':
        ans[i] = 0

out = ""
for i in range(len(ans)):
    out += str(ans[i])

print(int(out))

### FIXED CODE ###

import sys

input = sys.stdin.readline

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

if M == 0:
    ans = 0
    if N == 2:
        ans = 10
    if N == 3:
        ans = 100
    print(ans)
    exit()

sc = []
dic = dict()
for _ in range(M):
    sc.append(list(map(int, input().split())))

sc.sort(key=lambda x:x[1])
sc.sort(key=lambda x:x[0])

if sc[-1][0] > N:
    print(-1)
    exit()

for i in range(M):
    if sc[i][0] not in dic.keys():
        dic[sc[i][0]] = [sc[i][1]]
    elif sc[i][1] not in dic[sc[i][0]]:
        dic[sc[i][0]].append(sc[i][1])

for value in dic.values():
    if len(value) > 1:
        print(-1)
        exit()

if N == 1:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(0)
        exit()
else:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(-1)
        exit()

ans = ['a'] * N

for i in range(M):
    ans[sc[i][0]-1] = sc[i][1] 

if ans[0] == 'a':
    ans[0] = 1
for i in range(len(ans)):
    if ans[i] == 'a':
        ans[i] = 0

out = ""
for i in range(len(ans)):
    out += str(ans[i])

print(int(out))
N = int(input())

Sdict = dict()
for _ in range(N):
    s = input()
    if s in Sdict:
        Sdict[s] += 1
    else:
        Sdict[s] = 0
    
print(Sdict)
maxi = 0
lis = []
for k,v in Sdict.itens():
	if v > maxi:
        lis = [k]
        maxi = v
    if v == maxi:
		lis.append(k)

print(lis.sort())

### FIXED CODE ###

N = int(input())

Sdict = dict()
max = 0
for _ in range(N):
    s = input()
    if s in Sdict:
        Sdict[s] += 1
    else:
        Sdict[s] = 0
    
maxi = 0
lis = []
for k,v in Sdict.items():
    if v > maxi:
        lis = [k]
        maxi = v
    elif v == maxi:
        lis.append(k)
lis.sort()
for k in lis:
    print(k)
S = input()
K = int(input())

if len(S)==1:
    print(S[0])
    
else:
    lst = []
    for i in range(len(S)):
        if S[i]!='1':
            lst.append(i)
        
    if lst==[]:
        print('1')
    else    
        if K<lst[0]:
            print('1')
        else:
            print(S[lst[0]])

### FIXED CODE ###

S = input()
K = int(input())

if len(S)==1:
    print(S[0])
    
else:
    lst = []
    for i in range(len(S)):
        if S[i]!='1':
            lst.append(i)
        
    if lst==[]:
        print('1')
    else:
        if K<lst[0]+1:
            print('1')
        else:
            print(S[lst[0]])
S,W = list(map(int,input()split()))
print("safe" if S>W else "unsafe")

### FIXED CODE ###

S,W = list(map(int,input().split()))
print("safe" if S>W else "unsafe")
S = input()
w = int(input())
count=0
str = ""
while count < len(S):
    str += S[count]
    count += w
print str


### FIXED CODE ###

s = raw_input()
w = int(raw_input())

ss = ''

for i in xrange(0, len(s), +w): ss += s[i]

print ss
N=int(input())
A=[]
D={}
cnt=0
for i in range(N):
    A.append(sorted(input()))

for sortstr in A:
    if sortstr in D:
        cnt+=D[sortstr]
        D[sortstr]+=1
    else:
        D[sortstr]=1
print(cnt)

### FIXED CODE ###

N=int(input())
A=[]
D={}
cnt=0
for i in range(N):
    A.append(str(sorted(input())))

for sortstr in A:
    if sortstr in D:
        cnt+=D[sortstr]
        D[sortstr]+=1
    else:
        D[sortstr]=1
print(cnt)
n=int(input())
count=0
scount=0
listcount=0
anslist=[]
s=[]
for i in range(n):
    a=input()
    s.append(a)
s_count=s.count
s.sort()
for i in range(n):
    if listcount==n:
        break
    scount=s_count(s[listcount])
    if scount>count:
        count=scount
        anslist.clear()
        anslist.append(s[listcount])
    elif scount==count:
        anslist.append(s[listcount])
    listcount+=scount
anslist.sort()
for i in range(len(anslist)):
    print(anslist[i])


### FIXED CODE ###

from collections import Counter
n=int(input())
list=[input() for _ in range(n)]
list.sort()
c=Counter(list).most_common()
most=c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1]==most:
        print(c[i][0])
N = int(input())

point = []
for i in range(N):
    x,y = map(int,input().split())
    point.append([x,y])

vec = []
for i in range(N):
    for j in range(i+1,N,1):
        vec.append([point[i][0]-point[j][0],point[i][1]-point[j][1]])

N2 = len(vec)
check = [0 for i in range(N2)]

for i in range(N2):
    for j in range(N2):
        minus = [-vec[j][0],-vec[j][1]]
        if vec[i] == vec[j] or vec[i] == minus:
            check[i] += 1
            
if N == 10:
    print(1)
else:
    print(N-max(check))

### FIXED CODE ###

N = int(input())

if N == 1:
    print(1)
else:
    point = []
    for i in range(N):
        x,y = map(int,input().split())
        point.append([x,y])

    vec = []
    for i in range(N):
        for j in range(i+1,N,1):
            vec.append([point[i][0]-point[j][0],point[i][1]-point[j][1]])

    N2 = len(vec)
    check = [0 for i in range(N2)]

    for i in range(N2):
        for j in range(N2):
            minus = [-vec[j][0],-vec[j][1]]
            if vec[i] == vec[j] or vec[i] == minus:
                check[i] += 1

    print(N-max(check))
s = input()
t = input()
if t in s:
  print(0)
else:
  ans = 1000
  for i in range(len(t)):
    for j in range(len(s)):
      if t[i] == s[j]:
        k = i
        l = j
        while k < len(t):
          if t[k] != s[l]:
            break
          k += 1
          l += 1
        ans = min(ans, len(t) - k)

print(ans)        

### FIXED CODE ###

s = input()
t = input()
if t in s:
    print(0)
else:
    ans = len(t)
    for i in range(len(s) - len(t) + 1):
        cnt = 0
        k = i
        l = 0
        while l < len(t) and k < len(s):
            if s[k] != t[l]:
                cnt += 1 
            k += 1
            l += 1    
        ans = min(ans, cnt)
    print(ans)
a,b =map(int,input().split())
 
for x in range(101):
 if (x*1.08)//1==a+x and (x*1.10)//1==b+x and x//1=int(x):
  print(int(x))
  exit()
  
print(-1)

### FIXED CODE ###

a,b =map(int,input().split())
 
for x in range(1009):
 if (x*0.08)//1==a and (x*0.10)//1==b and x//1==int(x):
  print(int(x))
  exit()
  
print(-1)
from collections import Counter

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

C=Counter(A)

A=set(A)

MAX_A=10**6

X=[0]*(MAX_A+1)

for a in A:
    for i in range(a,MAX_A+1,a):
        X[i]+=1

ans=len([a for a in A if (X[1]==1) and (C[a]==1)])

print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)
def main():
    A = int(input())
    B = int(input())

    ans = 0
    if A < B:
        ans += B
        B = B - 1
    else:
        ans += A
        A = A - 1

    if A < B:
        ans += B
        B = B - 1
    else:
        ans += A
        A = A - 1

    print(ans)

    return

if __name__ == '__main__' :
    main()



### FIXED CODE ###

def main():
    A,B = list(map(int, input().split()))

    ans = 0
    if A < B:
        ans += B
        B = B - 1
    else:
        ans += A
        A = A - 1

    if A < B:
        ans += B
        B = B - 1
    else:
        ans += A
        A = A - 1

    print(ans)

    return

if __name__ == '__main__' :
    main()
a,p=map(int,input().split())
m=(3*A+P)//2
print(m)

### FIXED CODE ###

a,p=map(int,input().split())
m=(3*a+p)//2
print(m)
N= input()
S= input()



Len = len(S)#文字数の長さ
LIST = list(S)#文字列を1文字ごとに分割する。

ANSWER = ""
#リストの中身をループ
for SS in LIST:
    NUNBER = ord(SS)#アスキーコードを出す組み込み関数:1文字しか対応していない
    NUNBER = NUNBER -64#アスキーコードからアルファベット順に変更
    AFFTER = NUNBER + N
    LAST  = AFFTER % 26
    if LAST == 0:
        LAST = 26
    LAST  = chr(LAST+64)#アスキーコードからアルファベットに戻す
    ANSWER = ANSWER + LAST
    
print(ANSWER)


### FIXED CODE ###

N= input()
S= input()


N = int(N)
Len = len(S)#文字数の長さ
LIST = list(S)#文字列を1文字ごとに分割する。

ANSWER = ""
#リストの中身をループ
for SS in LIST:
    NUNBER = ord(SS)#アスキーコードを出す組み込み関数:1文字しか対応していない
    NUNBER = NUNBER -65#アスキーコードからアルファベット順に変更
    AFFTER = NUNBER + N
    LAST  = AFFTER % 26
    LAST  = chr(LAST+65)#アスキーコードからアルファベットに戻す
    ANSWER = ANSWER + LAST
    
print(ANSWER)
import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
array = np.ones((ipt[0],ipt[1]),int)
for i in range(cr[0]):
  array[i] = array[i] * 0
for j in range(cr[1]):
  array[:,j] = array[:,i] * 0
print(array[array==1].sum())

### FIXED CODE ###

import numpy as np

ipt = list(map(int,input().split()))
cr = list(map(int,input().split()))
print((ipt[0]-cr[0])*(ipt[1]-cr[1]))
s = input()
t = input()

ans = 0
for i in range(3)
  
  a = s[i]
  b = t[i]
  
  if a == b:
    ans += 1
    
print(ans)

### FIXED CODE ###

s = input()
t = input()

ans = 0
for i in range(3):
  
  a = s[i]
  b = t[i]
  
  if a == b:
    ans += 1
    
print(ans)
n = int(input())
list = [1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,
       24,25,27,28,30,32,35,36,40,42,45,48,49,54,
       56,63,64,72,81]

if list in n:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())
list = [1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,
       24,25,27,28,30,32,35,36,40,42,45,48,49,54,
       56,63,64,72,81]

if n in list:
  print('Yes')
else:
  print('No')
b = list(map(int, input().split()))
tmp1 = list(map(int, input().split()))
tmp2 = list(map(int, input().split()))
b.extend(tmp1)
b.extend(tmp2)
answer = [False]*9
N = int(input())
for i in range(N):
    num = int(input())
    if num in b:
        answer[b.index(num)] = True
if (answer[0] and answer[1] and answer[2]) or (answer[3] and answer[4] and answer[5]) or (answer[6] and answer[7] and answer[8]) or (answer[1-1] and answer[4-1] and answer[7-1]) or (answer[2-1] and answer[5-1] and answer[8-1]) or (answer[3-1] and answer[6-1] and answer[9-1]) or (answer[1-1] and answer[5-1] and answer[9-1]) or (answer[3-1] and answer[5-1] and [b7]):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

b = list(map(int, input().split()))
tmp1 = list(map(int, input().split()))
tmp2 = list(map(int, input().split()))
b.extend(tmp1)
b.extend(tmp2)
answer = [False]*9
N = int(input())
for i in range(N):
    num = int(input())
    if num in b:
        answer[b.index(num)] = True
if (answer[0] and answer[1] and answer[2]) or (answer[3] and answer[4] and answer[5]) or (answer[6] and answer[7] and answer[8]) or (answer[1-1] and answer[4-1] and answer[7-1]) or (answer[2-1] and answer[5-1] and answer[8-1]) or (answer[3-1] and answer[6-1] and answer[9-1]) or (answer[1-1] and answer[5-1] and answer[9-1]) or (answer[3-1] and answer[5-1] and [7-1]):
    print("Yes")
else:
    print("No")
a = int(input())
b = int(input())

area = a * b
ci = 2 * a + 2 * b

print(area)
print(ci)

### FIXED CODE ###

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

print(a * b,(a + b) * 2)
n,k,x,y = map(int, input())
if n > k:
  sum = k*x+(n-k)*y
else:
  sum = n*x
print(int(sum))

### FIXED CODE ###

N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N >= K:
  print(K*X+(N-K)*Y)
else:
  print(N*X)
n=int(input())
def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f**2<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return(a)

import collections
A=collections.Counter(prime_factorize(n-1))
B=collections.Counter(prime_factorize(n))
ans=1
cnt=0
for a,b in A.items():
    ans*=(b+1)

import math
for i in range(1,math.floor(n**0.5)+1):
    if n%i==0:
        if j in B.keys():
            if (n // (j ** B[j])) % j == 1:
                cnt+=1
        else:
            if (n//i)%i==1:
                cnt+=1
                
        if (i-1)%(n//i)==0:
            cnt+=1
            
print(ans-1+cnt)

### FIXED CODE ###

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

import collections
A=collections.Counter(prime_factorize(n-1))
ans=1
cnt=0
for a,b in A.items():
    ans*=(b+1)

import math
li=[]
for i in range(2,math.floor(n**0.5)+1):
    if n%i==0:
        li.append(i)
        if i!=n//i:
            li.append(n//i)
li.append(n)
for i in li:
    x = n
    while x % i == 0:
        x //= i
    if x % i == 1:
        cnt += 1
print(ans - 1 + cnt)
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF 1001001001
using ll = long long;
using dd = long double;

const int D = 60;
const int MAX_N = 20005;
int to[D][MAX_N];


int main() {
    int n;
    ll k;
    cin >> n >> k;
    rep(i,n) {
        cin >> to[0][i];
        to[0][i]--;
    }

    rep(i,D-1)rep(j,n) {
        to[i+1][j] = to[i][to[i][j]];
    }

    int v = 0;
    for (int i = D-1; i >= 0; --i) {
        ll l = 1ll<<i;
        if (l <= k) {
            v = to[i][v];
            k -= l;
        }
    }
    cout << v+1 << endl;
    
    return 0;
}



### FIXED CODE ###

import sys
import time
st = time.perf_counter()
# ------------------------------

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [i-1 for i in A]

cnt = [-1] * N
cnt[0] = 0
now = 0
for i in range(1, 1001001001):
    now = A[now]
    if cnt[now] == -1:
        cnt[now] = i
    else:
        circle = i - cnt[now]
        t = cnt[now]
        break
if K - t > 0:
    amari = (K - t) % circle
    for _ in range(amari):
        now = A[now]
else:
    now = 0
    for i in range(K):
        now = A[now]
print(now + 1)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
a,b,c = map(int, input(),split(" "))

if a < b < c:
    print "Yes"
else:
    print"No"

### FIXED CODE ###

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

if a < b < c:
    print("Yes")
else:
    print("No")
A,V = map(int,input().split())
B,W = map(int,input().split())
T=int(input())

ans = "NO"

if(A<B):
    if(A+V*T >= B+W*T):
        ans = "YES"
elif(A>B):
    if(A+(-1)*V*T =< B+(-1)*W*T):
        ans = "YES"
print(ans)


### FIXED CODE ###

A,V = map(int,input().split())
B,W = map(int,input().split())
T=int(input())

ans = "NO"

if(A<B):
    if(A+V*T >= B+W*T):
        ans = "YES"
elif(A>B):
    if(A+(-1)*V*T <= B+(-1)*W*T):
        ans = "YES"
print(ans)
n,k=map(int,input().split())
list=[0]*11
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for l in range(1,len(list)):
    sum+=list[l]
    if sum>=k:
        print(l)
        exit()


### FIXED CODE ###

n,k=map(int,input().split())
list=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for l in range(1,len(list)):
    sum+=list[l]
    if sum>=k:
        print(l)
        exit()
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = [26**i for i in range(1,30)]
A = [0]+list(itertools.accumulate(A))
cnt = 0
for i in range(N):
    if A[i] >= N:
        p = cnt
        break
    cnt += 1
if p == 1:
    print(chr(N+96))
s = []
if N in A:
    print('z'*p)
    exit()
for i in range(p-1):
    s.append(chr(N%26+96))
    N = N//26
s.append(chr(N+96))
s.reverse()
print(''.join(s))

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
S = []
for i in range(1,100):
    if N < 27:
        break
    N -= 1
    S.append(chr(ord('a')+N%26))
    N = N//26
S.append(chr(ord('a')+N-1))
print(''.join(S[::-1]))