Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02621 (python)

Fixed submission:
a = int(input())
ans = a * (1 + a + a * a)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.append(k+1)
b.append(k+1)
ia = 0
ib = 0
count = 0

for i in range(n + m + 1):
    if (a[ia] < b[ib]):
        if(a[ia] > k):
            print(count)
            break
        else:
            k -= a[ia]
            ia += 1
            count += 1
    else:
        if(b[ib] > k):
            print(count)
            break
        else:
            k -= b[ib]
            ib += 1
            count += 1

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.append(k+1)
b.append(k+1)
ia = 0
ib = 0
count = 0

for i in range(n + m + 1):
  if (a[ia] < b[ib]):
    if(a[ia] > k):
      print(count)
      break
      else:
        k -= a[ia]
        ia += 1
        count += 1
        else:
          if(b[ib] > k):
            print(count)
            break
            else:
              k -= b[ib]
              ib += 1
              count += 1
Problem p03081 (python)

Fixed submission:
N, Q = map(int, input().split())
s = " " + input() + " "
td = []
for i in range(Q):
    td.append(input().split())
#print("td = {}".format(td))

llim = 0
rlim = N + 1
for t, d in reversed(td):
    if((s[llim + 1] == t) and ("L" == d)):
        llim += 1
    elif((s[llim] == t) and ("R" == d)):
        llim -= 1
    if((s[rlim - 1] == t) and ("R" == d)):
        rlim -= 1
    elif((s[rlim] == t) and ("L" == d)):
        rlim += 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, rlim - llim - 1)))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s = input()
td = [input().split() for i in range(Q)]
#print("td = {}".format(td))

llim = 0
rlim = N - 1
for t, d in reversed(td):
    if("L" == d):
        if(s[llim] == t):
            llim += 1
        if(rlim < N - 1):
            if(s[rlim + 1] == t):
                rlim += 1
    else:# if("R" == d):
        if(s[rlim] == t):
            rlim -= 1
        if(llim > 0):
            if(s[llim - 1] == t):
                llim -= 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, rlim - llim + 1)))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s = input()
td = []
for i in range(Q):
    td.append(input().split())
#print("td = {}".format(td))

llim = 0
rlim = - 1
for t, d in reversed(td):
    if((s[llim] == t) and ("L" == d)):
        llim += 1
    elif(llim > 0):
        if((s[llim - 1] == t) and ("R" == d)):
            llim -= 1
    if((s[rlim] == t) and ("R" == d)):
        rlim -= 1
    elif(rlim < - 1):
        if((s[rlim + 1] == t) and ("L" == d)):
            rlim += 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, N + rlim - llim + 1)))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s = input()
td = []
for i in range(Q):
    td.append(input().split())
#print("td = {}".format(td))

llim = 0
rlim = N - 1
for t, d in reversed(td):
    if((s[llim] == t) and ("L" == d)):
        llim += 1
    elif(llim - 1 >= 0):
        if((s[llim - 1] == t) and ("R" == d)):
            llim -= 1
    if((s[rlim] == t) and ("R" == d)):
        rlim -= 1
    elif(rlim + 1 <= N - 1):
        if((s[rlim + 1] == t) and ("L" == d)):
            rlim += 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, rlim - llim + 1)))
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
lr = []
for i in range(Q):
    lr.append(list(map(int, input().split())))

ACnum = [0]
for i in range(N - 1):
    ACnum.append(ACnum[-1])
    if("AC" == S[i:i + 2]):
        ACnum[i + 1] += 1
#print("ACnum = {}".format(ACnum))

for l, r in lr:
    print(str(ACnum[r - 1] - ACnum[l - 1]))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
lr = []
for i in range(Q):
    lr.append(list(map(int, input().split())))

for idx in lr:
    sub = S[idx[0] - 1:idx[1]]
    cnt = sub.count("AC")
    print("cnt = {}, sub = {}".format(cnt, sub))
    print(str(cnt))
Problem p03105 (python)

Fixed submission:
cost, money, enough = map(int, input().split())

times = money // cost
if(times > enough):
    print(enough)
else:
    print(times)

