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

Fixed submission:
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()
    else:
        place.append(s)
        first.add(s)

print(s)

Buggy submission (verdict: Runtime Error):
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))
        break
    else:
        place.append(s)
        first.add(s)
else:
    print(s)
Problem p02743 (python)

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

if c - a - b > 0 and (c - a - b) ** 2  > 4 * a * b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math

a, b, c = map(int, input().split())

k = a + b + 2 * math.sqrt(a * b)) / c - 1

if k < 0:
    print("Yes")
else:
    print("No")
Problem p02756 (python)

Fixed submission:
from collections import deque

L = deque([])
S = str(input())
q = int(input())
Q = [[] for _ in range(q)] 

for i in range(len(S)):
    L.append(S[i])

for i in range(q):
    A = input().split()
    Q[i] = A

num = 0

for i in range(q):
    if Q[i][0] == '1':
        num ^= 1
    if Q[i][0] == '2':
        if num == 0:
            if Q[i][1] == '1':
                L.appendleft(Q[i][2])
            else:
                L.append(Q[i][2])
        else:
            if Q[i][1] == '2':
                L.appendleft(Q[i][2])
            else:
                L.append(Q[i][2])

if num:
    L.reverse()

print(''.join(L))

Buggy submission (verdict: Runtime Error):
L = []
S = str(input())
Q = int(input())
Ql = [[] for _ in range(Q)] 

for i in range(len(S)):
    L.append(S[i])

for i in range(Q):
    A = input().split()
    Ql[i] = A

for i in range(Q):
    print(L)
    if Ql[i][0] == '1':
        L.reverse()
            
    elif Ql[i][0] == '2':
        if Ql[i][1] == '1':
            L.insert(0, Ql[i][2])
        else:
            L.append(Ql[i][2])

print(''.join(L))
Problem p02761 (python)

Fixed submission:
from operator import itemgetter

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

num = [''] * n

if m == 0:
    for i in range(n):
        num[i] = '0'
    if n != 1:
        num[0] = '1'
    print(''.join(num))
    exit()

sc = sorted([list(map(int, input().split())) for _ in range(m)], key = itemgetter(0))

last = sc[0][0]
num[last-1] = str(sc[0][1])
number = True

if last != 1:
    num[0] = '1'

for i in range(m):
    if n != 1 and sc[i][0] == 1 and sc[i][1] == 0:
        number = False
    if sc[i][0] == last and num[last-1] != '':
        if num[last-1] != str(sc[i][1]):
            number = False
    last = sc[i][0]
    num[last-1] = str(sc[i][1])

for i in range(n):
    if num[i] == '':
        num[i] = '0'

if number:
    print(''.join(num))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

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

num = [''] * n

if m == 0:
    for i in range(n):
        num[i] = '0'
    if n != 1:
        num[0] = '1'
    print(''.join(num))
    exit()

sc = sorted([list(map(int, input().split())) for _ in range(m)], key = itemgetter(0))

last = sc[0][0]
num[last-1] = str(sc[i][1])
number = True

if last != 1:
    num[0] = '1'

for i in range(m):
    if sc[i][0] == 1 and sc[i][1] == 0:
        number = False
    if sc[i][0] == last and num[last-1] != '':
        if num[last-1] != sc[i][1]:
            number = False
    last = sc[i][0]
    num[last-1] = str(sc[i][1])

for i in range(n):
    if num[i] == '':
        num[i] = '0'
        
if number:
    print(''.join(num))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

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

num = [''] * n

if m == 0:
    for i in range(n):
        num[i] = '0'
    if n != 1:
        num[0] = '1'
    print(''.join(num))

sc = sorted([list(map(int, input().split())) for _ in range(m)], key = itemgetter(0))

last = sc[0][0]
num[last-1] = str(sc[0][1])
number = True

if last != 1:
    num[0] = '1'

for i in range(m):
    if n != 1 and sc[i][0] == 1 and sc[i][1] == 0:
        number = False
    if sc[i][0] == last and num[last-1] != '':
        if num[last-1] != str(sc[i][1]):
            number = False
    last = sc[i][0]
    num[last-1] = str(sc[i][1])

for i in range(n):
    if num[i] == '':
        num[i] = '0'

if number:
    print(''.join(num))
else:
    print(-1)
Problem p02813 (python)

Fixed submission:
import itertools
 
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
 
