Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def solve():
  n,a = (int(i) for i in input().split())
  x = list(int(i) for i in input().split())
  tp = max(x)
  dp = [[[0 for i in range(n*tp +1)] for j in range(n+1)] for k in range(n+1)]
  query = a*n
  dp[0][0][0] = 1
  for i in range(1,n+1):
    for j in range(n+1):
      for k in range(n*tp +1):
        #選ばない
        dp[i][j][k] = dp[i-1][j][k]
        if x[i-1] <= k and j > 0:
         dp[i][j][k] += dp[i-1][j-1][k-x[i-1]]
        
  ans = 0
  for j in range(1,n+1):
    ans += dp[n][j][j*a]
  #print(dp)
  print(ans)
  
  
  
  
  
  
solve()

Fixed submission:
def solve():
  n,a = (int(i) for i in input().split())
  x = list(int(i) for i in input().split())
  tp = max(x)
  if tp < a:
    print(0)
    exit()
  
  dp = [[[0 for i in range(n*tp +1)] for j in range(n+1)] for k in range(n+1)]
  query = a*n
  dp[0][0][0] = 1
  for i in range(1,n+1):
    for j in range(n+1):
      for k in range(n*tp +1):
        #選ばない
        dp[i][j][k] = dp[i-1][j][k]
        if x[i-1] <= k and j > 0:
         dp[i][j][k] += dp[i-1][j-1][k-x[i-1]]
        
  ans = 0
  for j in range(1,n+1):
    ans += dp[n][j][j*a]
  #print(dp)
  print(ans)
  
  
  
  
  
  
solve()
Buggy python submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())
dp = [0]*(m+1)
ball = [1]*(m+1)
dp[0] = 1
for i in range(m):
  x,y = (int(i) for i in input().split())
  if dp[x-1] == 1:
    dp[y-1] = 1
  ball[x-1] -= 1
  ball[y-1] += 1
  if ball[x-1] == 0:
    dp[x-1] = 0
print(sum(dp))

Fixed submission:
n,m = (int(i) for i in input().split())
dp = [0]*(n+1)
ball = [1]*(n+1)
dp[0] = 1
for i in range(m):
  x,y = (int(i) for i in input().split())
  if dp[x-1] == 1:
    dp[y-1] = 1
  ball[x-1] -= 1
  ball[y-1] += 1
  if ball[x-1] == 0:
    dp[x-1] = 0
print(sum(dp))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()));
lis = [0]*N
ans = [0]*N
ans_selected = [0]*N
ans_sum = 0

for i in A:
    lis[i] += 1

for num, i in enumerate(lis):
    ans[num] = i * (i-1) // 2
    ans_sum += i * (i-1) // 2
    if i != 0:
        ans_selected[num] = (i-1) * (i-2) // 2

for i in A:
    print(ans_sum - ans[i] + ans_selected[i])


Fixed submission:
N = int(input())
A = list(map(int, input().split()));
lis = [0]*(N+1)
ans = [0]*(N+1)
ans_selected = [0]*(N+1)
ans_sum = 0

for i in A:
    lis[i] += 1

for num, i in enumerate(lis):
    ans[num] = i * (i-1) // 2
    ans_sum += i * (i-1) // 2
    if i != 0:
        ans_selected[num] = (i-1) * (i-2) // 2

for i in A:
    print(ans_sum - ans[i] + ans_selected[i])
Buggy python submission (verdict: Runtime Error):

N = int(input())

list = []

for i in range(N):
    A, B = input().split()

    A = A + "000000000000"
    A = A[:10]
    B = str(2000-int(B))+str(i+1001)
    list.append(A+B)

list = merge_sort(list)

for i in list:
    print(int(i[-3:]))


Fixed submission:
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

# 以上マージソート

N = int(input())
 
list = []
 
for i in range(N):
    A, B = input().split()
 
    A = A + "000000000000"
    A = A[:10]
    B = str(2000-int(B))+str(i+1001)
    list.append(A+B)
 
list = merge_sort(list)
 
for i in list:
    print(int(i[-3:]))
Buggy python submission (verdict: Time Limit Exceeded):

N, M = map(int, input().split())
A = [];
B = [];

for i in range(N):
    Aap, Bap = map(int, input().split())
    A.append(Aap);
    B.append(Bap);

cost = 0;

while(M>0):
    lowestPrice = min(A);
    num = A.index(lowestPrice);
    if (B[num] >= M):
        cost += M*lowestPrice;
        M = 0;
    else:
        cost += B[num]*lowestPrice;
        M -= B[num];
        del A[num];
        del B[num];

print(cost);


Fixed submission:

N, M = map(int, input().split())
shopList = [];

for i in range(N):
    Aap, Bap = map(int, input().split())
    listap = [Aap, Bap]
    shopList.append(listap);

cost = 0;
shopList.sort();

while(M>0):
    lowestPrice = shopList[0][0];
    if (shopList[0][1] >= M):
        cost += M*lowestPrice;
        M = 0;
    else:
        cost += shopList[0][1]*lowestPrice;
        M -= shopList[0][1];
        del shopList[0];

print(cost);
Buggy python submission (verdict: Runtime Error):
N = int,input()

count = 0
for i in range (1,N+1):
  if i % 3 == 0 or i % 5 == 0:
    count += i
  print(count)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in A:
         if  i % 2 ==0:
           if (i % 3 != 0) and ( i % 5 != 0):
             print('DENIED')
             exit()
print ('APPROVED')
Buggy python submission (verdict: Runtime Error):
N = int(input())
kuku = []
for i in range(1,10):
  for j in range(1,10):
    kuku.append(i*j)
    
if N in kuku:
  print('Yes')
else:
  print('No')

Fixed submission:
a,b = input().split()
a = int(a)
b = int(b)
if a >= 10 or b >=10:
  print ('-1')
else:
  print (a * b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
kuku = []
for x in range(1,10):
  for y in range(1,10):
    kuku.append(x*y)
    
if N in kuku:
  print('Yes')
else:
  print('No')

Fixed submission:
a,b = input().split()
a = int(a)
b = int(b)
if a >= 10 or b >=10:
  print ('-1')
else:
  print (a * b)
Buggy python submission (verdict: Runtime Error):
a,n = input().split()
a = int(a)
n = int(n)
print (n * n - a)

Fixed submission:
n = input()
a = input()
n = int(n)
a = int(a)

print (n * n - a)

Buggy python submission (verdict: Runtime Error):
a,n = input().split()
a = int(a)
n = int(n)
print (n * n - a)

Fixed submission:
n = input()
a = input()
n = int(n)
a = int(a)

print (n * n - a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

int cnt=0

while True:
    exist_odd = False
    for a in A:
        if a % 2 == 0:
            continue
        else:
            exist_odd = True
            break 
    if exist_odd: 
        break
    A = [a/2 for a in A]
    cnt = cnt + 1
print(cnt)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))

# n = 5
# A = [2,4, 6]

cnt = 0

flag=True
while flag:
    for a in A:
        if a % 2 == 0:
            continue
        else:
            flag=False
            break 
    if not flag: 
        break
    A = [a/2 for a in A]
    cnt = cnt + 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
x = input.split()
y = int(x[0])*int(x[1])
print(y)

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
a,b = (int(x) for x in input.split())
print(a*b)

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
num[]=input()
x = num[0]*num[1]
print(x)

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
A=input()
B=input()
print(A*B)

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
print(A*B)

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy python submission (verdict: Runtime Error):
A*B

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)
Buggy python submission (verdict: Runtime Error):
x, y, z = input.split()
a = "No"
if x != y:
	if y = z:
      a = "Yes"
      elif x = z:
        a = "Yes"
      else: a = "No"
if x = y:
  if y = z:
    a = "No"
    elif x = z:
      a = "No"
    else: a = "Yes"
print(a)

Fixed submission:
x, y, z = input().split()
a = "No"
if x != y:
    if x == z:
        a = "Yes"
    elif y == z:
        a = "Yes"
    else:
        a = "No"
if x == y:
    if x == z:
        a = "No"
    elif y == z:
        a = "No"
    else:
        a = "Yes"
print(a)

Buggy python submission (verdict: Runtime Error):
x,y,z = input.split()
if x = y:
  if y = z:
    print('No')
  else print('Yes')
if y = z:
  if x = z:
    print('No')
  else print('Yes')
if x = z:
  if x = y:
    print('No')
  else print('Yes')

Fixed submission:
x, y, z = input().split()
a = "No"
if x != y:
    if x == z:
        a = "Yes"
    elif y == z:
        a = "Yes"
    else:
        a = "No"
if x == y:
    if x == z:
        a = "No"
    elif y == z:
        a = "No"
    else:
        a = "Yes"
print(a)
Buggy python submission (verdict: Runtime Error):
N=int(input())
D=False
ans=1
List=list(map(int,input()split()))
if 0 in List:
  print(0)
else:
  for i in ragne(N):
    ans=ans*List[i]
    if ans>10**18:
      print(-1)
      D=True
      break
  if D==False:
    print(ans)

Fixed submission:
N=int(input())
D=False
ans=1
List=list(map(int,input().split()))
if 0 in List:
  print(0)
