Harryxun/stf_run huggingface dataset:
import math

# D - Maximum Average Sets
# 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d

# N:商品の数　A個以上B個以下の範囲で選ぶ
N, A, B = map(int, input().split())
# C：最大価値組み合わせ総数
C = 0

# 商品価値をリストに入れる
V = [int(value) for value in input().split()]
# 商品価値が高い順に並び替え
V.sort(reverse=True)

# 商品価値が高いものから出来るだけ少なく（＝A個）選ぶのが最も平均価値が高くなる
S = V[:A]
ave = sum(S) / A
print(ave)

Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか
Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか

if min(S) == max(S): # もしもA個選んだ中の商品価値が全て同じだったら
    i = A
    while i <= B and V[-i] == min(S):
        C = C + math.factorial(Vs) // ( math.factorial(Vs - i) * math.factorial(i))
        i += 1
    

else: # 商品価値が均一でなかったのなら
    # nCk = n! /( (n-k)! * k! )に基づきCを計算
    C = math.factorial(Vs) // (math.factorial(Vs - Ss) * math.factorial(Ss) )

print(C)

### FIXED CODE ###

# 元ソースコード：http://abc057.contest.atcoder.jp/submissions/1183710
# 初心者の実験用です

import math
N,A,B = map(int,input().split())
V = list(map(int,input().split()))
V.sort()
S = V[-A:]
avgmax = sum(S) / A
print(avgmax)
 
Vs = V.count(min(S))
Ss = S.count(min(S))
if min(S) != max(S):
	C = math.factorial(Vs) // (math.factorial(Vs -Ss) * math.factorial(Ss))
	print(C)
else:
	i = A
	C = 0
	while i <= B and V[-i] == min(S):
		c = math.factorial(Vs) // (math.factorial(Vs -i) * math.factorial(i))
		C = C + c
		i = i + 1
	print(C)
def main():
    d = {}
    N = int(input())
    for i in range(N):
        s = input()
        d.setdefault(s, 1)
        d[s] += 1
    
    d = sorted(d.items())
    d = sorted(d, key=lambda x:x[1], reverse=True)
    n = d[0][1]
    for i in range(N):
        if d[i][1] != n:
            break
        print(d[i][0])

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    d = {}
    N = int(input())
    for i in range(N):
        s = input()
        d.setdefault(s, 1)
        d[s] += 1
    
    d = sorted(d.items())
    d = sorted(d, key=lambda x:x[1], reverse=True)
    n = d[0][1]
    for i in range(len(d)):
        if d[i][1] != n:
            break
        print(d[i][0])

if __name__ == '__main__':
    main()
s = list((input()))
k = int(input())
if "1" in s:
	flag = True
	if k > 100:
		k = 100
	for i in range(k):
		if s[i] != "1":
			if flag:
				p = int(s[i])
			flag = False
	if flag:
		print(1)
	else:
		print(p)
else:
	print(int(s[0]))

### FIXED CODE ###

s = list((input()))
k = int(input())
if "1" in s:
	flag = True
	if k > len(s):
		k = len(s)
	for i in range(k):
		if s[i] != "1":
			if flag:
				p = int(s[i])
			flag = False
	if flag:
		print(1)
	else:
		print(p)
else:
	print(int(s[0]))
"""半分くらいWA"""
# 最大公約数(mathは3.5以降) 
from functools import reduce
import fractions #(2020-0405  fractions→math)
def lcm_base(x, y):
    return  fractions.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm_list(numbers):
    return reduce(lcm_base, numbers)
def lcm_fukusu(*numbers):
    return reduce(lcm_base, numbers)

# 初期入力
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

#Aの隣り合う要素の最大公約数
ans =[]
if N==2:
    ans =max(A)
    print(ans)
    exit()
else:
    for i in range(N-1):
        ans.append(lcm_fukusu(A[i],A[i+1]))
    ans.append(lcm_fukusu(A[0],A[-1])) #len(A) ==3の時必要
    ans =list(set(ans))
    ans.sort()

if len(ans) ==1:
    print(ans[0])
elif len(ans) ==2:
    print(ans[1])
