Harryxun/stf_run huggingface dataset:
import numpy as np
import itertools
 
H, W, K = list(map(int, input().split())) 
c = [input().split() for i in range(H)]
b=[]
d=[]
for i in range(len(c)):
  for item in c[i]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("#" , "1")
    b.append(item_mod)
  d.append(b)
  b=[]


C_arr = np.array(d)
 
In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertolls.product([0,1] , repeat=W)))
 
ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
    
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
    
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
    
    if ICO.count(1) == K:
      ans += 1
      
print(ans)

### FIXED CODE ###

H, W, K = list(map(int, input().split()))
 
c = [list(input()) for i in range(H)]
 
cnt = 0
for i in range(2**H):
    for j in range(2**W):
        cnt_black = 0
        for k in range(H):
            if (i >> k) & 1:
                continue
            for l in range(W):
                if (j >> l) & 1:
                    continue
                if c[k][l] == '#':
                    cnt_black += 1
        if cnt_black == K:
            cnt += 1
 
print(cnt)
X, A = map(int. input().split())

if X < A :
  print(0)
else :
  print(10)


### FIXED CODE ###

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

if X < A :
  print(0)
else :
  print(10)
import sys
while True:
    x = sys.stdin.readline().strip()
    if x == "0":
        break
    print("Case %d: %s"%(i, x))
    i += 1

### FIXED CODE ###

import sys
i = 1
while True:
    x = sys.stdin.readline().strip()
    if x == "0":
        break
    print("Case %d: %s"%(i, x))
    i += 1
s = list(input())
count = 0
list1 = []
for x in s:
  if x == 'A' or x == 'G' or x == 'T' or x == 'C':
    count = count + 1
  else:
    list1.append(count)
    count = 0
    
print(max(list1))

### FIXED CODE ###

s = list(input())
count = 0
list1 = []
for x in s:
  if x == 'A' or x == 'G' or x == 'T' or x == 'C':
    count = count + 1
  list1.append(count)
  if x != 'A' and x != 'G' and x != 'T' and x != 'C':
    count = 0
    

print(max(list1))
N = input()

N = N.splitlines()

N_num = int(N[0])

AC_num = 0
WA_num = 0
TLE_num = 0
RE_num = 0

for i in range(N_num):
    #print(i+1)
    
    if 'AC' == N[i+1]:
        AC_num += 1
        #print(AC_num)
    
    elif 'WA' == N[i+1]:
        WA_num += 1
        #print(WA_num)

    elif 'TLE' == N[i+1]:
        TLE_num += 1
        #print(TLE_num)
    
    else 'RE' == N[i+1]:
        RE_num += 1
        #print(RE_num)


print('AC x {}'.format(AC_num))
print('WA x {}'.format(WA_num))
print('TLE x {}'.format(TLE_num))
print('RE x {}'.format(RE_num))

### FIXED CODE ###

import sys


N = input()
    

N_in = int(N)

if N_in>10000 or N_in<0:
    print('error')
    sys.exit()

N = N_in/1000;

N_f = float(N)

N_i = int(N)


if (N_f - N_i) == 0:
    Ans = 0
    print(Ans)

else:
    N_i = N_i + 1
    Ans = N_i*1000 - N_in
    print(Ans)
import sys
# sys.stdin = open('input.txt')

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(len(a)):
    a[i] -= 1

cycle = n + 1
# sub = []
place = 0

for i in range(len(a)):
    place = a[i]
    # sub.append(a[i])
    if place == 0:
        # sub = sub[:-1]
        cycle = i
        break

# print(cycle, sub)
# ans = sub[k%cycle] + 1
ans = 0
for i in range(k%cycle+1):
    ans = a[i] + 1
print(ans)

### FIXED CODE ###

import sys
# sys.stdin = open('input.txt')

n, k = map(int, input().split())
a = list(map(int, input().split()))

s = []  #　頂点を訪れた順番に持つ数列
ord = [-1 for i in range(n+1)]  # 訪問済みの頂点の index. 未訪問のときは -1
c = 1  # 周期
l = 0  # 例外部分の長さ

v = 1  # 現在の頂点
while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v-1]

l = ord[v]
c = len(s) - l

if k < l:
    print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])
num = input()
list = inpit().split()

def hoge(list):
  new_list = []
  for i in list:
    if i % 2 == 0:
      new_list << i
    else:
      return False

    count = 0
while(True);
  list = hoge(list)
  break if list == False
  count += 1

print(count)

### FIXED CODE ###

num = input()
listt = input().split()