else:
  for i in range(N):
    ans=ans*List[i]
    if ans>10**18:
      print(-1)
      D=True
      break
  if D==False:
    print(ans)
Buggy python submission (verdict: Runtime Error):
A,B=map(str,input().split())
A=int(A)
B=B.replase(".","")
print(int((A*B)/100))

Fixed submission:
A,b=map(str,input().split())
A=int(A)
b=b.replace(".","")
b=int(b)
print(int((A*b)//100))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

from collections import defaultdict

G = defaultdict(set)


results = [-1]*N
flags   = [False]*N

for _ in range(M):
    A, B = map(int, input().split())
    G[A-1].add(B-1)
    G[B-1].add(A-1)

#print(G)

### 最初の段階は、全て繋がっているかどうか。
seen = [False]*N
def rec(i):
    seen[i] = True
    for j in G[i]:
        if seen[j]:
            continue
        rec(j)

for i in range(N):
    if seen[i]:
        continue
    rec(i)

#print(seen)
#全て繋がっているなら、whileループを実装して良い
if sum(seen) != N:
    print('No')
else:
    searchs = set(range(1,N))
    for i in list(searchs):
        if 0 in G[i]:
            results[i] = 0
            flags[i]   = True
            searchs.remove(i)
    while len(searchs) != 0:
        for i in list(searchs):
            for j in G[i]:
                if flags[j] == True:
                    results[i] = j
                    searchs.remove(i)
                    break

    print('Yes')
    for i,v in enumerate(results[1:]):
        print(f'{v+1}')


Fixed submission:
N, M = map(int, input().split())

from collections import defaultdict, deque

G = defaultdict(set)


results = [-1]*N
flags   = [False]*N

for _ in range(M):
    A, B = map(int, input().split())
    G[A-1].add(B-1)
    G[B-1].add(A-1)

seen    = [False]*N
partner = [0]*N

q = deque([0])
seen[0] = True


while q:
    now = q.popleft()
    for i in G[now]:
        if seen[i]:
            continue
        seen[i] = True
        partner[i] = now
        q.append(i)

if len(seen) != N:
    print('No')
else:
    print('Yes')
    for i in partner[1:]:
        print(i+1)
Buggy python submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    A    = [int(i)-1 for i in input().split()]

    visited_town = []
    current_town = 0
    loop_flg     = False
    visited_town.append(current_town)
    set_visted_town = set(visited_town)
    for i in range(K):
        current_town = A[current_town]
        if current_town in set_visted_town:
            visited_town.append(current_town)
            loop_flg = True
            break
        visited_town.append(current_town)
        set_visted_town.add(current_town)


    if loop_flg:
        loop_start = visited_town.index(current_town)
        loop_end   = len(visited_town) - 1
        loop_length = loop_end - loop_start
        last_index = (K-loop_start)%loop_length
        current_town = visited_town[loop_start+last_index]

    print(current_town+1)


if __name__ == '__main__':
    main()

Fixed submission:
S = input()
T = input()

if S == T[:-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

A    = [int(i)-1 for i in input().split()]

visited_town = []
current_town = 0
loop_flg     = False
visited_town.append(current_town)
for i in range(K):
    current_town = A[current_town]
    if current_town in visited_town:
        visited_town.append(current_town)
        loop_flg = True
        break
    visited_town.append(current_town)


if loop_flg:
    loop_start = visited_town.index(current_town)
    loop_end   = len(visited_town) - 1
    loop_length = loop_end - loop_start
    last_index = (K-loop_start)%loop_length
    current_town = visited_town[loop_start+last_index]

print(current_town+1)

Fixed submission:
def main():
    N, K = map(int, input().split())
    A    = [int(i)-1 for i in input().split()]

    visited_town = []
    current_town = 0
    loop_flg     = False
    visited_town.append(current_town)
    set_visted_town = set(visited_town)
    for i in range(K):
        current_town = A[current_town]
        if current_town in set_visted_town:
            visited_town.append(current_town)
            loop_flg = True
            break
        visited_town.append(current_town)
        set_visted_town.add(current_town)


    if loop_flg:
        loop_start = visited_town.index(current_town)
        loop_end   = len(visited_town) - 1
        loop_length = loop_end - loop_start
        last_index = (K-loop_start)%loop_length
        current_town = visited_town[loop_start+last_index]

    print(current_town+1)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())

import itertools
from collections import defaultdict

seq = list(range(1, M+1))
dlist = defaultdict(list)
dres  = defaultdict(int)
Na    = 0

for i,v in enumerate(itertools.combinations(seq, N)):
    dlist[i] = v
    Na += 1

#print(seq)
#print(dlist)

#import numpy as np

#X = np.r_[[dlist[i] for i in range(Na)]]

#Y = np.zeros((Q, 4), dtype=int)

for i in range(Q):
    ai, bi, ci, di = map(int, input().split())
    #Y[i] = [ai, bi, ci, di]
    #print(ai-1, bi-1, ci, di)
    for j in range(Na):
        tmp = dlist[j]
        if tmp[bi-1] - tmp[ai-1] == ci:
            dres[j] += di
print(max([dres[i] for i in range(Na)]))

Fixed submission:
import itertools
from collections import defaultdict

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


seq = list(range(1, M+1))
dlist = defaultdict(list)
dres  = defaultdict(int)
Na    = 0

for i,v in enumerate(itertools.combinations_with_replacement(seq, N)):
    dlist[i] = v
    Na += 1


for i in range(Q):
    ai, bi, ci, di = map(int, input().split())
    for j in range(Na):
        tmp = dlist[j]
        if tmp[bi-1] - tmp[ai-1] == ci:
            dres[j] += di
print(max([dres[i] for i in range(Na)]))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

K = int(input())

res = 0

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

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            res += gcd(a,b,c)

print(res)

Fixed submission:
import math
from collections import defaultdict

d = defaultdict(lambda : defaultdict(int))

K = int(input())

res = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        d[a][b] = math.gcd(a,b)

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            res += d[d[a][b]][c]

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

R = []
G = []
B = []

for i in range(N):
    if S[i] == 'R':
        R.append(i+1)
    elif S[i] == 'G':
        G.append(i+1)
    else:
        B.append(i+1)

#print(R, G, B)
res = 0

for i in R:
    for j in G:
        for k in B:
            l = [i, j, k]
            l.sort()
            if l[1] - l[0] != l[2] - l[1]:
                res += 1

print(res)

Fixed submission:
from collections import defaultdict
N = int(input())
S = input()

R = []
G = []
B = []

d = defaultdict(int)
for i in range(N):
    if S[i] == 'R':
        R.append(i+1)
    elif S[i] == 'G':
        G.append(i+1)
    else:
        B.append(i+1)
        d[i+1] = 1

res = 0
bl = len(B)
sb = set(B)
for r in R:
    for g in G:
        for b in [2*r-g, 2*g-r, g+(r-g)/2]:
            res -= d[b]
        res += bl


#        for k in B:
#            res += 1

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, X, Y = map(int, input().split())
X -= 1; Y -= 1

pat = defaultdict(int)

for i in range(N):
  for j in range(i+1, N):
    d = min([abs(i-j), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)])
    pat[d] += 1

for i in range(1, N):
  print(pat[i])

Fixed submission:

N, X, Y = map(int, input().split())
X -= 1; Y -= 1

pat = [0]*(N-1)

for i in range(N):
  for j in range(i+1, N):
    d = min(abs(i-j), abs(X-i)+1+abs(j-Y))
    pat[d-1] += 1

for i in range(N-1):
  print(pat[i])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N, X, Y = map(int, input().split())
X -= 1; Y -= 1
dist = []
for i in range(N):
  for j in range(i+1, N):
    dist.append(min([abs(i-j), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)]))
    