Buggy submission (verdict: Runtime Error):
cost, money, enogh = map(int, input().split())

times = money // cost
if(times > enough):
    print(enough)
else:
    print(times)
Problem p04048 (python)

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

[N, X] = list(map(int, input().split()))
print(int(3*(N-gcd(N,X))))

Buggy submission (verdict: Runtime Error):
import math
[N, X] = list(map(int, input().split()))
print(int(3*(N-math.gcd(N,X))))
Problem p02969 (python)

Fixed submission:
r = int(input())

print(3*r**2)

Buggy submission (verdict: Runtime Error):
r = input()

print(3*r**2)
Problem p03323 (python)

Fixed submission:
a,b = map(int,input().split())

if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())

if a <= 8 ans b <= 8:
  print('Yay!')
else:
  print(':(')
Problem p03657 (python)

Fixed submission:
a,b = map(int,input().split())

if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
  print('Possible')
else:
  print('Impossible')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())

if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
  print('Possible')
else:
  pritn('Impossible')
Problem p03679 (python)

Fixed submission:
x, a, b=map(int, input().split())

if a>=b:
  print('delicious')
elif b - a < x + 1:
  print('safe')
else:
  print('dangerous')

Buggy submission (verdict: Runtime Error):
x,a,b = map(int,input().split())

if b < a:
  print('delicious')
elif b <= x:
  pritn('safe')
elif b > x:
  print('dangerous')
Problem p03697 (python)

Fixed submission:
a,b = map(int,input().split())

print(a+b if a+b < 10 else 'error')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())

print(a+b if a+b < 10 else error)
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

print(((a+b)*h)//2)

Buggy submission (verdict: Runtime Error):
a,b,h = map(int,input().split())

print(((a+b)*h)//2)

Buggy submission (verdict: Runtime Error):
a,b,h = map(int,input().split())

print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a,b,h = map(int,input().split())

print((a+b)*h//2)
Problem p04043 (python)

Fixed submission:
a = list(map(int,input().split()))
 
a.sort()
print('YES' if a[0] == 5 and a[1] == 5 and a[2] == 7 else 'NO')

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))

a,sort()
print('YES' if a[0] == 5 and a[1] == 5 and a[2] == 7 else 'NO')
Problem p02789 (python)

Fixed submission:
n, m = map(int, input().split())
if n==m:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split)
if n==m:
  print('Yes')
else:
  print('No')
Problem p02936 (python)

Fixed submission:
def o():return map(int,input().split())
n,q=o()
a=[[]for i in range(n)]
x=[0]*n
for i in range(n-1):
  u,v=o()
  a[u-1]+=[v-1]
  a[v-1]+=[u-1]
for i in range(q):
  u,v=o()
  x[u-1]+=v
p=[[0,0]]
s=0
while p:
  r,s=p.pop()
  for i in a[r]:
    if i!=s:
      p+=[[i,r]]
      x[i]+=x[r]
print(*x)

Buggy submission (verdict: Runtime Error):
def o():return map(int,input().split())
n,q=o()
a=[[]for i in range(n)]
x=[0]*n
for i in range(n-1):u,v=o()
  a[u-1]+=[v-1]
for i in range(q):u,v=o()
  p=[u-1]
  while p:r=p.pop()
    x[r]+=v
    p+=a[r]
print(*x)
Problem p02974 (python)

Fixed submission:
import copy
n,m=map(int,input().split())
a=[[0 for _ in range(m+3)] for _ in range(n+2)]
a[0][0]=1
a[1][2]=1
for i in range(1,n):
  b=copy.deepcopy(a)
  for j in range(0,i+2):
    for k in range(0,m+1):
      if k>=2*j:
        a[j][k]=(2*j+1)*b[j][k-2*j]+(j+1)**2*b[j+1][k-2*j]
        if j>0:
          a[j][k]+=b[j-1][k-2*j]
        a[j][k]%=(10**9+7)
      else:
        a[j][k]=0
print(a[0][m])