def hoge(fuga):
    new_list = []
    for i in fuga:
        if int(i) % 2 == 0:
            new_list.append(int(i)/2)
        else:
            return False
    return new_list


count = 0
while True:
    listt = hoge(listt)
    if listt == False:
        break
    count += 1

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


prod = 1
for a in A:
  if a == 0:
    prod = 0
  prod *= a
  if prod > 1000000000000000000:
  prod = -1

print(prod)

### FIXED CODE ###

def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    if 0 in A:
        print(0)
        return

    mul = 1
    for a in A:
        mul *= a

        if mul > 1e18:
            print(-1)
            return

    print(mul)


main()
from operator import itemgetter

n = int(input())
e = [[j for j in input().split()] for i in range(n)] 
f = [[i,e[i]] for i in range(n)]

restaurant.sort(key=itemgetter(0),reverse=True)
restaurant = sorted(f,key=itemgetter(1))

for i in range(n):
    print(restaurant[i][0]+1)

### FIXED CODE ###

n = int(input())
a= []
for i in range(n):
	city, score = input().split()
	score = int(score)
	a.append((city, score, i+1))
a.sort(key=lambda k : (k[0], -k[1]))
for i in range(n):
	print(a[i][2])
input()
data = input().split()

minimum = print(max(data))
maximum = print(min(data))
total = print(sum(data))

print(minimum, maximum, total)

### FIXED CODE ###

input()
nums = [int(i) for i in input().split()]

maximum = max(nums)
minimum = min(nums)
total = sum(nums)

print(minimum, maximum, total)
import sys
for line in sys.stdin:
    a,b,c = line.split()
    a,c = int(a), int(c)
    p = '+-*/?'.index(b)
    if p = 0: a += c
    elif p == 1: a -= c
    elif p == 2: a *= c 
    elif p == 3: a /= c
    elif p == 4: break
    print a

### FIXED CODE ###

while True:
    a, op, b = raw_input().split()
    a = int(a)
    b = int(b)

    if op == '+': print a + b
    elif op == '-': print a - b
    elif op == '*': print a * b 
    elif op == '/': print a / b
    elif op == '?': break
a,b,c = map(float, input().split())

if a > 10**5 or b> 10**5 or c> 10**5:
    assert False ,"aa"

import numpy as np
sqa=np.sqrt(a)
sqb=np.sqrt(b)
sqc=np.sqrt(c)




if sqa + sqb < sqc:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

from decimal import Decimal
sqa=Decimal(a).sqrt()
sqb=Decimal(b).sqrt()
sqc=Decimal(c).sqrt()

if sqa+sqb<sqc:
    print("Yes")
else:
    print("No")
# LCS: Longest common subsequence
# dp[i][j]: Sのi-1番目まで, Tのj-1番目まででの最長共通文字列
# dp[0][0] = 0 長さ0の文字列
# dp[0][1] = 0 長さ1の文字列と長さ0の文字列
# dp[1][0] = 0 長さ0の文字列と長さ1の文字列
# dp[i][j] = max(dp[i-1][j], dp[i][j-1]) (S[i] != T[j])
# dp[i][j] = max(
#                dp[i-1][j-1]+1  (共通文字列を利用する),
#                dp[i-1][j]        (共通文字列を利用しない),
#                dp[i][j-1]        (共通文字列を利用しない),
#            )


dp = [[0 for _ in range(1001)] for _ in range(1001)]

def main():
    S = input()
    T = input()

    result = solve(S, T)
    print(result)


def solve(S, T):
    for i in range(1, len(S)+1):
        for j in range(1, len(T) + 1):
            if S[i-1] != T[j-1]:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
            else:
                dp[i][j] = max(dp[i-1][j-1] + 1, dp[i-1][j], dp[i][j-1])
    result = ''
    i = len(S)
    j = len(T)
    while i > 0 and j >0:
        if i >= 1 and j >=1 and dp[i][j] == dp[i-1][j-1] + 1:
            result += S[i-1]
            i -= 1
            j -= 1
        elif i >= 1 and dp[i][j] == dp[i-1][j]:
            i -= 1
        else:
            j -= 1
    return ''.join(reversed(result))


if __name__ == "__main__":
    main()


### FIXED CODE ###

