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

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

N=int(input())
graph=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    graph[a].append([b,c])
    graph[b].append([a,c])

def dfs(start):
    for x,cost in graph[start]:
        if d[x]==-1:
            d[x]=d[start]+cost
            dfs(x)

Q,K=map(int,input().split())
K-=1
d=[-1]*N
d[K]=0
dfs(K)
for i in range(Q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(d[x]+d[y])

Buggy submission (verdict: Runtime Error):
N=int(input())
graph=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    graph[a].append([b,c])
    graph[b].append([a,c])

def dfs(start):
    for x,cost in graph[start]:
        if d[x]==-1:
            d[x]=d[start]+cost
            dfs(x)

Q,K=map(int,input().split())
K-=1
d=[-1]*N
d[K]=0
dfs(K)
for i in range(Q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(d[x]+d[y])
Problem p02729 (python)

Fixed submission:
import math
def nCr(n,r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n-r) if n>1 else 0
N,M=list(map(int,input().split(' ')))
print(int(nCr(N,2)+nCr(M,2)))

Buggy submission (verdict: Runtime Error):
import math
def nCr(n,r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n-r)
N,M=list(map(int,input().split(' ')))
print(int(nCr(N,2)+nCr(M,2)))
Problem p02754 (python)

Fixed submission:
n,a,b=list(map(int,input().split(' ')))
R=n//(a+b)
if (n%(a+b))-a>0:
    R2=a
else:
    R2=n%(a+b)
print(R*a+R2)

Buggy submission (verdict: Runtime Error):
n,a,b=list(map(int,input().split(' ')))
R=n//(a+b)
R2=(n%(a+b))%a
print(R*a+R2)
Problem p02819 (python)

Fixed submission:
X=int(input())
X=X-1
a=0
b=1
while b==1:
    X=X+1
    a=0
    for i in range(2,X):
        if X%i==0:
            a=a+1
    if a==0:
        print(X)
        break;

Buggy submission (verdict: Runtime Error):
X=input()
X=X-1
a=0
b=1
while b==1:
    X=X+1
    a=0
    for i in range(2,X):
        if X%i==0:
            a=a+1
    if a==0:
        print(X)
        break;
Problem p02859 (python)

Fixed submission:
print(int(input())**2)

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

Buggy submission (verdict: Runtime Error):
r=input()
print(r^2)
Problem p02860 (python)

Fixed submission:
N=int(input())
S=input()
f='sf'
s='fs'
if N%2==0 and N!=0:
    f,s=S[:int(N/2)], S[int(N/2):]
if f==s:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
if N%2==0:
    f,s=S[:int(N/2)], S[int(N/2):]
if f==s:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N,S=input()
if N%2==0:
    f,s=S[:int(N/2)], S[int(N/2):]
if f==s:
    print('Yes')
else:
    print('No')
Problem p02879 (python)

Fixed submission:

string=input()
string=string.split(' ')
A= int(string[0])
B= int(string[1])

if A>9 or B>9:
    print(-1)
else:
        print(A*B)

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

string=string.split(' ')
A= int(A[0])
B= int(A[1])

if A>9 or B>9:
    print(-1)
    else:
        print(A*B)

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

string=string.split(' ')
A= int(A[0])
B= int(A[1])

if A>9 or b>9:
    print(-1)
    else:
        print(A*B)

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

string=string.split(' ')
A= int(A[0])
B= int(A[1])

if A in range(1,10):
else:
    print(-1) break
if B in range(1,10):
else:
    print(-1) break
print(A*B)

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

string=string.split(' ')
A= int(A[0])
B= int(A[1])

if A in range(1,10):
else:
    print(-1) break
if B in range(1,10):
else:
    print(-1 break)
print(A*B)
Problem p02880 (python)

Fixed submission:
N=int(input())

prime=[1]
for i in range(0,82):
    for j in range(2,10):
        P=i%j
        if P==0 and i/j<10:
            prime.append(i)
            break
if N in prime:
    print('Yes')
else:
    print('No')

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

if N>9*9:
    print('No')
else:
    print('Yes')
Problem p02916 (python)

Fixed submission:
n=int(input())
A=input()
B=input()
C=input()

As=list(map(int,A.split(' ')))
Bs=list(map(int,B.split(' ')))
Cs=list(map(int,C.split(' ')))
total=0
for i in range(0,n):
    if As[i]-As[i-1]==1 and i!=0:
        total=total+Cs[As[i]-2]
    total=total+Bs[As[i]-1]
print(total)

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

As=list(map(int,A.split(' ')))
Bs=list(map(int,B.split(' ')))
Cs=list(map(int,C.split(' ')))
total=0
for i in range(0,n):
    if As[i]-As[i-1]==1 and i!=0:
        total=total+Cs[As[i]-1]
    else:
        total=total+Bs[As[i]-1]
print(total)

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

As=map(int,A.split(' '))
Bs=map(int,B.split(' '))
Cs=map(int,C.split(' '))
total=0
for i in range(0,n):
    if As[i]-As[i-1]==1 and i!=0:
        total=total+Cs[As[i]]
    else:
        total=total+Bs[As[i]]
print(total)

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

As=map(int,A.split(' '))
Bs=map(int,B.split(' '))
Cs=map(int,C.split(' '))
total=0
for i in range(0,n):
    if As[i]-As[i-1]==1 and i!=0:
        total=total+Cs[A[i]]
    else:
        total=total+Bs[A[i]]
print(total)

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

As=map(int,A.split(' '))
Bs=map(int,B.split(' '))
Cs=map(int,C.split(' '))
total=0
for i in range(0,n):
    if A[i]-A[i-1]==1 and i!=0:
        total=total+Cs[A[i]]
    else:
        total=total+Bs[A[i]]
print(total)
Problem p03315 (python)

Fixed submission:
S = input()
X = 0
for i in range(len(S)):
    if S[i] == "+":
        X += 1
    else:
        X -= 1

print(X)

Buggy submission (verdict: Runtime Error):
S = int(input())
X = 0
for i in range(len(S)):
    if S[i] == "+":
        X += 1
    else:
        X -= 1

print(X)
Problem p02624 (python)

Fixed submission:
n = int(input())

cnt = [1] * (n + 1)
cnt[0] = 0
cnt[1] = 0

p = 2
while p  <= n // 2:
    for i in range(p*2, n+1, p):
        cnt[i] += 1
    p += 1

ans = 0
for i in range(1, n+1):
    # print(i, cnt[i]+1)
    ans += i * (cnt[i] + 1)

print(ans)

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

def calc_sum(b, e):
    cnt = (e - b) // b
    return (b + e) * cnt // 2

ans = 0
for i in range(n+1):
    ans += calc_sum(i, n // i * i)

print(ans)
Problem p02723 (python)

Fixed submission:
S = input()

if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

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

if S[2] == S[3] and S[4] == S[5]
    print("Yes")
else:
    print("No`")
Problem p02754 (python)

Fixed submission:
n,a,b = map(int,input().split())
ans = n // (a + b)*a

rem = n % (a + b)

ans += min(rem,a)
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
ans = []
blue = ["b"]*a
red = ["r"]*b

while len(ans) < (n-min(a,b)):
	ans.extend(blue)
	ans.extend(red)

print(ans[:n].count("b"))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
ans = []
blue = ["b"]*a
red = ["r"]*b

while len(ans) <= n:
	ans.extend(blue)
	ans.extend(red)
	
tmp = ans[:n]
print(tmp.count("b"))

Buggy submission (verdict: Runtime Error):
i = list(map(int,input().split()))
ans = ""
while len(ans) <= i[0]:
	blue = "b" * i[1]
	red = "r" * i[2]
	ans += blue
	ans += red
end = ans[:i[0]]
print(end.count("b"))
Problem p02571 (python)

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

ans=10000

for i in range(len(S)-len(T)+1):
  score=0
  U=S[i:i+len(T)]#Sのi文字目から{i+len(T)}文字目までがU->部分文字列を抜き出している
  for j in range(len(T)):
    if U[j] != T[j]:
      score += 1
  ans = min(ans, score)

print(ans)

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

ans=10000

for i inrange(len(S)-len(T)+1):
  score=0
  U=S[i:i+len(T)]#Sのi文字目から{i+len(T)}文字目までがU->部分文字列を抜き出している
  for j in range(len(T)):
    if U[j] != T[J]:
      score += 1
  ans = min(ans, score)

print(ans)

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

ans=10000

for i inrange(len(S)-len(T)+1):
  score=0
  U=S[i:i+len(T)]#Sのi文字目から{i+len(T)}文字目までがU->部分文字列を抜き出している
  for j in range(len(T)):
    if U[j] != T[J]:
      score += 1
  ans = min(ans, score)

print(ans)
Problem p02711 (python)

Fixed submission:
N=str(input())
if N.count('7')>0:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
if N.count(7)>0:
	print('Yes')
else:
	print('No')
Problem p02753 (python)

Fixed submission:
s = str(input())
station_a = s.count('A')
station_b = s.count('B')
if station_a != 3 and station_b != 3:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S=(str(input())
if S.count('A')>=1:
    print('Yse')
else:
  print('No')
Problem p02712 (python)

Fixed submission:
N = int(input())
K = 0
for i in range(N):
    s = (i+1) % 3
    t = (i +1) % 5
    if s !=0 and t != 0:
        K +=( i+1)
print(K)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = 0
for i in range(N):
    s = i % 3
    t = i % 5
        if s !=0 and t != 0:
            K += i

print(K)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = 0
for i in range(N)
    s = i % 3
    t = i % 5
    if s !=0 and t != 0:
        K += i
print(K)
Problem p02773 (python)

Fixed submission:
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word).most_common()
u = s[0][1]
v = []
for i, j in s:
  if j == u:
    v.append(i)
v.sort()
print(*v)

Buggy submission (verdict: Runtime Error):
from collections import Counter
int = int(input())
word = [input() for i in range(int)]
s = Counter(word)
u = a.most_common()
u.sort()
for j in range(len(u)):
    print(u[j])
Problem p02572 (python)

Fixed submission:
n=int(input())
l=list(map(int, input().split()))
ans=sum(l)**2

sq=0
for i in range(n):
  sq+=l[i]**2
ans=(ans-sq)//2

import numpy as np
print(np.mod(ans, 10**9+7))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int, input().split()))
ans=sum(l)**2
sq=0
for i in range(n):
  sq+=l[i]**2
ans=(ans-sq)/2

import numpy as np
print(int(np.mod(ans, 10**9+7)))
Problem p02676 (python)

Fixed submission:
k=int(input())
s=str(input())
if len(s)>k:
  print(s[0:k]+"...")
else:
  print(s)

Buggy submission (verdict: Runtime Error):
k=int(input())
s=str(input())
if len(s)>k:
  print(s[0:k]+"...")
elif:
  print(s)
Problem p03805 (python)

Fixed submission:
import itertools as itl
n, m=map(int, input().split())
#ここでリストを作成する
hen=[]
check=0

for _ in range(m):
  hen.append(list(map(int, input().split())))
#print(hen)
l=list(range(2, n+1))
for v in itl.permutations(l):
  #print(v)
  for i in range(n-2):
    if not(sorted(v[i:i+2]) in hen) or not(list([1, v[0]]) in hen):
      break
  else:
    if n==2:
      check+=1
    elif i==n-3:
      check+=1
    continue
print(check)

Buggy submission (verdict: Runtime Error):
import itertools as itl
n, m=map(int, input().split())
#ここでリストを作成する
hen=[]
check=0
if m==0:
  print(0)
  exit()
for _ in range(m):
  hen.append(list(map(int, input().split())))
#print(hen)
l=list(range(2, n+1))
for v in itl.permutations(l):
  #print(v)
  for i in range(n-2):
    if not(sorted(v[i:i+2]) in hen) or not(list([1, v[0]]) in hen):
      break
  else:
    if i==n-3:
      check+=1
    continue
print(check)

Buggy submission (verdict: Runtime Error):
import itertools as itl
n, m=map(int, input().split())
#ここでリストを作成する
hen=[]
check=0
for _ in range(m):
  hen.append(list(map(int, input().split())))
#print(hen)
l=list(range(2, n+1))
for v in itl.permutations(l):
  #print(v)
  for i in range(n-2):
    if not(sorted(v[i:i+2]) in hen) or not(list([1, v[0]]) in hen):
      break
  else:
    if i==n-3:
      check+=1
    continue
    break 
print(check)

Buggy submission (verdict: Runtime Error):
import itertools as itl
n, m=map(int, input().split())
#ここでリストを作成する
hen=[]
check=0
for _ in range(m):
  hen.append(tuple(map(int, input().split())))
#print(hen)
l=list(range(2, n+1))
for v in itl.permutations(l):
  #print(v)
  for i in range(n-2):
    if not(tuple(sorted(v[i:i+2])) in hen) or not(tuple([1, v[0]]) in hen):
      break
  else:
    if i==n-3:
      check+=1
    continue
    break 
print(check)

Buggy submission (verdict: Runtime Error):
import itertools as itl
n, m=map(int, input().split())
#ここでリストを作成する
hen=[]
check=0
for _ in range(m):
  hen.append(tuple(map(int, input().split())))
#print(hen)
l=list(range(2, n+1))
for v in itl.permutations(l):
  #print(v)
  for i in range(n-2):
    if not(tuple(sorted(v[i:i+2])) in hen) or not(tuple([1, v[0]]) in hen):
      #print(sorted(v[i:i+2]))
      break
  else:
    if i==n-3:
      check+=1
    continue
print(check)
Problem p02729 (python)

Fixed submission:
import math
import itertools as it


i = input().split()



n = int(i[0])
m = int(i[1])
nc = it.combinations(range(n),2)
mc = it.combinations(range(m),2)

print(len(list(nc) + list(mc)))

Buggy submission (verdict: Runtime Error):
import math
import itertools as it


i = input().split()



n = i[0]
m = i[1]
nc = it.combinations(range(n),2)
mc = it.combinations(range(m),2)

print(len(list(nc) + list(mc)))
Problem p02948 (python)

Fixed submission:
import numpy
import heapq
import math

N,M = list(map(int, input().split()))
data = [[]for _ in range(M)]
for _ in range(N):
    A,B = list(map(int, input().split()))
    if (A - 1) < M:
        data[A-1].append(-B)

rew = 0
heap=[]
for i in range(M):
    for rewo in data[i]:
        heapq.heappush(heap,rewo)
    if len(heap) > 0:
        r = heapq.heappop(heap)
        rew += -r

print(rew)

Buggy submission (verdict: Runtime Error):
import numpy
import heapq
import math

N,M = list(map(int, input().split()))
data = [[]for _ in range(M)]
for _ in range(N):
    A,B = list(map(int, input().split()))
    if (A - 1) <= M:
        data[A-1].append(-B)

rew = 0
heap=[]
for i in range(M):
    for rewo in data[i]:
        heapq.heappush(heap,rewo)
    if len(heap) > 0:
        r = heapq.heappop(heap)
        rew += -r

print(rew)
Problem p02623 (python)

Fixed submission:
import bisect

n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_cum = [0]
B_cum = [0]

for i in range(n):
  A_cum.append(A_cum[i]+A[i])
  
for i in range(m):
  B_cum.append(B_cum[i]+B[i])

ans = 0  
for i in range(n+1):
  rest = k-A_cum[i]
  if rest<0:
    continue
  
  ans = max(ans, bisect.bisect_right(B_cum, rest)-1+i)
  
print(ans)

Buggy submission (verdict: Runtime Error):
counter = 0
ans = 0

for i in range(n+1):
    if sum(A[:i])>k:
        break
    for j in range(m+1):
        if sum(A[:i])+sum(B[:j])<=k:
            ans = max(ans, i+j)
        else:
            break
            
print(ans)
Problem p02712 (python)

Fixed submission:
n = int(input())
ans = 0

for i in range(1, n+1):
  if i%3!=0 and i%5!=0:
    ans += i
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
ans = 0

for i in range(1, n+1):
  if i%3!=0 and i%5!=0:
    ans += i
    
print(ans)
Problem p02754 (python)

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

ans = n//(a+b)*a 
x = n%(a+b) 

if x<=a:
  ans += x
else:
  ans += a

print(ans)

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

s = 'b'*a+'r'*b
x = n//(a+b) 
y = n%(a+b) 

print(x*a+s[:y].count('b'))

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

s = 'b'*a+'r'*b
x = n//(a+b) 
y = n%(a+b) 

print(x*a+s[y-1].count('b'))

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

s = 'b'*a+'r'*b
ind = n%(a+b) 

print(s[ind-1])
Problem p02790 (python)

Fixed submission:
a,b = map(int, input().split())
s_1 = str(a)*b
s_2 = str(b)*a

print(s_1 if s_1<=s_2 else s_2)

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

print(_1 if s_1<=s_2 else s_2)
Problem p02881 (python)

Fixed submission:
x = int(input())
cand_list = []

for i in range(1, int(x**(1/2))+1):
    if x%i==0:
      cand_list.append([i, x//i])

ans = min([sum(cand_i)-2 for cand_i in cand_list])
if x == 2:
  ans = 1
elif x == 3:
  ans = 2

print(ans)

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

for i in range(1, int(x**(1/2))):
    if x%i==0:
      cand_list.append([i, x//i])
        
print(min([sum(cand_i)-2 for cand_i in cand_list]))
Problem p02951 (python)

Fixed submission:
a, b, c = map(int, input().split())
 
trans_amount = min(a - b, c)
print(c - trans_amount)

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

trans_amouint = min(b - a, c)
print(c - trans_amount)

Buggy submission (verdict: Runtime Error):
a, b, c = int(input())
print(c - (a - b))
Problem p03012 (python)

Fixed submission:
n = int(input())
w_list = list(map(int, input().split()))
print(min([abs(sum(w_list[:i])-sum(w_list[i:])) for i in range(1, n)]))

Buggy submission (verdict: Runtime Error):
n = int(input())
w_list = list(map(int, input().split()))
print(min([abs(s[:i]-s[i:]) for i in range(1, n)]))
Problem p03013 (python)

Fixed submission:
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

if 1 in A:
  dp_l = [1, 0] + [0]*(n-1)
else:
  dp_l = [1, 1] + [0]*(n-1)

if n==1:
  print(1)
else:
  for i in range(1, len(dp_l)):
    if i in A:
      dp_l[i] = 0
    else:
      dp_l[i] = (dp_l[i-1]+dp_l[i-2])%mod 
  print(dp_l.pop())

Buggy submission (verdict: Runtime Error):
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

dp_l = [1, 1]+[-1]*(n-1)

def dp(n):
  if n in A:
    dp_l[n] = 0
  
  if dp_l[n] == -1:
    dp_l[n] = (dp(n-1)+dp(n-2))%mod
  
  return(dp_l[n])

print(dp(n))

Buggy submission (verdict: Runtime Error):
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

dp_l = [-1]*(n+1)

def dp(n):
  if n in A:
    return(0)
  
  if n==0:
    return(1)
  elif n==1:
    return(1)
  
  if dp_l[n] == -1:
    dp_l[n] = (dp(n-1)+dp(n-2))%mod
    return(dp_l[n])
  else:
    return(dp_l[n])
    
print(dp(n))
Problem p03127 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

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

print(reduce(gcd, A))

Buggy submission (verdict: Runtime Error):
import functools import reduce
import fractions import gcd

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

print(reduce(gcd, A))
Problem p03221 (python)

Fixed submission:
from collections import defaultdict
from bisect import bisect

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

a = defaultdict(list)

for p_i in sorted(p):
  a[p_i[0]].append(p_i[1])
  
for p_i in p:
  x = p_i[0]
  y = bisect(a[x], p_i[1])
  
  print(str(x).zfill(6), str(y).zfill(6), sep='')

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
info = [[i] + list(map(int, input().split())) for i in range(1, m+1)]
city = sorted(set([info_i[0] for info_i in info]))

sorted_info = sorted(info, key=lambda x:x[1])

print(sorted_info)

counter = 0

p = city.pop(0)

for i in range(m):
  if sorted_info[i][1] == p:
    counter += 1
    sorted_info[i].append(counter)
  else:
    p =  city.pop(0)
    counter = 1
    sorted_info[i].append(counter)

result = sorted(sorted_info, key=lambda x:x[0])

for res_i in result:
  print(str(res_i[1]).zfill(6) + str(res_i[3]).zfill(6))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
info = [[i] + list(map(int, input().split())) for i in range(1, m+1)]
city = sorted(set([info_i[0] for info_i in info]))

sorted_info = sorted(info, key=lambda x: [x[1], x[2]])
counter = 0

p = city.pop(0)

for i in range(m):
  if sorted_info[i][1] == p:
    counter += 1
    sorted_info[i].append(counter)
  else:
    p =  city.pop(0)
    counter = 1
    sorted_info[i].append(counter)

result = sorted(sorted_info, key=lambda x:x[0])

for res_i in result:
  print(str(res_i[1]).zfill(6) + str(res_i[3]).zfill(6))
Problem p03329 (python)

Fixed submission:
n = int(input())

counter_min = n

for i in range(n+1):
  counter = 0
  n_six = i
  n_nine = n-i

  # 6
  j = 1
  while True:
    if  n_six >= 6**j:
      j += 1
    else:
      div_n = 6**(j-1)
      break
  
  while n_six > 0:
    counter += n_six // div_n
    n_six %= div_n
    div_n //= 6 
    
  # 9
  j = 1
  while True:
    if  n_nine >= 9**j:
      j += 1
    else:
      div_n = 9**(j-1)
      break
        
  while n_nine > 0:
    counter += n_nine // div_n
    n_nine %= div_n
    div_n //= 9
  
  counter_min = min(counter, counter_min)

print(counter_min)

Buggy submission (verdict: Runtime Error):
import heapq

n = int(input())
max_i = 0

while n>6**max_i:
  max_i+=1
  
cand_list = list(set([-6**i for i in range(max_i)] + [-9**i for i in range(max_i)]))

heapq.heapify(cand_list)
counter = 0

while n > 0:
  cand_n = -1 * heapq.heappop(cand_list)
  while n >= cand_n:
    n -= cand_n
    counter += 1
  
print(counter)

Buggy submission (verdict: Runtime Error):
import heapq

n = int(input())
max_i = 0

while n>6**max_i:
  max_i+=1
  
cand_list = list(set([-6**i for i in range(max_i)] + [-9**i for i in range(max_i)]))

heapq.heapify(cand_list)
counter = 0

while n > 0:
  cand_n = -1 * heapq.heappop(cand_list)
  if n >= cand_n:
    n -= cand_n
    counter += 1
  
print(counter)
Problem p03803 (python)

Fixed submission:
a, b = map(int, input().split())
print('Draw' if a==b else 'Alice' if (a==1)or(b!=1 and a>b) else 'Bob')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print('Draw' if a==b else 'Alice' if (a==1)or(b!=1 and a>b)) else 'Bob')
Problem p02819 (python)

Fixed submission:
import math

x = int(input())


def is_prime(n):
    if n < 2:
        return False
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))


for n in range(100005):
    if n >= x and is_prime(n):
        print(n)
        break

Buggy submission (verdict: Runtime Error):
import sympy

pg = sympy.primerange(2, 100001)

x = int(input())

for p in pg:
    if p >= x:
        print(p)
        break