pat = Counter(dist)

for i in range(1, N):
  print(pat[i])

Fixed submission:

N, X, Y = map(int, input().split())
X -= 1; Y -= 1

pat = [0]*(N-1)

for i in range(N):
  for j in range(i+1, N):
    d = min(abs(i-j), abs(X-i)+1+abs(j-Y))
    pat[d-1] += 1

for i in range(N-1):
  print(pat[i])
Buggy python submission (verdict: Runtime Error):
S = str(input())
Q = int(input())

qs = [input().split() for i in range(Q)]

for q in qs:
    if q[0] == '1':
        S = S[::-1]
    else:
        if q[1] == '1':
            S = q[2] + S
        else:
            S = S + q[2]

print(S)

Fixed submission:
S = input()


if ('AB' in S) | ('BA' in S):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
S = str(input())
Q = int(input())

qs = [input().split() for i in range(Q)]

i = 0
while i < len(qs):
    q = qs[i]
    if q[0] == '1':
        if qs[i+1][0] == '1':
            i += 2
        else:
            S = S[::-1]
            i += 1
    else:
        if q[1] == '1':
            S = q[2] + S
        else:
            S = S + q[2]
        i += 1



print(S)

Fixed submission:
from collections import deque

S = str(input())
Q = int(input())

d = deque([S[i] for i in range(len(S))])
#print(d)

flg = 0