# LCS: Longest common subsequence
# dp[i][j]: Sのi-1番目まで, Tのj-1番目まででの最長共通文字列
# dp[0][0] = 0 長さ0の文字列
# dp[0][1] = 0 長さ1の文字列と長さ0の文字列
# dp[1][0] = 0 長さ0の文字列と長さ1の文字列
# dp[i][j] = max(dp[i-1][j], dp[i][j-1]) (S[i] != T[j])
# dp[i][j] = max(
#                dp[i-1][j-1]+1  (共通文字列を利用する),
#                dp[i-1][j]        (共通文字列を利用しない),
#                dp[i][j-1]        (共通文字列を利用しない),
#            )


dp = [[0 for _ in range(3001)] for _ in range(3001)]


def main():
    S = input()
    T = input()

    result = solve(S, T)
    print(result)


def solve(S, T):
    for i in range(1, len(S) + 1):
        for j in range(1, len(T) + 1):
            if S[i - 1] != T[j - 1]:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i-1][j-1])
            else:
                dp[i][j] = max(dp[i - 1][j - 1] + 1, dp[i - 1][j], dp[i][j - 1])
    result = ""
    i = len(S)
    j = len(T)
    while dp[i][j] != 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            result += S[i-1]
            i -= 1
            j -= 1
    return "".join(reversed(result))


if __name__ == "__main__":
    main()
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
# A = range(M)
B = range(M)

Ans = reduce(lambda a, b: a*b, B)
# Ans = 10
print(Ans)
    


### FIXED CODE ###

N, M = map(int, input().split())
A = [True] * (N+1)
for _ in range(M):
  idx = int(input())
  A[idx] = False

step = [0] * (N+1)
step[0] = 1
for i in range(1, N+1):
  if A[i]:
    step[i] = step[i-1] + step[i-2]
  else:
    step[i] = 0
print(step[N]%(10**9+7))
n = int(input())
    t, a = [ int(v) for v in input().split() ]
    height_list = [ abs(t-a-int(V)*0.006) for v in input().split() ]
    print(height_list.index(min(height_list))+1)

### FIXED CODE ###

n = int(input())
t, a = [ int(v) for v in input().split() ]
height_list = [ abs(t-a-int(v)*0.006) for v in input().split() ]
print(height_list.index(min(height_list))+1)
y = input()
y = input().split()
y = [ int(x) for x in y]
sum_go = []
sum_back = []
for i in range(1, num):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))

### FIXED CODE ###

y = input()
y = input().split()
y = [ int(x) for x in y]
sum_go = []
sum_back = []
for i in range(1, len(y)):
    sum_go.append(sum(y[0:i] ))
    sum_back.append(sum(y[i:] ))
#print(sum_go)
#print(sum_back)
result = []
for i in range(len(sum_go)):
    result.append( abs(sum_go[i] - sum_back[i]) )
print(min(result))
k = int(input())
s = input()

length = len(s)
MOD = 10**9 + 7

dp = [[0] * (k + 1) for _ in range(2)]
dp[0][0] = pow(26, k, MOD)
dp[1][0] = pow(26, k, MOD)

div = pow(26, -1, MOD)

for i in range(1, k + 1):
    dp[0][i] = dp[0][i - 1] * 25 * div * (length + i - 1) * pow(i, -1, MOD) % MOD
    dp[1][i] = (dp[1][i - 1] + dp[0][i]) % MOD

print(dp[-1][-1])

### FIXED CODE ###

def solve(k, length, MOD, div, dp):
    for i in range(1, k + 1):
        dp[0] = dp[0] * 25 * div * (length + i - 1) * pow(i, -1, MOD) % MOD
        dp[1] = (dp[1] + dp[0]) % MOD

    return(dp[1])


k = int(input())
s = input()
length = len(s)
MOD = 10**9 + 7
div = pow(26, -1, MOD)

dp = [pow(26, k, MOD)] * 2

print(solve(k, length, MOD, div, dp))
x,y,z = map(int, input().split())
x,y,z >= 1 && <= 100 
print(z,y,x)

### FIXED CODE ###

a, b, c = map(int, input().split())
print(c, a, b)
N = int(input())
W = list(map(int, input().split()))

# O(N^2)で解いても間に合う
m = 10**10
for i in range(1, N):
  a, b = 0, 0
  for j in range(i):
    a += W[j]
  for j in range(i, N):
    b += W[j]
  m = min(m, abs(a-b))
print(m)

### FIXED CODE ###

P, Q, R = map(int, input().split())

print(min(P+Q, Q+R, R+P))
product = a*b
divide_type = type(product/2)

if divide_type == int:
    print("Even")
if divide_type==float:
    print('Odd')

### FIXED CODE ###

a,b = map(int,input().split())
 