l = list(itertools.permutations(range(1, n+1)))
a = l.index(p)
b = l.index(q)
 
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
p = tuple(map(int, input().split())
q = tuple(map(int, input().split())

l = list(itertools.permutations(range(1, n+1)))
a = l.index(p)
b = l.index(q)

print(abs(a-b))
Problem p02848 (python)

Fixed submission:
n = int(input())
s = input()
for x in s:
    st = (ord(x) +n-65)%26
    print(chr(65+st),end='')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
  
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
f = ''
 
for i in range(len(s)):
    for j in range(26):
        m = i + n
        if m >= 26:
            m -= 26
        if s[m] == alp[j]:
            f += alp[j]
print(f)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
  
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
f = ''

for in range(len(s)):
    for j in range(26):
        if s[i] == alp[j]:
            f += alp[j]
print(f)
Problem p02882 (python)

Fixed submission:
import numpy as np
 
a, b, x = map(int, input().split())
 
if x == a**2*b:
    print(0)
    exit()
 
if x < 1/2*b*a**2:
    a1 = 2*x/(a*b)
    rad = np.arctan(a1/b)
else:
    y = 2*(b-x/a**2)
    rad = np.arctan(a/y)
 
print(90-rad*180/np.pi)

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

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

if x < 1/2*a*b:
    a1 = 2*x/(a*b)
    rad = np.arctan(a1/b)
else:
    y = 2*(b-x/a**2)
    rad = np.arctan(a/y)

print(90-rad*180/np.pi)
Problem p02924 (python)

Fixed submission:
n = int(input())
print(n*(n-1)//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(n(n-1)//2)
Problem p02972 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ball = [0] * n

for i in range(n)[::-1]:
    m = n//(i+1)
    count = 0
    for j in range(1, m+1):
        count += ball[j*(i+1)-1]
    ball[i] = (a[i]%2)^(count%2)

print(sum(ball))
for i in range(n):
    if ball[i] == 1:
        print(i+1)

Buggy submission (verdict: Runtime Error):
x = int(input())
l = set([])
i = 1
while i < x:
    j = 2
    while j < 10:
        if i**j <= x:
            l.add(i**j)
        j += 1
    i += 1

print(max(l))
Problem p03048 (python)

Fixed submission:
r, g, b, n = map(int, input().split())
ball = [0, r, g, b]
dp = [[0] * 4 for _ in range(n+1)]
dp[0][0] = 1

for i in range(n+1):
    for k in range(4):
        if k == 0:
            if i != 0:
                dp[i][k] = 0
        else:
            if i - ball[k] < 0:
                dp[i][k] = dp[i][k-1]
            else:
                dp[i][k] = dp[i-ball[k]][k] + dp[i][k-1]

print(dp[n][3])

Buggy submission (verdict: Runtime Error):
r, g, b, n = map(int, input().split())
ball = [0, r, g, b]
count = 0

for i in range(n+1):
    for j in range(n+1):
        m = math.floor((n-i*r-j*g)/b)
        if i*r+j*g+m*b == n and m >= 0:
            count += 1
            #print(i, j, m)
print(count)
Problem p03059 (python)

Fixed submission:
A, B, T = map(int,input().split())

print(int((T+0.5)//A * B))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
L = [0]*(N+2)
R = [0]*(N+2)
 
import fractions
 
for i in range(1,N+1):
    L[i] = fractions.gcd(L[i-1],A[i-1])
for i in range(0,N)[::-1]:
    R[i] = fractions.gcd(R[i+1],A[i])
 
M = [fractions.gcd(L[i-1],R[i]) for i in range(1,N+1)]
print(max(M))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
G = []

for i in range(N):
    for j in range(N):
        if i == j:
            pass
        else:
            G.append(gcd(A[i], A[j]))
            

print(max(G))
Problem p03061 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
L = [0]*(N+2)
R = [0]*(N+2)
 
import fractions
 
for i in range(1,N+1):
    L[i] = fractions.gcd(L[i-1],A[i-1])
for i in range(0,N)[::-1]:
    R[i] = fractions.gcd(R[i+1],A[i])
 
M = [fractions.gcd(L[i-1],R[i]) for i in range(1,N+1)]
print(max(M))

Buggy submission (verdict: Runtime Error):

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

L = [0]*(N+2)
R = [0]*(N+2)
M = [0]*(N+2)

import fractions

for i in range(1,N+1):
    L[i] = fractions.gcd(L[i-1],A[i-1])
for i in range(0,N)[::-1]:
    R[i] = fractions.gcd(R[i+1],A[i])

M = [gractions.gcd(L[i-1],R[i]) for i in range(1,N+1)]
print(max(M))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
G = []

for i in range(N):
    for j in range(N):
        if i == j:
            pass
        else:
            G.append(gcd(A[i], A[j]))
            

print(max(G))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
max_gcd = 1

import math

for i in range(N):
    for j in range(N):
        if i == j:
            pass
        else:
            if math.gcd(A[i], A[j]) > max_gcd:
                max_gcd = math.gcd(A[i], A[j])

print(max_gcd)
Problem p03068 (python)

Fixed submission:
N = int(input())
S = list(str(input()))
K = int(input())

for i in range(0, N):
    if S[i] == S[K-1]:
        pass
    else:
        S[i] = '*'
print(''.join(map(str, S)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(str(input()))
K = int(input())

for i in range(N):
    if S[i] == S[K]:
        pass
    else:
        S[i] = '*'
print(''.join(map(str, S)))
Problem p03086 (python)

Fixed submission:
S = list(input())
N = len(S)
H = list('ATGC')
m = 0
ans = 0
for i in range(N):
    if S[i] in H:
        m += 1
        if ans < m:
            ans = m
    else:
        m = 0
print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
N = len(S)
for i in range(N):
    if S[i] is not 'A' or 'T' or 'G' or 'C':
        S.remove(S[i])
print(len(S))
Problem p03288 (python)

Fixed submission:
r = int(input())

rate = [1200, 2800, 4209]
contest = ['ABC', 'ARC', 'AGC']

for i in range(3):
    if r < rate[i]:
        break
print(contest[i])

Buggy submission (verdict: Runtime Error):
def dfs(i, total, S, remain):
    global ans
    if i == D:
        if S < G:
           use = max(remain)
           N = min(L[use-1][0], (G-S)//(100*use))
           S += 100 * N * use
           total += N
           
        if S >= G:
           ans = min(ans, total)
    else:
        dfs(i+1, total, S, remain)
        dfs(i+1, total + L[i][0], S + 100 * (i+1) * L[i][0] + L[i][1], remain - {i+1})
 
D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10 ** 9
 
dfs(0, 0, 0, set(range(1, D+1)))
 
print(ans)
Problem p03290 (python)

Fixed submission:
# まだ解いてない配点を nokori として持つ
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)

Buggy submission (verdict: Runtime Error):
def dfs(i, total, S, remain):
    global ans
    if i == D:
        if S < G:
           use = max(remain)
           N = min(L[use-1][0], (G-S)//(100*use)
           S += 100 * N * use
           total += N
           
        if S >= G:
           ans = min(ans, total)
    else:
        dfs(i+1, total, S, remain)
        dfs(i+1, total + L[i][0], S + 100 * (i+1) * L[i][0] + L[i][1], remain - {i+1})

D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10 ** 9

dfs(0, 0, 0, set(range(1, D+1)))

print(ans)

Buggy submission (verdict: Runtime Error):
def dfs(i, total, S, remain):
    global ans
    if i == D:
        if S < G:
           """
           If all the problems of the segment don't have to be calculated,
           it is preferable to solve some of the segment with the highest rate.
           """
           use = max(remain)
           N = min(L[use-1][0], (G-S)//(100*L[use-1][0]))
           S += 100 * N * use
           total += N
           
        if S >= G:
           ans = min(ans, total)
    else:
        dfs(i+1, total, S, remain)
        dfs(i+1, total + L[i+1][0], S + 100 * (i+1) * L[i+1][0] + L[i+1][1], remain - (i+1))

D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10 ** 9

dfs(0, 0, 0, set(range(1, D+1)))

print(ans)

Buggy submission (verdict: Runtime Error):
def dfs(i, total, S, remain):
    global ans
    if i == D:
        if S < G:
           """
           If all the problems of the segment don't have to be calculated,
           it is preferable to solve some of the segment with the highest rate.
           """
           use = max(remain)
           N = min(L[use-1][0], (G-S)//(100*L[use-1][0])
           S += 100 * N * use
           total += N
           
        if S >= G:
        ans = min(ans, total)
    else:
        dfs(i+1, total, S, remain)
        dfs(i+1, total + L[i+1][0], S + 100 * (i+1) * L[i+1][0] + L[i+1][1], remain - (i+1))

D, G = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(D)]
ans = 10 ** 9

dfs(0, 0, 0, set(range(1, D+1)))

print(ans)
Problem p03352 (python)

Fixed submission:
x = int(input())
l = set([1])
i = 1
while i < x:
    j = 2
    while j < 10:
        if i**j <= x:
            l.add(i**j)
        j += 1
    i += 1

print(max(l))

Buggy submission (verdict: Runtime Error):
x = int(input())
l = set([])
i = 1
while i < x:
    j = 2
    while j < 10:
        if i**j <= x:
            l.add(i**j)
        j += 1
    i += 1

print(max(l))
Problem p03379 (python)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
m1 = Y[N//2]
m2 = Y[N//2-1]
 
for i in range(N):
    if m1 > X[i]:
        print(m1)  # left
    else:
        print(m2)  # right

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
xsort = sorted(x)
 
for i in range(n):
    if xsort[n//2] > x[i]
        print(xsort[2//n])
    else:
        print(xsort[n//2-1])
Problem p03409 (python)

Fixed submission:
from operator import itemgetter

n = int(input())
R = [list(map(int, input().split())) for i in range(n)]
B = sorted([list(map(int, input().split())) for _ in range(n)], key = itemgetter(0))
pair = 0

for b in B:
   L = [r for r in R if r[0] < b[0] and r[1]<b[1]]
   if len(L) != 0:
       s = L[0]
       for l in L:
           if s[1] < l[1]:
               s = l
       R.remove(s)
       pair += 1
           
print(pair)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n = int(input())
R = [list(map(int, input().split())) for i in range(n)]
B = sorted([list(map(int, input().split())) for _ in range(n)], key = itemgetter(0))
pair = 0

for b in B:
   L = [r for r in R if r[0] < b[0] and r[1]<b[1]]
   if len(L) > 0:
       s = L[0]
       for l in L:
           if s[1] < l[1]:
               s = l
           R.remove(s)
           pair += 1
           
print(pair)
Problem p03456 (python)

Fixed submission:
a, b = map(str, input().split())
f = int(a+b)
#print(f)
 
for i in range(1, 318):
  if i ** 2 == f:
    print('Yes')
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
from ath import sqrt

a, b = map(str, input().split())
f = int(a+b)

for i in range(1, 101):
  if sqrt(f) / i == i:
    print('Yes')
    exit()
print('No')
Problem p03565 (python)

Fixed submission:
s = str(input())
t = str(input())
s_l =[]
for i in range(len(s)):
    s_l.append(s[i])

if len(s) < len(t):
    print("UNRESTORABLE")
    exit()

a = len(s) - len(t)

while a >= 0:
    insert = False
    string = True
    i = 0
    while i < len(t):
        if s[a + i] != "?" and s[a + i] != t[i]:
            string = False
            break
        i += 1
        
    if string == True:
        for i in range(len(t)):
                s_l[a+i] = t[i]
        insert = True
        break
    a -= 1

f = ""
if insert == True:
    for i in range(len(s)):
        if s_l[i] == "?":
            f += "a"
        else:
            f += s_l[i]
    print(f)
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s = str(input())
t = str(input())
s_l =[]
for i in range(len(s)):
    s_l.append(s[i])

a = len(s) - len(t)

while a >= 0:
    insert = False
    string = True
    i = 0
    while i < len(t):
        if s[a + i] != "?" and s[a + i] != t[i]:
            string = False
            break
        i += 1
        
    if string == True:
        for i in range(len(t)):
                s_l[a+i] = t[i]
        insert = True
        break
    a -= 1

f = ""
if insert == True:
    for i in range(len(s)):
        if s_l[i] == "?":
            f += "a"
        else:
            f += s_l[i]
    print(f)
else:
    print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s = str(input())
t = str(input())
s_l =[]
for i in range(len(s)):
    s_l.append(s[i])

a = len(s) - len(t)

while a >= 0:
    insert = False
    count = 0
    for i in range(0, len(t)):
        if s[a + i] == "?" or s[a + i] == t[i]:
            count += 1
    if count == len(t):
        for i in range(len(t)):
                s_l[a+i] = t[i]
        insert = True
        break
    i -= 1

f = ""

if insert:
    for i in range(len(s)):
        if s[i] == "?":
            f += "a"
        else:
            f += s_l[i]
    print(f)
else:
    print("UNRESTORABLE")
Problem p03579 (python)

Fixed submission:
from collections import deque

def dfs():
    global color
    color = [-1] * n
    q = deque([])
    q.append(0)
    color[0] = 1
    
    while q:
        p = q.pop()
        for u in edge[p]:
            if color[u] == -1:
                color[u] = (color[p] + 1) % 2
                q.append(u)
            else:
                if color[u] == color[p]:
                    return False
    return True

n, m = map(int, input().split())
edge = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)


if dfs():
    B = 0
    W = 0
    for i in range(n):
        if color[i] == 1:
            B += 1
        else:
            W += 1
    print(B*W - m)
else:
    print(n * (n-1) // 2 - m)

Buggy submission (verdict: Runtime Error):
from collections import deque

def dfs():
    global color
    global edge
    color = [-1] * n
    edge = [[] for _ in range(n)]

    q = deque([])
    q.append(0)
    color[0] = 1
    
    while q:
        p = q.pop()
        for u in edge[p]:
            if color[u] == -1:
                color[u] = (color[p] + 1) % 2
                q.append(u)
            else:
                if color[u] == color[p]:
                    return False
    return True

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

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)


if dfs():
    B = 0
    W = 0
    for i in range(n):
        if color[i] == 1:
            B += 1
        else:
            W += 1
    print(B*W - m)
else:
    print(n * (n-1) // 2 - m)
Problem p03583 (python)

Fixed submission:
N = int(input())


for h in range(1, 3501):
    for n in range(1, 3501):
        if 4*h*n-N*n-N*h == 0:
            continue
        else:
            w = N * h * n /(4*h*n-N*n-N*h)
            if w > 0 and w.is_integer():
                print(h, n, int(w))
                exit()

Buggy submission (verdict: Runtime Error):
N = int(input())


for h in range(1, 3501):
    for n in range(1, 14000):
        if 4/N - 1/h -1/n == 0:
            continue
        else:
            w = N * h * n /(4*h*n-N*n-N*h)
            if 4/N != 1/h + 1/n + 1/w:
                continue
            elif w > 0 and w.is_integer():
                print(h, n, int(w))
                exit()
Problem p02609 (python)

Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
x=input().rstrip()
x10=int(x,2)
pcx=x.count("1")

plus=x10%(pcx+1)
if pcx>=2:
    minus=x10%(pcx-1)

def popcnt(x):
    cnt=1
    while x>=1:
        x%=(bin(x).count("1"))
        cnt+=1
    return cnt

for i in range(n):
    if x[i]=="0":
        amari=(plus+pow(2,n-i-1,pcx+1))%(pcx+1)
        print(popcnt(amari))
    else:
        if pcx==1:
            print(0)
        else:
            amari=(minus-pow(2,n-i-1,pcx-1))%(pcx-1)
            print(popcnt(amari))

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n=int(input())
x=input().rstrip()
p=x.count("1")
numx=0
for i in range(n):
    if x[-i-1]=="1":
        numx+=2**i
minus=numx%(p-1)
plus=numx%(p+1)

def popcnt(x):
    cnt=str(bin(x)).count("1")
    x%=cnt
    return x

for i in range(n):
    if x[i]=="0":
        amari=(plus+2**(n-i-1)%(p+1))%(p+1)
        ans=1
        while amari>=1:
            amari=popcnt(amari)
            ans+=1
        print(ans)
    else:
        if p==1:
            print(0)
            continue
        amari=(minus-2**(n-i-1)%(p-1))%(p-1)
        ans=1
        while amari>=1:
            amari=popcnt(amari)
            ans+=1
        print(ans)
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
a = [int(i)-1 for i in input().split()]

p = 0

if n>=k:
    for i in range(k):
        p = a[p]
    print(p+1)

else:
    lst = [-1]*n
    lst[0] = 0
    
    for i in range(1,n+1):
        p = a[p]
        if lst[p] == -1:
            lst[p] = i
        else:
            loop = i - lst[p]
            k -= lst[p]
            extra = k % loop
            break

    for i in range(extra):
        p = a[p]
    print(p+1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = [int(i)-1 for i in input().split()]

p = 0

if n>=k:
    for i in range(k):
        p = a[p]
    print(p+1)

else:
    lst = [-1]*n
    lst[0] = 0
    
    for i in range(1,n+1):
        p = a[p]
        if lst[p] == -1:
            lst[p] = i
        else:
            loop = i - lst[p]
            k -= lst[p]
            extra = k % loop
            break

for i in range(extra):
    p = a[p]
print(p+1)

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

place = 0
memory = [0]

for i in range(n):
    place = a[place]-1
    if not place in memory:
        memory.append(place)
    else:
        if a[place] in memory:
            loopstart = memory.index(a[place])
            k -= loopstart
            extra = k % (len(memory) - loopstart)
            if extra == 0:
                ans = memory[-1]+1
            else:
                ans = memory[place+extra-1]+1
            break
        else:
            ans = a[place]
            break
print(ans)
Problem p02705 (python)

Fixed submission:
r = int(input())
r = 6.28 * r
print(r)

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

print(r)