Datasets:

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
def main(): N,K=map(int,input().split()) A=list(map(int,input().split())) cal=0 time=[0]*N town=[] roop=[] while time[cal]!=2: if time[cal]==0: town.append(cal) else : roop.append(cal) time[cal]+=1 cal=A[cal]-1 if N>K: p...
def main(): N,K=map(int,input().split()) A=list(map(int,input().split())) cal=0 time=[0]*N town=[] roop=[] while time[cal]!=2: if time[cal]==0: town.append(cal) else : roop.append(cal) time[cal]+=1 cal=A[cal]-1 if len(town)>K: ...
[ "control_flow.branch.if.condition.change", "call.arguments.add" ]
413,943
413,942
u434296044
python
p02684
N, K = map(int, input().split()) S = list(num-1 for num in map(int, input().split())) loc = 0 arrived = [0]*N ar = set() cnt = 0 while not loc in ar: arrived[cnt] = loc ar.add(loc) loc = S[loc] cnt += 1 if K < cnt: print(arrived[K-1]+1) else: for i in range(cnt): if arrived[i] == loc:...
N, K = map(int, input().split()) S = list(num-1 for num in map(int, input().split())) loc = 0 arrived = [0]*N ar = set() cnt = 0 while not loc in ar: arrived[cnt] = loc ar.add(loc) loc = S[loc] cnt += 1 if K < cnt: print(arrived[K]+1) else: for i in range(cnt): if arrived[i] == loc: ...
[ "expression.operation.binary.remove" ]
413,946
413,947
u135346354
python
p02684
N, K = map(int, input().split()) S = list(num-1 for num in map(int, input().split())) loc = 0 arrived = [0]*N ar = set() cnt = 0 while not loc in ar: arrived[cnt] = loc ar.add(loc) loc = S[loc] cnt += 1 if K < cnt: print(arrived[K-1]) else: for i in range(cnt): if arrived[i] == loc: ...
N, K = map(int, input().split()) S = list(num-1 for num in map(int, input().split())) loc = 0 arrived = [0]*N ar = set() cnt = 0 while not loc in ar: arrived[cnt] = loc ar.add(loc) loc = S[loc] cnt += 1 if K < cnt: print(arrived[K]+1) else: for i in range(cnt): if arrived[i] == loc: ...
[ "expression.operation.binary.remove" ]
413,948
413,947
u135346354
python
p02684
n, k = map(int, input().split()) a = list(map(int, input().split())) s = 1 place = [s] first = set(place) for i in range(n): s = a[s-1] if s in first: loops = place.index(s) loope = len(place) ans = loops + (k-loope) % (loope-loops) print(place[ans]) exit() else: ...
n, k = map(int, input().split()) a = list(map(int, input().split())) s = 1 place = [s] first = set(place) for i in range(1, k+1): s = a[s-1] if s in first: loops = place.index(s) loope = len(place) ans = loops + (k-loope) % (loope-loops) print(place[ans]) exit() els...
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "call.arguments.add" ]
413,966
413,967
u955125992
python
p02684
n,k = list(map(int, input().split())) lst = list(map(int, input().split())) checker = [None for i in range(n)] checker[0] = 0 num = 0 count = 0 flag = 0 while flag==0 and count!=k: if checker[lst[num]-1]==None: checker[lst[num]-1]=count+1 count+=1 num = lst[num]-1 else: flag = ...
n,k = list(map(int, input().split())) lst = list(map(int, input().split())) checker = [None for i in range(n)] checker[0] = 0 num = 0 count = 0 flag = 0 # 同じ地点に2度目に到着する or k回移動するまで移動する while flag==0 and count!=k: if checker[lst[num]-1]==None: checker[lst[num]-1]=count+1 count+=1 num = lst[...
[ "control_flow.branch.if.add" ]
413,968
413,969
u189326411
python
p02684
n,k = list(map(int, input().split())) lst = list(map(int, input().split())) checker = [None for i in range(n)] checker[0] = 0 num = 0 count = 0 flag = 0 while flag==0 and count!=k: if checker[lst[num]-1]==None: checker[lst[num]-1]=count+1 count+=1 num = lst[num]-1 else: flag = ...
n,k = list(map(int, input().split())) lst = list(map(int, input().split())) checker = [None for i in range(n)] checker[0] = 0 num = 0 count = 0 flag = 0 while flag==0 and count!=k: if checker[lst[num]-1]==None: checker[lst[num]-1]=count+1 count+=1 num = lst[num]-1 else: flag = ...
[ "control_flow.branch.if.add" ]
413,968
413,970
u189326411
python
p02684
N, K= (int(v) for v in input().split()) A = [0] + [int(v) for v in input().split()] first_visit = [0 for i in range(N+1)] visited = [] current = 1 step = 0 loop_length = 1 loop_start = 0 while True: if step == K: print(A[current]) exit() if first_visit[current] != 0: loop_length =...
N, K= (int(v) for v in input().split()) A = [0] + [int(v) for v in input().split()] first_visit = [0 for i in range(N+1)] visited = [] current = 1 step = 0 loop_length = 1 loop_start = 0 while True: if step == K: print(current) exit() if first_visit[current] != 0: loop_length = st...
[ "call.arguments.change" ]
413,976
413,977
u478856278
python
p02684
#0や1のケースに注意 #index out of range def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import ...
#0や1のケースに注意 #index out of range def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import ...
[ "control_flow.branch.if.condition.change" ]
413,998
413,999
u863442865
python
p02684
N,K=map(int,input().split()) A=list(map(int,input().split())) num=[-1]*N rep=[] now=0 for i in range(N): if i==K: print(now) exit() aft=A[now]-1 rep.append(now) if num[now]==-1: num[now]=i else: break now=aft end=i start=num[aft] loop=end-start+1 print(rep[star...
N,K=map(int,input().split()) A=list(map(int,input().split())) num=[-1]*N rep=[] now=0 for i in range(N): if i==K: print(now+1) exit() aft=A[now]-1 rep.append(now) if num[now]==-1: num[now]=i else: break now=aft end=i start=num[aft] loop=end-start+1 print(rep[st...
[ "expression.operation.binary.add" ]
414,015
414,016
u173148629
python
p02684
N, K = map(int, input().split()) trans = list(map(int, input().split())) townOrder = [-1 for _ in range(N+1)] townOrder[1] = 1 nextTown = 1 cicleStart = 0 cicleEnd = 0 for order in range(1, N+1): nextTown = trans[nextTown-1] if townOrder[nextTown] == -1: townOrder[nextTown] = order +1 else: cicleStart =...
N, K = map(int, input().split()) trans = list(map(int, input().split())) townOrder = [-1 for _ in range(N+1)] townOrder[1] = 1 nextTown = 1 cicleStart = 0 cicleEnd = 0 for order in range(1, N+1): nextTown = trans[nextTown-1] if townOrder[nextTown] == -1: townOrder[nextTown] = order +1 else: cicleStart =...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.value.change", "identifier.change" ]
414,017
414,018
u860338101
python
p02684
n, k = list(map(int, input().split())) a = list(map(int, input().split())) s = 1 g = 0 i = 1 history = [s] flag = [False] * n flag[0] = True while True: g = a[s-1] if flag[g-1] == True: break else: flag[g-1] = True history.append(g) s = g i += 1 x = history.index(...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) s = 1 g = 0 i = 1 history = [s] flag = [False] * n flag[0] = True while True: g = a[s-1] if flag[g-1] == True: break else: flag[g-1] = True history.append(g) s = g i += 1 x = history.index(...
[ "identifier.change", "control_flow.branch.if.condition.change" ]
414,040
414,041
u123872895
python
p02680
import sys input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.par = [-1] * n def root(self, x): if self.par[x] < 0: return x else: self.par[x] = self.root(self.par[x]) # contraction return self.par[x] def unite(self, x, ...
import sys input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.par = [-1] * n def root(self, x): if self.par[x] < 0: return x else: self.par[x] = self.root(self.par[x]) # contraction return self.par[x] def unite(self, x, ...
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
414,046
414,047
u533039576
python
p02680
import sys input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.par = [-1] * n def root(self, x): if self.par[x] < 0: return x else: self.par[x] = self.root(self.par[x]) # contraction return self.par[x] def unite(self, x, ...
import sys input = sys.stdin.readline class UnionFind(): def __init__(self, n): self.par = [-1] * n def root(self, x): if self.par[x] < 0: return x else: self.par[x] = self.root(self.par[x]) # contraction return self.par[x] def unite(self, x, ...
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
414,048
414,047
u533039576
python
p02680
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=(f,F),(f,-F),;H=(F,f),(-F,f), for i in r(n):*a,c=I();R+=(a,c),;Y+=c,;X+=a for i in r(m):a,*b=I();H+=(a,b),;X+=a,;Y+=b def g(X):s=sorted(set(X));l=len(s);return{s[i]:i for i in r(l)},s,l h,s,K=g(X);w,t,L=g(Y);V,U,v=[[[0]*-~K for i in r(L+...
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=(f,F),(f,-F),;H=(F,f),(-F,f), for i in r(n):*a,c=I();R+=(a,c),;Y+=c,;X+=a for i in r(m):a,*b=I();H+=(a,b),;X+=a,;Y+=b def g(X):s=sorted(set(X));l=len(s);return{s[i]:i for i in r(l)},s,l h,s,K=g(X);w,t,L=g(Y);V,U,v=[[[0]*-~K for i in r(L+...
[ "assignment.variable.change", "identifier.change", "call.arguments.change", "io.output.change", "variable_access.subscript.index.change" ]
414,055
414,056
u623819879
python
p02680
I=lambda:[int(i) for i in input().split()] F=1<<65 n,m=I() X=set([0,F,-F]) Y=set(X) R=[] H=[] for i in range(n): a,b,c=I() R.append(((a,b),c)) Y.add(c) X.add(a) X.add(b) n+=2 R+=[((-F,F),F),((-F,F),-F)] for i in range(m): a,b,c=I() H.append((a,(b,c))) X.add(a) Y.add(b) Y.add(...
I=lambda:[int(i) for i in input().split()] F=1<<65 n,m=I() X=set([0,F,-F]) Y=set(X) R=[] H=[] for i in range(n): a,b,c=I() R.append(((a,b),c)) Y.add(c) X.add(a) X.add(b) n+=2 R+=[((-F,F),F),((-F,F),-F)] for i in range(m): a,b,c=I() H.append((a,(b,c))) X.add(a) Y.add(b) Y.add(...
[ "literal.string.change", "assignment.value.change" ]
414,063
414,064
u623819879
python
p02680
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): INF = 10**9 + 1 MOD = 10**9 + 7 LI = lambda : [int(x) for x in sys.stdin.readline().split()] N,M = LI() x = []; y = [] A = [] D = [] for _ in range(N): a,b,c = LI() A.append((a,b,c)) x.app...
import sys,queue,math,copy,itertools,bisect,collections,heapq def main(): INF = 10**9 + 1 MOD = 10**9 + 7 LI = lambda : [int(x) for x in sys.stdin.readline().split()] N,M = LI() x = []; y = [] A = [] D = [] for _ in range(N): a,b,c = LI() A.append((a,b,c)) x.app...
[ "expression.operation.binary.remove", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
414,248
414,249
u703950586
python
p02669
import sys sys.setrecursionlimit(10**8) def main(): n, a, b, c, d = map(int, input().split()) memo = {} def dfs(x): if x == 0: return 0 elif x == 1: return d elif x in memo: return memo[x] else: ret = min( d * x,...
import sys sys.setrecursionlimit(10**8) def main(): n, a, b, c, d = map(int, input().split()) memo = {} def dfs(x): if x == 0: return 0 elif x == 1: return d elif x in memo: return memo[x] else: ret = min( d * x,...
[ "literal.number.integer.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
414,344
414,345
u595952233
python
p02669
import sys from functools import lru_cache sys.setrecursionlimit(1000000) t = int(input()) l = [list(map(int, input().split())) for i in range(t)] for i in range(t): N = l[i][0] A = l[i][1] B = l[i][2] C = l[i][3] D = l[i][4] @lru_cache(maxsize=10**18) def min_coin(n): if(n == 0)...
import sys from functools import lru_cache sys.setrecursionlimit(1000000) t = int(input()) l = [list(map(int, input().split())) for i in range(t)] for i in range(t): N = l[i][0] A = l[i][1] B = l[i][2] C = l[i][3] D = l[i][4] @lru_cache(maxsize=10**18) def min_coin(n): if(n == 0)...
[ "expression.operator.arithmetic.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
414,409
414,410
u749742659
python
p02669
import sys from functools import lru_cache sys.setrecursionlimit(100000) t = int(input()) l = [list(map(int, input().split())) for i in range(t)] for i in range(t): N = l[i][0] A = l[i][1] B = l[i][2] C = l[i][3] D = l[i][4] @lru_cache(maxsize=10**18) def min_coin(n): if(n == 0):...
import sys from functools import lru_cache sys.setrecursionlimit(1000000) t = int(input()) l = [list(map(int, input().split())) for i in range(t)] for i in range(t): N = l[i][0] A = l[i][1] B = l[i][2] C = l[i][3] D = l[i][4] @lru_cache(maxsize=10**18) def min_coin(n): if(n == 0)...
[ "literal.number.integer.change", "call.arguments.change", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
414,411
414,410
u749742659
python
p02669
import sys from functools import lru_cache sys.setrecursionlimit(10000) t = int(input()) l = [list(map(int, input().split())) for i in range(t)] for i in range(t): N = l[i][0] A = l[i][1] B = l[i][2] C = l[i][3] D = l[i][4] @lru_cache(maxsize=10**18) def min_coin(n): if(n == 0): ...
import sys from functools import lru_cache sys.setrecursionlimit(1000000) t = int(input()) l = [list(map(int, input().split())) for i in range(t)] for i in range(t): N = l[i][0] A = l[i][1] B = l[i][2] C = l[i][3] D = l[i][4] @lru_cache(maxsize=10**18) def min_coin(n): if(n == 0)...
[ "literal.number.integer.change", "call.arguments.change", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
414,412
414,410
u749742659
python
p02669
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import time,random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 mod2 = 998244353 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return lis...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import time,random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 mod2 = 998244353 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return lis...
[ "control_flow.return.remove", "control_flow.break.add" ]
414,418
414,419
u637175065
python
p02684
n, k = map(int, input().split()) roads = list(map(int, input().split())) city = 1 route = [] cnt = [0] * n cnt[0] += 1 route.append(1) while True: city = roads[city-1] cnt[city-1] += 1 if cnt[city-1] == 2: st = route.index(city) length = len(route) - st break route.append(ci...
n, k = map(int, input().split()) roads = list(map(int, input().split())) city = 1 route = [] cnt = [0] * n cnt[0] += 1 route.append(1) while True: city = roads[city-1] cnt[city-1] += 1 if cnt[city-1] == 2: st = route.index(city) length = len(route) - st break route.append(ci...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
414,431
414,432
u324197506
python
p02684
N,K=map(int, input().split()) A=list(map(int, input().split())) loopcount=0 tmpPoint=1 vis={1:0} for i in range(N): Next=A[tmpPoint-1] if Next in vis: startat=i #print(startat) #print(tmpPoint) #print(vis) #print(Next) #print(vis[Next]+1) loopcount=i - vi...
N,K=map(int, input().split()) A=list(map(int, input().split())) loopcount=0 tmpPoint=1 vis={1:0} for i in range(N): Next=A[tmpPoint-1] if Next in vis: startat=i #print(startat) #print(tmpPoint) #print(vis) #print(Next) #print(vis[Next]+1) loopcount=i - vi...
[ "assignment.variable.change", "identifier.change" ]
414,460
414,461
u112114596
python
p02684
N, K = map(int, input().split()) list_A = list(map(int, input().split())) l = [1] s = {1} while True: next = list_A[l[-1] - 1] if not next in s: l.append(next) s.add(next) else: start = l.index(next) roop = len(l) - start break if len(l) == 1: print(1) ex...
N, K = map(int, input().split()) list_A = list(map(int, input().split())) l = [1] s = {1} while True: next = list_A[l[-1] - 1] if not next in s: l.append(next) s.add(next) else: start = l.index(next) roop = len(l) - start break if len(l) == 1: print(1) ex...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
414,474
414,475
u129325056
python
p02684
nk = input().split() n , k = int(nk[0]), int(nk[1]) a = [int(i) for i in input().split()] t = 1 tl = [1] ts = {1} for i in range(len(a)): t = a[t-1] if t in ts: break else: tl.append(t) ts.add(t) tl2 = tl[tl.index(t):len(tl)] # print(tl) # print(tl2) ans = 0 if k...
nk = input().split() n , k = int(nk[0]), int(nk[1]) a = [int(i) for i in input().split()] t = 1 tl = [1] ts = {1} for i in range(len(a)): t = a[t-1] if t in ts: break else: tl.append(t) ts.add(t) tl2 = tl[tl.index(t):len(tl)] # print(tl) # print(tl2) ans = 0 if k...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
414,476
414,477
u966542724
python
p02684
nk = input().split() n , k = int(nk[0]), int(nk[1]) a = [int(i) for i in input().split()] t = 1 tl = [1] ts = {1} flg = False for i in range(len(a)): # flg = t > a[t-1] t = a[t-1] # stl = sorted(tl) if t in ts: break else: tl.append(t) ts.add(t) tl2 = tl[tl.index(t):len(t...
nk = input().split() n , k = int(nk[0]), int(nk[1]) a = [int(i) for i in input().split()] t = 1 tl = [1] ts = {1} for i in range(len(a)): t = a[t-1] if t in ts: break else: tl.append(t) ts.add(t) tl2 = tl[tl.index(t):len(tl)] # print(tl) # print(tl2) ans = 0 if k...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
414,478
414,477
u966542724
python
p02684
N,K = map(int,input().split()) A = list(map(int,input().split())) adj_list=[0]*N for i in range(N): adj_list[i]=(A[i]) k=0 node = 1 c=[0]*N count=1 flag=0 ROOP=[] roopstart=0 while k<K: k+=1 c[node-1]+=1 node = adj_list[node-1] if c[node-1] ==1: if flag ==0: roopstart = k ...
N,K = map(int,input().split()) A = list(map(int,input().split())) adj_list=[0]*N for i in range(N): adj_list[i]=(A[i]) k=0 node = 1 c=[0]*N count=1 flag=0 ROOP=[] roopstart=0 while k<K: k+=1 c[node-1]+=1 node = adj_list[node-1] if c[node-1] ==1: if flag ==0: roopstart = k ...
[]
414,497
414,498
u516566941
python
p02684
import sys n, k = map(int, input().split()) l = list(map(int, input().split())) count = 0 li = [0 for _ in range(n)] b = 1 for i in range(1,n + 1): # print(b) if li[b-1] != 0: break li[b-1] = i b = l[b-1] count += 1 # print('count',count) d = count - li[b-1] + 1 intercep = li[b-1] -1 #...
import sys n, k = map(int, input().split()) l = list(map(int, input().split())) count = 0 li = [0 for _ in range(n)] b = 1 for i in range(1,n + 1): # print(b) if li[b-1] != 0: break li[b-1] = i b = l[b-1] count += 1 # print('count',count) d = count - li[b-1] + 1 intercep = li[b-1] -1 #...
[ "assignment.add" ]
414,546
414,547
u091489347
python
p02684
n,k = (int(x) for x in input().split()) A = [int(x) for x in input().split()] flag = [False] * n town = 1 towns = [1] flag[0] = True while(True): ntown = A[town-1] if flag[ntown-1]: l_s = towns.index(ntown) if k < l_s: print(towns[k-1]) break else: ...
n,k = (int(x) for x in input().split()) A = [int(x) for x in input().split()] flag = [False] * n town = 1 towns = [1] flag[0] = True while(True): ntown = A[town-1] if flag[ntown-1]: l_s = towns.index(ntown) if k < l_s: print(towns[k]) break else: ...
[ "expression.operation.binary.remove" ]
414,548
414,549
u917363866
python
p02684
import collections import numpy as np import sys import copy N,K=map(int,input().split()) A=list(map(int,input().split())) for i in range(N): A[i]-=1 B=[0] visited=[0]*N visited[0]=1 Flag=True for i in range(0,N*2): next=A[B[i]] if visited[next]==0: B.append(next) visited[next]=1 else: ...
import collections import numpy as np import sys import copy N,K=map(int,input().split()) A=list(map(int,input().split())) for i in range(N): A[i]-=1 B=[0] visited=[0]*N visited[0]=1 Flag=True for i in range(0,N*2): next=A[B[i]] if visited[next]==0: B.append(next) visited[next]=1 else: ...
[ "expression.operation.binary.add" ]
414,554
414,555
u163907160
python
p02684
import collections import numpy as np import sys import copy N,K=map(int,input().split()) A=list(map(int,input().split())) for i in range(N): A[i]-=1 B=[0] visited=[0]*N visited[0]=1 Flag=True for i in range(0,N*2): next=A[B[i]] if visited[next]==0: B.append(next) visited[next]=1 else: ...
import collections import numpy as np import sys import copy N,K=map(int,input().split()) A=list(map(int,input().split())) for i in range(N): A[i]-=1 B=[0] visited=[0]*N visited[0]=1 Flag=True for i in range(0,N*2): next=A[B[i]] if visited[next]==0: B.append(next) visited[next]=1 else: ...
[ "control_flow.branch.if.condition.change", "call.arguments.change" ]
414,556
414,555
u163907160
python
p02684
n, k = list(map(int, input().split())) t = list(map(int, input().split())) visited = [False]*(2*10**5 + 10) val = 1 count = 0 hold = k while hold > 0 : if visited[val - 1] or val == t[val - 1]: break visited[val - 1] = True val = t[val - 1] # print('a', val) count += 1 hold -= 1 if hold...
n, k = list(map(int, input().split())) t = list(map(int, input().split())) visited = [False]*(2*10**5 + 10) val = 1 count = 0 hold = k while hold > 0 : if visited[val - 1] or val == t[val - 1]: break visited[val - 1] = True val = t[val - 1] # print('a', val) count += 1 hold -= 1 # print...
[]
414,557
414,558
u585613332
python
p02684
#!/usr/bin/env python3 N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(N): A[i] -= 1 tele = [0] #tele = [0,A[0]-1] z = 0 s = 0 #B = {0:0,A[0]-1:1} B = {0:0} for i in range(N): if A[tele[-1]] in B and len(B) != 1: s = B[A[tele[-1]]] break B[A[tele[-1]]] ...
#!/usr/bin/env python3 N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(N): A[i] -= 1 tele = [0] #tele = [0,A[0]-1] z = 0 s = 0 #B = {0:0,A[0]-1:1} B = {0:0} for i in range(N): if A[tele[-1]] in B and len(B) != 1: s = B[A[tele[-1]]] break B[A[tele[-1]]] ...
[ "expression.operation.binary.add" ]
414,567
414,568
u998733244
python
p02684
import sys sys.setrecursionlimit(1000000000) import math from math import gcd def lcm(a, b): return a * b // gcd(a, b) from itertools import count, permutations, chain from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(input()) mis = lambda: map(int, in...
import sys sys.setrecursionlimit(1000000000) import math from math import gcd def lcm(a, b): return a * b // gcd(a, b) from itertools import count, permutations, chain from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(input()) mis = lambda: map(int, in...
[ "identifier.change", "call.function.change", "call.arguments.add" ]
414,569
414,570
u402629484
python
p02684
import numpy as np import itertools n, k = map(int, input().split()) a = list(map(int, input().split())) now = 1 town_list = [0]*n town_list[0] = 1 tn_list = [1] while(1): next = a[now-1] now = next if town_list[now-1] == 0: town_list[now-1] = 1 tn_list.append(now) else: idx =...
import numpy as np import itertools n, k = map(int, input().split()) a = list(map(int, input().split())) now = 1 town_list = [0]*n town_list[0] = 1 tn_list = [1] while(1): next = a[now-1] now = next if town_list[now-1] == 0: town_list[now-1] = 1 tn_list.append(now) else: idx =...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
414,578
414,579
u542190960
python
p02684
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = 10**20 def I(): return int(input()) def F(): return float(input()) def S(): return input() def LI(): return [int(x) for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] def LF(): return [float(x) for ...
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = 10**20 def I(): return int(input()) def F(): return float(input()) def S(): return input() def LI(): return [int(x) for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] def LF(): return [float(x) for ...
[ "call.add" ]
414,596
414,597
u648881683
python
p02684
import sys readline = sys.stdin.readline n, k = map(int, readline().split()) A = list(map(int, readline().split())) visited = [False] * n visited[0] = True l = [1] while True: x = A[l[-1]-1] if visited[x-1]: break l.append(x) visited[x-1] = True # print(l[l.index(x):]) if len(l) > k-1: pri...
import sys readline = sys.stdin.readline n, k = map(int, readline().split()) A = list(map(int, readline().split())) visited = [False] * n visited[0] = True l = [1] while True: x = A[l[-1]-1] if visited[x-1]: break l.append(x) visited[x-1] = True # print(l[l.index(x):]) if len(l) > k: print...
[ "expression.operation.binary.remove" ]
414,607
414,608
u644516473
python
p02684
import sys readline = sys.stdin.readline n, k = map(int, readline().split()) A = list(map(int, readline().split())) visited = [False] * n visited[0] = True l = [1] while True: x = A[l[-1]-1] if visited[x-1]: break l.append(x) visited[x-1] = True # print(l[l.index(x):]) if len(l) >= k-1: pr...
import sys readline = sys.stdin.readline n, k = map(int, readline().split()) A = list(map(int, readline().split())) visited = [False] * n visited[0] = True l = [1] while True: x = A[l[-1]-1] if visited[x-1]: break l.append(x) visited[x-1] = True # print(l[l.index(x):]) if len(l) > k: print...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
414,609
414,608
u644516473
python
p02684
from sys import stdin import numpy as np def main(): N, K = [int(x) for x in stdin.readline().rstrip().split()] A = [int(x) for x in stdin.readline().rstrip().split()] X = 1 L = [1] if A[0] == 1: print(1) if N >= K : for i in range(K): X = A[X-1] print(X) ...
from sys import stdin import numpy as np def main(): N, K = [int(x) for x in stdin.readline().rstrip().split()] A = [int(x) for x in stdin.readline().rstrip().split()] X = 1 L = [1] if A[0] == 1: print(1) exit() if N >= K : for i in range(K): X = A[X-1] ...
[ "call.add" ]
414,622
414,623
u250061066
python
p02684
from sys import stdin import numpy as np def main(): N, K = [int(x) for x in stdin.readline().rstrip().split()] A = [int(x) for x in stdin.readline().rstrip().split()] X = 1 L = [1] if A[0] == 1: print(1) if N >= K : for i in range(K): X = A[X-1] print(X...
from sys import stdin import numpy as np def main(): N, K = [int(x) for x in stdin.readline().rstrip().split()] A = [int(x) for x in stdin.readline().rstrip().split()] X = 1 L = [1] if A[0] == 1: print(1) exit() if N >= K : for i in range(K): X = A[X-1] ...
[ "call.add" ]
414,624
414,623
u250061066
python
p02684
import collections def getls(): return [ipt for ipt in input().split()] def getlsi(): return [int(ipt) for ipt in input().split()] [n,k] = getlsi() a = getlsi() dic = collections.defaultdict(int) now = 1 cnt = 1 while dic[now] == 0: dic[now] = cnt now = a[now-1] cnt += 1 lp = cnt - dic[now] if ...
import collections def getls(): return [ipt for ipt in input().split()] def getlsi(): return [int(ipt) for ipt in input().split()] [n,k] = getlsi() a = getlsi() dic = collections.defaultdict(int) now = 1 cnt = 1 while dic[now] == 0: dic[now] = cnt now = a[now-1] cnt += 1 lp = cnt - dic[now] if ...
[ "expression.operation.binary.remove" ]
414,625
414,626
u333139319
python
p02684
import collections def getls(): return [ipt for ipt in input().split()] def getlsi(): return [int(ipt) for ipt in input().split()] [n,k] = getlsi() a = getlsi() dic = collections.defaultdict(int) now = 1 cnt = 1 while dic[now] == 0: dic[now] = cnt now = a[now-1] cnt += 1 lp = cnt - dic[now] if ...
import collections def getls(): return [ipt for ipt in input().split()] def getlsi(): return [int(ipt) for ipt in input().split()] [n,k] = getlsi() a = getlsi() dic = collections.defaultdict(int) now = 1 cnt = 1 while dic[now] == 0: dic[now] = cnt now = a[now-1] cnt += 1 lp = cnt - dic[now] if ...
[ "expression.operation.binary.remove", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change" ]
414,627
414,626
u333139319
python
p02684
n, k = map(int, input().split()) a = list(map(int,input().split())) timestamp = [0]*n position = 1 period = 0 start=0 for i in range(n*2): if timestamp[position-1] != 0: start = timestamp[position-1] period = i-timestamp[position-1] break timestamp[position-1] =i position = a[position-1] if k <=...
n, k = map(int, input().split()) a = list(map(int,input().split())) timestamp = [0]*n position = 1 period = 0 start=0 for i in range(n*2): if timestamp[position-1] != 0: start = timestamp[position-1] period = i-timestamp[position-1] break timestamp[position-1] =i position = a[position-1] if k <=st...
[ "expression.operation.binary.remove" ]
414,643
414,644
u471503862
python
p02684
import sys sys.setrecursionlimit(10**6) n, k = map(int, input().split()) A = list(map(int, input().split())) L = [1] S = {1} def f(L, S): last = L[-1]-1 if A[last] not in S: L.append(A[last]) S |= {last} return f(L, S) else: return L P = f(L, S) a = A[P[-1]-1] j = P.index(a)...
import sys sys.setrecursionlimit(10**6) n, k = map(int, input().split()) A = list(map(int, input().split())) L = [1] S = {1} def f(L, S): last = L[-1]-1 if A[last] not in S: L.append(A[last]) S |= {A[last]} return f(L, S) else: return L P = f(L, S) a = A[P[-1]-1] j = P.inde...
[]
414,645
414,646
u745687363
python
p02684
# coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.readline read = sys.stdin.read #from heapq import heappop, heappush #from collections import defaultdict sys.setrecursionlimit(10**7) #import math #from itertools import combinations, product #import bisect# lower_bound etc #import numpy as...
# coding: utf-8 import sys #from operator import itemgetter sysread = sys.stdin.readline read = sys.stdin.read #from heapq import heappop, heappush #from collections import defaultdict sys.setrecursionlimit(10**7) #import math #from itertools import combinations, product #import bisect# lower_bound etc #import numpy as...
[ "call.arguments.change" ]
414,651
414,652
u044220565
python
p02684
import sys sys.setrecursionlimit(10**6) def f(x,dic,i): p=dic1[x] if p in dic: return [dic,p] else: dic[p]=i return f(p,dic,i+1) def inv(x,dic): for k,v in dic.items(): if v==x: return k n,k=map(int,input().split()) m=[i for i in range(n)] l=list(map(int,inp...
import sys sys.setrecursionlimit(10**6) def f(x,dic,i): p=dic1[x] if p in dic: return [dic,p] else: dic[p]=i return f(p,dic,i+1) def inv(x,dic): for k,v in dic.items(): if v==x: return k n,k=map(int,input().split()) m=[i for i in range(n)] l=list(map(int,inp...
[ "expression.operation.binary.remove" ]
414,653
414,654
u562662744
python
p02684
from collections import defaultdict n,k=map(int,input().split()) l=list(map(int,input().split())) d=defaultdict(int) for i in range(n): d[i+1]=l[i] visited=set() l=[] i=1 while True: l.append(i) if i not in visited: visited.add(i) else: break i=d[i] first=l.index(l[-1]) if k<first: ...
from collections import defaultdict n,k=map(int,input().split()) l=list(map(int,input().split())) d=defaultdict(int) for i in range(n): d[i+1]=l[i] visited=set() l=[] i=1 while True: l.append(i) if i not in visited: visited.add(i) else: break i=d[i] first=l.index(l[-1]) if k<first: ...
[ "assignment.value.change", "expression.operation.binary.change", "call.arguments.change" ]
414,655
414,656
u316231243
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) A = list(map(lambda x: x - 1, A)) # 0-indexed pos = 0 memo = [[False, 0] for _ in range(N)] # memo[i]: [bool, tel_cnt] , [数えたか、何回移動したか] memo[0] = [True, 0] distance = 0 l_pos = 0 tel_cnt = 0 while True: next = A[pos] tel_cnt += 1 if memo[...
N, K = map(int, input().split()) A = list(map(int, input().split())) A = list(map(lambda x: x - 1, A)) # 0-indexed pos = 0 memo = [[False, 0] for _ in range(N)] # memo[i]: [bool, tel_cnt] , [数えたか、何回移動したか] memo[0] = [True, 0] distance = 0 l_pos = 0 tel_cnt = 0 while True: next = A[pos] tel_cnt += 1 if memo[...
[ "expression.operation.binary.add" ]
414,663
414,664
u390901183
python
p02684
n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] # 入力値を添字に合わせる path = [] # 通った道を記録。通過済みのところに到達したら記録中止 now = 0 visited = [False] * n while not visited[now]: path.append(now) visited[now] = True now = a[now] # sはループの開始地点の添字 # whileループが終わった時点のnowには、堂々巡りの開始地点の添字が入っている ...
n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] # 入力値を添字に合わせる path = [] # 通った道を記録。通過済みのところに到達したら記録中止 now = 0 visited = [False] * n while not visited[now]: path.append(now) visited[now] = True now = a[now] # sはループの開始地点の添字 # whileループが終わった時点のnowには、堂々巡りの開始地点の添字が入っている ...
[ "expression.operation.binary.add" ]
414,677
414,678
u699089116
python
p02684
n,k=map(int,input().split()) a=list(map(int,input().split())) l1=[0]*n l1[0]+=1 c=0 #ループに入る前までの移動回数 now=0#現在位置 ne=a[now]-1 #次の移動位置 while True: if c==k: print(now+1) exit() if l1[ne]==0: l1[ne]+=1 now=ne ne=a[now]-1 c+=1 else: now=ne ne=a[now]-1...
n,k=map(int,input().split()) a=list(map(int,input().split())) l1=[0]*n l1[0]+=1 c=0 #ループに入る前までの移動回数 now=0#現在位置 ne=a[now]-1 #次の移動位置 while True: if c==k: print(now+1) exit() if l1[ne]==0: l1[ne]+=1 now=ne ne=a[now]-1 c+=1 else: now=ne ne=a[now]-1...
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
414,679
414,680
u440129511
python
p02684
import sys sys.setrecursionlimit(300000) def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LMI(): return list(map(int, sys.stdin.readline().split())) MOD = 10 ** 9 + 7 INF = float('inf') N, K = MI() A = LMI() d = dict() seen = set() i = 0 cur = 0 while True: i...
import sys sys.setrecursionlimit(300000) def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LMI(): return list(map(int, sys.stdin.readline().split())) MOD = 10 ** 9 + 7 INF = float('inf') N, K = MI() A = LMI() d = dict() seen = set() i = 0 cur = 0 while True: i...
[ "identifier.change", "control_flow.branch.if.condition.change" ]
414,684
414,685
u380772254
python
p02684
n,k=map(int,input().split()) a=[int(i)-1 for i in input().split()] p=0 visited=[0]*n first=[] roop=[] while visited[p]!=2:#二回通っていたらやめる if visited[p]==0:#初めて通った first.append(p) else:#一回通った roop.append(p) visited[p]+=1#通った跡をつける p=a[p]#テレポート print(first,roop) if len(first)>k:#一回もループしていないのなら...
n,k=map(int,input().split()) a=[int(i)-1 for i in input().split()] p=0 visited=[0]*n first=[] roop=[] while visited[p]!=2:#二回通っていたらやめる if visited[p]==0:#初めて通った first.append(p) else:#一回通った roop.append(p) visited[p]+=1#通った跡をつける p=a[p]#テレポート if len(first)>k:#一回もループしていないのなら print(first[k...
[ "call.remove" ]
414,690
414,691
u413632062
python
p02684
n, k = map(int, input().split()) a = list(map(int, input().split())) visited = [0] for _ in range(n): now = a[visited[-1]]-1 visited.append(now) if k <= n: print(visited[-1]) else: p = visited.index(visited[-1]) loop = visited[::-1][1:].index(visited[-1])+1 x = (k-p-1)%loop print(visited[p+...
n, k = map(int, input().split()) a = list(map(int, input().split())) visited = [0] for _ in range(n): now = a[visited[-1]]-1 visited.append(now) if k < n: print(visited[k]+1) else: p = visited.index(visited[-1]) loop = visited[::-1][1:].index(visited[-1])+1 x = (k-p-1)%loop print(visited[p+...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "variable_access.subscript.index.change", "call.arguments.change", "io.output.change", "expression.operation.unary.remove" ]
414,708
414,709
u375172966
python
p02684
N,K = map(int, input().split()) A = [*map(lambda x:int(x)-1, input().split())] index = [-1]*N path = [] pre = 0 while index[pre] < 0: index[pre] = len(path) path += [pre] pre = A[pre] one = index[pre] loops = len(path) - one if K < one: print(path[K]) else: print(path[(K-one) % loops + one]+1)
N,K = map(int, input().split()) A = [*map(lambda x:int(x)-1, input().split())] index = [-1]*N path = [] pre = 0 while index[pre] < 0: index[pre] = len(path) path += [pre] pre = A[pre] one = index[pre] loops = len(path) - one if K < one: print(path[K]+1) else: print(path[(K-one) % loops + one]+1)
[ "expression.operation.binary.add" ]
414,713
414,714
u525065967
python
p02684
N, K = map(int, input().split()) A = tuple( map(int, input().split()) ) L = [0 for i in range(N+1)] L[1] = 1 x = 1 t = 1 while K>0: t += 1 K -= 1 x = A[x] if L[x] != 0: p = t - L[x] K %= p break else: L[x] = t while K>0: x = A[x] K -= 1 print(x)
N, K = map(int, input().split()) A = tuple( map(int, input().split()) ) L = [0 for i in range(N+1)] L[1] = 1 x = 1 t = 1 while K>0: t += 1 K -= 1 x = A[x-1] if L[x] != 0: p = t - L[x] K %= p break else: L[x] = t while K>0: x = A[x-1] K -= 1 print(x)
[ "assignment.change" ]
414,729
414,730
u779728630
python
p02684
N, K = map(int, input().split()) A = [-1] + list(map(int, input().split())) visited = {} for i in range(1, N+1): visited[i] = False i2p = {} p2i = {} i = 0 cur = 1 while True: i2p[i] = cur p2i[cur] = i visited[cur] = True if visited[A[cur]]: break cur = A[cur] i += 1 start_loop = ...
N, K = map(int, input().split()) A = [-1] + list(map(int, input().split())) visited = {} for i in range(1, N+1): visited[i] = False i2p = {} p2i = {} i = 0 cur = 1 while True: i2p[i] = cur p2i[cur] = i visited[cur] = True if visited[A[cur]]: break cur = A[cur] i += 1 start_loop = ...
[ "identifier.change", "control_flow.branch.if.condition.change" ]
414,767
414,768
u829859091
python
p02684
n, k = map(int, input().split()) a = [0] + list(map(int, input().split())) loop = [1] now = 1 d = set([1]) for i in range(n): now = a[now] if now in d: for j in range(len(loop)): if now == loop[j]: ind = j break d.add(now) loop.append(now) if len(loo...
n, k = map(int, input().split()) a = [0] + list(map(int, input().split())) loop = [1] now = 1 d = set([1]) for i in range(n): now = a[now] if now in d: for j in range(len(loop)): if now == loop[j]: ind = j break d.add(now) loop.append(now) if len(loop) >= k+...
[ "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
414,769
414,770
u426108351
python
p02684
n, k = map(int, input().split()) a = list(map(int, input().split())) b = [] ord = [-1 for x in range(n+1)] c = 1 l = 1 v = 1 for x in range(k): if (ord[v] != -1): break ord[v] = x b.append(v) v = a[v-1] c = len(b) - ord[v] l = ord[v] if (k < l): print(b[k]) else: k -= l k %= c ...
n, k = map(int, input().split()) a = list(map(int, input().split())) b = [] ord = [-1 for x in range(n+1)] c = 1 l = 1 v = 1 #while(ord[v] == -1): for x in range(n): if (ord[v] != -1): break ord[v] = x b.append(v) v = a[v-1] c = len(b) - ord[v] l = ord[v] if (k < l): print(b[k]) else: ...
[ "identifier.change", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
414,782
414,783
u830297276
python
p02684
N,K = map(int,input().split()) A = [0] + list(map(int,input().split())) from collections import deque tmp = 1 num = [] seen = [-1]*(N+1) while seen[tmp] == -1: seen[tmp] = tmp num.append(tmp) tmp = A[tmp] l = num.index(tmp) c = len(num) - l if K < l: print(num[K-1]) else: print(num[(K-l)%c+l]...
N,K = map(int,input().split()) A = [0] + list(map(int,input().split())) from collections import deque tmp = 1 num = [] seen = [-1]*(N+1) while seen[tmp] == -1: seen[tmp] = tmp num.append(tmp) tmp = A[tmp] l = num.index(tmp) c = len(num) - l if K < l: print(num[K]) else: print(num[(K-l)%c+l])
[ "expression.operation.binary.remove" ]
414,784
414,785
u698919163
python
p02684
# 4 5 (4 cities and 5 steps) # 3 2 4 1 # 1 => 3 # 2 => 2 # 3 => 4 # 4 => 1 # 1 (0) # 1 => 3 (1) # 3 => 4 (2) # 4 => 1 (3) # 2 を作る 5 と2 と 1 を使う # 2 = (5 - 3) % 2 + 3 - 1 N, K = map(int, input().split()) A_i = list(map(int, input().split())) paths = {} for i in range(N): paths[i+1] = A_i[i] # print('paths:', ...
# 4 5 (4 cities and 5 steps) # 3 2 4 1 # 1 => 3 # 2 => 2 # 3 => 4 # 4 => 1 # 1 (0) # 1 => 3 (1) # 3 => 4 (2) # 4 => 1 (3) # 2 を作る 5 と2 と 1 を使う # 2 = (5 - 3) % 2 + 3 - 1 N, K = map(int, input().split()) A_i = list(map(int, input().split())) paths = {} for i in range(N): paths[i+1] = A_i[i] # print('paths:', ...
[ "assignment.variable.change", "expression.operation.binary.change" ]
414,792
414,793
u764501786
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) journey = [1] dup = {} for i in range(N+100000): journey.append(A[journey[-1] - 1]) end_idx, start_idx = 0, 0 dup = {} for i, j in enumerate(journey): if j in dup: end_idx = i break else: dup[j] = 0 for i, j in enu...
N, K = map(int, input().split()) A = list(map(int, input().split())) journey = [1] dup = {} for i in range(N+100000): journey.append(A[journey[-1] - 1]) end_idx, start_idx = 0, 0 dup = {} for i, j in enumerate(journey): if j in dup: end_idx = i break else: dup[j] = 0 for i, j in enu...
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
414,794
414,795
u327532412
python
p02684
N,K=map(int,input().split()) A=list(map(int,input().split())) genzaichi=1 rireki=set() houmon=[0]*(N+1) flag=0 for i in range(1,K+1): genzaichi=A[genzaichi-1] if genzaichi not in rireki: houmon[genzaichi]=i rireki.append(genzaichi) else: roop_from=genzaichi x=houmon[roop_fr...
N,K=map(int,input().split()) A=list(map(int,input().split())) genzaichi=1 rireki=set() houmon=[0]*(N+1) flag=0 for i in range(1,K+1): genzaichi=A[genzaichi-1] if genzaichi not in rireki: houmon[genzaichi]=i rireki.add(genzaichi) else: roop_from=genzaichi x=houmon[roop_from]...
[ "identifier.change" ]
414,798
414,799
u102218630
python
p02684
n,k,*a=map(int,open(0).read().split()) now=1 if k<=n: for i in range(k): now=a[now-1] print(now) exit() # 絶対ループする visited=[False]*n visited[now-1]=-1 for i in range(4*10**5): now=a[now-1] if visited[now-1]==False: visited[now-1]=i else: c,d=visited[now-1],i break k=(k-c)%(d-c)+c while k<n: ...
n,k,*a=map(int,open(0).read().split()) now=1 if k<=n: for i in range(k): now=a[now-1] print(now) exit() # 絶対ループする visited=[False]*n visited[now-1]=-1 for i in range(4*10**5): now=a[now-1] if visited[now-1]==False: visited[now-1]=i else: c,d=visited[now-1],i break k=(k-c)%(d-c)+c while k<n: ...
[ "assignment.add" ]
414,805
414,806
u130900604
python
p02684
n,k,*a=map(int,open(0).read().split()) now=1 if k<=n: for i in range(k): now=a[now-1] print(now) exit() # 絶対ループする visited=[False]*n visited[now-1]=-1 for i in range(4*10**5): now=a[now-1] if visited[now-1]==False: visited[now-1]=i else: c,d=visited[now-1],i break k=(k-c)%(d-c)+c while k<n: ...
n,k,*a=map(int,open(0).read().split()) now=1 if k<=n: for i in range(k): now=a[now-1] print(now) exit() # 絶対ループする visited=[False]*n visited[now-1]=-1 for i in range(4*10**5): now=a[now-1] if visited[now-1]==False: visited[now-1]=i else: c,d=visited[now-1],i break k=(k-c)%(d-c)+c while k<n:...
[ "assignment.add" ]
414,805
414,807
u130900604
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) n = 1 order = [n] order_set = set([n]) for i in range(1, K + 1): n = A[n - 1] if n in order_set: Li = order.index(n) Ri = len(order) idx = Li + (K - Li) % (Ri - Li) print(order[idx]) break else...
N, K = map(int, input().split()) A = list(map(int, input().split())) n = 1 order = [n] order_set = set([n]) for i in range(1, K + 1): n = A[n - 1] if n in order_set: Li = order.index(n) Ri = len(order) idx = Li + (K - Li) % (Ri - Li) print(order[idx]) exit() else: ...
[ "control_flow.break.remove", "control_flow.exit.add", "call.add", "identifier.change", "call.arguments.change", "io.output.change" ]
414,829
414,830
u526094365
python
p02684
n, k = map(int, input().split()) a = list(map(int, input().split())) pos = -1 seen = [False] * n last = [-1] * n hist = [] i = 0 cnt = 0 while(seen[i] == False): seen[i] = True last[i] = cnt cnt += 1 hist.append(i) ne = a[i]-1 i = ne if (seen[i] == True): pos = i cycle = hist[last...
n, k = map(int, input().split()) a = list(map(int, input().split())) pos = -1 seen = [False] * n last = [-1] * n hist = [] i = 0 cnt = 0 while(seen[i] == False): seen[i] = True last[i] = cnt cnt += 1 hist.append(i) ne = a[i]-1 i = ne if (seen[i] == True): pos = i cycle = hist[last...
[ "expression.operation.binary.add" ]
414,848
414,849
u845620905
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) t_zero = [-1] * N t = 0 a = 1 while t_zero[a-1] == -1: if t == K: break t_zero[a-1] = t t += 1 a = A[a-1] else: k = (K - t_zero[a-1]) % (t - t_zero[a-1]) a = t_zero.index(t_zero[a] + k) print(a)
N, K = map(int, input().split()) A = list(map(int, input().split())) t_zero = [-1] * N t = 0 a = 1 while t_zero[a-1] == -1: if t == K: break t_zero[a-1] = t t += 1 a = A[a-1] else: k = (K - t_zero[a-1]) % (t - t_zero[a-1]) a = t_zero.index(t_zero[a-1] + k) + 1 print(a)
[ "assignment.change" ]
414,859
414,860
u875541136
python
p02684
#入力 a = input().split() N = int(a[0]) K = int(a[1]) c = input().split() c=[int(i) for i in c] #それぞれ頂点が向かう先。 current_num_set = set() current_num_list=[] #これまでの道筋 current_num = 1 #現在の位置 #今いる位置が今まで出てきていない場合に、次どこにいくのかをチェック while (current_num not in current_num_set): current_num_set.add(current_num) curr...
a = input().split() N = int(a[0]) K = int(a[1]) c = input().split() c=[int(i) for i in c] #それぞれ頂点が向かう先。 current_num_set = set() current_num_list=[] #これまでの道筋 current_num = 1 #現在の位置 #今いる位置が今まで出てきていない場合に、次どこにいくのかをチェック while (current_num not in current_num_set): current_num_set.add(current_num) current_...
[ "identifier.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
414,869
414,870
u876295560
python
p02684
a = input().split() N = int(a[0]) K = int(a[1]) c = input().split() c=[int(i) for i in c] #それぞれ頂点が向かう先。 current_num_set = set() current_num_list=[] #これまでの道筋 current_num = 1 #現在の位置 #今いる位置が今まで出てきていない場合に、次どこにいくのかをチェック while (current_num not in current_num_set): current_num_set.add(current_num) current_...
a = input().split() N = int(a[0]) K = int(a[1]) c = input().split() c=[int(i) for i in c] #それぞれ頂点が向かう先。 current_num_set = set() current_num_list=[] #これまでの道筋 current_num = 1 #現在の位置 #今いる位置が今まで出てきていない場合に、次どこにいくのかをチェック while (current_num not in current_num_set): current_num_set.add(current_num) current_...
[ "expression.operation.binary.remove" ]
414,871
414,870
u876295560
python
p02684
#N=int(input()) N,K = map(int,input().split()) #N=int(input()) A = list(map(int,input().split())) #S=str(input()) now=1 flag=[0]+[-1]*(N-1) for i in range(N): now = A[now-1] if flag[now-1]==-1: flag[now-1]+=i+2 else: loop = i+1 - flag[now-1] zan=(K-i-1) - (K-i-1)//loop * loop ...
#N=int(input()) N,K = map(int,input().split()) #N=int(input()) A = list(map(int,input().split())) #S=str(input()) now=1 flag=[0]+[-1]*(N-1) for i in range(K): now = A[now-1] if flag[now-1]==-1: flag[now-1]+=i+2 else: loop = i+1 - flag[now-1] zan=(K-i-1) - (K-i-1)//loop * loop ...
[ "identifier.change", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
414,879
414,880
u991619971
python
p02684
#N=int(input()) N,K = map(int,input().split()) #N=int(input()) A = list(map(int,input().split())) #S=str(input()) now=1 flag=[0]+[-1]*(N-1) for i in range(N): now = A[now-1] if flag[now-1]==-1: flag[now-1]+=i+2 else: loop = i+1 - flag[now-1] zan=(K-i-1) - (K-i-1)//loop * loop ...
#N=int(input()) N,K = map(int,input().split()) #N=int(input()) A = list(map(int,input().split())) #S=str(input()) now=1 flag=[0]+[-1]*(N-1) for i in range(K): now = A[now-1] if flag[now-1]==-1: flag[now-1]+=i+2 else: loop = i+1 - flag[now-1] zan=(K-i-1) - (K-i-1)//loop * loop ...
[ "identifier.change", "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "call.add" ]
414,881
414,880
u991619971
python
p02684
#N=int(input()) N,K = map(int,input().split()) #N=int(input()) A = list(map(int,input().split())) #S=str(input()) now=1 flag=[-1]*(N) for i in range(N): if flag[now-1]==-1: flag[now-1]=i now = A[now-1] else: loop = i - flag[now-1] zan=(K-(i-loop))%loop ans = flag.index(...
#N=int(input()) N,K = map(int,input().split()) #N=int(input()) A = list(map(int,input().split())) #S=str(input()) now=1 flag=[-1]*(N) for i in range(K): if flag[now-1]==-1: flag[now-1]=i now = A[now-1] else: loop = i - flag[now-1] zan=(K-(i-loop))%loop ans = flag.index(...
[ "identifier.change", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
414,882
414,883
u991619971
python
p02684
import sys input = sys.stdin.readline n,k = map(int,input().split()) a = list(map(int,input().split())) p = [1] for i in range(n): p.append(a[p[i]-1]) print(p) if k <= n: print(p[k]) else: # 周期の来る前の回数 num = p.index(p[-1]) p = p[num:] # 周期 pn = len(p)-1 k -= num # 回数/周期のあまり a...
import sys input = sys.stdin.readline n,k = map(int,input().split()) a = list(map(int,input().split())) p = [1] for i in range(n): p.append(a[p[i]-1]) if k <= n: print(p[k]) else: # 周期の来る前の回数 num = p.index(p[-1]) p = p[num:] # 周期 pn = len(p)-1 k -= num # 回数/周期のあまり ans = k%pn...
[ "call.remove" ]
414,891
414,892
u628707847
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) e = [False] * (N+1) idx = 1 move = [] while True: if e[idx]: break move.append(idx) e[idx] = True idx = A[idx-1] m = move.index(idx) c = len(move) - m if K <= m: print(D[K]) else: print(D[m+(K-m) % c])
N, K = map(int, input().split()) A = list(map(int, input().split())) e = [False] * (N+1) idx = 1 move = [] while True: if e[idx]: break move.append(idx) e[idx] = True idx = A[idx-1] m = move.index(idx) c = len(move) - m if K <= m: print(move[K]) else: print(move[m+(K-m) % c])
[ "identifier.change", "call.arguments.change", "io.output.change" ]
414,895
414,896
u873616440
python
p02684
def main(): n,k = map(int, input().split()) town = list(map(int, input().split())) town = [i-1 for i in town] visited = [-1] * n current_town = 0 current_order = 0 memo = [] while visited[current_town] == -1: visited[current_town] = current_order memo.append(current_town)...
def main(): n,k = map(int, input().split()) town = list(map(int, input().split())) town = [i-1 for i in town] visited = [-1] * n current_town = 0 current_order = 0 memo = [] while visited[current_town] == -1: visited[current_town] = current_order memo.append(current_town)...
[ "expression.operation.binary.add" ]
414,908
414,909
u738287470
python
p02684
import sys # print('input >>') N, K = map(int,(input().split())) As = list(map(lambda x: int(x)-1,(input().split()))) visited = [0] * N visited[0] = 1 roots = [0] now = 0 # print('-----output-----') while True: now = As[now] if visited[now] == 1: p = now rep_start = roots.index(now) m...
import sys # print('input >>') N, K = map(int,(input().split())) As = list(map(lambda x: int(x)-1,(input().split()))) visited = [0] * N visited[0] = 1 roots = [0] now = 0 # print('-----output-----') while True: now = As[now] if visited[now] == 1: p = now rep_start = roots.index(now) m...
[ "call.remove" ]
414,928
414,929
u657994700
python
p02684
import sys # print('input >>') N, K = map(int,(input().split())) As = list(map(lambda x: int(x)-1,(input().split()))) visited = [0] * N visited[0] = 1 roots = [0] now = 0 # print('-----output-----') while True: now = As[now] if visited[now] == 1: p = now rep_start = roots.index(now) m...
import sys # print('input >>') N, K = map(int,(input().split())) As = list(map(lambda x: int(x)-1,(input().split()))) visited = [0] * N visited[0] = 1 roots = [0] now = 0 # print('-----output-----') while True: now = As[now] if visited[now] == 1: p = now rep_start = roots.index(now) m...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
414,930
414,929
u657994700
python
p02684
n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] curr = 0 arr = [] visited = [False]*n while(not visited[curr]): visited[curr] = True arr.append(curr) curr = a[curr]-1 visited = [False]*n cycleSize = 0 while(not visited[curr]): visited[curr] = True cycleSize+=1 c...
n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] curr = 0 arr = [] visited = [False]*n while(not visited[curr]): visited[curr] = True arr.append(curr) curr = a[curr]-1 visited = [False]*n cycleSize = 0 while(not visited[curr]): visited[curr] = True cycleSize+=1 c...
[ "expression.operation.binary.add" ]
414,931
414,932
u719873358
python
p02684
N = [int(e) for e in input().split()] nums = [int(t) for t in input().split()] count=[] k = 0 check = [] t = nums[0] for i in range(N[0]): count.append(0) while count[t-1] == 0: check.append(t) count[t-1] += 1 k = t -1 t = nums[k] s = check.index(t) + 1 if(N[1] < s): print(check[N[1]]) else: ...
N = [int(e) for e in input().split()] nums = [int(t) for t in input().split()] count=[] k = 0 check = [] t = nums[0] for i in range(N[0]): count.append(0) while count[t-1] == 0: check.append(t) count[t-1] += 1 k = t -1 t = nums[k] s = check.index(t) + 1 if(N[1] < s): print(check[N[1] - 1]) else...
[ "expression.operation.binary.add" ]
414,935
414,936
u282978698
python
p02684
# coding: utf-8 import sys import math import collections import itertools import bisect INF = 10 ** 13 MOD = 10 ** 9 + 7 def input() : return sys.stdin.readline().strip() def gcd(x, y) : return x if y == 0 else gcd(y, x%y) def lcm(x, y) : return (x * y) // gcd(x, y) def I() : return int(input()) def LI() : return [in...
# coding: utf-8 import sys import math import collections import itertools import bisect INF = 10 ** 13 MOD = 10 ** 9 + 7 def input() : return sys.stdin.readline().strip() def gcd(x, y) : return x if y == 0 else gcd(y, x%y) def lcm(x, y) : return (x * y) // gcd(x, y) def I() : return int(input()) def LI() : return [in...
[ "expression.operation.binary.remove" ]
414,941
414,942
u102278909
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) now = 1 loop_node = [] first_loop = 0 l = [0 for _ in range(N)] while True: l[now - 1] += 1 if l[now - 1] == 3: break if l[now - 1] == 2: loop_node.append(now) now = A[now - 1] first_loop += 1 loop_num = len(loo...
N, K = map(int, input().split()) A = list(map(int, input().split())) now = 1 loop_node = [] first_loop = 0 l = [0 for _ in range(N)] while True: l[now - 1] += 1 if l[now - 1] == 3: break if l[now - 1] == 2: loop_node.append(now) now = A[now - 1] first_loop += 1 loop_num = len(loo...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "identifier.change", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
414,948
414,949
u759726213
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) now = 1 loop_node = [] first_loop = 0 l = [0 for _ in range(N)] while True: l[now - 1] += 1 if l[now - 1] == 3: break if l[now - 1] == 2: loop_node.append(now) now = A[now - 1] first_loop += 1 loop_num = len(loo...
N, K = map(int, input().split()) A = list(map(int, input().split())) now = 1 loop_node = [] first_loop = 0 l = [0 for _ in range(N)] while True: l[now - 1] += 1 if l[now - 1] == 3: break if l[now - 1] == 2: loop_node.append(now) now = A[now - 1] first_loop += 1 loop_num = len(loo...
[ "identifier.change", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
414,950
414,949
u759726213
python
p02684
n,k=map(int,input().split()) a=list(map(int, input().split())) b=[1] ba={1} c=0 m=0 # while flag==1: for i in range(n): if a[m] not in ba: b.append(a[m]) ba.add(a[m]) c+=1 m=a[m]-1 else: e=a[m] break # print(b,e,c+1) e=b.index(e) # print(b,e) b=b[e:c+1] f=c+1-e i...
n,k=map(int,input().split()) a=list(map(int, input().split())) b=[1] ba={1} c=0 m=0 # while flag==1: for i in range(n): if a[m] not in ba: b.append(a[m]) ba.add(a[m]) c+=1 m=a[m]-1 else: e=a[m] break # print(b,e,c+1) e=b.index(e) # print(b,e) bc=b b=b[e:c+1] f=c+...
[ "identifier.change", "call.arguments.change", "io.output.change" ]
414,956
414,957
u548069143
python
p02684
n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] visited = [-1]*n route = [] now = 0 hop = 0 while visited[now] == -1: visited[now]=hop route.append(now) now = a[now] hop+=1 loop_st = 0 for r in route: if r==now: break loop_st+=1 loop = route[loop_st:] if...
n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] visited = [-1]*n route = [] now = 0 hop = 0 while visited[now] == -1: visited[now]=hop route.append(now) now = a[now] hop+=1 loop_st = 0 for r in route: if r==now: break loop_st+=1 loop = route[loop_st:] if...
[ "expression.operation.binary.remove" ]
414,960
414,961
u595952233
python
p02684
n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] visited = [-1]*n route = [] now = 0 hop = 0 while visited[now] == -1: visited[now]=hop route.append(now) now = a[now] hop+=1 loop_st = 0 for r in route: if r==now: break loop_st+=1 loop = route[loop_st:] if...
n, k = map(int, input().split()) a = list(map(int, input().split())) a = [i-1 for i in a] visited = [-1]*n route = [] now = 0 hop = 0 while visited[now] == -1: visited[now]=hop route.append(now) now = a[now] hop+=1 loop_st = 0 for r in route: if r==now: break loop_st+=1 loop = route[loop_st:] if...
[ "expression.operation.binary.remove" ]
414,962
414,961
u595952233
python
p02684
n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] loc = 0 lst = [False]*n lst[0] = True while True: if lst[a[loc]]: x = a[loc] break loc = a[loc] lst[loc] = True cnt = 0 loc = 0 if x != 0: while True: loc = a[loc] cnt += 1 if loc == x: break c...
n,k = map(int,input().split()) a = [int(i)-1 for i in input().split()] loc = 0 lst = [False]*n lst[0] = True while True: if lst[a[loc]]: x = a[loc] break loc = a[loc] lst[loc] = True cnt = 0 loc = 0 if x != 0: while True: loc = a[loc] cnt += 1 if loc == x: break c...
[ "identifier.change", "control_flow.loop.condition.change" ]
414,967
414,968
u677121387
python
p02684
mNK = map(int, input().split()) lNK = list(mNK) mTel = map(int, input().split()) lTel = list(mTel) lWent = [-1 for i in range(lNK[0])] nTown = 0 loopCnt = -1 for i in range(lNK[1]): nextTown = lTel[nTown] - 1 lWent[nTown] = i if(lWent[nextTown] != -1): loopCnt = i - lWent[nextTown] + 1 su...
mNK = map(int, input().split()) lNK = list(mNK) mTel = map(int, input().split()) lTel = list(mTel) lWent = [-1 for i in range(lNK[0])] nTown = 0 loopCnt = -1 for i in range(lNK[1]): nextTown = lTel[nTown] - 1 lWent[nTown] = i if(lWent[nextTown] != -1): loopCnt = i - lWent[nextTown] + 1 su...
[]
414,982
414,983
u082945913
python
p02684
n,k=map(int,input().split()) a=list(map(int,input().split())) now=1 to=0 t=k l=[0]*n l[0]=1 cnt=2 while t>0: to=a[now-1] t-=1 if l[to-1]!=0: break else: l[to-1]=cnt cnt+=1 now=to if t==0: print(now) else: loop=max(l)-l[to-1]+1 start=l[to-1]-1 ans=l.index((k...
n,k=map(int,input().split()) a=list(map(int,input().split())) now=1 to=0 t=k l=[0]*n l[0]=1 cnt=2 while t>0: to=a[now-1] t-=1 if l[to-1]!=0: now=to break else: l[to-1]=cnt cnt+=1 now=to if t==0: print(now) else: loop=max(l)-l[to-1]+1 #loopの長さ start=l[to...
[ "assignment.add" ]
414,986
414,987
u357230322
python
p02684
n,k=map(int,input().split()) a=list(map(int,input().split())) now=1 arr=[0]*(n+1) for i in range(1,10**6): now=a[now-1] if i==k: print(now) quit() if arr[now]!=0: first=arr[now] break arr[now]=i # print(arr) cycle=max(arr)-first+1 # print(cycle) mod=(k-first+1)%cycle # print(mod) ans=arr.index(f...
n,k=map(int,input().split()) a=list(map(int,input().split())) now=1 arr=[0]*(n+1) for i in range(1,10**6): now=a[now-1] if i==k: print(now) quit() if arr[now]!=0: first=arr[now] break arr[now]=i # print(arr) cycle=max(arr)-first+1 # print(cycle) mod=(k-first)%cycle # print(mod) ans=arr.index(fir...
[ "expression.operation.binary.remove" ]
414,998
414,999
u791489811
python
p02684
N,K = map(int,input().split()) A = list(map(int,input().split())) A = [i-1 for i in A] flag = [False]*N from collections import deque q = deque([]) q.append(0) flag[0] = True now = 0 while True: now = A[now] if flag[now]: break else: flag[now] = True q.append(now) l = list(q) if K<=len(l): pr...
N,K = map(int,input().split()) A = list(map(int,input().split())) A = [i-1 for i in A] flag = [False]*N from collections import deque q = deque([]) q.append(0) flag[0] = True now = 0 while True: now = A[now] if flag[now]: break else: flag[now] = True q.append(now) l = list(q) if K<len(l): pri...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
415,004
415,005
u268554510
python
p02684
n, m = map(int, input().split()) lis = list(map(lambda z: int(z) - 1, map(int, input().split()))) s = {0} res = [0] while lis[res[-1]] not in s: res.append(lis[res[-1]]) s.add(res[-1]) x, y = res.index(res[-1]), len(res) if m < y: print(res[m]+1) else: mm = (m - x) % (y - x) print(res[mm + x]+1)...
n, m = map(int, input().split()) lis = list(map(lambda z: int(z) - 1, map(int, input().split()))) s = {0} res = [0] while lis[res[-1]] not in s: res.append(lis[res[-1]]) s.add(res[-1]) x, y = res.index(lis[res[-1]]), len(res) if m < y: print(res[m] + 1) else: mm = (m - x) % (y - x) print(res[mm ...
[ "call.arguments.change" ]
415,008
415,009
u189023301
python
p02684
n, k = map(int, input().split()) As = list(map(int, input().split())) maps = {} for i, a in enumerate(As): maps[i] = a - 1 probs = [0] * n p = 0 # 現在位置 target = 0 # はじめて2回出現する場所 h = 0 # ターゲットの初回出現時のワープ回数 t = 0 # ターゲットの2回目の出現時のワープ回数 # はじめて2回出現する場所(target)と、その時点でのワープ回数を取得 for i in range(n + 1): probs[p] +=...
n, k = map(int, input().split()) As = list(map(int, input().split())) maps = {} for i, a in enumerate(As): maps[i] = a - 1 probs = [0] * n p = 0 # 現在位置 target = 0 # はじめて2回出現する場所 h = 0 # ターゲットの初回出現時のワープ回数 t = 0 # ターゲットの2回目の出現時のワープ回数 # はじめて2回出現する場所(target)と、その時点でのワープ回数を取得 for i in range(n + 1): probs[p] +=...
[ "call.add" ]
415,010
415,011
u908763441
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) A = [i-1 for i in A] check = [0]*N i = 0 c = 0 check = [] visited = [0]*N flag = False while c<=K: if visited[i] == 1: flag = True break else: check.append(i) visited[i] = 1 i = A[i] c += 1 if f...
N, K = map(int, input().split()) A = list(map(int, input().split())) A = [i-1 for i in A] check = [0]*N i = 0 c = 1 check = [] visited = [0]*N flag = False while c<=K: if visited[i] == 1: flag = True break else: check.append(i) visited[i] = 1 i = A[i] c += 1 if f...
[ "literal.number.integer.change", "assignment.value.change" ]
415,014
415,015
u686036872
python
p02684
N, K, *A = map(int, open(0).read().split()) A = [0] + A visited = [-1] * (N + 1) pre = 0 cycle = 0 cur = 1 for i in range(N): visited[cur] = i cur = A[cur] if visited[cur] >= 0: pre = visited[cur] cycle = i + 1 - visited[cur] break cur = 1 for _ in range(pre + ((K - pre) % cycle...
N, K, *A = map(int, open(0).read().split()) A = [0] + A visited = [-1] * (N + 1) pre = 0 cycle = 0 cur = 1 for i in range(N): visited[cur] = i cur = A[cur] if visited[cur] >= 0: pre = visited[cur] cycle = i + 1 - visited[cur] break cur = 1 for _ in range(min(K, pre + ((K - pre) ...
[ "call.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
415,033
415,034
u606045429
python
p02684
N, K, *A = map(int, open(0).read().split()) A = [0] + A visited = [-1] * (N + 1) pre = 0 cycle = 0 cur = 1 for i in range(N): visited[cur] = i cur = A[cur] if visited[cur] > 0: pre = visited[cur] cycle = i + 1 - visited[cur] break cur = 1 for _ in range(pre + ((K - pre) % cycle)...
N, K, *A = map(int, open(0).read().split()) A = [0] + A visited = [-1] * (N + 1) pre = 0 cycle = 0 cur = 1 for i in range(N): visited[cur] = i cur = A[cur] if visited[cur] >= 0: pre = visited[cur] cycle = i + 1 - visited[cur] break cur = 1 for _ in range(min(K, pre + ((K - pre) ...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "call.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
415,035
415,034
u606045429
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) m = {} for i, a in enumerate(A): m[i+1] = a visited = [] cycle = set() current_city = 1 visited.append(current_city) cycle.add(current_city) cycle_start_index = -1 while 1: current_city = m[current_city] if current_city in cycle: ...
N, K = map(int, input().split()) A = list(map(int, input().split())) m = {} for i, a in enumerate(A): m[i+1] = a visited = [] cycle = set() current_city = 1 visited.append(current_city) cycle.add(current_city) cycle_start_index = -1 while 1: current_city = m[current_city] if current_city in cycle: ...
[ "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
415,054
415,055
u471214054
python
p02684
N, K = map(int, input().split()) A = list(map(int, input().split())) m = {} for i, a in enumerate(A): m[i+1] = a visited = [] cycle = set() current_city = 1 visited.append(current_city) cycle.add(current_city) cycle_start_index = -1 while 1: current_city = m[current_city] if current_city in cycle: ...
N, K = map(int, input().split()) A = list(map(int, input().split())) m = {} for i, a in enumerate(A): m[i+1] = a visited = [] cycle = set() current_city = 1 visited.append(current_city) cycle.add(current_city) cycle_start_index = -1 while 1: current_city = m[current_city] if current_city in cycle: ...
[ "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
415,056
415,055
u471214054
python
p02684
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline n, k = map(int, input().split()) a = list(map(int, input().split())) a = [a[i] - 1 for i in range(n)] next_i = 0 seen = [-1] * n count = 0 while True: if seen[next_i] != -1: start = n...
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline n, k = map(int, input().split()) a = list(map(int, input().split())) a = [a[i] - 1 for i in range(n)] next_i = 0 seen = [-1] * n count = 0 while True: if seen[next_i] != -1: start = s...
[]
415,059
415,060
u390727364
python
p02684
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline n, k = map(int, input().split()) a = list(map(int, input().split())) a = [a[i] - 1 for i in range(n)] next_i = 0 seen = [-1] * n count = 0 while True: if seen[next_i] != -1: start = ...
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline n, k = map(int, input().split()) a = list(map(int, input().split())) a = [a[i] - 1 for i in range(n)] next_i = 0 seen = [-1] * n count = 0 while True: if seen[next_i] != -1: start = s...
[ "control_flow.exit.remove", "control_flow.break.add", "call.arguments.change" ]
415,061
415,060
u390727364
python
p02684
n,k = map(int,input().split()) a = list(map(int,input().split())) l = [1] for i in range(n): l.append(a[l[i]]) p = l.index(l[-1]) if k<=n: print(l[k]) exit() x = (k-n+1)%(n-p) if x==0: print(l[n-1]) else: print(l[x+p-1])
n,k = map(int,input().split()) a = list(map(int,input().split())) l = [1] for i in range(n): l.append(a[l[i]-1]) p = l.index(l[-1]) if k<=n: print(l[k]) exit() x = (k-n+1)%(n-p) if x==0: print(l[n-1]) else: print(l[x+p-1])
[ "expression.operation.binary.add" ]
415,069
415,070
u987326700
python