product = a*b
if product%2==0:
    print("Even")
elif product%2==1:
    print('Odd')
N = input()
N = int(N)
l = [input() for i in range(N)]
ma = -100
for i in range(0,len(l)-1):
    for j in range(i+1,len(l)):
        if(l[j] - l[i] > ma):
            ma = l[j] - l[i]
print(ma)




### FIXED CODE ###

N = input()
N = int(N)
l = [int(input()) for i in range(N)]
flg = 1
ma = 0
mi = 0
for i in range(1,len(l)):
    if(mi > l[i-1] or flg ==1):
        mi = l[i-1]
    if(ma < l[i] - mi or flg ==1):
        ma = l[i] - mi
        flg = 0
print(ma)
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
ans = 0
d = 2
for d in range(2, int(n**0.5) + 1):
    e = d
    while n%d == 0:
        n //= d
        d *= d
        ans += 1
    while n%e == 0:
        n // e
if n >= d:
    ans += 1
print(ans)




### FIXED CODE ###

a, b = input().split()
b = b.replace('.', '')
a = int(a)
b = int(b)
print((a*b)//100)
N = int(input())
Hs = input().split()
A = []
for k in range(N): # 0, 1, 2, 3, 4
  c = 0
  for i in range(k, N - 1): # 0~3, 1~3, ... 
    if int(Hs[i]) < int(Hs[i+1]):
      A.append(c)
      break
    elif int(Hs[i]) >= int(Hs[i+1]):
      c += 1
    if i == N - 2:
      A.append(c)
      break
  if i == N - 2:
    break
      
print(max(A))

### FIXED CODE ###

N = int(input())
Hs = input().split()
A = []
b = 0
b_h = 0
for i in range(N-1):
  if int(Hs[i]) < int(Hs[i+1]):
    b = i
    A.append(b-b_h)
    b_h = b+1

if len(A) != N-1:
  b = i + 1
  A.append(b-b_h)
  print(max(A))
else:
  print(0)
a=int(input())
b=int(input())

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


### FIXED CODE ###

a,b=map(int,input().split())
print(a*b,2*(a+b))
n,k=map(int,input().split())
h=[i for i in range(n)]
h.sort()
l=[]
for i in range(k-2):
  l.append(abs(h[i]-h[i+k-1]))
print(min(l))

### FIXED CODE ###

n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()
l=[]
for i in range(len(h)-k+1):
  l.append(abs(h[i]-h[i+k-1]))
print(min(l))
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(n):
    b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n+1):
    if a[i] > k:
        break
    while [b] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)


### FIXED CODE ###

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
from math import *
def popcount(x):
    s=0
    y=int(log2(x))+2
    for i in range(y):
        if(x>>i)&1:
            s+=1
    return x%s
n=int(input())
x=input()[::-1]
#1がなんこ出るのか
c=x.count("1")
#c+1とc-1だけ考えれば良い
#c=1の時場合分け
#m[i][j]:2^iまで考えたときのmod(c+j-1)
m=[[1%(c-1),1%(c+1)]]
for i in range(1,n):
    m.append([(2*m[-1][0])%(c-1),(2*m[-1][1])%(c+1)])
#一個だけ変えたいので全体を求める
l=[0,0]
for i in range(n):
    if x[i]=="1":
        l[0]+=m[i][0]
        l[1]+=m[i][1]
        l[0]%=(c-1)
        l[1]%=(c+1)