Buggy submission (verdict: Runtime Error):
import copy
n,m=map(int,input().split())
a=[[0 for _ in range(m+2)] for _ in range(n+2)]
a[0][0]=1
a[1][2]=1
for i in range(1,n):
  b=copy.deepcopy(a)
  for j in range(0,i+2):
    for k in range(0,m+1):
      if k>=2*j:
        a[j][k]=(2*j+1)*b[j][k-2*j]+(j+1)**2*b[j+1][k-2*j]
        if j>0:
          a[j][k]+=b[j-1][k-2*j]
      else:
        a[j][k]=0
print(a[0][m]%(10**9+7))
Problem p02657 (python)

Fixed submission:
a,b=map(int,input().split())
 
print(a*b)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())

print(a*b)
Problem p02660 (python)

Fixed submission:
N=int(input())
ans=0
p=2
 
while N>1 and p*p<=N:
  if N%p==0:
    c=0
    while N%p==0:
      N=N/p
      c=c+1
    Y=1
    U=2
    while c>=Y:
      ans=ans+1
      Y=Y+U
      U=U+1
  p=p+1
 
if N>1:
  ans=ans+1
 
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
N = n
ans = 0
d = 0
i = 2
while n>1 and i*i<=N:
  c = 0
  if n % i == 0:
    d == 1
    while n % i == 0:
      n = int(n / i)
      c += 1

    while c>=Y:
      ans=ans+1
      Y=Y+U
      U=U+1

  i += 1
      
    
if n > 1:
  ans = 1
print(ans)
Problem p02678 (python)

Fixed submission:
from collections import deque

N, M=map(int,input().split())
a=[]
b=[]
for i in range(M):
  A,B=map(int,input().split())
  a.append(A)
  b.append(B)

graph = [[] for _ in range(N + 1)]
for i in range(M):
  graph[a[i]].append(b[i])
  graph[b[i]].append(a[i])

    # bfs
queue = deque([1])
signposts = [0] * (N + 1)
signposts[1] = 1
while queue:#キューが空になるまで
  u = queue.popleft()
  for v in graph[u]:
    if not signposts[v]:
      signposts[v] = u
      queue.append(v)
 
if all(signposts[2:]):
  print("Yes")
  print("\n".join(map(str, signposts[2:])))
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]
C=[]
s=[0 for i in range(n)]
s[0] = "Yes"
 
for i in range(m):
  c,d=map(int,input().split())
  a.append(c)
  b.append(d)
 
def Next(be):
  C.clear()
  for j in be:
    for i in range(len(a)):
      if a[i] == j:
        if s[b[i]-1]==0 and 0 == be.count(b[i]):
          C.append(b[i])
          s[b[i]-1]=j
        continue

      if b[i] == j: 
        if s[a[i]-1]==0 and 0 == be.count(a[i]):
          C.append(a[i])
          s[a[i]-1]=j
        continue
    Dele(j)
  return C

def Dele(be):
  for j in range(a.count(be)):
    a.remove(be)
  for j in range(b.count(be)):
    b.remove(be)

co=[1]
while True:
  if s.count(0) == 0:
    break
  co = Next(list(co))
 
for i in s:
  print(i)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]
C=[]
s=[0 for i in range(n)]
s[0] = "Yes"
 
for i in range(m):
  c,d=map(int,input().split())
  a.append(c)
  b.append(d)
 
def Next(be):
  C.clear()
  for j in be:
    for i in range(len(a)):
      if a[i] == j:
        if s[b[i]-1]==0 and 0 == be.count(b[i]):
          C.append(b[i])
          s[b[i]-1]=j
        continue

      if b[i] == j: 
        if s[a[i]-1]==0 and 0 == be.count(a[i]):
          C.append(a[i])
          s[a[i]-1]=j
        continue
    Dele(j)
  return C

def Dele(be):
  for j in range(a.count(be)):
    a.remove(be)
  for j in range(b.count(be)):
    b.remove(be)

co=[1]
for i in range(5):
  if s.count(0) == 0:
    break
  co = Next(list(co))
 
for i in s:
  print(i)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]
C=[]
s=[0 for i in range(n)]
s[0] = "Yes"

for i in range(m):
  a,b=map(int,input().split())