else:
    ans1=[]
    for i in ans[1:3]:
        aa= np.count_nonzero(np.array(A) %i ==0) #iで割り切れる要素を数える
        if aa >=N-1:
            ans1.append(i)
    ans =max(ans1)
    print(ans)

### FIXED CODE ###

"""参考
@ct158603292321　　2019年05月03日に更新
qiita AtCoder ABC125 解説
https://qiita.com/ct158603292321/items/4cddafa5c2500a657ccf
"""
#約数
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

# 初期入力
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A_np =np.array(A)

#list(A)の内、任意で2つ選び約数の和集合（公約数ではない）
div_A_2 =make_divisors(A[0]) + make_divisors(A[1])
ans =[]
for i in div_A_2:
    aa= np.count_nonzero(A_np %i ==0) #iで割り切れる要素を数える
    if aa >=N-1:
        ans.append(i)
print(max(ans))
import sys
input = sys.stdin.readline

n,q = map(int,input().split())
ab = [list(map(int,input().split()))for i in range(n-1)]
px = [list(map(int,input().split()))for i in range(q)]

def dfs(m):
    if m in vdic:
        for i in range(len(vdic[m])):
            point[vdic[m][i]] += point[m]
            dfs(vdic[m][i])

point = [0]*(n+1)

vdic = {}
for i in range(n-1):
    if ab[i][0] not in vdic:
        vdic[ab[i][0]] = []
    vdic[ab[i][0]].append(ab[i][1])

for i in range(q):
    point[px[i][0]] += px[i][1]
'''
for v in vdic:
    for c in vdic[v]:
        point[c] += point[v]
'''
dfs(1)

for i in range(1,len(point)):
    print(point[i],end = ' ')



### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

n,q = map(int,input().split())
ab = [list(map(int,input().split()))for i in range(n-1)]
px = [list(map(int,input().split()))for i in range(q)]

def dfs(m):
    for i in range(len(adj[m])):
        if depth[adj[m][i]] == float('inf'):
            depth[adj[m][i]] = depth[m] + 1
            point[adj[m][i]] += point[m]
            dfs(adj[m][i])


point = [0]*(n+1)
depth = [float('inf')]*(n+1)
adj = [[]for _ in range(n+1)]

for i in range(n-1):
    adj[ab[i][0]].append(ab[i][1])
    adj[ab[i][1]].append(ab[i][0])

for i in range(q):
    point[px[i][0]] += px[i][1]

depth[1] = 1
dfs(1)

for i in range(1,n+1):
    print(point[i],end = ' ')










'''
n,q = map(int,input().split())
ab = [list(map(int,input().split()))for i in range(n-1)]
px = [list(map(int,input().split()))for i in range(q)]

def dfs(m):
    if m in vdic:
        for i in range(len(vdic[m])):
            point[vdic[m][i]] += point[m]
            dfs(vdic[m][i])

point = [0]*(n+1)

vdic = {}
for i in range(n-1):
    if ab[i][0] not in vdic:
        vdic[ab[i][0]] = []
    vdic[ab[i][0]].append(ab[i][1])

for i in range(q):
    point[px[i][0]] += px[i][1]

dfs(1)

for i in range(1,len(point)):
    print(point[i],end = ' ')

'''
s=str(input())
even = ["L". "U", "D"]
odd = ["R", "U", "D"]
a = []
b = []
for i in range(len(str)):
     if i%2 == 0:
            if s[i] in even:
                a.apend(True) 
            else:
                a.apend(False)
     elif i%2 i= 0:
            if s[i] in odd:
                b.apend(True) 
            else:
                b.apend(False)
if all(a) and all(b):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s=str(input())
even = ["L","U", "D"]
odd = ["R", "U", "D"]
a = []
b = []
for i in range(len(s)):
     if (i+1)%2 == 0:
            if s[i] in even:
                a.append(True) 
            else:
                a.append(False)
     elif (i+1)%2 != 0:
            if s[i] in odd:
                b.append(True) 
            else:
                b.append(False)
if all(a) and all(b):
    print('Yes')
else:
    print('No')
q = input()
  