#最初以外はpopcount使って間に合う
ans=[0]*n
for i in range(n):
    if x[i]=="1":
        if c-1==0:
            ans[i]=0
            continue
        p=(l[0]+(c-1)-m[i][0])%(c-1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
    else:
        p=(l[1]+m[i][1])%(c+1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
ans=ans[::-1]
for i in range(n):
    print(ans[i])






### FIXED CODE ###

import math
def popcount(x):
    s=0
    y=int(math.log2(x))+2
    for i in range(y):
        if(x>>i)&1:
            s+=1
    return x%s
n=int(input())
x=input()[::-1]
#1がなんこ出るのか
c=x.count("1")
#c+1とc-1だけ考えれば良い
#c=1の時場合分け
#m[i][j]:2^iまで考えたときのmod(c+j-1)
if c!=1:
    m=[[1%(c-1),1%(c+1)]]
    for i in range(n-1):
        m.append([(2*m[-1][0])%(c-1),(2*m[-1][1])%(c+1)])
    l=[0,0]
    for i in range(n):
        if x[i]=="1":
            l[0]+=m[i][0]
            l[1]+=m[i][1]
            l[0]%=(c-1)
            l[1]%=(c+1)
else:
    m=[[1%(c+1),1%(c+1)]]
    for i in range(n-1):
        m.append([(2*m[-1][0])%(c+1),(2*m[-1][1])%(c+1)])
    l=[0,0]
    for i in range(n):
        if x[i]=="1":
            l[0]+=m[i][0]
            l[1]+=m[i][1]
            l[0]%=(c+1)
            l[1]%=(c+1)
#一個だけ変えたいので全体を求める

#最初以外はpopcount使って間に合う
ans=[0]*n
for i in range(n):
    if x[i]=="1":
        if c-1==0:
            ans[i]=0
            continue
        p=(l[0]+(c-1)-m[i][0])%(c-1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
    else:
        p=(l[1]+m[i][1])%(c+1)
        ans[i]+=1
        while p!=0:
            p=popcount(p)
            ans[i]+=1
ans=ans[::-1]
for i in range(n):
    print(ans[i])
n = int(input())
ans = 0
a = input()
b = input()
c = input()
for i in n:
  if a[i] == b[i] == c[i]:
    pass
  elif a[i] == b[i] or a[i] == c[i] or a[i] == c[i]:
    ans += 1
  else:
    ans += 2
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
a = input()
b = input()
c = input()
for i in range(n):
  if a[i] == b[i] == c[i]:
    pass
  elif a[i] == b[i] or a[i] == c[i] or b[i] == c[i]:
    ans += 1
  else:
    ans += 2
print(ans)
import numpy as np

def abc166_e():
    N = int(input())
    A = np.array(input().split(), dtype=np.int64)

    # indexの差の絶対値
    idx = np.arange(1, N+1, dtype=np.int64) - np.arange(1, N+1, dtype=np.int64).reshape(-1, 1)
    np.absolute(idx, out=idx)
    # 値の和
    valsum = A + A.reshape(-1, 1)

    # 差をとって0なら等しい
    # 対角成分はidxが0でvalsumが2以上なのでdiffは0にならないため無視できる
    diff = idx - valsum
    ans = N*N - np.count_nonzero(diff)
    ans //= 2  # 同じ組合せが2回数えられているので半分にする
    print(ans)

abc166_e()

### FIXED CODE ###

# https://atcoder.jp/contests/abc166/submissions/12754173

def abc166_e():
    _ = int(input())
    A = list(map(int, input().split()))
    ans = 0
    from collections import defaultdict
    d = defaultdict(int)
    for i, x in enumerate(A, 1):
        ans += d[i - x]
        d[x + i] += 1
    print(ans)

abc166_e()
def resolve():
    # 整数 1 つ
    n = str(input().rstrip())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]
    n[3] = "8"

    print(n)


resolve()

### FIXED CODE ###


def resolve():
    # 整数 1 つ
    n = input()
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]
    m = n[:3] + "8" + n[4:]

    print(m)


resolve()
a, b = input().split()
a, b = int(a), int(b)
print("Draw" if a == b elif a < b "Bob" else "Alice")

### FIXED CODE ###

a, b = input().split()
a, b = int(a), int(b)
if a == 1:
  a += 13
if b == 1:
  b += 13
print("Alice" if a > b else "Draw" if a == b else "Bob")
f,g = list(map(int,input().split()))

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

c = 1
p = 0
if a[0] > g:
    c += a[0] - g
    a[0] = g
while p <= f-1:
    if a[p-1] + a[p] > x:
        eat = a[p-1] + a[p] - x
        c += eat
        a[p] -= eat
    p += 1
print(c)


### FIXED CODE ###

f,g = list(map(int,input().split()))

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

c = 0
p = 1
if a[0] > g:
    c += a[0] - g
    a[0] = g
while p <= f-1:
    if a[p-1] + a[p] > g:
        eat = a[p-1] + a[p] - g
        c += eat
        a[p] -= eat
    p += 1
print(c)
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input.split())))
ans = N
mx = max(ab,key=lambda x:x[1])[0]
ans += mx - 1
mn = min(ab,key=lambda x:x[1])[1]
ans += mn
print(ans)

### FIXED CODE ###

N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
mn = min(ab,key=lambda x:x[1])
print(sum(mn))
a,b,c = inpl_int()
print(a+b+c-max(a,b,c))


### FIXED CODE ###

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl_int(): return list(map(int, input().split()))
def inpl_str(): return list(map(int, input().split()))