def Next(be):
  C.clear()
  for j in be:
    for i in range(len(a)):
      if len(a) <= i:
        break
      if a[i] == j:
        
        if s[b[i]-1]==0 and 0 == be.count(b[i]):
          C.append(b[i])
          s[b[i]-1]=j
        continue
      if b[i] == j:
        
        if s[a[i]-1]==0 and 0 == be.count(a[i]):
          C.append(a[i])
          s[a[i]-1]=j
        continue
  return C
co=[1]

while True:
  if s.count(0) == 0:
    break
  co = Next(list(co))

for i in s:
  print(i)
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
kiseki=[-1]*n
i=0
v=1
while kiseki[v-1]==-1:
  kiseki[v-1]=i
  v=l[v-1]
  i+=1
saisyo=kiseki[v-1]
kuri=i-saisyo

if saisyo>k:
  print(kiseki.index(k)+1)
else:
  amari=(k-saisyo)%kuri
  print(kiseki.index(amari+saisyo)+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,k=map(int,input().split())
l=list(map(int,input().split()))
kiseki=deque()
tori=[-1]*n
#町1からスタート
u=1
kiseki.append(1)
for i in range(len(l)):
  u=l[u-1]
  if kiseki.count(u)==0:
    kiseki.append(u)
  else:
    kiseki.append(u)
    break
kuri=[]
while True:
  if u == kiseki[0]:
    kiseki.pop()
    break
  kuri.append(kiseki.popleft())

if k<=len(kuri):
  print(kuri[k])
else:
  K=k-len(kuri)
  amari=K%len(kiseki)
  print(kiseki[amari])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
iran=[]
l=list(map(int,input().split()))
#n,k=6,727202214173249351
#l=[6,5,2,5,3,2]
for i in range(N):
  if l.count(i+1)==0:
    iran.append(i+1)
kiseki=[]
#町1からスタート
u=1
kiseki.append(1)
for i in l:
  u=l[u-1]
  if kiseki.count(u)==0:
    kiseki.append(u)
  else:
    kiseki.append(u)
    break
kuri=kiseki[kiseki.index(u):len(kiseki)-1]
if k<=len(kiseki)-(len(kuri)+1):
  print(kiseki[k])
else:
  K=k-(len(kiseki)-(len(kuri)+1))
  amari=K%len(kuri)
  print(kuri[amari])
Problem p02556 (python)

Fixed submission:
N=int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

xyp=[]
xym=[]
for i in range(N):
    xyp.append(x[i]+y[i])
    xym.append(x[i]-y[i])
    
print(max(max(xyp)-min(xyp),-min(xym)+max(xym),max(xym)-min(xym),-min(xym)+max(xym)))

Buggy submission (verdict: Runtime Error):
2
1 1
1 1
Problem p02573 (python)

Fixed submission:
N, M=map(int, input().split())
A=[]
B=[]
for i in range(M):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)
# AB= [map(int, input().split()) for _ in range(M)]
# A, B = [list(i) for i in zip(*AB)]
def find(x,parent):
    if parent[x]==x:
        return x
    else:
        parent[x]=find(parent[x],parent)
        return(parent[x])
        
def union(x,y,parent,rank):
    xroot=find(x,parent)
    yroot=find(y,parent)
    if rank[xroot]>rank[yroot]:
        parent[yroot]=xroot
    elif rank[yroot]>rank[xroot]:
        parent[xroot]=yroot
    elif rank[yroot]==rank[xroot]:
        parent[yroot]=xroot
        rank[xroot]+=1
    return(parent,rank)

    
parent=[i for i in range(N+1)]
rank=[0]*(N+1)
for i in range(M):
    parent,rank=union(A[i],B[i],parent,rank)
for i in range(N+1):
    find(i,parent)
G=parent[1:]
import collections
c=collections.Counter(G)
print(int(c.most_common()[0][1]))

Buggy submission (verdict: Runtime Error):
import sys
import math
N=int(input())
A=list(map(int,input().split()))


