problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k | fixed_code stringlengths 12 526k | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M | fixed_submission_id int64 2 1.54M | user_id stringlengths 10 10 | language stringclasses 8
values |
|---|---|---|---|---|---|---|---|
p02684 | N , K = map(int, input().split())
li = list(map(int, input().split()))
if K < N:
town = 0
for i in range(N):
town = li[town]-1
print(town+1)
else:
li2 = [0for i in range(N)]
count = 1
town = 0
while(1):
if li2[town] != 0:
num = count - li2[town]
num2 =... | N , K = map(int, input().split())
li = list(map(int, input().split()))
if K < N:
town = 0
for i in range(K):
town = li[town]-1
print(town+1)
else:
li2 = [0for i in range(N)]
count = 1
town = 0
while(1):
if li2[town] != 0:
num = count - li2[town]
num2 =... | [
"identifier.change",
"call.arguments.change",
"control_flow.loop.range.bounds.upper.change"
] | 415,656 | 415,657 | u133566678 | python |
p02684 | def search(now, teleporter, limit):
visit = [-1] * len(teleporter)
cnt = 0
while visit[now] == -1:
if limit <= cnt:
break
visit[now] = cnt
cnt += 1
now = teleporter[now]
return now, cnt, cnt - visit[now]
n, k = map(int, input(... | def search(now, teleporter, limit):
visit = [-1] * len(teleporter)
cnt = 0
while visit[now] == -1:
if limit <= cnt:
break
visit[now] = cnt
cnt += 1
now = teleporter[now]
return now, cnt, cnt - visit[now]
n, k = map(int, input(... | [
"assignment.add"
] | 415,664 | 415,665 | u872538555 | python |
p02684 | import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
# import heapq
# from collections import deque
# import decimal
sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7
ni = lambda: int(sys.stdin.readline())
ns... | import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
# import heapq
# from collections import deque
# import decimal
sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7
ni = lambda: int(sys.stdin.readline())
ns... | [
"expression.operation.binary.add"
] | 415,672 | 415,673 | u888337853 | python |
p02684 | N,K=map(int, input().split())
A=list(map(int, input().split()))
check=[0]*(N)
check[0]=1
D=[]
C=[0]
p=0
for i in range(N):
pp=A[p]-1
if check[pp]==0:
check[pp]=1
C.append(pp)
p=pp
else:
roop=pp
break
rs=C.index(roop)
if K<=rs-1:
print(C[K]+1)
else:
K-=(rs-1)
F=C[rs:]
e=K%(len(F))
pri... | N,K=map(int, input().split())
A=list(map(int, input().split()))
check=[0]*(N)
check[0]=1
D=[]
C=[0]
p=0
for i in range(N):
pp=A[p]-1
if check[pp]==0:
check[pp]=1
C.append(pp)
p=pp
else:
roop=pp
break
rs=C.index(roop)
if K<=rs-1:
print(C[K]+1)
else:
K-=(rs-1)
F=C[rs:]
e=K%(len(F))
pri... | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 415,678 | 415,679 | u572142121 | python |
p02684 | N,K=map(int, input().split())
A=list(map(int, input().split()))
check=[0]*(N)
check[0]=1
D=[]
C=[0]
p=0
for i in range(N):
pp=A[p]-1
if check[pp]==0:
check[pp]=1
C.append(pp)
p=pp
else:
roop=pp
break
rs=C.index(roop)
if K<=rs-1:
print(A[K]+1)
else:
K-=(rs-1)
C=C[rs:]
e=K%(len(C))
... | N,K=map(int, input().split())
A=list(map(int, input().split()))
check=[0]*(N)
check[0]=1
D=[]
C=[0]
p=0
for i in range(N):
pp=A[p]-1
if check[pp]==0:
check[pp]=1
C.append(pp)
p=pp
else:
roop=pp
break
rs=C.index(roop)
if K<=rs-1:
print(C[K]+1)
else:
K-=(rs-1)
F=C[rs:]
e=K%(len(F))
pri... | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change",
"assignment.variable.change",
"assignment.value.change"
] | 415,680 | 415,679 | u572142121 | python |
p02684 | n,k=map(int,input().split())
A=list(map(int,input().split()))
tele=[0 for _ in range(n+1)]
cnt=1
v=1
while True:
if tele[v]!=0:
break
else:
tele[v]=cnt
cnt+=1
v=A[v-1]
circle_in=tele[v]
circle=[]
for idx,t in enumerate(tele):
if t<circle_in:
continue
else:
... | n,k=map(int,input().split())
A=list(map(int,input().split()))
tele=[0 for _ in range(n+1)]
cnt=1
v=1
while True:
if tele[v]!=0:
break
else:
tele[v]=cnt
cnt+=1
v=A[v-1]
circle_in=tele[v]
circle=[]
for idx,t in enumerate(tele):
if t<circle_in:
continue
else:
... | [
"assignment.change"
] | 415,681 | 415,682 | u998262711 | python |
p02684 | int1 = lambda s: int(s)-1
N, K = map(int, input().split())
A = list(map(int1, input().split()))
X = []
visited = set()
now = 0
while now not in visited:
visited.add(now)
X.append(now)
now = A[now]
if K < len(X):
print(X[K])
else:
s = X.index(now)
print(X[s + ((K - s) % (len(X) - s))] + 1)
| int1 = lambda s: int(s)-1
N, K = map(int, input().split())
A = list(map(int1, input().split()))
X = []
visited = set()
now = 0
while now not in visited:
visited.add(now)
X.append(now)
now = A[now]
if K < len(X):
print(X[K] + 1)
else:
s = X.index(now)
print(X[s + ((K - s) % (len(X) - s))] + 1)... | [
"expression.operation.binary.add"
] | 415,689 | 415,690 | u565711859 | python |
p02684 | int1 = lambda s: int(s)-1
N, K = map(int, input().split())
A = list(map(int1, input().split()))
X = []
visited = set()
now = 0
while now not in visited:
visited.add(now)
X.append(now)
now = A[now]
if K < len(X):
print(X[k])
else:
s = X.index(now)
print(X[s + ((K - s) % (len(X) - s))] + 1)
| int1 = lambda s: int(s)-1
N, K = map(int, input().split())
A = list(map(int1, input().split()))
X = []
visited = set()
now = 0
while now not in visited:
visited.add(now)
X.append(now)
now = A[now]
if K < len(X):
print(X[K] + 1)
else:
s = X.index(now)
print(X[s + ((K - s) % (len(X) - s))] + 1)... | [
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"io.output.change"
] | 415,691 | 415,690 | u565711859 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = {1: 0}
index = 0
last = 1
for i in range(K):
t = A[last - 1]
index += 1
if t in visited:
z = K - i - 1
l = index - visited[t]
print([k for k, v in visited.items() if v == visited[t] + (z % l)][0])
... | N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = {1: 0}
index = 0
last = 1
for i in range(K):
t = A[last - 1]
index += 1
if t in visited:
z = K - i - 1
l = index - visited[t]
print([k for k, v in visited.items() if v == visited[t] + (z % l)][0])
... | [
"call.arguments.change",
"io.output.change"
] | 415,692 | 415,693 | u596368396 | python |
p02684 | N,K = map(int,input().split())
A = list(map(lambda x: int(x) - 1, input().split()))
P = [-1] * N
cur = 0
P[cur] = 0
route = [1]
for step in range(K):
cur = A[cur]
route.append(cur + 1)
if P[cur] >= 0:
l_start = P[cur]
l_end = step + 1
l_len = l_end - l_start
break
else:
P[cur] = step + 1
e... | N,K = map(int,input().split())
A = list(map(lambda x: int(x) - 1, input().split()))
P = [-1] * N
cur = 0
P[cur] = 0
route = [1]
for step in range(K):
cur = A[cur]
route.append(cur + 1)
if P[cur] >= 0:
l_start = P[cur]
l_end = step + 1
l_len = l_end - l_start
break
else:
P[cur] = step + 1
e... | [
"expression.operation.binary.add"
] | 415,696 | 415,697 | u419354839 | python |
p02684 | N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
ans = 1
n = 1
check = 1
city = [-1 for i in range(N+1)]
city[1] = 0
roop = 1
i = 0
while(check == 1):
if i == K:
check = 0
else:
n = A[n]
i = i + 1
if city[n] == -1:
city[n] = i
else:
roop = i - city[n] + 1
... | N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
ans = 1
n = 1
check = 1
city = [-1 for i in range(N+1)]
city[1] = 0
roop = 1
i = 0
while(check == 1):
if i == K:
check = 0
else:
n = A[n]
i = i + 1
if city[n] == -1:
city[n] = i
else:
roop = i - city[n]
ch... | [
"expression.operation.binary.remove"
] | 415,700 | 415,701 | u078816252 | python |
p02684 | N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
ans = 1
n = 1
check = 1
city = [-1 for i in range(N+1)]
city[1] = 0
roop = 1
i = 0
while(check == 1):
if i == K:
check = 0
else:
n = A[n]
i = i + 1
if city[n] == -1:
city[n] = i
else:
roop = i - city[n] + 1
... | N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
ans = 1
n = 1
check = 1
city = [-1 for i in range(N+1)]
city[1] = 0
roop = 1
i = 0
while(check == 1):
if i == K:
check = 0
else:
n = A[n]
i = i + 1
if city[n] == -1:
city[n] = i
else:
roop = i - city[n]
ch... | [
"expression.operation.binary.remove"
] | 415,702 | 415,701 | u078816252 | python |
p02684 | N,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
A.insert(0,0)
rireki = [1]
counter = 1
now = 1
flag = [0 for _ in range(N + 1)]
flag[1] = 1
while(flag[A[now]] == 0):
counter += 1
rireki.append(A[now])
flag[A[now]] = counter
now = A[now]
if K < flag[A[now]]:
print(rireki[K - 1... | N,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
A.insert(0,0)
rireki = [1]
counter = 1
now = 1
flag = [0 for _ in range(N + 1)]
flag[1] = 1
while(flag[A[now]] == 0):
counter += 1
rireki.append(A[now])
flag[A[now]] = counter
now = A[now]
if K < flag[A[now]]:
print(rireki[K])
e... | [
"expression.operation.binary.remove"
] | 415,708 | 415,709 | u017050982 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, (input().split())))
done = [0]*N
now = 0
cnt = 1
while True:
if done[now] != 0:
start = done[now] - 1
cycle = cnt - start - 1
break
else:
done[now] = cnt
now = A[now]-1
cnt += 1
if K>=start:
K -= start
K ... | N, K = map(int, input().split())
A = list(map(int, (input().split())))
done = [0]*N
now = 0
cnt = 1
while True:
if done[now] != 0:
start = done[now] - 1
cycle = cnt - start - 1
break
else:
done[now] = cnt
now = A[now]-1
cnt += 1
if K>=start:
K -= start
K ... | [
"assignment.add"
] | 415,710 | 415,711 | u475503988 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, (input().split())))
done = [0]*N
now = 0
cnt = 1
while True:
if done[now] != 0:
start = done[now] - 1
cycle = cnt - start - 1
break
else:
done[now] = cnt
now = A[now]-1
cnt += 1
if K>=start:
K -= start
K %= c... | N, K = map(int, input().split())
A = list(map(int, (input().split())))
done = [0]*N
now = 0
cnt = 1
while True:
if done[now] != 0:
start = done[now] - 1
cycle = cnt - start - 1
break
else:
done[now] = cnt
now = A[now]-1
cnt += 1
if K>=start:
K -= start
K ... | [
"assignment.add"
] | 415,712 | 415,711 | u475503988 | python |
p02684 | import sys
sys.setrecursionlimit(10**7)
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n, k = na()
a = na()
for i in range(n):
a[i] -= 1
ct = [0 for i in range(n)]
seen = [False] * n
def dfs(v):
... | import sys
sys.setrecursionlimit(10**7)
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
n, k = na()
a = na()
for i in range(n):
a[i] -= 1
ct = [0 for i in range(n)]
seen = [False] * n
def dfs(v):
... | [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"control_flow.branch.if.replace.remove",
"control_flow.branch.else_if.replace.add"
] | 415,713 | 415,714 | u177411511 | python |
p02684 | def main():
from sys import stdin
n,k = map(int,stdin.readline().rstrip().split())
As = list(map(int,stdin.readline().rstrip().split()))
As = [0]+As
g = set({1})
l = [0,1]
now = 1
i = 0
while True:
i+=1
now = As[now]
if now in g:
j = l.index(now)
... | def main():
from sys import stdin
n,k = map(int,stdin.readline().rstrip().split())
As = list(map(int,stdin.readline().rstrip().split()))
As = [0]+As
g = set({1})
l = [0,1]
now = 1
i = 0
while True:
i+=1
now = As[now]
if now in g:
j = l.index(now)
... | [
"call.arguments.change"
] | 415,715 | 415,716 | u474561976 | python |
p02684 | N, K= [int(i) for i in input().split()]
An = [int(i) for i in input().split()]
i = 0
checked = [0 for _ in range(N)]
c = 0
while checked[i] == 0:
c += 1
checked[i] = c
i = An[i] - 1
if checked[i] >= K:
i = 0
for k in range(mod_K):
i = An[i] - 1
print(i + 1)
else:
period = c - checked[i] + 1
diff = ... | N, K= [int(i) for i in input().split()]
An = [int(i) for i in input().split()]
i = 0
checked = [0 for _ in range(N)]
c = 0
while checked[i] == 0:
c += 1
checked[i] = c
i = An[i] - 1
if checked[i] >= K:
i = 0
for k in range(K):
i = An[i] - 1
print(i + 1)
else:
period = c - checked[i] + 1
diff = K - ... | [
"identifier.change",
"call.arguments.change",
"control_flow.loop.range.bounds.upper.change"
] | 415,719 | 415,720 | u770199020 | python |
p02684 | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
if K == 1:
print(A[0])
exit()
if A[0] == 1:
print(1)
exit()
# (cnt, k)
visit_town = [(0, 0)]*N
history = [0]*N
visit_town[0] = (1, 0)
history[0] = 1
visit = -1
for i in range(K):
next_town = A[history[i]-1]
if visit_t... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
if K == 1:
print(A[0])
exit()
if A[0] == 1:
print(1)
exit()
# (cnt, k)
visit_town = [(0, 0)]*N
history = [0]*N
visit_town[0] = (1, 0)
history[0] = 1
visit = -1
for i in range(K):
next_town = A[history[i]-1]
if visit_t... | [
"assignment.change"
] | 415,739 | 415,740 | u513519822 | python |
p02684 | N, K = map(int, input().split())
A = list(map(lambda x:int(x) - 1, input().split()))
already = [False for i in range(N)]
already[0] = True
tel = [0]
while True:
tmp = A[tel[-1]]
tel.append(tmp)
if already[tmp]:
tel.pop()
break
already[tmp] = True
for i in range(len(tel))... | N, K = map(int, input().split())
A = list(map(lambda x:int(x) - 1, input().split()))
already = [False for i in range(N)]
already[0] = True
tel = [0]
while True:
tmp = A[tel[-1]]
tel.append(tmp)
if already[tmp]:
tel.pop()
break
already[tmp] = True
for i in range(len(tel))... | [
"call.arguments.change"
] | 415,744 | 415,745 | u651109406 | python |
p02684 | N, K = map(int, input().split())
A = list(map(lambda x:int(x) - 1, input().split()))
already = [False for i in range(N)]
already[0] = True
tel = [0]
while True:
tmp = A[tel[-1]]
tel.append(tmp)
if already[tmp]:
tel.pop()
break
already[tmp] = True
for i in range(len(tel))... | N, K = map(int, input().split())
A = list(map(lambda x:int(x) - 1, input().split()))
already = [False for i in range(N)]
already[0] = True
tel = [0]
while True:
tmp = A[tel[-1]]
tel.append(tmp)
if already[tmp]:
tel.pop()
break
already[tmp] = True
for i in range(len(tel))... | [
"expression.operation.binary.add"
] | 415,746 | 415,745 | u651109406 | python |
p02684 | N,K=map(int,input().split())
A=list(map(int,input().split()))
ischecked=[0]*N
move=[]
move1=[]
now=0
count=0
count1=0
while 1:
move.append(now+1)
nex=A[now]-1
ischecked[now]=1
if ischecked[nex]==1:
roop=nex+1
break
now=nex
for i in range(len(move))[::-1]:
move1.append(move[i])
... | N,K=map(int,input().split())
A=list(map(int,input().split()))
ischecked=[0]*N
move=[]
move1=[]
now=0
count=0
count1=0
while 1:
move.append(now+1)
nex=A[now]-1
ischecked[now]=1
if ischecked[nex]==1:
roop=nex+1
break
now=nex
for i in range(len(move))[::-1]:
move1.append(move[i])
... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 415,760 | 415,761 | u265506056 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, input().split()))
tele = [0] * N
for i in range(N):
tele[i] = A[i] - 1
now = 0
cnt = 0
exp = [False] * N
period = 0
loop = False
start = -1
while cnt < K:
exp[now] = True
now = tele[now]
cnt += 1
if loop:
period += 1
if now == start:... | N, K = map(int, input().split())
A = list(map(int, input().split()))
tele = [0] * N
for i in range(N):
tele[i] = A[i] - 1
now = 0
cnt = 0
exp = [False] * N
period = 0
loop = False
start = -1
while cnt < K:
exp[now] = True
now = tele[now]
cnt += 1
if loop:
period += 1
if now == start:... | [
"assignment.value.change"
] | 415,780 | 415,781 | u514390882 | python |
p02684 | n, k = list(map(int, input().split()))
al = list(map(int, input().split()))
al = [a-1 for a in al]
used = [0]*n
first = [0]*n
step = 0
used[0] = 1
now = 0
for i in range(k):
step += 1
get = al[now]
if used[get] == 0:
first[get] = step
used[get] = 1
now = get
else:
dif = s... | n, k = list(map(int, input().split()))
al = list(map(int, input().split()))
al = [a-1 for a in al]
used = [0]*n
first = [0]*n
step = 0
used[0] = 1
now = 0
for i in range(k):
step += 1
get = al[now]
if used[get] == 0:
first[get] = step
used[get] = 1
now = get
else:
dif = s... | [
"expression.operation.binary.add"
] | 415,782 | 415,783 | u540877546 | python |
p02684 | n, k = map(int, input().split())
a = list(map(int, input().split()))
b = 1
c = [-1]*n
c[0] = 0
for i in range(n):
b = a[b-1]
if c[b-1] == -1:
c[b-1] = i+1
else:
d = i+1-c[b-1]
e = c[b-1]
break;
b = 1
for i in range(e+(k-e)%d):
b = a[b-1]
print(b) | n, k = map(int, input().split())
a = list(map(int, input().split()))
b = 1
c = [-1]*n
c[0] = 0
for i in range(n):
b = a[b-1]
if c[b-1] == -1:
c[b-1] = i+1
else:
d = i+1-c[b-1]
e = c[b-1]
break;
b = 1
for i in range(min(k, e+(k-e)%d)):
b = a[b-1]
print(b) | [
"call.add",
"call.arguments.change",
"control_flow.loop.range.bounds.upper.change"
] | 415,784 | 415,785 | u785573018 | python |
p02684 | #author: raghav_0901
from math import *
mod = (10**9) + 7
def _in():
return [int(x) - 1 for x in input().split(' ')]
def main():
n, k = [int(x) for x in input().split(' ')]
arr, dp = _in(), [0, ]
vis = [False] * (n)
vis[0], nxt = True, arr[0]
while(not vis[nxt] and len(dp) < k):
dp.... | #author: raghav_0901
from math import *
mod = (10**9) + 7
def _in():
return [int(x) - 1 for x in input().split(' ')]
def main():
n, k = [int(x) for x in input().split(' ')]
arr, dp = _in(), [0, ]
vis = [False] * (n)
vis[0], nxt = True, arr[0]
while(not vis[nxt] and len(dp) <= k):
dp... | [
"expression.operator.compare.change",
"control_flow.loop.condition.change",
"control_flow.branch.if.condition.change"
] | 415,802 | 415,803 | u287182213 | python |
p02684 | n,k=map(int,input().split())
a=[0]*n
a=list(map(int,input().split()))
List=[0]*n
pattern=[1]
now=0
nex=0
List[0]=1
end_flag=0
while end_flag==0:
nex=a[now]
if (List[nex-1]==1):
target1=nex
end_flag=1
break
else:
List[nex-1]+=1
pattern.append(nex)
now=nex-1
... | n,k=map(int,input().split())
a=[0]*n
a=list(map(int,input().split()))
List=[0]*n
pattern=[1]
now=0
nex=0
List[0]=1
end_flag=0
while end_flag==0:
nex=a[now]
if (List[nex-1]==1):
target1=nex
end_flag=1
break
else:
List[nex-1]+=1
pattern.append(nex)
now=nex-1
... | [
"control_flow.branch.if.condition.change"
] | 415,814 | 415,815 | u286754585 | python |
p02684 | def resolve():
n, g = map(int, input().split())
a = list(map(int, input().split()))
ar = [-1] * n
k = 0
now = 0
for i in range(n+1):
if ar[now] == -1:
ar[now] = k
now = a[now]-1
k += 1
else:
start = ar[now]
startnode = n... | def resolve():
n, g = map(int, input().split())
a = list(map(int, input().split()))
ar = [-1] * n
k = 0
now = 0
for i in range(n+1):
if ar[now] == -1:
ar[now] = k
now = a[now]-1
k += 1
else:
start = ar[now]
startnode = n... | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 415,816 | 415,817 | u793868662 | python |
p02684 | n,k=map(int,input().split())
A=[int(i) for i in input().split()]
went={i:0 for i in range(1,n+1)}
now=1
cnt=1
for i in range(n+1):
if went[now]>0:
t=cnt-1
s=went[now]
break
else:
went[now]=cnt
now=A[now-1]
cnt+=1
if k <= t:
val=k+1
else:
val=((k+1-t)%(... | n,k=map(int,input().split())
A=[int(i) for i in input().split()]
went={i:0 for i in range(1,n+1)}
now=1
cnt=1
for i in range(n+1):
if went[now]>0:
t=cnt-1
s=went[now]
break
else:
went[now]=cnt
now=A[now-1]
cnt+=1
if k <= t-1:
val=k+1
else:
val=((k+1-t)... | [
"control_flow.branch.if.condition.change"
] | 415,831 | 415,832 | u459798349 | python |
p02684 | import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
d... | import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()
d... | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 415,835 | 415,836 | u634461820 | python |
p02684 | # -*- coding: utf-8 -*-
n,k=map(int, input().split())
a=list(map(int, input().split()))
isUsed=[False]*n
path = [1]
#isUsed[0] = True
i = 1
while(True):
idx = i-1
if isUsed[idx]: #既に行ったことがある町であれば
#print("行ったことのある町です")
#print("i", i)
start = path.index(i)
break
else:
... | # -*- coding: utf-8 -*-
n,k=map(int, input().split())
a=list(map(int, input().split()))
isUsed=[False]*n
path = [1]
#isUsed[0] = True
i = 1
while(True):
idx = i-1
if isUsed[idx]: #既に行ったことがある町であれば
#print("行ったことのある町です")
#print("i", i)
start = path.index(i)
break
else:
... | [
"expression.operation.binary.remove"
] | 415,839 | 415,840 | u971237642 | python |
p02684 | import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect ... | import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect ... | [
"expression.operation.binary.remove"
] | 415,841 | 415,842 | u852110531 | python |
p02684 | import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect ... | import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect ... | [
"expression.operation.binary.remove",
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"call.function.change",
"io.output.change"
] | 415,843 | 415,842 | u852110531 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
A[i] -= 1
li = [False] * N
f = True
now = 0
l = []
l2 = [0] * N
i = 0
while f:
l.append(now)
li[now] = True
l2[now] = i
if li[A[now]]:
f = False
num = len(l) - l2[A[now]]
n = l2[A[now]]
... | N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
A[i] -= 1
li = [False] * N
f = True
now = 0
l = []
l2 = [0] * N
i = 0
while f:
l.append(now)
li[now] = True
l2[now] = i
if li[A[now]]:
f = False
num = len(l) - l2[A[now]]
n = l2[A[now]]
... | [
"call.add",
"call.arguments.change"
] | 415,844 | 415,845 | u871352270 | python |
p02684 | import math,sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda:int(input())
li = lambda:list(map(int,input().split()))
def case():
n,k=li()
a=li()
d=defaultdict(int)
i=0
d[1]=1
c=0
ans=[1]
while(a[i] not in d):
... | import math,sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda:int(input())
li = lambda:list(map(int,input().split()))
def case():
n,k=li()
a=li()
d=defaultdict(int)
i=0
d[1]=1
c=0
ans=[1]
while(a[i] not in d):
... | [
"call.remove",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 415,848 | 415,849 | u183383816 | python |
p02684 | import math,sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda:int(input())
li = lambda:list(map(int,input().split()))
def case():
n,k=li()
a=li()
d=defaultdict(int)
i=0
d[1]=1
c=0
ans=[1]
while(a[i] not in d):
... | import math,sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda:int(input())
li = lambda:list(map(int,input().split()))
def case():
n,k=li()
a=li()
d=defaultdict(int)
i=0
d[1]=1
c=0
ans=[1]
while(a[i] not in d):
... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"identifier.change"
] | 415,850 | 415,849 | u183383816 | python |
p02684 | N,K=map(int,input().split())
A=list(map(int,input().split()))
visited=[0 for i in range(N)]
visited[0]=1
tour=[1]
while True:
goto=A[tour[-1]-1]
tour.append(goto)
if visited[goto-1]:
break
visited[goto-1]=1
#print(tour)
before=0
shuuki=1
for i in range(len(tour)):
if tour[i]==tour[-1]... | N,K=map(int,input().split())
A=list(map(int,input().split()))
visited=[0 for i in range(N)]
visited[0]=1
tour=[1]
while True:
goto=A[tour[-1]-1]
tour.append(goto)
if visited[goto-1]:
break
visited[goto-1]=1
#print(tour)
before=0
shuuki=1
for i in range(len(tour)):
if tour[i]==tour[-1]... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 415,851 | 415,852 | u614875193 | python |
p02684 | N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
counter=1
now=1
gone_set={1}
gone_list=[1]
place=1
while counter<=N:
next=A[now]
if next in gone_set:
start=gone_list.index(next)
loop=len(gone_list)-start
last=(K-start)%loop
place=gone_list[start+last]
b... | N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
counter=1
now=1
gone_set={1}
gone_list=[1]
place=1
while counter<=K:
next=A[now]
place=next
if next in gone_set:
start=gone_list.index(next)
loop=len(gone_list)-start
last=(K-start)%loop
place=gone_list[start+... | [
"identifier.change",
"control_flow.loop.condition.change"
] | 415,853 | 415,854 | u523545435 | python |
p02684 | n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
cnt=[]
m=0
ans=0
for i in range(2*n):
if a[m] in d:
ans+=1
cnt.append(a[m])
if ans==k:
print(a[m])
break
else:
d[a[m]]=0
cnt.append(a[m])
ans+=1
if ans==k:
print(a[m])
break
m=a[m]-1
if ans!=k:
... | n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
cnt=[]
m=0
ans=0
for i in range(2*n):
if a[m] in d:
ans+=1
cnt.append(a[m])
if ans==k:
print(a[m])
break
else:
d[a[m]]=0
cnt.append(a[m])
ans+=1
if ans==k:
print(a[m])
break
m=a[m]-1
if ans!=k:
... | [
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 415,861 | 415,862 | u385309449 | python |
p02684 | n, k = map(int, input().split())
a = list(map(int, input().split()))
move = [a[i] - 1 for i in range(n)]
#print(move)
d = [-1 for _ in range(n)]
d[0] = 0
cur = 0
for _ in range(300000):
to = move[cur]
if d[to] == -1:
d[to] = d[cur] + 1
else:
rou = d[cur] + 1 - d[to]
rou_start = to
... | n, k = map(int, input().split())
a = list(map(int, input().split()))
#n, k = 200000, 100
#a = [i+2 for i in range(n-1)] + [2]
move = [a[i] - 1 for i in range(n)]
#print(move)
d = [-1 for _ in range(n)]
d[0] = 0
cur = 0
for _ in range(300000):
to = move[cur]
if d[to] == -1:
d[to] = d[cur] + 1
else:
... | [
"assignment.add"
] | 415,869 | 415,870 | u139112865 | python |
p02684 | import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
#各頂点が白(0)か黒(1)か
flag = [-1 for _ in range(n)]
#dfsで色を塗っていく
#頂点の数をN、辺の数をMとすると、O(N+M)で解ける
stack = [a[0]-1]
flag[0] = 0
count = 0
while stack:
u = stack.pop()
if flag[u] == -1:
stack.append(a[u] - 1)
count += 1
if count == k:
print(... | import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
#各頂点が白(0)か黒(1)か
flag = [-1 for _ in range(n)]
#dfsで色を塗っていく
#頂点の数をN、辺の数をMとすると、O(N+M)で解ける
stack = [a[0]-1]
flag[0] = 0
count = 0
while stack:
u = stack.pop()
if flag[u] == -1:
stack.append(a[u] - 1)
count += 1
if count == k:
print(... | [
"call.arguments.change",
"io.output.change"
] | 415,875 | 415,876 | u773265208 | python |
p02684 | n, k =[int(i) for i in input().split()]
a = [int(i) - 1 for i in input().split()]
go = dict()
res = []
go[0] = True
res = [0]
now = a[0]
while True:
if now in go:
break
res.append(now)
go[now] = True
now = a[now]
# 1
# [0, 1, 2, 3]
# (5 - 1) % (xunhuan)
amari = res.index(now)
xunhuan = res[a... | n, k =[int(i) for i in input().split()]
a = [int(i) - 1 for i in input().split()]
go = dict()
res = []
go[0] = True
res = [0]
now = a[0]
while True:
if now in go:
break
res.append(now)
go[now] = True
now = a[now]
# 1
# [0, 1, 2, 3]
# (5 - 1) % (xunhuan)
amari = res.index(now)
xunhuan = res[a... | [
"expression.operation.binary.add"
] | 415,877 | 415,878 | u215115622 | python |
p02684 | import sys
sys.setrecursionlimit(10 ** 6) # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1 # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n") # リストの要素を改行を挟んで表示する関数
# 入力を整数に変換して受け取る
def input_int():
return int(input())
def map_int_input():
return map(int, input())
MII = map_int_input
def ... | import sys
sys.setrecursionlimit(10 ** 6) # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1 # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n") # リストの要素を改行を挟んで表示する関数
# 入力を整数に変換して受け取る
def input_int():
return int(input())
def map_int_input():
return map(int, input())
MII = map_int_input
def ... | [
"expression.operation.binary.remove"
] | 415,887 | 415,888 | u199830845 | python |
p02684 | n , k = map(int, input().split())
a = list(map(int,input().split()))
v = [0]*(n+1)
v[1]=1
v2=[1]
i=0
step=1
while True:
if v[a[i]]!=0:
loop=step-v[a[i]]+1
loopstart=v[a[i]]
break
else:
step+=1
v[a[i]]=step
v2.append(a[i])
i=a[i]-1
ans = (k-loopstart+2)%lo... | n , k = map(int, input().split())
a = list(map(int,input().split()))
v = [0]*(n+1)
v[1]=1
v2=[1]
i=0
step=1
while True:
if v[a[i]]!=0:
loop=step-v[a[i]]+1
loopstart=v[a[i]]
break
else:
step+=1
v[a[i]]=step
v2.append(a[i])
i=a[i]-1
ans = (k-loopstart+2)%lo... | [
"expression.operation.binary.remove",
"call.add"
] | 415,889 | 415,890 | u151785909 | python |
p02684 | def main(sample_file = ''):
""" convenient functions
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# Higher-order function: reduce(operator.mul, xyz_count, 1)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc... | def main(sample_file = ''):
""" convenient functions
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# Higher-order function: reduce(operator.mul, xyz_count, 1)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc... | [
"assignment.change"
] | 415,899 | 415,900 | u988402778 | python |
p02684 | def main(sample_file = ''):
""" convenient functions
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# Higher-order function: reduce(operator.mul, xyz_count, 1)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc... | def main(sample_file = ''):
""" convenient functions
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# Higher-order function: reduce(operator.mul, xyz_count, 1)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc... | [
"assignment.change",
"expression.operation.binary.add"
] | 415,901 | 415,900 | u988402778 | python |
p02684 | N, K = map(int, input().split())
A = [int(x) - 1 for x in input().split()]
# 最初のループを回るまで
loop = 0
city = 0
b = set([0])
while True:
loop += 1
if A[city] in b:
break
else:
city = A[city]
b.add(city)
loop_start = A[city]
# ループの始点にたどり着くまで
pre = 0
city = 0
while True:
pre += 1
... | N, K = map(int, input().split())
A = [int(x) - 1 for x in input().split()]
# 最初のループを回るまで
loop = 0
city = 0
b = set([0])
while True:
loop += 1
if A[city] in b:
break
else:
city = A[city]
b.add(city)
loop_start = A[city]
# ループの始点にたどり着くまで
pre = 0
city = 0
while True:
pre += 1
... | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 415,902 | 415,903 | u726285999 | python |
p02684 | #import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
import itertools
import heapq
#import bisect
import copy
from functools import lru_cache
def sosuhante(n):
for k in range(2, int(math.sqrt(n))+1):
if n% k ==0:
return False
return True
def cmb(n, r):
i... | #import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
import itertools
import heapq
#import bisect
import copy
from functools import lru_cache
def sosuhante(n):
for k in range(2, int(math.sqrt(n))+1):
if n% k ==0:
return False
return True
def cmb(n, r):
i... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 415,911 | 415,912 | u366482170 | python |
p02684 | #import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
import itertools
import heapq
#import bisect
import copy
from functools import lru_cache
def sosuhante(n):
for k in range(2, int(math.sqrt(n))+1):
if n% k ==0:
return False
return True
def cmb(n, r):
i... | #import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
import itertools
import heapq
#import bisect
import copy
from functools import lru_cache
def sosuhante(n):
for k in range(2, int(math.sqrt(n))+1):
if n% k ==0:
return False
return True
def cmb(n, r):
i... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 415,913 | 415,912 | u366482170 | python |
p02684 | n, k = map(int, input().split())
an = list(map(int, input().split()))
group = [0]
now = 0
seen = [0]*n
seen[0] = 1
while True:
now = an[now] - 1
group.append(now)
if seen[now] == 1:
break
seen[now] = 1
l = len(group)
a = group.index(group[-1])
roop = l - a - 1
if k < a:
print(group[k... | n, k = map(int, input().split())
an = list(map(int, input().split()))
group = [0]
now = 0
seen = [0]*n
seen[0] = 1
while True:
now = an[now] - 1
group.append(now)
if seen[now] == 1:
break
seen[now] = 1
l = len(group)
a = group.index(group[-1])
roop = l - a - 1
if k < a:
print(group[k... | [
"expression.operation.binary.add"
] | 415,920 | 415,921 | u086438369 | python |
p02684 | n, k = map(int, input().split())
a = list(map(int, input().split()))
flg = True
c = [0 for i in range(n)]
i = 1
b = []
d = []
one = False
while flg:
x = i-1
if c[x] == 1 and a[x] == 1:
flg = False
one = True
break
elif c[x] == 3:
flg = False
break
else:
c[x] += 1
if c[x] == 1:
b.append(x+1)
if c... | n, k = map(int, input().split())
a = list(map(int, input().split()))
flg = True
c = [0 for i in range(n)]
i = 1
b = []
d = []
one = False
while flg:
x = i-1
if c[x] == 1 and a[x] == 1:
flg = False
one = True
break
elif c[x] == 3:
flg = False
break
else:
c[x] += 1
if c[x] == 1:
b.append(x+1)
if c... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 415,924 | 415,925 | u124498235 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, input().split()))
def solve():
visited = [-1]*N
visited[0] = 0
goto = 1
counter = 0
period = 0
while 1:
counter += 1 #counter 回ワープした
goto = A[goto-1] #counter回目につく場所
if counter == K:
print(A)
ret... | N, K = map(int, input().split())
A = list(map(int, input().split()))
def solve():
visited = [-1]*N
visited[0] = 0
goto = 1
counter = 0
period = 0
while 1:
counter += 1 #counter 回ワープした
goto = A[goto-1] #counter回目につく場所
if counter == K:
print(goto)
... | [
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 415,928 | 415,929 | u539969758 | python |
p02684 | n, k = map(int, input().split())
l = list(map(int, input().split()))
arr = []
check = [0] * (n + 2)
check[1] = 1
c = 0
num = 1
yo = 0
while 1:
arr.append(l[c])
if l[c] == 1:
yo = 1
break
if check[l[c]]:
arr.pop()
c = l[c]
break
check[l[c]] = 1
num -= -1
c ... | n, k = map(int, input().split())
l = list(map(int, input().split()))
arr = []
check = [0] * (n + 2)
check[1] = 1
c = 0
num = 1
yo = 0
while 1:
arr.append(l[c])
if l[c] == 1:
yo = 1
break
if check[l[c]]:
arr.pop()
c = l[c]
break
check[l[c]] = 1
num -= -1
c ... | [
"expression.operation.binary.add"
] | 415,932 | 415,933 | u912997017 | python |
p02684 | n,k=map(int,input().split())
A=list(map(int,input().split()))
p=1
l=[0]*n
#l[0]+=1
if k<=100000:
for i in range(k):
p=A[p-1]
l[p-1]+=1
print(p)
exit()
else:
for i in range(100001):
p=A[p-1]#A[0]の番号の町に飛ぶ
l[p-1]+=1
#print(p)
if l[p-1]==2:
x=i
... | n,k=map(int,input().split())
A=list(map(int,input().split()))
p=1
l=[0]*n
#l[0]+=1
if k<=200000:
for i in range(k):
p=A[p-1]
l[p-1]+=1
print(p)
exit()
else:
for i in range(200001):
p=A[p-1]#A[0]の番号の町に飛ぶ
l[p-1]+=1
#print(p)
if l[p-1]==2:
x=i
... | [
"literal.number.integer.change",
"control_flow.branch.if.condition.change",
"call.arguments.change",
"control_flow.loop.range.bounds.upper.change"
] | 415,940 | 415,941 | u349444371 | python |
p02684 | import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
array = [-1] * (n+1)
array[1] = 0
li = []
li.append(1)
tmp = -1
index = 0
for i in range(2 * (10**5)):
if array[a[index]] != -1:
tmp = array[a[index]]
break
if i == k:
print(index)
sys.exit(0)
li.append(a[in... | import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
array = [-1] * (n+1)
array[1] = 0
li = []
li.append(1)
tmp = -1
index = 0
for i in range(2 * (10**5)):
if array[a[index]] != -1:
tmp = array[a[index]]
break
if i == k:
print(index+1)
sys.exit(0)
li.append(a[... | [
"expression.operation.binary.add"
] | 415,949 | 415,950 | u952491523 | python |
p02684 | import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
array = [-1] * (n+1)
array[1] = 0
li = []
li.append(1)
tmp = -1
index = 0
for i in range(2 * (10**5)):
if array[a[index]] != -1:
tmp = array[a[index]]
break
if i == k:
print(a[index])
sys.exit(0)
li.append(a... | import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
array = [-1] * (n+1)
array[1] = 0
li = []
li.append(1)
tmp = -1
index = 0
for i in range(2 * (10**5)):
if array[a[index]] != -1:
tmp = array[a[index]]
break
if i == k:
print(index+1)
sys.exit(0)
li.append(a[... | [
"call.arguments.change",
"io.output.change"
] | 415,951 | 415,950 | u952491523 | python |
p02684 | from collections import deque
n,k = map(int,input().split())
li = list(map(int,input().split()))
for i,l in enumerate(li):
li[i]-=1
done = [0]*n
root = []
que = deque()
done[0] = 1
root.append(0)
que.append(li[0])
while(len(que)!=0 and len(root)<k+1):
v = que.pop()
if done[v]!=0:
root.append(v)
... | from collections import deque
n,k = map(int,input().split())
li = list(map(int,input().split()))
for i,l in enumerate(li):
li[i]-=1
done = [0]*n
root = []
que = deque()
done[0] = 1
root.append(0)
que.append(li[0])
while(len(que)!=0 and len(root)<k+1):
v = que.pop()
if done[v]!=0:
root.append(v)
... | [
"call.remove"
] | 415,969 | 415,970 | u522293645 | python |
p02684 | from collections import deque
n,k = map(int,input().split())
li = list(map(int,input().split()))
for i,l in enumerate(li):
li[i]-=1
done = [0]*n
root = []
que = deque()
done[0] = 1
root.append(0)
que.append(li[0])
while(len(que)!=0 or len(root)<k+2):
v = que.pop()
if done[v]!=0:
root.append(v)
b... | from collections import deque
n,k = map(int,input().split())
li = list(map(int,input().split()))
for i,l in enumerate(li):
li[i]-=1
done = [0]*n
root = []
que = deque()
done[0] = 1
root.append(0)
que.append(li[0])
while(len(que)!=0 and len(root)<k+1):
v = que.pop()
if done[v]!=0:
root.append(v)
... | [
"control_flow.loop.condition.change",
"literal.number.integer.change"
] | 415,971 | 415,970 | u522293645 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, input().split()))
went_town = set()
now = 1
turn_town = [0]
while True:
if now-1 in went_town:
break
else:
went_town.add(now-1)
now = A[now-1]
turn_town.append(now-1)
for i in range(len(turn_town)-1):
if turn_town[i] == tur... | N, K = map(int, input().split())
A = list(map(int, input().split()))
went_town = set()
now = 1
turn_town = [0]
while True:
if now-1 in went_town:
break
else:
went_town.add(now-1)
now = A[now-1]
turn_town.append(now-1)
for i in range(len(turn_town)-1):
if turn_town[i] == tur... | [
"expression.operation.binary.add"
] | 415,974 | 415,975 | u572193732 | python |
p02684 | n,k=(int(i) for i in input().split())
r=[0 for i in range(n)]
l=[int(i) for i in input().split()]
wazap=[]
count=1
saver=None
temp=0
while r[temp]==0:
r[temp]=count
wazap.append(temp)
temp=l[temp]-1
start=wazap[-1]
for i in range(len(wazap)):
if wazap[i]==start-1:
left=i
break
loop=len(wazap)-left
if k<... | n,k=(int(i) for i in input().split())
r=[0 for i in range(n)]
l=[int(i) for i in input().split()]
wazap=[]
count=1
saver=None
temp=0
while r[temp]==0:
r[temp]=count
wazap.append(temp)
temp=l[temp]-1
start=l[wazap[-1]]
left=None
for i in range(len(wazap)):
if wazap[i]==start-1:
left=i
break
loop=len(waza... | [
"assignment.add"
] | 415,996 | 415,997 | u907223098 | python |
p02684 | N,K = (int(x) for x in input().split())
A = list(map(int, input().split()))
newlist = [1,A[0]]
num = A[0] - 1
ans = [0]*N
ans[0] = 1
ans[A[0]-1] = 1
b = 0
c = 0
r = 0
for i in range(10000000000000000000):
if(ans[A[num]-1] == 1):
b = A[num]
break
newlist.append(A[num])
ans[A[num]-1] = 1
n... | N,K = (int(x) for x in input().split())
A = list(map(int, input().split()))
newlist = [1,A[0]]
num = A[0] - 1
ans = [0]*N
ans[0] = 1
ans[A[0]-1] = 1
b = 0
c = 0
r = 0
for i in range(K):
if(ans[A[num]-1] == 1):
b = A[num]
break
newlist.append(A[num])
ans[A[num]-1] = 1
num = A[num]-1
for i... | [
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change",
"control_flow.loop.range.bounds.upper.change"
] | 416,012 | 416,013 | u107601154 | python |
p02684 | from collections import deque
N, K = map(int, input().split())
memo = [-1]*(N+1)
junban = deque()
A = [0]+list(map(int, input().split()))
i = 0
x = 1
while memo[x] < 0:
junban.append(x)
memo[x] = i
x = A[x]
i += 1
T = i-memo[x]
if K < T:
print(junban[K])
else:
print(list(junban)[memo[x]:][(K-memo[x])%T])
| from collections import deque
N, K = map(int, input().split())
memo = [-1]*(N+1)
junban = deque()
A = [0]+list(map(int, input().split()))
i = 0
x = 1
while memo[x] < 0:
junban.append(x)
memo[x] = i
x = A[x]
i += 1
T = i-memo[x]
if K < i:
print(junban[K])
else:
print(list(junban)[memo[x]:][(K-memo[x])%T])
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 416,014 | 416,015 | u978178314 | python |
p02684 | n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
a[i] -= 1
d = {0}
p = 0
while not a[p] in d:
d.add(a[p])
p = a[p]
#print(d)
val = [0]
p = 0
for i in range(len(d)):
val.append(a[p])
p = a[p]
#print(val)
cnt = 0
p = 0
while val[p] != val[-1]:
cnt += 1
p ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
a[i] -= 1
d = {0}
p = 0
while not a[p] in d:
d.add(a[p])
p = a[p]
#print(d)
val = [0]
p = 0
for i in range(len(d)):
val.append(a[p])
p = a[p]
#print(val)
cnt = 0
p = 0
while val[p] != val[-1]:
cnt += 1
p ... | [
"call.add"
] | 416,029 | 416,030 | u361381049 | python |
p02684 | def main():
N, K = map(int, input().split())
A = list(map(int, input().split()))
flag = [False] * N
flag[0] = True
move = [0]
num = 0
while True:
num += 1
c_next = A[move[-1]]-1
move.append(c_next)
if flag[c_next]:
break
else:
flag[c_next] = True
for i, j in enumerate(mo... | def main():
N, K = map(int, input().split())
A = list(map(int, input().split()))
flag = [False] * N
flag[0] = True
move = [0]
num = 0
while True:
num += 1
c_next = A[move[-1]]-1
move.append(c_next)
if flag[c_next]:
break
else:
flag[c_next] = True
for i, j in enumerate(mo... | [
"expression.operation.binary.add"
] | 416,045 | 416,046 | u025287757 | python |
p02684 | n,k=map(int,input().split())
A=list(map(int,input().split()))
a=[0]*n
a[0]=1
nxt=A[0]-1
i=2
while 1:
a[nxt]=i
nxt=A[nxt]-1
i+=1
if a[nxt]!=0:
g=i-a[nxt]
t=a[nxt]-1
break
if g>=k+1:
print(a.index(k+1))
else:
k-=t
u=k%g
print(a.index(t+u+1)+1) | n,k=map(int,input().split())
A=list(map(int,input().split()))
a=[0]*n
a[0]=1
nxt=A[0]-1
i=2
while 1:
a[nxt]=i
nxt=A[nxt]-1
i+=1
if a[nxt]!=0:
g=i-a[nxt]
t=a[nxt]-1
break
if t>=k:
print(a.index(k+1)+1)
else:
k-=t
u=k%g
print(a.index(t+u+1)+1) | [
"identifier.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 416,067 | 416,068 | u568576853 | python |
p02684 | n,k=map(int,input().split())
A=list(map(int,input().split()))
a=[0]*n
a[0]=1
nxt=A[0]-1
i=2
while 1:
a[nxt]=i
nxt=A[nxt]-1
i+=1
if a[nxt]!=0:
g=i-a[nxt]
t=a[nxt]-1
break
if t>=k:
print(a.index(k))
else:
k-=t
u=k%g
print(a.index(t+u+1)+1) | n,k=map(int,input().split())
A=list(map(int,input().split()))
a=[0]*n
a[0]=1
nxt=A[0]-1
i=2
while 1:
a[nxt]=i
nxt=A[nxt]-1
i+=1
if a[nxt]!=0:
g=i-a[nxt]
t=a[nxt]-1
break
if t>=k:
print(a.index(k+1)+1)
else:
k-=t
u=k%g
print(a.index(t+u+1)+1) | [
"expression.operation.binary.add"
] | 416,069 | 416,068 | u568576853 | python |
p02684 | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return... | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return... | [
"assignment.value.change",
"identifier.change"
] | 416,078 | 416,079 | u423585790 | python |
p02684 | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return... | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return... | [
"identifier.change",
"control_flow.branch.if.condition.change",
"assignment.value.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 416,080 | 416,079 | u423585790 | python |
p02684 | def main():
N,K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0,0)
B = [0]*(N+1)
tel = 1
telmae = 1
for i in range(K):
if B[tel] ==0:
B[tel] = i
telmae = tel
tel = A[tel]
else:
temp = i - B[tel]
... | def main():
N,K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0,0)
B = [0]*(N+1)
tel = 1
telmae = 1
for i in range(K):
if B[tel] ==0:
B[tel] = i
telmae = tel
tel = A[tel]
else:
temp = i - B[tel]
... | [
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 416,103 | 416,104 | u983853152 | python |
p02684 | import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect... | import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect... | [
"expression.operation.binary.add"
] | 416,111 | 416,112 | u404290207 | python |
p02684 | n, k = map(int, input().split())
an = list(map(int, input().split()))
tp = []
current = 1
tp.append(1)
if k > n:
for i in range(n):
current = an[current-1]
tp.append(current)
tps = len(set(tp))
tp = tp[0:tps]
kurikaesi_start = an[tp[-1]-1]
start_ind = tp.index(kurikaesi_start)
num = (k - star... | n, k = map(int, input().split())
an = list(map(int, input().split()))
tp = []
current = 1
tp.append(1)
if k > n:
for i in range(n):
current = an[current-1]
tp.append(current)
tps = len(set(tp))
tp = tp[0:tps]
kurikaesi_start = an[tp[-1]-1]
start_ind = tp.index(kurikaesi_start)
num = (k - star... | [
"assignment.change"
] | 416,137 | 416,138 | u959340534 | python |
p02684 | n,k = map(int,input().split())
A = list(map(int,input().split()))
t = 0
c = 0
ans = [0] * n
L = []
s = 0
for _ in range(k):
if ans[t] == 1:
n = len(L) - L.index(t)
temp = t + k%n
temp %= n
t = L[L.index(t):][temp]
break
else:
ans[t] = 1
L.append(t)
... | n,k = map(int,input().split())
A = list(map(int,input().split()))
t = 0
c = 0
ans = [0] * n
L = []
s = 0
for _ in range(k):
if ans[t] == 1:
n = len(L) - L.index(t)
temp = (k-c)%n
t = L[L.index(t):][temp]
break
else:
ans[t] = 1
L.append(t)
t = A[t]-1
... | [
"assignment.value.change",
"expression.operation.binary.change"
] | 416,155 | 416,156 | u291028869 | python |
p02684 | n,k=map(int,input().split())
ar=list(map(int,input().split()))
vis=[0 for i in range(n+1)]
x=1
seq=[1]
go=0
rep=0
ct=1
while (vis[x]==0):
vis[x]=ct
seq.append(ar[x-1])
x=ar[x-1]
ct+=1
if vis[x]!=0:
rep=ct-vis[x]
go=vis[x]
if k<=go:
print(seq[k-1])
else:
print(seq[go+(k-go)%re... | n,k=map(int,input().split())
ar=list(map(int,input().split()))
vis=[0 for i in range(n+1)]
x=1
seq=[1]
go=0
rep=0
ct=1
while (vis[x]==0):
vis[x]=ct
seq.append(ar[x-1])
x=ar[x-1]
ct+=1
if vis[x]!=0:
rep=ct-vis[x]
go=vis[x]
if k<=go:
print(seq[k])
else:
print(seq[go+(k-go)%rep]... | [
"expression.operation.binary.remove"
] | 416,186 | 416,187 | u983154415 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
C = []
C.append(0)
now = 0
B[0] = 1
for i in range(N):
now = A[now] - 1
if B[now] == 1:
break
else:
C.append(now)
B[now] = 1
mae = 0
for i in range(len(C)):
if C[i] == now:
mae = i
... | N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
C = []
C.append(0)
now = 0
B[0] = 1
for i in range(N):
now = A[now] - 1
if B[now] == 1:
break
else:
C.append(now)
B[now] = 1
mae = 0
for i in range(len(C)):
if C[i] == now:
mae = i
... | [
"expression.operation.binary.remove"
] | 416,188 | 416,189 | u137913818 | python |
p02684 | import sys
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
kyori = [-1]*n
now = 0;kyori[now] = 0
jyunkan = 0;v = 0
for i in range(n):
tugi = a[now] - 1
if kyori[tugi] != -1:
jyunkan = kyori[now] + 1
v = tugi
break
kyori[tugi] = kyori[now] + 1
if kyori[tu... | import sys
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
kyori = [-1]*n
now = 0;kyori[now] = 0
jyunkan = 0;v = 0
for i in range(n):
tugi = a[now] - 1
if kyori[tugi] != -1:
jyunkan = kyori[now] + 1
v = tugi
break
kyori[tugi] = kyori[now] + 1
if kyori[tu... | [
"call.remove"
] | 416,199 | 416,200 | u924406834 | python |
p02684 | import sys
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
kyori = [-1]*n
now = 0;kyori[now] = 0
jyunkan = 0;v = 0
for i in range(n):
tugi = a[now] - 1
if kyori[tugi] != -1:
jyunkan = kyori[now] + 1
v = tugi
break
kyori[tugi] = kyori[now] + 1
if kyori[tu... | import sys
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
kyori = [-1]*n
now = 0;kyori[now] = 0
jyunkan = 0;v = 0
for i in range(n):
tugi = a[now] - 1
if kyori[tugi] != -1:
jyunkan = kyori[now] + 1
v = tugi
break
kyori[tugi] = kyori[now] + 1
if kyori[tu... | [
"control_flow.loop.for.condition.change",
"expression.operation.binary.remove"
] | 416,201 | 416,200 | u924406834 | python |
p02684 | import sys
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
kyori = [-1]*n
now = 0;kyori[now] = 0
jyunkan = 0;v = 0
for i in range(n):
tugi = a[now] - 1
if kyori[tugi] != -1:
jyunkan = kyori[now] + 1
v = tugi
break
kyori[tugi] = kyori[now] + 1
if kyori[tu... | import sys
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
kyori = [-1]*n
now = 0;kyori[now] = 0
jyunkan = 0;v = 0
for i in range(n):
tugi = a[now] - 1
if kyori[tugi] != -1:
jyunkan = kyori[now] + 1
v = tugi
break
kyori[tugi] = kyori[now] + 1
if kyori[tu... | [
"expression.operation.binary.add"
] | 416,202 | 416,200 | u924406834 | python |
p02684 | if __name__ == '__main__':
from sys import stdin
# from collections import defaultdict
# from collections import deque
# from collections import Counter
import numpy as np
# import math
# import random
input = stdin.readline
n, k = map(int, input().split())
aa = [0]+list(map(in... | if __name__ == '__main__':
from sys import stdin
# from collections import defaultdict
# from collections import deque
# from collections import Counter
import numpy as np
# import math
# import random
input = stdin.readline
n, k = map(int, input().split())
aa = [0]+list(map(in... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 416,221 | 416,222 | u511268447 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, input().split()))
flag = [0] * (N+1)
cnt = [0] * (N+1)
now = 0
i = 1
while(flag[i] == 0 and K >= now):
flag[i] = 1
cnt[i] = now
i = A[i-1]
now += 1
if(K < now):
print(i)
else:
loop = now-cnt[i]
kn = (K-now)%loop
for j in range(kn):
i = A[i-1]
prin... | N, K = map(int, input().split())
A = list(map(int, input().split()))
flag = [0] * (N+1)
cnt = [0] * (N+1)
now = 0
i = 1
while(flag[i] == 0 and K > now):
flag[i] = 1
cnt[i] = now
i = A[i-1]
now += 1
if(K <= now):
print(i)
else:
loop = now-cnt[i]
kn = (K-now)%loop
for j in range(kn):
i = A[i-1]
prin... | [
"expression.operator.compare.change",
"control_flow.loop.condition.change",
"control_flow.branch.if.condition.change"
] | 416,229 | 416,230 | u114920558 | python |
p02684 | def resolve():
N,K = map(int,input().split())
A = [int(i)-1 for i in input().split()]
visited =[False]*N
steps = [K for i in range(N)]
current = 0
while True:
if K == 0:
return
if not visited[current]:
visited[current]=True
steps[current]=K
... | def resolve():
N,K = map(int,input().split())
A = [int(i)-1 for i in input().split()]
visited =[False]*N
steps = [K for i in range(N)]
current = 0
while True:
if K == 0:
print(current+1)
return
if not visited[current]:
visited[current]=True
... | [
"call.add"
] | 416,233 | 416,234 | u307592354 | python |
p02684 |
n, k = map(int,input().split())
cities = list(map(lambda x:int(x)-1,input().split()))
footprint_L = list()
footprint_S = set()
i = 0
footprint_S.add(i)
footprint_L.append(i)
while cities[i] not in footprint_S:
footprint_S.add(cities[i])
footprint_L.append(cities[i])
i = cities[i]
#print("terminal:", cit... |
n, k = map(int,input().split())
cities = list(map(lambda x:int(x)-1,input().split()))
footprint_L = list()
footprint_S = set()
i = 0
footprint_S.add(i)
footprint_L.append(i)
while cities[i] not in footprint_S:
footprint_S.add(cities[i])
footprint_L.append(cities[i])
i = cities[i]
#print("terminal:", cit... | [
"expression.operation.binary.add"
] | 416,243 | 416,244 | u946969297 | python |
p02684 | n, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
visited_city = {1: 0}
visited_city_inv = {0: 1}
now = 1
num = 0
while True:
next_city = arr[now - 1]
num += 1
if next_city not in visited_city:
visited_city[next_city] = num
visited_city_inv[num] = next_city
... | n, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
visited_city = {1: 0}
visited_city_inv = {0: 1}
now = 1
num = 0
while True:
next_city = arr[now - 1]
num += 1
if next_city not in visited_city:
visited_city[next_city] = num
visited_city_inv[num] = next_city
... | [
"assignment.value.change",
"identifier.change"
] | 416,249 | 416,250 | u162612857 | python |
p02684 | N, K = map(int, input().split())
A = list(map(int, input().split()))
order = [-1]*N
crr = 0
T = 0
s = -1
order[0] = 0
for i in range(N+1):
crr = A[crr] - 1
if order[crr] >= 0:
T = (i+1) - order[crr]
s = order[crr]
break
order[crr] = i+1
if K <= s:
crr = 0
while(K):
K... | N, K = map(int, input().split())
A = list(map(int, input().split()))
order = [-1]*N
crr = 0
T = 0
s = -1
order[0] = 0
for i in range(N+1):
crr = A[crr] - 1
if order[crr] >= 0:
T = (i+1) - order[crr]
s = order[crr]
break
order[crr] = i+1
if K <= s:
crr = 0
while(K):
K... | [
"assignment.change"
] | 416,255 | 416,256 | u814986259 | python |
p02684 | # -*- coding: utf-8 -*-
N,K = map(int, input().split())
A = [0]+list(map(int, input().split()))
town_list = [-1,0]+[-1 for i in range(N-1)]
town_now = 1
n_teleport = 0
while n_teleport<N:
n_teleport += 1
town_now = A[town_now]
if town_list[town_now]==-1:
town_list[town_now] = n_teleport
else:
break
... | # -*- coding: utf-8 -*-
N,K = map(int, input().split())
A = [0]+list(map(int, input().split()))
town_list = [-1,0]+[-1 for i in range(N-1)]
town_now = 1
n_teleport = 0
while n_teleport<K:
n_teleport += 1
town_now = A[town_now]
if town_list[town_now]==-1:
town_list[town_now] = n_teleport
else:
break
... | [
"identifier.change",
"control_flow.loop.condition.change",
"control_flow.branch.if.condition.change"
] | 416,266 | 416,267 | u249218427 | python |
p02684 | n,k=map(int,input().split())
a=list(map(int,input().split()))
c=0
d={}
d[1]=0
dd={}
d[0]=1
now=1
while True:
now=a[now-1]
c+=1
if now in d:
break
d[now]=c
dd[c]=now
s=d[now]
if k<=s:
print(dd[k])
exit()
p=c-s
k-=s
k%=p
k+=s
print(dd[k])
| n,k=map(int,input().split())
a=list(map(int,input().split()))
c=0
d={}
d[1]=0
dd={}
dd[0]=1
now=1
while True:
now=a[now-1]
c+=1
if now in d:
break
d[now]=c
dd[c]=now
s=d[now]
if k<=s:
print(dd[k])
exit()
p=c-s
k-=s
k%=p
k+=s
print(dd[k])
| [
"assignment.variable.change",
"identifier.change"
] | 416,275 | 416,276 | u366959492 | python |
p02684 | from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
n,k=map(int,input().split())
l=list(map(int,input().split()))
a=1
s=set()
count=0
while a not in s:
s.add(a)
a=l[a-1]
count+=1
if count==k:
print(a)
exit()
if count<k:
k-=count
# print(k)
else:
a=1
for i i... | from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
n,k=map(int,input().split())
l=list(map(int,input().split()))
a=1
s=set()
count=0
while a not in s:
s.add(a)
a=l[a-1]
count+=1
if count==k:
print(a)
exit()
if count<k:
k-=count
# print(k)
else:
a=1
for i i... | [
"expression.operation.binary.remove"
] | 416,291 | 416,292 | u213485233 | python |
p02684 | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")
from collections import defaultdict
class Graph(object):
def __init__(self, N):
self.N = N
self.E = defaultdict(list)
def add_edge(self, f, t, w=1):
self.E[f].append((t, w))
def main():
N, K = ma... | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")
from collections import defaultdict
class Graph(object):
def __init__(self, N):
self.N = N
self.E = defaultdict(list)
def add_edge(self, f, t, w=1):
self.E[f].append((t, w))
def main():
N, K = ma... | [
"expression.operation.binary.add"
] | 416,293 | 416,294 | u947883560 | python |
p02684 | n,k = map(int,input().split())
a = list(map(int,input().split()))
l = [1]
al = [0 for i in range(n+1)]
al[1] = 1
now = 1
for i in range(n):
nex = a[now-1]
if al[nex] == 0:
l.append(nex)
now = nex
al[nex] += 1
if i == n-1:
goal = nex
else:
goal = nex
... | n,k = map(int,input().split())
a = list(map(int,input().split()))
l = [1]
al = [0 for i in range(n+1)]
al[1] = 1
now = 1
for i in range(n):
nex = a[now-1]
if al[nex] == 0:
l.append(nex)
now = nex
al[nex] += 1
if i == n-1:
goal = nex
else:
goal = nex
... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 416,326 | 416,327 | u918935103 | python |
p02684 | from collections import defaultdict as dd
N,K=map(int,input().split())
a = list(map(int,input().split()))
res = 1
dic=dd(int)
now = 1
mita = set()
mita.add(now)
dic[now] = 1
start = 0
end = 0
# loop
while 1:
next_town = a[now-1]
# print(next_town)
if next_town in mita:
start = next_town
... | from collections import defaultdict as dd
N,K=map(int,input().split())
a = list(map(int,input().split()))
res = 1
dic=dd(int)
now = 1
mita = set()
mita.add(now)
dic[now] = 1
start = 0
end = 0
# loop
while 1:
next_town = a[now-1]
# print(next_town)
if next_town in mita:
start = next_town
... | [
"control_flow.branch.if.condition.change"
] | 416,362 | 416,363 | u871980676 | python |
p02684 | n,k = map(int,input().split())
al = list(map(int,input().split()))
ansl = []
used = [0 for i in range(n)]
now = 0
while True:
if used[now] == 1:
break
ansl.append(now)
used[now] = 1
now = al[now] -1
l = len(ansl)
last = ansl.index(now)
loop = ansl[last:]
if k < len(ansl):
print(ansl[k])
... | n,k = map(int,input().split())
al = list(map(int,input().split()))
ansl = []
used = [0 for i in range(n+1)]
now = 0
while True:
if used[now] == 1:
break
ansl.append(now)
used[now] = 1
now = al[now] - 1
l = len(ansl)
last = ansl.index(now)
loop = ansl[last:]
if k < len(ansl):
print(ansl[k... | [
"control_flow.loop.range.bounds.upper.change",
"assignment.change",
"expression.operation.binary.add"
] | 416,372 | 416,373 | u683134447 | python |
p02684 | n,k = map(int,input().split())
al = list(map(int,input().split()))
ansl = []
used = [0 for i in range(n)]
now = 0
while True:
if used[now] == 1:
break
ansl.append(now)
used[now] = 1
now = al[now] -1
l = len(ansl)
last = ansl.index(now)
loop = ansl[last:]
if k <= len(ansl):
print(ansl[k])
... | n,k = map(int,input().split())
al = list(map(int,input().split()))
ansl = []
used = [0 for i in range(n+1)]
now = 0
while True:
if used[now] == 1:
break
ansl.append(now)
used[now] = 1
now = al[now] - 1
l = len(ansl)
last = ansl.index(now)
loop = ansl[last:]
if k < len(ansl):
print(ansl[k... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 416,374 | 416,373 | u683134447 | python |
p02684 | n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
a[i]-=1
#print(a)
ever=[False]*n
ever[0]=True
now=0
saisho=[0]
for i in range(n):
now=a[now]
if(not ever[now]):
saisho.append(now)
ever[now]=True
else:
break
#print(saisho)
roop=[]
roop.appen... | n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
a[i]-=1
#print(a)
ever=[False]*n
ever[0]=True
now=0
saisho=[0]
for i in range(n):
now=a[now]
if(not ever[now]):
saisho.append(now)
ever[now]=True
else:
break
#print(saisho)
roop=[]
roop.appen... | [
"expression.operation.binary.remove"
] | 416,379 | 416,380 | u965840662 | python |
p02684 | import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))
cities = [0]
c = 0
used = [False] * N
used[0] = True
while not used[A[c]]:
used[A[c]] = True
cities.append(A[c])
c = A[c]
x = cities.index(A[c])
if K < x:
print(cities[K])
else:
... | import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))
cities = [0]
c = 0
used = [False] * N
used[0] = True
while not used[A[c]]:
used[A[c]] = True
cities.append(A[c])
c = A[c]
x = cities.index(A[c])
if K < x:
print(cities[K] + 1)
else:... | [
"expression.operation.binary.add"
] | 416,437 | 416,438 | u144913062 | python |
p02684 | from collections import deque
def main():
def int_0(num):
return int(num) - 1
N, K = map(int, input().split())
A = tuple(map(int_0, input().split()))
# dfs
INF = 10 ** 18
visited = [False] * N
dist = [INF] * N
info = {}
def dfs(s):
stack = deque()
stac... | from collections import deque
def main():
def int_0(num):
return int(num) - 1
N, K = map(int, input().split())
A = tuple(map(int_0, input().split()))
# dfs
INF = 10 ** 18
visited = [False] * N
dist = [INF] * N
info = {}
def dfs(s):
stack = deque()
stac... | [
"call.add"
] | 416,474 | 416,475 | u707498674 | python |
p02684 | from collections import deque
def main():
def int_0(num):
return int(num) - 1
N, K = map(int, input().split())
A = tuple(map(int_0, input().split()))
# dfs
INF = 10 ** 18
visited = [False] * N
dist = [INF] * N
info = {}
def dfs(s):
stack = deque()
stac... | from collections import deque
def main():
def int_0(num):
return int(num) - 1
N, K = map(int, input().split())
A = tuple(map(int_0, input().split()))
# dfs
INF = 10 ** 18
visited = [False] * N
dist = [INF] * N
info = {}
def dfs(s):
stack = deque()
stac... | [
"call.add"
] | 416,476 | 416,475 | u707498674 | python |
p02684 | import sys
l = sys.stdin.readline().strip()
N, K = map(int, l.split())
l = sys.stdin.readline().strip()
A = [0] + list(map(int, l.split()))
visited = [-1] * (len(A)+1)
remain = K
crt = 1
entrance = -1
while remain > 0:
remain -= 1
# check visited
if visited[crt] == -1:
visited[crt] = K - remain
... | import sys
l = sys.stdin.readline().strip()
N, K = map(int, l.split())
l = sys.stdin.readline().strip()
A = [0] + list(map(int, l.split()))
visited = [-1] * (len(A)+1)
remain = K
crt = 1
entrance = -1
while remain > 0:
remain -= 1
# check visited
if visited[crt] == -1:
visited[crt] = K - remain
... | [
"call.remove"
] | 416,485 | 416,486 | u734442632 | python |
p02684 | import sys
from _collections import deque
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(len(A)):
A[i] = A[i]-1
used = [0]*N
m = 0
c = 0
used[m] = 1
while(True):
m = A[m]
c += 1
if c == K:
print(m)
sys.exit()
if used[m] == 1:
break
else:... | import sys
from _collections import deque
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(len(A)):
A[i] = A[i]-1
used = [0]*N
m = 0
c = 0
used[m] = 1
while(True):
m = A[m]
c += 1
if c == K:
print(m+1)
sys.exit()
if used[m] == 1:
break
els... | [
"expression.operation.binary.add"
] | 416,487 | 416,488 | u454093752 | python |
p02684 | # @author
import sys
class DTeleporter:
def solve(self, tc=0):
n, k = [int(_) for _ in input().split()]
a = [int(_) - 1 for _ in input().split()]
done = dict()
cur = 0
steps = 0
while cur not in done and steps < k:
done[cur] = steps
cur = a[... | # @author
import sys
class DTeleporter:
def solve(self, tc=0):
n, k = [int(_) for _ in input().split()]
a = [int(_) - 1 for _ in input().split()]
done = dict()
cur = 0
steps = 0
while cur not in done and steps < k:
done[cur] = steps
cur = a[... | [
"expression.operation.binary.add"
] | 416,506 | 416,507 | u911537358 | python |
p02684 | import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a
visited = set([])
hist = [-1 for _ in range(n+1)]
cur = 1
cnt = 0
d = 0
while True:
if cnt == k:
# print(cur)
sys.exit()
if hist[cur] != -1:
d = cnt - hist[cur]
break
hist[cur] = cn... | import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + a
visited = set([])
hist = [-1 for _ in range(n+1)]
cur = 1
cnt = 0
d = 0
while True:
if cnt == k:
print(cur)
sys.exit()
if hist[cur] != -1:
d = cnt - hist[cur]
break
hist[cur] = cnt
... | [
"call.add"
] | 416,512 | 416,513 | u711539583 | python |
p02684 | import sys
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
d=dict()
for i,a in enumerate(A):
d[i+1] = a
p=1
li = set()
li.add(1)
for i in range(k):
#print(p,li)
p = d[p]
#print(p,li)
if p in li:
cyc = i+ 1- pidx
q = 1
st=0
while q != p:
q... | import sys
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
d=dict()
for i,a in enumerate(A):
d[i+1] = a
p=1
li = set()
li.add(1)
for i in range(k):
#print(p,li)
p = d[p]
#print(p,li)
if p in li:
cyc = i + 1
q = 1
st=0
while q != p:
q = d[... | [
"expression.operation.binary.remove"
] | 416,528 | 416,529 | u349091349 | python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.