for i in range(Q):
    query = input()
    if query[0] == '1':
        flg = flg%2 + 1
    else:
        t, f, c = query.split()
        if f == '1':
            if flg % 2 == 0:
                d.appendleft(c)
            else:
                d.append(c)
        else:
            if flg % 2 == 0:
                d.append(c)
            else:
                d.appendleft(c)
if flg % 2 == 0:
    print(''.join(list(d)))
else:
    tmp = ''.join(list(d))
    print(tmp[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
Q = int(input())

qs = [input().split() for i in range(Q)]

for q in qs:
    if q[0] == '1':
        S = S[::-1]
    else:
        if q[1] == '1':
            S = q[2] + S
        else:
            S = S + q[2]

print(S)

Fixed submission:
from collections import deque

S = str(input())
Q = int(input())

d = deque([S[i] for i in range(len(S))])
#print(d)

flg = 0

for i in range(Q):
    query = input()
    if query[0] == '1':
        flg = flg%2 + 1
    else:
        t, f, c = query.split()
        if f == '1':
            if flg % 2 == 0:
                d.appendleft(c)
            else:
                d.append(c)
        else:
            if flg % 2 == 0:
                d.append(c)
            else:
                d.appendleft(c)
if flg % 2 == 0:
    print(''.join(list(d)))
else:
    tmp = ''.join(list(d))
    print(tmp[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
Q = int(input())


for i in range(Q):
    query = input()
    if query[0] == '1':
        S = S[::-1]
    else:
        t, f, c = query.split()
        if f == '1':
            S = c + S
        else:
            S = S + c

print(S)


Fixed submission:
from collections import deque

S = str(input())
Q = int(input())

d = deque([S[i] for i in range(len(S))])
#print(d)

flg = 0

for i in range(Q):
    query = input()
    if query[0] == '1':
        flg = flg%2 + 1
    else:
        t, f, c = query.split()
        if f == '1':
            if flg % 2 == 0:
                d.appendleft(c)
            else:
                d.append(c)
        else:
            if flg % 2 == 0:
                d.append(c)
            else:
                d.appendleft(c)
if flg % 2 == 0:
    print(''.join(list(d)))
else:
    tmp = ''.join(list(d))
    print(tmp[::-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
*l, = map(int,input().split())
ans = 1
for i in l:
  ans *= i
  if ans > 10**18:
    ans = -1
    break
if 0 in ;:
  ans = 0
print(ans)


Fixed submission:
n = int(input())
*l, = map(int,input().split())
ans = 1
for i in l:
  ans *= i
  if ans > 10**18:
    ans = -1
    break
if 0 in l:
  ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())
l = [1]*a + [0]*b + [-1]*c
print(sum(l[:k]))

Fixed submission:
a,b,c,k = map(int,input().split())
print(min([a,k])-max([0,k-a-b]))

Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())
l = [1]*a + [0]*b + [-1]*c
print(sum(l[:k])

Fixed submission:
a,b,c,k = map(int,input().split())
print(min([a,k])-max([0,k-a-b]))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
*l, = map(int,input().split())
seenl = [1]
temp=1
for i in range(k):
  temp=l[temp-1]
  if temp in set(seenl):
    lenloop = len(seenl)-seenl.index(temp)
    r = (k-i-1)%lenloop
    temp = seenl[seenl.index(temp):][r]
    break
  seenl.append(temp)
print(temp)

Fixed submission:
n,k = map(int,input().split())
*l, = map(int,input().split())
seenl = [1]
seen = {1}
d={}
for index,i in enumerate(l):
  d[index+1]=i
#print(d)
temp=1
for i in range(k):
  temp=d[temp]
  if temp in seen:
    #print('i=',i)
    #print('temp=',temp)
    lenloop = len(seenl)-seenl.index(temp)
    #print('lenloop=',lenloop)
    r = (k-i-1)%lenloop
    temp = seenl[seenl.index(temp):][r]
    break
  seenl.append(temp)
  seen.add(temp)
print(temp)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = set()
for i in [0]*n:
  _ = input()
  s|=set(map(int,input().split()))
print(k-len(s))

Fixed submission:
n,k = map(int,input().split())
l=[]
for i in [0]*k:
  d = input()
  l+=list(map(int,input().split()))
print(n-len(set(l)))
Buggy python submission (verdict: Runtime Error):
print(int(input())*6.283)


Fixed submission:
n,m = map(int,input().split())
s = sum(map(int,input().split()))
print(max([n-s,-1]))

Buggy python submission (verdict: Runtime Error):
print(int(input())*6.283)


Fixed submission:
n,m = map(int,input().split())
s = sum(map(int,input().split()))
print(max([n-s,-1]))