def sieve_of_eratosthenes(n): #エラトステネスのふるい
    candidate = list(range(2, n+1)) #候補
    prime = []
    limit = n**0.5 + 1 #+1がないと平方数を素数にしてしまう

    while True:
        p = candidate[0] 
        if limit <= p:
            prime.extend(candidate) #この時点での残っているのは素数
            break
        prime.append(p) #pを素数リストに登録

        candidate = [i for i in candidate if i % p != 0]

        # i = 0
        # while True:
            # if i >= len(candidate): #iはcandidateの長さ分
                # break
            # elif candidate[i] % p == 0: #余りがゼロなら
                # candidate.pop(i) #素数ではないのでpop(取り除く)する
            # i += 1

    return prime



maxA=max(A)

prime = sieve_of_eratosthenes(maxA)

X=[0]*(maxA+1)
for i in range(N):
    X[A[i]]+=1

check=0
for i in prime:
    count=0
    for j in range(1,int(maxA/i)+1):
        count+=X[j*i]
    if count==N:
        print('not coprime')
        sys.exit()
    elif count>1:
        check=1
        
if check==1:
    print('setwise coprime')
else:
    print('pairwise coprime')

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
AB= [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]

G=[0]*(N+1)
sw=1
for i in range(M):
    if G[A[i]]+G[B[i]]==0:
        G[A[i]]=sw
        G[B[i]]=sw
        sw+=1
    if G[A[i]]!=0:
        G[B[i]]=G[A[i]]
    else:
        G[A[i]]=G[B[i]]
G=G[1:]
import collections
c=collections.Counter(G)
print(c.most_common()[0][1])

Buggy submission (verdict: Runtime Error):

N, M=map(int, input().split())
AB= [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]
G=[[A[0],B[0]]]

for i in range(1,M):
    count=0
    for j in range(len(G)):
        if A[i] in G[j]:
            if B[i] not in G[j]:
                G[j].append(B[i])
                count=1
        elif B[i] in G[j]:
            if A[i] not in G[j]:
                G[j].append(A[i])
                count=1
    if count==0:
        G.append([A[i],B[i]])
print(max([len(v) for v in G]))
Problem p02657 (python)

Fixed submission:
A=list(map(int,input().split()))
print(A[0]*A[1])

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split())
print(A[0]*A[1])

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split)
print(A[0]*A[1])
Problem p02657 (python)

Fixed submission:
A, B = list(map(int, input().split()))
print(A*B)

Buggy submission (verdict: Runtime Error):
A, B = int(input().split())
print(A, B)

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

Fixed submission:
S = str(input())
T = str(input())
 
if len(S) + 1 == len(T) and S == T[:-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = str(input())
T = str(input())
 
if len(S) + 1 == len(T) and S = T[:-1]:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
S = str(input())
T = str(input())

if len(S) + 1 == len(T) and S = T[:-1]:
  print("Yes")
else:
  print("No")
Problem p02683 (python)

Fixed submission:
import numpy as np

N, M, X = list(map(int, input().split()))
a = np.zeros((N, M))
C = np.zeros(N)
for i in range(N):
    tmp = list(map(int, input().split()))
    C[i] += tmp[0]
    a[i] += tmp[1:]
    
answer_price = 10**10

for i in range(1 << N):
    tmp = np.zeros(M)
    cost = 0
    for j in range(N):
        if i % 2 == 1:
            tmp += a[j]
            cost += C[j]
        i = i >> 1

    if all(tmp >= X) and (cost < answer_price):
        answer_price = cost
        
if answer_price == 10**10:
    print("-1")
else:
    print(int(answer_price))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, X = list(map(int, input().split()))
a = np.zeros((N, M))
C = np.zeros(N)
for i in range(N):
    tmp = list(map(int, input().split()))
    C[i] += tmp[0]
    a[i] += tmp[1:]

a = a.reshape(M, N)

answer_price = 2**10

for i in range(1 << N):
    tmp = np.zeros(M)
    cost = 0
    for j in range(N):
        if i % 2 == 1:
            tmp += a[j]
            cost += C[j]
        i = i >> 1
    if all(tmp >= X) and cost < answer_price:
        answer_price = cost
        
if answer_price == 2**10:
    print("-1")
else:
    print(int(answer_price))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M, X = list(map(int, input().split()))
a = np.zeros((M, N))
C = np.zeros(N)
for i in range(N):
    tmp = list(map(int, input().split()))
    C[i] += tmp[0]
    a[i] += tmp[1:]

a = a.reshape(M, N)

answer_price = 2**10

for i in range(1 << N):
    tmp = np.zeros(M)
    cost = 0
    for j in range(N):
        if i % 2 == 1:
            tmp += a[j]
            cost += C[j]
        i = i >> 1
    if all(tmp >= X) and cost < answer_price:
        answer_price = cost
        
if answer_price == 2**10:
    print("-1")
else:
    print(int(answer_price))
Problem p02684 (python)

Fixed submission:
N, K = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))