a,b,c = inpl_int()
print(a+b+c-max(a,b,c))
from fractions import gcd
import math
n=int(input())
a=[int(i) for i in input().split()]

L=[0]*(n+1)
R=[0]*(n+1)
ans=0
for i in range(n):
    L[i]=math.gcd(L[i-1],a[i])
for i in reversed(range(n)):
    R[i]=math.gcd(R[i-1],a[i])
for i in range(n):
    if math.gcd(L[i-1],R[i+1]) > ans:
        ans=math.gcd(L[i-1],R[i-1])

print(ans)


### FIXED CODE ###

N = int(input())
A = [int(n) for n in input().split()]

from fractions import gcd
L = [0]*(N+1)
R = [0]*(N+1)
ans = 0
for i in range(N):
    L[i] = gcd(L[i-1],A[i])
for i in reversed(range(N)):
    R[i] = gcd(R[i+1],A[i])
for i in range(N):
    if gcd(L[i-1],R[i+1]) > ans:
        ans = gcd(L[i-1],R[i+1])
print(ans)
N = int(input())
x = [0] * N
u = [0] * N
ans = 0

for i in range(N):
    x[i], u[i] = map(float, input().split())
    
    if u[i] == 'BTC':
        ans += x[i] * 380000
    else:
        ans += x[i]

print(ans)


### FIXED CODE ###

N = int(input())
x = [0] * N
u = [0] * N
ans = 0

for i in range(N):
    x[i], u[i] = map(str, input().split())
    x[i] = float(x[i])

    if u[i] == 'BTC':
        ans += x[i] * 380000
    else:
        ans += x[i]

print(ans)
import bisect

N = int(input())
a = list(map(int,input().split(' ')))
a.sort()

# print(a)


def do(index,father):
    result = True
    
    if len(a) == 0 :
        return True
    
    son = a.pop(bisect.bisect_left(a,father)-1)
    
#     print(father,son,index)
    
    if father > son:
        result = do(index*2,son) and result
        result =do(index*2 + 1,son) and result
    else:
        return False
    
    return result
        
if do(1,10**9 + 1):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
A = sorted((int(x) for x in input().split()))
 
parent = [A[-1]]
rest = A[:-1]
bl = True
for _ in range(N):
    next_parent = []
    next_rest = []
    for p in parent[::-1]:
        while rest:
            x = rest.pop()
            if x < p:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent += next_parent
    parent.sort()
    rest = rest + next_rest[::-1]
 
bl = len(parent) == (2**N)
answer = 'Yes' if bl else 'No'
print(answer)
N = int(input())
s =[int(input()) for _ in range(N)]
S = sum(s)
print(S-min([x for x in s if x % 10!=0]+[[0,S][(S%10)*1]]))



### FIXED CODE ###

N = int(input())
ssum = 0
not10min = -1
for si in (int(input()) for _ in range(N)):
  ssum += si
  if si % 10 != 0:
    if not10min < 0:
      not10min = si
    else:
      not10min = min(not10min, si)

if ssum % 10 ==0:  
  if not10min >= 0:
    ssum -= not10min
  else:
    ssum = 0
print(ssum)
#abc066d
mod=10**9+7

def com(n,r,m):
 f=[1,1]
 for i in range(2,n+1):
  f.append(f[i-1]*i%m)
 return f[n]*pow(f[r]*f[n-r]%m,m-2,m)%m


N=int(raw_input())
A=map(int,raw_input().split())
c=[-1]*N
for i in range(N+1):
 if c[A[i]-1]!=-1:
  break
 c[A[i]-1]=i
j=c[A[i]-1]
i=N-i
for k in range(1,N+2):
 res=com(N+1,k,mod)
 if k-1<=i+j:
  res-=com(i+j,k-1,mod)
 print res%mod


### FIXED CODE ###

#ABC066A

l=map(int,raw_input().split())
ls=sorted(l)
print ls[0]+ls[1]
n,k=map(int,input().split())
a=list(map(int,input().split()))
result=[1]
temp=1
i=0
while i<k:
  temp=a[temp-1]
  result.append(temp)
  if temp in result:
    break
  i=i+1

l=len(result)
temp=result.index(result[l-1])
if k<l:
  print(result[k+1])
else:
  l2=l-1-temp
  print(result[temp+(k-temp)%l2])

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
result=[1]
temp=1
for i in range(n):
  temp=a[temp-1]
  result.append(temp)
temp=result.index(result[len(result)-1])
c=len(result)-temp-1
if k<n:
  print(result[k])
else:
  print(result[temp+(k-temp)%c])