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

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

A,B,C,D,E,F = I()
lim1 = F//(100*A)
lim2 = F//(100*B)
ans = 0
ansnum = 0
for i in range(lim1+1):
    for j in range(lim2+1):
        w = 100*i*A+100*j*B
        if i == j == 0:
            continue
        if w > F:
            continue
        r = F-w
        num = 0
        lim3 = min(r,(i*A+j*B)*E)//C
        for k in range(lim3+1):
            num = max(num,k*C+((min(r,(i*A+j*B)*E)-k*C)//D)*D)
        if 100*num/(w+num) > ansnum:
            ans = [w+num,num]
            ansnum = 100*num/(w+num)
if ans == 0:
    print(A*100,0)
else:
    print(*ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

A,B,C,D,E,F = I()
lim1 = F//(100*A)
lim2 = F//(100*B)
f = F-C
ans = 0
ansnum = 0
for i in range(lim1+1):
    for j in range(lim2+1):
        w = 100*i*A+100*j*B
        if i == j == 0:
            continue
        if w > f:
            continue
        r = F-w
        num = 0
        lim3 = min(r,(i*A+j*B)*E)//C
        for k in range(1,lim3+1):
            num = max(num,k*C+((min(r,(i*A+j*B)*E)-k*C)//D)*D)
        if 100*num/(w+num) > ansnum:
            ans = [w+num,num]
            ansnum = 100*num/(w+num)
print(*ans)
Problem p03625 (python)

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
A.sort(reverse=True)
list = []
start = 0
while start < N-1: 
    if A[start] == A[start+1]:
        list.append(A[start])
        start += 2
    else:
        if start == N-2:
            break
        start += 1
if len(list) >= 2:
    print(list[0]*list[1])
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
A.sort(reverse=True)
list = []
start = 0
while start < N:
    if A[start] == A[start+1]:
        list.append(A[start])
        start += 2
    else:
        if start == N-2:
            break
        start += 1
if len(list) >= 2:
    print(list[0]*list[1])
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = l()
A.sort(reverse=True)
list = []
start = 0
while start < N:
    if A[start] == A[start+1]:
        list.append(A[start])
        start += 2
    else:
        start += 1
if len(list) >= 2:
    print(list[0]*list[1])
else:
    print(0)
Problem p03657 (python)

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B = I()
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=int(input())
if A%3*B%3*(A+B)%3==0:print('Possible')
else:print('Impossible')
Problem p03659 (python)

Fixed submission:
import itertools
N = int(input())
a = list(map(int,input().split()))
ruiseki = list(itertools.accumulate(a))
b = sum(a)
ans = 10**100
for i in range(N-1):
    ans = min(ans,abs(ruiseki[i]*2-b))
print(ans)

Buggy submission (verdict: Runtime Error):
mport itertools
N = int(input())
a = list(map(int,input().split()))
ruiseki = list(itertools.accumulate(a))
ans = 10**100
for i in range(N-1):
    ans = min(ans,abs(sum(a[:i+1])-sum(a[i+1:])))
print(ans)
Problem p03711 (python)

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x,y = I()
if (x in a and y in a) or (x in b and y in b) or x == y == 2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x,y = I()
if (x in a and y in a) or (x in b ans y in b) or x == y == 2:
    print('Yes')
else:
    print('No')
Problem p03721 (python)

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,K = I()
L = [l() for _ in range(N)]
L.sort()
for i in range(N):
    K -= L[i][1]
    if K <= 0:
        print(L[i][0])
        exit()

Buggy submission (verdict: Runtime Error):
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,K = I()
L = [l() for _ in range(N)]
L.sort()
for i in range(N):
    K -= L[i][1]
    if K <= 0:
        print(L[i][0])
        exit()
Problem p03729 (python)

Fixed submission:
A,B,C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A,B,C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES'):
else:
    print('NO')
Problem p03862 (python)

Fixed submission:
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if a[i] > x:
        ans +=  a[i]-x
        a[i] = x
    if a[i] + a[i+1] > x:
        ans += a[i]+a[i+1]-x
        a[i+1] -= a[i]+a[i+1]-x
print(ans)

Buggy submission (verdict: Runtime Error):
N,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if a[i] > x:
        ans +=  a[i]-x
        a[i] = x
    if a[i] + a[i+1] > x:
        ans += a[i]+a[i+1]-x
        a[i+i] -= a[i]+a[i+1]-x
print(ans)
Problem p04043 (python)

Fixed submission:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

A = l()
A.sort()
if A == [5,5,7]:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
N,L = map(int,input().split())
S = [input() for i_ in range(N)]
S.sort()
s = S[0]
for i in range(1,N):
    s += S[i]
print(s)
Problem p02783 (python)

Fixed submission:
x = input().split()
h = int(x[0])
a = int(x[1])
if h%a == 0:
    print(h//a)
else:
    print(h//a+1)

Buggy submission (verdict: Runtime Error):
x = input().split()
n = int(x[0])
k = int(x[1])
 
h = input().split()
 
h = sorted(h)
 
if n-k <= 0:
    print(0)
    exit()
 
c = 0
for i in range(n-k):
    c += int(h[i])
print(c)

Buggy submission (verdict: Runtime Error):
x = input().split()
n = int(x[0])
k = int(x[1])
 
h = input().split()
 
sorted(h)
 
if n-k <= 0:
    print(0)
    exit()
 
c = 0
for i in range(n-k):
    c += int(h[i])
print(c)

Buggy submission (verdict: Runtime Error):
x = input().split()
n = int(x[0])
k = int(x[1])
 
h = input().split()
 
sorted(h)
 
if n-k <= 0:
    print(0)
    exit()
 
c = 0
for i in range(n-k):
    c += int(h[i])
print(c)
Problem p03035 (python)

Fixed submission:
x = input().split()
a = int(x[0])
b = int(x[1])
if a >= 13:
  print(b)
elif 6 <= a <= 12:
  print(b//2)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
x = input().split()
n = int(x[0])
m = int(x[1])
a = list()
for i in range(m):
  y = input().split()
  l = int(y[0])
  r = int(y[1])
  for i in range(l,r+1):
    a.append(i)
b = 0
for i in range(n):
  if a.count(i) == m:
    b += 1
print(b)

Buggy submission (verdict: Runtime Error):
x = input().split()
a = int(x[0])
b = int(x[1])
if a >= 13:
  print(b)
elif 6 <= a <= 12:
  priny(b//2)
else:
  print(0)
Problem p02664 (python)

Fixed submission:
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline

T=input()

T=T.replace('?','D')

print(T)

Buggy submission (verdict: Runtime Error):
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline

T=input()

T.replace("?","D")

print(T.count("D")+T.count("PD")
Problem p02848 (python)

Fixed submission:
N=int(input())
S=input()
tmp=""
for i in range(len(S)):
  chtmp=ord(S[i])+N
  if(chtmp>ord('Z')):
    chtmp-=(ord('Z') - ord('A') + 1)
  tmp+=chr(chtmp)
print(tmp)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
tmp=""
for i in range(N):
  if(S[i]!="Z"):
    tmp+=chr(ord(S[i])+1)
  else:
    tmp+="A"
print(tmp)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
tmp=""
for i in range(N):
  if(S[i]!=Z):
    tmp+=chr(ord(S[i])+1)
  else:
    tmp+="A"
print(tmp)
Problem p02934 (python)

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

ans=0
for i in range(N):
  ans+=1/A[i]

print(1/ans)

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

for i in range(N):
  ans+=1/A[i]

print(1/ans)
Problem p02969 (python)

Fixed submission:
r=int(input())
print(3*r**2)

Buggy submission (verdict: Runtime Error):
print(3*(int(input())**2)
Problem p03023 (python)

Fixed submission:
N=int(input())
print((180*(N-2)))

Buggy submission (verdict: Runtime Error):
N=input()
print(180*(N-2))
Problem p03085 (python)

Fixed submission:
#import sys
#input = sys.stdin.readline

list={"A":"T","T":"A","G":"C","C":"G"}
b = input()
print(list[b])

Buggy submission (verdict: Runtime Error):
import sys
lines = sys.stdin.readlines()

list={"A":"T","T":"A","G":"C","C":"G"}
b = lines
print(list[b])

Buggy submission (verdict: Runtime Error):
import sys
#input = sys.stdin.readlines

list={"A":"T","T":"A","G":"C","C":"G"}
b = sys.stdin.readlines()
print(list[b])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readlines

list={"A":"T","T":"A","G":"C","C":"G"}
b = input()
print(list[b])

Buggy submission (verdict: Runtime Error):
import sys

list={"A":"T","T":"A","G":"C","C":"G"}
b = sys.stdin.readline()
print(list[b])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

list={"A":"T","T":"A","G":"C","C":"G"}
b = input()
print(list[b])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

list={"A":"T","T":"A","G":"C","C":"G"}
b = input()
print(list[b])
Problem p03129 (python)

Fixed submission:
N,K=map(int,input().split())
if(N>(2*(K-1))):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
if(N>=(2*(K-1)))
  print("YES")
else:
  print("NO")
Problem p03139 (python)

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

if(A>B):
  ans1=B
  ans2=max(0,A-(N-B))
else:
  ans1=A
  ans2=max(0,B-(N-A))
  
print(str(ans1)+" "+str(ans2))

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

if(A>B):
  ans1=B
  ans2=A-(N-B)
else:
  ans1=A
  ans2=B-(N-A)
  
print(ans1+" "+ans2)
Problem p02534 (python)

Fixed submission:
K = int(input())
spam=('ACL')
print(spam*K)

Buggy submission (verdict: Runtime Error):
spam='ACL'
print(spam*K)

Buggy submission (verdict: Runtime Error):
spam='ACL'
print(spam*K)

Buggy submission (verdict: Runtime Error):
spam='ACL'
print(spam*K)
Problem p04043 (python)

Fixed submission:
i = list(map(int, input().split(" ")))
#print(s)
#print(s[1])
#import pdb; pdb.set_trace()

if  [5, 5, 7] == sorted(i):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
s = sorted([input() for i in range(N)])

print(*s, sep="")
Problem p02534 (python)

Fixed submission:
k=int(input())
print(k*"ACL")

Buggy submission (verdict: Runtime Error):
print(K*"AKL")

Buggy submission (verdict: Runtime Error):
if C<=A<=D or C<=B<=D or A<=C<=B or A<=D<=B: print("Yes")
else: print("No")
Problem p02657 (python)

Fixed submission:
A,B = input().split()
C = int(A) * int(B)

print(int(C))

Buggy submission (verdict: Runtime Error):
A, B = input.trim().split()
C = int(A) * float(B)
D = C // 1
print(round(C))
Problem p02555 (python)

Fixed submission:
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

S = int(input())
ans = 0
mod = 10 ** 9 + 7
for i in range(1,700):
    x = S - 3 * i
    if x < 0:
        break
    ans += (combinations_count(x + i - 1, i - 1)) % mod
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
S = int(input())
mod = 10 ** 9 + 7
dp = [0 for _ in range(S)]
dp[0] = dp[1] = 0
dp[2] = dp[3] = 1

for i in range(3, S):
    dp[i] = (dp[i - 3] + dp[i - 1]) % mod
    
print(dp[-1])

Buggy submission (verdict: Runtime Error):
S = int(input())
mod = 10 ** 9 + 7
dp = [0 for _ in range(S)]
dp[0] = dp[1] = 0
dp[2] = dp[3] = 0

for i in range(S - 3):
    dp[i + 3] = (dp[i] + dp[i + 2]) % mod
    
print(dp[-1])

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
@lru_cache(maxsize=None)
def dp(i):
    if i == 1 or i == 2:
        return 0
    elif i == 3 or i == 4:
        return 1
    else:
        return dp(i - 3) + dp(i - 1)


S = int(input())
print(dp(S))

Buggy submission (verdict: Runtime Error):
def dp(i):
    if i == 1 or i == 2:
        return 0
    elif i == 3 or i == 4:
        return 1
    else:
        return dp[i - 3] + dp[i - 1]


S = int(input())
print(dp(S))

Buggy submission (verdict: Runtime Error):
import math
#n個からr個とるときの組み合わせの数
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

S = int(input())
ans = 0
mod = 10 ** 9 + 7
for i in range(1,S // 3 + 1):      #長さiの数列のとき
   
    x = S - 3 * i       #3を分配後の余り
    
    ans += (combinations_count(x + i - 1, i - 1)) % mod　#重複組み合わせを足す
    ans %= mod

print(ans)
Problem p02606 (python)

Fixed submission:
L, R, d =map(int, input().split())
ans = 0
for i in range(L, R + 1):
  if i % d == 0:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
L R d =map(int, input().split())
ans = 0
for i in range(L, R + 1):
  if i % d == 0:
    ans += 1
print(ans)
Problem p02615 (python)

Fixed submission:
from collections import deque
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
d = deque([A[0]])
for x in A[1:]:
  ans += d.popleft()
  d.append(x)
  d.append(x)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
N = int(input())
A = list(map(int, input().split()))
A.sort(reversre=True)
ans = 0
d = deque(A[0])
for x in A[1:]:
  ans += d.popleft()
  d.append(x)
  d.append(x)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import heapq
N = int(input())
A = sorted(list(map(int, input().split())))
max3 = heapq.nlargest(3, A)
d = Counter(A)
if d[max3[1]] == 1:
  ans = sum(A) + max3[1] - max3[2] - A[0]
else:
  ans = sum(A) - A[0]
print(ans)
Problem p02639 (python)

Fixed submission:
N = map(int, input().split())
for x, n in enumerate(N, 1):
  if n == 0:
    print(x)
    break

Buggy submission (verdict: Runtime Error):
N = map(int. input().split())
for x, n in enumarate(N, 1):
  if n == 0:
    print(x)
    break
Problem p02683 (python)

Fixed submission:
N, M, X = map(int, input().split(" "))
book_information = []
result = 12 * 10**5 + 1
for i in range(N):
	book_information.append(input())
for i in range(1, 1 << N):
  bought_book = []
  n = 0
  cost = 0
  skill = [0 for j in range(M)]
  for j in range(N):
    if (i >> j) & 1:
      bought_book.append(book_information[j])
      n += 1
  for j in range(n):
    bought_book_information = list(bought_book[j].split(" "))
    cost += int(bought_book_information[0])
    for k in range(M):
      skill[k] += int(bought_book_information[k + 1])
  if all(x >= X for x in skill):
    result = min(result, cost)
if result == 12 * 10**5 + 1:
  print(-1)
else:
  print(result)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
books = [input() for i in range(N)]
result = 12 * 10**5 + 1
for i in range(1, 1 << N):
  cost = 0
  skill = [0 for i in range(N)]
  for j in range(N):
    if (i >> j) & 1:
      book = books[j].split()
      cost += int(book[0])
      for k in range(M):
        skill[k] += int(book[k + 1])
  if all(j >= X for j in skill):
    result = min(result, cost)
if result == 12 * 10**5 + 1:
  print(-1)
else:
  print(result)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
books = [input() for i in range(N)]
result = 12 * 10**5 + 1
for i in range(1, 1 << N):
  skill = [0 for i in range(N)]
  for j in range(N):
    if (i >> j) & 1:
      book = books[j].split()
      cost += int(book[0])
      for k in range(M):
        skill[k] += int(book[k + 1])
  if all(j >= X for j in skill):
    result = min(result, cost)
if result == 12 * 10**5 + 1:
  print(-1)
else:
  print(result)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
book_information = []
result = 12 * 10**5
for i in range(N):
	book_information.append(input())
for i in range(1, 1 << N):
  bought_book = []
  n = 0
  skill = [0 for j in range(M)]
  for j in range(N):
    if (i >> j) & 1:
      bought_book.append(book_information[j - 1])
      n += 1
  for j in range(n - 1):
    bought_book_information = list(map(bought_book[j].split(" ")))
    cost += bought_book_information[0]
    for k in range(M):
      skill[k] += bought_book_information[k + 1]
  if all(x >= X for x in skill):
    result = min(result, cost)
if result == 12 * 10**5:
  print(-1)
else:
  print(result)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split(" "))
routs = {}
location = [0 for i in range(N + 1)]
tereporter = list(map(int, input().split()))
for i in range(N):
  routs[i] = tereporter[i] - 1
present_location = 0
n = 0
for i in range(K):
  n += 1
  present_location = routs[present_location]
  if location[present_location] == 0:
    location[present_location] = n
  else:
    loop = n - location[present_location]
    if (K - location[present_location]) % loop == 0:
      break
    else:
      for i in range((K - location[present_location]) % loop):
        present_location = routs[present_location]
      break
print(present_location + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
routs = {}
location = [0 for i in range(N + 1)]
tereporter = list(map(int, input().split()))
for i in range(N):
  routs[i] = tereporter[i] - 1
present_location = 0
n = 0
for i in range(K):
  n += 1
  present_location = routs[present_location]
  if location[present_location] == 0:
    location[present_location] = n
  else:
  loop = n - location[present_location]
  if (K - location[present_location]) % loop == 0:
    break
  else:
    for i in range((K - location[present_location]) % loop):
      present_location = routs[present_location]
	break
print(present_location + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
routs = {}
location = [0 for i in range(N + 1)]
tereporter = list(map(int, input().split()))
for i in range(N):
  routs[i] = tereporter[i] - 1
present_location = 0
n = 0
for i in range(K):
  n += 1
  present_location = routs[present_location]
  if location[present_location] == 0:
    location[present_location] = n
  else:
    break
loop = n - location[present_location]
if (K - location[present_location]) % loop == 0:
  print(present_location + 1)
else:
  for i in range((K - location[present_location]) % loop):
    present_location = routs[present_location]
  print(present_location + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
routs = {}
tereporter = list(map(int, input().split()))
for i in range(N):
  routs[i + 1] = tereporter[i]
present_location = 1
n = 0
for i in range(K):
  n += 1
  present_location = routs[present_location]
  if present_location = 1:
    if n == 0 or K % n == 0:
      break
    for i in range(K % n):
      present_location = routs[present_location]
    break

print(present_location)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
routs = {}
tereporter = list(map(int, input().split()))
for i in range(N):
  routs[i] = tereporter[i]
present_location = 1
for i in tange(K):
  present_location = routs[present_location]
print(present_location)
Problem p02687 (python)

Fixed submission:
s = input()
if s == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
height = list(map(int, input().split(" ")))
flag = [1 for i in height]
for i in range(M):
  a, b = map(int, input().split(" "))
  if height[a - 1] > height[b - 1]:
    flag[b - 1] = 0
  elif height[b - 1] > height[a - 1]:
    flag[a - 1] = 0
  else:
    flag[a - 1] = 0
    flag[b - 1] = 0
print(sum(flag))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split(" "))
flag = [1 for i in range(N)]
for i in range(K):
  input()
  for j in map(int,input().split(" ")):
    flag[j-1] = 0
sum(flag)

Buggy submission (verdict: Runtime Error):
if imput() = "ABC":
  print("ADC")
else:
  print("ABC")