before = 1
start = 0
end = 0

if K <= N:
    for i in range(K):
        before = a[before]
    print(before)

# 周期がどこからどこまでかっていうのを求めると逆に時間がかかってしまうので、N回移動したあとの街っていうのをマークしたほうがはやい
    
else:
    market_town = 0
    for i in range(N):
        before = a[before]
    marked_town = before
    K -= N
    counter = 1
    while marked_town != a[before]:
        before = a[before]
        counter += 1
    K = K % counter
    for i in range(K+1):
        before = a[before]
    print(before)

Buggy submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

done_list = [1]
cur_place = 1
flag = True
for i in range(K):
    if a_list[cur_place-1] not in done_list:
        cur_place = a_list[cur_place-1]
        done_list.append(cur_place)
    else:
        period = len(done_list) - done_list.index(a_list[cur_place-1])
        print(done_list[done_list.index(a_list[cur_place-1]) + (K - i) % period + 1])
        flag = False
        break

if flag:        
    print(cur_place)
Problem p02760 (python)

Fixed submission:
def mark(a, b):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0


def check_h(a):
    for row in a:
        if row == [0, 0, 0]:
            return True


def check_v(a):
    for col in range(3):
        if [row[col] for row in a] == [0, 0, 0]:
            return True


def check_c(a):
    if [a[i][i] for i in range(3)] == [0, 0, 0] or [a[i][2 - i] for i in range(3)] == [0, 0, 0]:
        return True


def resolve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    for _ in range(N):
        B = int(input())
        mark(A, B)
    if check_h(A) or check_v(A) or check_c(A):
        print("Yes")
    else:
        print("No")
resolve()

Buggy submission (verdict: Runtime Error):
def check_h(a):
    for row in a:
        if row == [0, 0, 0]:
            return True


def check_v(a):
    for col in range(3):
        if [row[col] for row in a] == [0, 0, 0]:
            return True


def check_c(a):
    if [a[i][i] for i in range(3)] == [0, 0, 0] or [a[i][2 - i] for i in range(3)] == [0, 0, 0]:
        return True


def resolve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    for _ in range(N):
        B = int(input())
        mark(A, B)
    if check_h(A) or check_v(A) or check_c(A):
        print("Yes")
    else:
        print("No")
resolve()
Problem p02600 (python)

Fixed submission:
x = int(input())
print(8 - ((x - 400) // 200))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
kane = 1000
kabu = 0
for i in range(0, n - 1):
    if a[i] > a[i + 1]:
        kane += a[i] * kabu
        kabu = 0
    if a[i] < a[i + 1]:
        kabu = kane // a[i]
        kane %= a[i]
kane += a[n - 1] * kabu
print(kane)
Problem p02628 (python)

Fixed submission:
K = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
y = 0
for i in range(K[1]):
    y += p[i]
print(y)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
p = []

for i in range(N):
    x = int(input())
    p.append(x)

p.sort()

y = 0

for i in range(K):
    y += p[i]

print(y)
Problem p02741 (python)

Fixed submission:
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])

Buggy submission (verdict: Runtime Error):
inp = list(map(int,input().split()))
if (inp[0]*inp[1])%2==1:
  print((inp[0]*inp[1])//2+1)
else:
  print((inp[0]*inp[1])//2)

Buggy submission (verdict: Runtime Error):
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())])