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

Fixed submission:
A,B,C = map(int,input().split())
print(min(B//A,C))

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
print(min(B//A),C)
Problem p03212 (python)

Fixed submission:
from itertools import product
target = ['3','5','7']

n=int(input())
tmp=n
keta=0
while tmp!=0:
  tmp//=10
  keta+=1
check_list = []
for i in range(1,keta+1):
  tmp=[]
  for _ in range(i):
    tmp.append(target.copy())
    tmp_product = list(product(*tmp))
  check_list+=[int(''.join(nums)) for nums in tmp_product]
check_list = sorted(check_list)

cnt=0
for i in check_list:
  if i <= n:
    tmp = set([w for w in str(i)])
    if len(tmp)==3:
      cnt+=1
  else:
    break
print(cnt)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
target = [3,5,7]

clear_list = combinations(target, 4)
print(clear_list)
Problem p03260 (python)

Fixed submission:
num = str(input()).split(' ')
A = int(num[0])
B = int(num[1])

if (A%2==1)&(B%2==1):
  print('Yes')
else:
  print('No')

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

if (A%2==1)&(B%2==1):
  print('Yes')
else:
  print('No')
Problem p03292 (python)

Fixed submission:
costs = list(map(int,input().split()))
costs.sort()
cnt = 0
for i in range(len(costs)-1):
  cnt += costs[i+1] - costs[i]
print(cnt)

Buggy submission (verdict: Runtime Error):
costs = map(int,input().split())
costs.sort()
cnt = 0
for i in range(len(costs)-1):
  cnt += costs[i+1] - costs[i]
print(cnt)
Problem p03415 (python)

Fixed submission:
moji = []
for i in range(3):
  moji.append(input()[i])
print("".join(moji))

Buggy submission (verdict: Runtime Error):
moji = []
for i in range(3):
  moji[i] = input()[i]
print("".join(moji))
Problem p03486 (python)

Fixed submission:
a=list(input())
b=list(input())
if a==b:
  print("No")
else:
  a.sort()
  a="".join(a)
  b.sort()
  b=b[::-1]
  b="".join(b)
  list_ = [a,b]
  list_.sort()
  if list_[0]==a:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=list(input())
b=lsit(input())
if a==b:
  print("No")
else:
  a.sort()
  a="".join(a)
  b.sort()
  b=b[::-1]
  b="".join(b)
  list_ = [a,b]
  list_.sort()
  if list_[0]==a:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
if a==b:
  print("No")
else:
  a.sort()
  b.sort()[::-1]
  list_ = [a,b]
  list_.sort()
  if list_[0]==a:
    print("Yes")
  else:
    print("No")
Problem p03493 (python)

Fixed submission:
input_ = input()
a, b, c = int(input_[0]), int(input_[1]), int(input_[2])
print(a+b+c)

Buggy submission (verdict: Runtime Error):
a, b, c = int(input[0]), int(input[1]), int(input[2])
print(a+b+c)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split())
print(a+b+c)
Problem p03543 (python)

Fixed submission:
n = input()
mae_n = n[:-1]
ushiro_n = n[1:]
if (len(set(mae_n))==1)or(len(set(ushiro_n))==1):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = list(map(int,input().split()))
cnt = 0
for i in range(3):
  if s[i]!==s[i+1]:
    cnt=i
    break
if cnt>=2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = list(map(int,input().split()))
cnt = 0
for i in range(3):
  if s[i]!=s[i+1]:
    cnt=i
    break
if cnt>=2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = set(int(input()))
if len(N)<=2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = set(int(input()))
if len(N)<=2:
  print("Yes")
else:
  print("No)
Problem p03547 (python)

Fixed submission:
alfa_map = {"A":0,"B":1,"C":2,"D":3,"E":4,"F":5}
X, Y = map(str,input().split())
if alfa_map[X] > alfa_map[Y]:
  print(">")
elif alfa_map[X] < alfa_map[Y]:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
alfa_map = {"A":0,"B":1,"C":2,"D":3,"E":4,"F":5}
X, Y = map(int,input().split())
if alfa_map[X] > alfa_map[Y]:
  print(">")
elif alfa_map[X] < alfa_map[Y]:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
alfa_map = {"A":0,"B":1,"C":2,"D":3,"E":4,"F":5}
X, Y = map(int,input().split())
if alfa_map[X] > alfa_map[X]:
  print(">")
elif alfa_map[X] < alfa_map[X]:
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
alfa_map = {"A":0,"B":1,"C":2,"D":3,"E":4,"F"5}
X, Y = map(int,input().split())
if alfa_map[X] > alfa_map[X]:
  print(">")
elif alfa_map[X] < alfa_map[X]:
  print("<")
else:
  print("=")
Problem p03555 (python)

Fixed submission:
C1=input()
C2=input()

if (C1[0]==C2[2]) and (C1[2]==C2[0]) and (C1[1]==C2[1]):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
C1=input()
C2=input()

if (C1[0]==C[2]) and (C1[0]==C2[2]) and (C1[1]==C2[1]):
  print("YES")
else:
  print("NO")
Problem p03606 (python)

Fixed submission:
N = int(input())
cnt=0
for _ in range(N):
  l,r = map(int,input().split())
  cnt+=(1+(r-l))
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
cnt=0
for _ in range(N):
  l,r = map(int,input())
  cnt+=(1+(r-l))
print(cnt)
Problem p03624 (python)

Fixed submission:
alpha_set = set([chr(i) for i in range(97,97+26)])
s = set(input())
diff = list(alpha_set-s)
if len(diff)==0:
  print("None")
else:
  diff.sort()
  print(diff[0])

Buggy submission (verdict: Runtime Error):
s = [char(i) for i in range(97,97+26)]
print(s)
Problem p03635 (python)

Fixed submission:
n,m = map(int,input().split())
print(int((n-1)*(m-1)))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
print(int((n-1)*(m-1))
Problem p03644 (python)

Fixed submission:
n = int(input())
i=0
while 2**(i+1)<=n:
  i+=1
print(2**i)

Buggy submission (verdict: Runtime Error):
n = int(intput())
i=0
while 2**(i+1)<=n:
  i+=1
print(2**1)
Problem p03680 (python)

Fixed submission:
N = int(input())
b_list = []
for _ in range(N):
  b_list.append(int(input())-1)

i = 0
cnt=0
keiyu_list = [0 for _ in range(N)]

while keiyu_list[i]==0:
  keiyu_list[i]=1
  i = b_list[i]
  cnt+=1
  if i == 1:
    cnt+1
    break
if i==1:
  print(cnt)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
b_list = []
for _ in range(N):
  b_list.append(int(input()))

i = b_list[0]
keiyu_list = [0 for _ in range(N)]
cnt=0
while keiyu_list[i]==0:
  i = b_list[i-1]
  keiyu_list[i]=1
  cnt+=1
  if i == 2:
    cnt+1
    break
if i==2:
  print(cnt)
else:
  print(-1)
Problem p03712 (python)

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

temp=["#" for _ in range(b+2)]
mass = []
mass.append(temp)
for _ in range(a):
  mass.append(["#"] + list(input()) + ["#"])
mass.append(temp)

for retsu in mass:
  retsu = "".join(retsu)
  print(retsu)

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

temp=["#" for _ in b+2]
mass = []
mass.append(temp)
for _ in range(a):
  mass.append(["#"] + list(input()) + ["#"])
mass.append(temp)

for retsu in mass:
  retsu = "".join(retsu)
  print(retsu)

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

temp=["#" for _ in b+2]
mass = []
mass.append(temp)
for _ in range(a):
  mass.append(["#"] + input() + ["#"])
mass.append(temp)

for retsu in mass:
  retsu = "".join(retsu)
  print(retsu)
Problem p03737 (python)

Fixed submission:
A,B,C = input().split()
print(A.upper()[0]+B.upper()[0]+C.upper()[0])

Buggy submission (verdict: Runtime Error):
A.upper(),B.upper(),C.upper() = input().split()
print(A[0]+B[0]+C[0])
Problem p03777 (python)

Fixed submission:
a,b = input().split()
H_D_map = {"H":1,"D":-1}
a = H_D_map[a]
b = H_D_map[b]

if a*b==1:
  print("H")
else:
  print("D")

Buggy submission (verdict: Runtime Error):
a,b = input().split()
H_D_map = {"H":1,"D":-1}
a = H_D_map[a]
b = H_D_map[b]

if a*B==1:
  print("H")
else:
  print("D")
Problem p03827 (python)

Fixed submission:
do_list = [0]
x=0
N = int(input())
s = input()
for i in range(N):
  if s[i]=="I":
    x+=1
  if s[i]=="D":
    x-=1
  do_list.append(x)
print(max(do_list))

Buggy submission (verdict: Runtime Error):
do_list = []
x=0
N = int(input())
s = input()
for i in range(N):
  if s[i]=="I":
    x+=1
  if S[i]=="D":
    x-=1
  do_list.append(x)
print(max(do_list))
Problem p03860 (python)

Fixed submission:
A,B,C = input().split()
print(A.upper()[0]+B.upper()[0]+C.upper()[0])

Buggy submission (verdict: Runtime Error):
A,B,C = input().split()
print(A.upper[0]+B.upper[0]+C.upper[0])
Problem p03943 (python)

Fixed submission:
a,b,c = map(int,input().split())
if ((a+b+c)-max(a,b,c))==max(a,b,c):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if (a+b+c)_max(a,b,c)==max(a,b,c):
  print("Yes")
else:
  print("No")
Problem p02608 (python)

Fixed submission:
N = int(input())
List = [0 for _ in range(10000)]

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      k = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if k<=N:
        List[k-1] += 1
        
for i in range(N):
  print(List[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
List = [0 for _ in range(1000)]

for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      k = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if k<=N:
        List[k-1] += 1
        
for i in range(N):
  print(List[i])
Problem p03274 (python)

Fixed submission:
N,K=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(N-K+1):
    b.append(min(abs(a[i])+abs(a[i+K-1]-a[i]),abs(a[i+K-1])+abs(a[i]-a[i+K-1])))
print(min(b))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(N-K+1):
    b.append(min(abs(a[i])+abs(a[i+K-1]-a[i]),abs(a[i+K-1])+abs(a[i]-a[i+K-1]))
print(min(b))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in (N-K+1):
    if a[i]<0:
        b.append(-2*a[i]+a[i+K-1])
    else:
        b.append(a[i]+a[i+K-1])
print(min(b))
Problem p03280 (python)

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

Buggy submission (verdict: Runtime Error):
a=input()
b=int(input())
i=0
t=0
while t<0:
    if a[i]!='1':
        t=1
    else:
        i+=1
if i<(b-1):
    print(a[i])
else:
    print('1')

Buggy submission (verdict: Runtime Error):
a=input()
b=int(input())
i=0
t=0
while t<0:
    if a[i]!='1':
        t=1
    else:
        i+=1
if i<b-1:
    print(a[i])
else:
    print('1')

Buggy submission (verdict: Runtime Error):
a=input()
b=int(input())
i=0
t=0
while t<0:
    if a[i]!=1:
        t=1
    else:
        i+=1
if i<b:
    print(a[i])
else:
    print(1)
Problem p02646 (python)

Fixed submission:
def main():
    A,V = [int(x) for x in input().split()]
    B,W = [int(x) for x in input().split()]
    T = int(input())
    D = abs(A-B)
    if V<=W:
        print('NO')
        return
    F = V-W
    if D/F <= T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    A,V = [int(x) for x in input().split()]
    B,W = [int(x) for x in input().split()]
    T = int(input())
    pA = A
    pB = B
    if pA > pB:
        print('NO')
        return
    for _ in range(T):
        print(pA,pB)
        if pA <= pB and pB+W <= pA+V:
            print('YES')
            return
        pA += V
        pB += W
    print('NO')

if __name__ == '__main__':
    main()
Problem p02787 (python)

Fixed submission:
# import numpy as np

def main():
    H,N = [int(x) for x in input().split()]
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)

    # dp = np.full((N+1,H+1),10 ** 18)
    # dp[0][0] = 0
    dp = [float('inf')]*(H+1)
    dp[0] = 0
    for i in range(N):
        for j in range(H+1):
            # print(i,j,dp[j],A[i],B[i])
            dp[min(j+A[i],H)] = min(dp[min(j+A[i],H)], dp[j]+B[i])
            # dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            # dp[i+1][min(j+A[i],H)] = min(dp[i+1][j]+B[i], dp[i+1][min(j+A[i],H)])
            # print(dp)
    print(int(dp[H]))


if __name__ == '__main__':
    main()

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

def main():
    H,N = [int(x) for x in input().split()]
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)

    # dp = np.full((N+1,H+1),10 ** 18)
    # dp[0][0] = 0
    dp = [float('inf')]*(H+1)
    dp[0] = 0
    for i in range(N):
        for j in range(H+1):
            # print(i,j,dp[j],A[i],B[i])
            dp[min(j+A[i],H)] = min(dp[min(j+A[i],H)], dp[j]+B[i])
            # dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            # dp[i+1][min(j+A[i],H)] = min(dp[i+1][j]+B[i], dp[i+1][min(j+A[i],H)])
            # print(dp)
    print(int(dp[H]))


if __name__ == '__main__':
    main()

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

def main():
    H,N = [int(x) for x in input().split()]
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)

    dp = np.full((N+1,H+1),10 ** 18)
    dp[0][0] = 0
    for i in range(N):
        for j in range(H+1):
            # print(i,j)
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            dp[i+1][min(j+A[i],H)] = min(dp[i+1][j]+B[i], dp[i+1][min(j+A[i],H)])
            # print(dp)
    print(int(dp[N][H]))


if __name__ == '__main__':
    main()

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

def main():
    H,N = [int(x) for x in input().split()]
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)

    dp = np.full((N+1,H+1),float('inf'))
    dp[0][0] = 0
    for i in range(N):
        for j in range(H+1):
            # print(i,j)
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            dp[i+1][min(j+A[i],H)] = min(dp[i+1][j]+B[i], dp[i+1][min(j+A[i],H)])
            # print(dp)
    print(int(dp[N][H]))


if __name__ == '__main__':
    main()
Problem p02898 (python)

Fixed submission:
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
cnt = 0

h = list(map(int, input().split()))

for high in h:
    if high >= k:
        cnt += 1


print(cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
cnt = 0

h = list(map(int, input().split()))

for high in h:
    if h >= k:
        cnt += 1


print(cnt)
Problem p02911 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, Q, *A = map(int, read().split())

    B = [0] * N
    for a in A:
        B[a - 1] += 1

    ans = [0] * N
    for i, b in enumerate(B):
        if Q >= K + b:
            ans[i] = 'No'
        else:
            ans[i] = 'Yes'

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np

n,k,q= map(int(input()))

scores = np.array([k] * n)

for i in range(q):
    ans = int(input())
    scores[:ans-1] = scores[:ans-1] - 1
    scores[ans:] = scores[ans:] - 1

for r in scores:
    if r >= 0:
        print('Yes')
    else:
        print('No')
Problem p02921 (python)

Fixed submission:
s = list(input())
t = list(input())

ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
s = input().split()
t = input().split()

ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)
Problem p02953 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
h = list(reversed(list(map(int, input().split()))))

cnt = 0
for i in range(n-1):
    if h[i+1] - h[i] > 1:
        print('No')
        exit(0)
    elif h[i+1] - h[i] == 1:
        h[i+1] -= 1

print('Yes')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
h = reversed(list(map(int, input().split())))

cnt = 0
for i in range(n-1):
    if h[i+1] - h[i] > 1:
        print('No')
        exit(0)
    elif h[i+1] - h[i] == 1:
        h[i+1] -= 1

print('Yes')
Problem p02969 (python)

Fixed submission:
# -*- coding: utf-8 -*-
print(3*int(input())**2)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
print(3*int(input)**2)
Problem p02982 (python)

Fixed submission:
n, d = map(int, input().split())
x_l = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
x_l = [list(map(int, input().split)) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
x_l = [list(map(int, input().split))) for _ in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1, n):
        tmp = 0
        for k in range(d):
            tmp += (x_l[j][k] - x_l[i][k]) ** 2
        if tmp**0.5%1 == 0:
            ans += 1

print(ans)
Problem p02994 (python)

Fixed submission:
# -*- coding: utf-8 -*-
def pop_min_abs(l):
    abs_l = list(map(abs, l))
    l.pop(abs_l.index(min(abs_l)))
    return l



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

apples = [l+i-1 for i in range(1,n+1)]
print(sum(pop_min_abs(apples)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def pop_min_abs(l):
    abs = map(abs, l)
    return l.pop(abs.index(min(abs)))



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

apples = [l+i-1 for i in range(1,n+1)]
print(sum(pop_min_abs(apples)))
Problem p03001 (python)

Fixed submission:
# -*- coding: utf-8 -*-

w, h, x, y = map(int, input().split())

def multi(w, h, x, y):
    core = (w/2, h/2)
    if (x == core[0])^(y == core[1]):
        return False
    elif x == core[0]:
        return True
    else:
        return False

print(w*h/2, 1 if multi(w, h, x, y) else 0)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

w, h, x, y = map(int, input().split())

core = (w/2, h/2)
base = h/w
slope = (core[1]-y)/(core[0]-x)

multi = (base >= slope and y == core[1]) or (base < slope and x == core[0])

print(w*h/2, 1 if multi else 0)
Problem p03031 (python)

Fixed submission:
# -*- coding: utf-8 -*-

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

lamps = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))

ans = 0

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

lamps = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(n)]
p = list(map(int, input().split()))

ans = 0

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

lamps = [list(map(lambda x: int(x)-1, input().split()))[1:] for _ in range(n)]
p = map(int, input().split())

ans = 0

for i in range(1 << n):
    for r in range(m):
        on_sum=0
        for j in range(n):
            if i >> j & 1 and j in lamps[r]:
                on_sum += 1

        if on_sum % 2 != p[r]:
            break

    else:
        ans += 1

print(ans)
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
ls=list(map(int,input().split()))
check_ls=[0 for i in range(n)]
ps=[1]
nxt=1
while True:
    idx=nxt-1
    if check_ls[idx]==-1:
        break
    ps.append(ls[idx])
    nxt=ls[idx]
    check_ls[idx]=-1

loop_start_idx = ps.index(ps[-1])
loop_length=len(ps)-loop_start_idx-1
loop_ls=ps[loop_start_idx:-1]
if k<len(ps):
    print(ps[k])
else:
    idx=(k-loop_start_idx)%loop_length
    print(loop_ls[idx])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ls=list(map(int,input().split()))
ps=[]
length=0
goto=1
while True:
    idx=goto-1
    goto=ls[idx]
    if goto==-1:
        break
    ps.append(goto)
    ls[idx]=-1
    length+=1

amari=(k-1)%3
print(ps[amari])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ls=list(map(int,input().split()))
ps=[]
length=0
goto=1
for _ in range(100):
    idx=goto-1
    goto=ls[idx]
    if goto==-1:
        break
    ps.append(goto)
    ls[idx]=-1
    length+=1

amari=(k-1)%3
print(ps[amari])
Problem p02690 (python)

Fixed submission:
import math
x=int(input())

b=0
while True:
    p,m=b, -b
    xp, xm = x+p**5, x+m**5
    flag=False
    for i in range(math.ceil(abs(xp)**0.2)+1):
        if i**5 - p**5 == x:
            ans=[i,p]
            flag=True
            break
        if (-1*i)**5 - p**5 == x:
            ans=[-1*i,p]
            flag=True
            break
    for i in range(math.ceil(abs(xm)**0.2)+1):
        if i**5 - m**5 == x:
            ans=[i,m]
            flag=True
            break
        if (-1*i)**5 - m**5 == x:
            ans=[-1*i,m]
            flag=True
            break
    if flag:
        break
    b+=1

print(" ".join(list(map(str,ans))))

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

b=0
while True:
    p,m=b, -b
    xp, xm = x+p**5, x+m**5
    if (xp**(1/5)).is_integer():
        ans=[int(xp**(1/5)),p]
        break
    if (xm**(1/5)).is_integer():
        ans=[int(xm**(1/5)),m]
        break
    b+=1

print(" ".join(list(map(str,ans))))
Problem p02714 (python)

Fixed submission:
n=int(input())
s=input()
afters={'R':0, 'B':0, 'G':0}
for i in range(n):
    afters[s[i]] += 1

befores = {'R':0, 'B':0, 'G':0}
befores[s[0]]+=1
afters[s[0]]-=1

ans=0
for i in range(1,n-1):
    head=s[0:i]
    last=s[i+1::]
    afters[s[i]]-=1
    if s[i]=='R':
        ans += befores['G'] * afters['B'] + befores['B'] * afters['G'] 
        bad =[['G','B'],['B','G']]
    elif s[i]=='B':
        ans += befores['G'] * afters['R'] + befores['R'] * afters['G'] 
        bad = [['G','R'],['R','G']]
    else:
        ans += befores['B'] * afters['R'] + befores['R'] * afters['B'] 
        bad = [['B','R'],['R','B']]
    for j in range(min(i-0, n-i-1)):
        if [s[i-j-1], s[i+j+1]] in bad:
            ans -= 1
    befores[s[i]]+=1
    

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
afters={}
for i in range(n):
    afters.setdefault(s[i],0)
    afters[s[i]] += 1

befores = {'R':0, 'B':0, 'G':0}
befores[s[0]]+=1
afters[s[0]]-=1

ans=0
for i in range(1,n-1):
    head=s[0:i]
    last=s[i+1::]
    afters[s[i]]-=1
    if s[i]=='R':
        ans += befores['G'] * afters['B'] + befores['B'] * afters['G'] 
        bad =[['G','B'],['B','G']]
    elif s[i]=='B':
        ans += befores['G'] * afters['R'] + befores['R'] * afters['G'] 
        bad = [['G','R'],['R','G']]
    else:
        ans += befores['B'] * afters['R'] + befores['R'] * afters['B'] 
        bad = [['B','R'],['R','B']]
    for j in range(min(i-0, n-i-1)):
        if [s[i-j-1], s[i+j+1]] in bad:
            ans -= 1
    befores[s[i]]+=1
    

print(ans)