def edit_distance()
   X = raw_input()
   Y = raw_input()
     
   for i in range(0. len(X)):
      s[i] = i
     
   for i in range(1, len(X)):
      t = s + []
      for j in range(1, len(Y)):
         if s[i-1] == j[i-1]:
            s[j+1] = t[j] + 1
         elif [j+1] < s[j]:
            s[j+1] = t[j]
  
   return s[-1]
 
for k in range(0, q-1):
   edit_distance()

### FIXED CODE ###

def common():
   X = raw_input()
   Y = raw_input()
  
   s = [0 for i in range(len(Y)+1)]
 
   for j in range(0, len(X)):
      t = s + []
      for k in range(0, len(Y)):
         if X[j] == Y[k]:
            s[k+1] = t[k] + 1
         elif s[k+1] < s[k]:
            s[k+1] = s[k]
  
   print s[-1]
 
q = input()
for l in range(0, q):
   common()
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=input()
ls = [10**i for i in range(1,6)]
if int(n) in ls:
  print(10)
else:
  print(sum([list(n)[i] for i in range(len(n))]))

### FIXED CODE ###

n=input()
ls = [10**i for i in range(1,6)]
if int(n) in ls:
  print(10)
else:
  print(sum([int(list(n)[i]) for i in range(len(n))]))
import numpy as np
N, M = map(int, input().split())
 
for a in range(N):
  for b in range(N):
    c = np.abs(N - a - b)
    X = 10000*a + 5000*b + 1000*c
    
    if X == M:
      m10000 = a
      m5000 = b
      m1000 = c
      break
      
      
Nt = m10000 + m5000 + m1000
  
if N >= Nt:
  print(m10000, " ", m5000, " ", m1000)
else:
  print(-1, " ", -1, " ", -1)

### FIXED CODE ###


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

m10000 = -1
m5000 = -1
m1000 = -1
  
for a in range(N+1):
  for b in range(N+1-a):
    c = abs(N - a - b)
    X = 10000*a + 5000*b + 1000*c
    
    if X == M:
      m10000 = a
      m5000 = b
      m1000 = c

print(m10000, " ", m5000, " ", m1000)
import sys

sys.setrecursionlimit(10 ** 5 + 10)

MOD = 10 ** 9 + 7
inv = [None, 1]
for i in range(2, 10 ** 5 + 1):
    inv.append(MOD - MOD // i * inv[MOD % i] % MOD)

fact = [1]
ifact = [1]
for i in range(1, 10 ** 5 + 1):
    fact.append((i * fact[-1]) % MOD)
    ifact.append((inv[i] * ifact[-1]) % MOD)


class Node:
    def __init__(self, ind):
        self.ind = ind
        self.val = 1
        self.ndesc = 1
        self.neighs = []

    def calc(self, fro):
        for neigh in self.neighs:
            if neigh.ind == fro:
                continue
            neigh.calc(self.ind)
            self.val = self.val * neigh.val * ifact[neigh.ndesc] % MOD
            self.ndesc += neigh.ndesc
        self.val = self.val * fact[self.ndesc - 1] % MOD

    def comp(self, fro, carry):
        self.val = carry * self.ndesc * inv[max(1, N - self.ndesc)] % MOD
        for neigh in self.neighs:
            if neigh.ind == fro:
                continue
            neigh.comp(self.ind, self.val)


N = int(input())
nodes = [Node(i) for i in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    nodes[a - 1].neighs.append(nodes[b - 1])
    nodes[b - 1].neighs.append(nodes[a - 1])
nodes[0].calc(0)
nodes[0].comp(0, (nodes[0].val * inv[N]) % MOD)
for i in range(N):
    print(nodes[i].val)


### FIXED CODE ###

MOD = 10 ** 9 + 7
inv = [None, 1]
for i in range(2, 10 ** 5 * 2 + 1):
    inv.append(MOD - MOD // i * inv[MOD % i] % MOD)

fact = [1]
ifact = [1]
for i in range(1, 10 ** 5 * 2 + 1):
    fact.append((i * fact[-1]) % MOD)
    ifact.append((inv[i] * ifact[-1]) % MOD)


class Node:
    def __init__(self, ind):
        self.ind = ind
        self.val = 1
        self.ndesc = 1
        self.neighs = []


N = int(input())
nodes = [Node(i) for i in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    nodes[a - 1].neighs.append(nodes[b - 1])
    nodes[b - 1].neighs.append(nodes[a - 1])

stack = [(-1, nodes[0])]
for i in range(N):
    fro, node = stack[i]
    for neigh in node.neighs:
        if neigh.ind == fro:
            continue
        stack.append((node.ind, neigh))

for i in range(N - 1, -1, -1):
    fro, node = stack[i]
    node.val = node.val * fact[node.ndesc - 1] % MOD
    if fro == -1:
        continue
    nodes[fro].ndesc += node.ndesc
    nodes[fro].val = nodes[fro].val * node.val * ifact[node.ndesc] % MOD

stack = [(-1, node, nodes[0].val * inv[N] % MOD)]
for i in range(N):
    fro, node, val = stack[i]
    node.val = val * node.ndesc * inv[max(1, N - node.ndesc)] % MOD
    for neigh in node.neighs:
        if neigh.ind == fro:
            continue
        stack.append((node.ind, neigh, node.val))

for i in range(N):
    print(nodes[i].val)
while true:
    a = input()
    if a[1] == "?":
        break
    if a[1] == "+":
        print a[0]+a[2]
    elif a[1] == "-":
        print a[0]-a[2]
    elif a[1] == "*":
        print a[0]*a[2]
    elif a[1] == "/":
        print a[0]/a[2]

### FIXED CODE ###

while True:
    a, op, b = raw_input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    elif op == "+":
        print a + b
    elif op == "-":
        print a - b
    elif op == "*":
        print a * b
    elif op == "/":
        print a / b
N=int(input())
L=list(map(int, input().split()))

a=max(L)
b=sum(L)-a

if a>=B:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

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

a=max(L)
b=sum(L)-a

if a>=b:
  print('No')
else:
  print('Yes')
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print([K-1])

### FIXED CODE ###

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(list[K-1])
# coding: utf-8

# https://atcoder.jp/contests/abc085/tasks/abc085_c
# 19:24-


def main():
    N, Y = map(int, input().split())
    y = Y // 1000

    for b in range(N+1):
        if (y-N-4*b) % 9 == 0:
            c = (y-N-4*b) // 9
            a = N - b - c
            if a >= 0:
                return f"{c} {b} {a}"

    return "-1 -1 -1"


print(main())


### FIXED CODE ###

# coding: utf-8

# https://atcoder.jp/contests/abc085/tasks/abc085_c
# 19:24-19:38


def main():
    N, Y = map(int, input().split())
    y = Y // 1000

    for b in range(N+1):
        if (y-N-4*b) >= 0 and (y-N-4*b) % 9 == 0:
            c = (y-N-4*b) // 9
            a = N - b - c
            if a >= 0:
                return "{} {} {}".format(c, b, a)

    return "-1 -1 -1"


print(main())
import math

a, b = map(int, input().split())
print(a * b // math.gcd(a, b))


### FIXED CODE ###

from fractions import gcd
#from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))
x=int(input())
t=x
c==0
while x%2==0:
    c.append(2)
    n//=2
f=3
while f*f<=x:
    if x%f==0:
        c.append(f)
    else: f+=2
if x!=1:
    c.append(x)
while i in c:
    for a in range(10*3):
        if i*(a**4+a**3*(a-i)+a**2*(a-i)**2+a*(a-i)**3+(a-i)**4)==t:
            print(a,a-i)
            break
        if -i*(a**4+a**3*(a+i)+a**2*(a+i)**2+a*(a+i)**3+(a+i)**4)==t:
            print(a,a+i)
            break

### FIXED CODE ###

x=int(input())
ma=200
for i in range(ma):
    for j in range(-ma,ma):
        if (i**5 - j**5) ==x:
            print(i,j)
            exit()
import itertools

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

lis=[]
for i in range(q):
    lis.append(list(map(int,input().split())))

Alist=[]

for l in itertools.combinations(range(1,n+m-1),n):
    ll=list(l)
    a=[]
    for i in range(n):
        a.append(ll[i]-i)
    Alist.append(a)
slist=[]
for i in range(len(Alist)):
    s=0
    for j in range(q):
        aj=lis[j][0]
        bj=lis[j][1]
        cj=lis[j][2]
        dj=lis[j][3]
        if Alist[i][bj-1]-Alist[i][aj-1]==cj:
            s+=dj
    slist.append(s)

print(max(slist))

### FIXED CODE ###

import itertools

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

lis=[]
for i in range(q):
    lis.append(list(map(int,input().split())))

M=0
for l in map(list,itertools.combinations(range(1,n+m),n)):
    s=0
    for j in range(q):
        aj=lis[j][0]
        bj=lis[j][1]
        cj=lis[j][2]
        dj=lis[j][3]
        if l[bj-1]-bj-l[aj-1]+aj==cj:
            s+=dj
    M=max(M,s)
print(M)
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

N = 0
ans = []
for hi in range(H):
  for wi in range(W-1):
    if a[hi][wi]%2 == 1:
      N += 1
      a[hi][wi+1] += 1
      ans.append((hi+1, wi+1, hi+1, wi+2))
      
for hi in range(H-1):
  if a[hi][-1]%2 == 1:
    N += 1
    a[hi+1][wi] += 1
    ans.append((hi+1, W, hi+2, W))
    
print(N)
for y, x, yp, xp in ans:
  print(y, x, yp, xp)

### FIXED CODE ###

H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

N = 0
ans = []
for hi in range(H):
  for wi in range(W-1):
    if a[hi][wi]%2 == 1:
      N += 1
      a[hi][wi+1] += 1
      ans.append((hi+1, wi+1, hi+1, wi+2))
      
for hi in range(H-1):
  if a[hi][-1]%2 == 1:
    N += 1
    a[hi+1][-1] += 1
    ans.append((hi+1, W, hi+2, W))
    
print(N)
for y, x, yp, xp in ans:
  print(y, x, yp, xp)
n=int(input())
x=list(map(int,input().split()))
num=[]
num2=[]
ans=[]
count=0
numcount=0
numcount2=0
yn=0
for i in range(2,n+1):
    num+=[i]*(i-1)
for i in range(1,n):
    num2+=[i]*(n-i)
for i in range(n*n):
    if x[count]==i+1:
        if numcount<((count+1)*count)//2:
            yn=1
            break
        elif len(num2)-((n-count)*(n-count-1))//2<numcount2:
            yn=1
            break
        else:
            ans+=str(count+1)
        count+=1
    else:
        if numcount<len(num):
            ans+=str(num[numcount])
            numcount+=1
        elif numcount2<len(num2):
            ans+=str(num2[numcount2])
            numcount2+=1
        else:
            yn=1
            break
if yn==1:
    print("No")
else:
    print("Yes")
    print(*ans)


### FIXED CODE ###

def solve():
    n=int(input())
    x=list(map(int,input().split()))
    list1=[]
    def ap1(num):
        list1.append(num)
    for i in range(n):
        ap1([x[i],i+1])
    str1= lambda val: val[0]
    list1.sort(key=str1)
    numa=[]
    numb=[]
    for i in range(n):
        num3=list1[i][1]
        numa+=[num3]*(num3-1)
        numb+=[num3]*(n-num3)
    count1=0
    count2=0
    count3=0
    ans=[]
    ansnum=0
    def countnum(num):
        return ans.count(num)
    def apans(num):
        ans.append(num)
    for i in range(n*n):
        yn=0
        if count1!=n:
            if i==list1[count1][0]-1:
                if countnum(list1[count1][1])!=list1[count1][1]-1:
                    ansnum=1
                    break
                apans(list1[count1][1])
                count1+=1
                yn=1
        if yn==0:
            if count2!=len(numa):
                apans(numa[count2])
                count2+=1
            elif count3!=len(numb):
                apans(numb[count3])
                count3+=1
            else:
                if i!=n*n-1:
                    ansnum=1
                    break
    if ansnum==1:
        print("No")
    else:
        print("Yes")
        print(*ans)
solve()
N = int(input())
HList = [int(i) for i in input().split(" ")]
stn = HList[0]
stn2 = HList[1]

count = 0
for i in range(len(HList)) :
    if i == 0 :
        count += 1
    elif HList[i] >= stn and HList[i] >= HList[i-1] :
        count += 1
        if stn > HList[i] :
            stn = HList[i]

print(count)

### FIXED CODE ###

N = int(input())
HList = [int(i) for i in input().split(" ")]
stn = -1
count = 0

for i in range(len(HList)) :
    if HList[i] >= stn  :
        count += 1
    if stn < HList[i] :
        stn = HList[i]

print(count)
return 1000 - (int(input()) % 1000)

### FIXED CODE ###

print((1000 - (int(input()) % 1000)) % 1000)
N, K = map(int,input().split())
devisor = 10 ** 9 + 7

import math


def C(n,r):
    return math.factorial(n)//math.factorial(r)//math.factorial(n-r)

for i in range(K):
    print(C(N-K+1, i+1)*C(K-1, i) % devisor)

### FIXED CODE ###

N, B = map(int,input().split())
R = N-B
T = 1000000007

def generating_combination(n):
	T = 1000000007
	C = C = [[0 for i in range(n+1)] for j in range(n+1)]
	C[0][0] = 1
	C[1][0] = 1
	C[1][1] = 1
	for i in range(2,n+1):
		C[i][0] = 1
		C[i][i] = 1
		for j in range(1,i):
			C[i][j] = (C[i-1][j-1] + C[i-1][j])%T
	return(C)

D = generating_combination(2000)
for i in range(1,B+1):
	print((D[B-1][i-1]*D[R+1][i])%T)
n,k = map(int,input().split())
a = [0] + list(map(int,input().split()))
vcnt = [0]*(n+1)
vcnt[1] += 1
v = 1
sentou = 0
slist = []
vlist = [1]
hajime = 10**10
for i in range(1,k+1):
    v = a[v]
    vlist.append(v)
    vcnt[v] += 1
    if sentou > 0:
        syuuki += 1
    if vcnt[v] == 2:
        syuuki = 1
        sentou = a[v]
        slist.append(v)
    if vcnt[v] == 3:
        syuuki += 1
        hajime = i - syuuki*2
        break
else:
    print(v)
    exit()
#print(syuuki,hajime,sentou)
#print(slist)
k -= hajime
print(slist)
slist = [0] + slist
if (k+1)%syuuki == 0:
    print(slist[-1])
else:
    print(slist[(k+1)%syuuki])

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,k = map(int,input().split())
alist = list(map(lambda x:int(x) - 1,input().split()))
count = [0]*n
count[0] += 1
now = 0
order = [0]
for i in range(k):
    now = alist[now]
    count[now] += 1
    if count[now] == 2:
        start = order.index(now)
        loop = len(order[start:])
        syoki = len(order[:start])
        break
    order.append(now)
else:
    print(now+1)
    exit()
k -= syoki
k %= loop
print(order[k+syoki] + 1)
print(inpit()[0]+input()[1]+input()[2])

### FIXED CODE ###

print(input()[0]+input()[1]+input()[2])
N = int(input())
str_row = ['z','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']
result = []

while N > 26:
    r = N % 26
    result.append(str_row[r])
    N = int(N / 26)
    if N == 27:
        break

if N == 27:
    result.append('z')
else:
    result.append(str_row[N])

for i in result[::-1]:
    print(str(i), end='')
    

### FIXED CODE ###

n = int(input())
ans = ''
check = 'abcdefghijklmnopqrstuvwxyz'
while n != 0:
    n -= 1
    ans += check[n%26]
    n //= 26
print(ans[::-1])
N=int(input())
A=list(map(int,input().split()))
count=0
 
while all(a%2==0 for a in A):
  A=[a//2 for a in A]
  count+=1
 
print(count)

### FIXED CODE ###

s=input()
print(s.count('1'))
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = SR(3)
    print(s[0][0]+s[1][0]+s[2][0])
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = LS()
    print(s[0][0]+s[1][0]+s[2][0])
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()