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

Fixed submission:
d = input().split()
N = int(d[0])
M = int(d[1])
d = input().split()
As = [int(num) for num in d]
As.sort()


def main():
    lis = []
    for i in range(1, M+1):
        d = input().split()
        b = int(d[0])
        c = int(d[1])
        lis.append([c, b])
    lis = sorted(lis,key=lambda x:(-x[0], x[1]))
    count = 0
    asum = 0
    tmp = [0 for i in range(N)]
    for c, b in lis:
        if count < N:
            for i in range(count, b+count):
                if i < N:
                    tmp[i] = c
            count += b
    for i in range(N):
        if tmp[i] > As[i]:
            asum += tmp[i]
        else:
            asum += As[i]
    print(asum)
        

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
d = input().split()
N = int(d[0])
M = int(d[1])
d = input().split()
As = [int(num) for num in d]
As.sort()


def main():
    dic = {}
    lis = []
    for i in range(1, M+1):
        d = input().split()
        b = int(d[0])
        c = int(d[1])
        lis.append([c, b])
        dic[c] = b
    dic = sorted(dic.items(), key=lambda x:(-x[0], x[1]))
    lis = sorted(lis,key=lambda x:(-x[0], x[1]))
    count = 0
    asum = 0
    tmp = [0 for i in range(N)]
    for c, b in lis:
        for i in range(count, b+count):
            tmp[i] = c
        count += b
    for i in range(N):
        if tmp[i] > As[i]:
            asum += tmp[i]
        else:
            asum += As[i]
    print(asum)
        

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

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
  
n = int(input())
d = make_divisors(n)
d.sort()
a = []
for i in range(len(d)-1):
  b = n // d[i]
  if b == d[i]:
    a.append([d[i], d[i]])
    break
  for j in range(i+1, len(d)):
    if b == d[j]:
      a.append([d[i], d[j]])
      break
m = n
ind = 0
for i in a:
  if abs(i[0]-i[1]) < m:
    m = abs(i[0]-i[1])
    ind = a.index(i)

print(a[ind][0]+a[ind][1]-2)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
n = int(input())
d = make_divisors(n)
d.sort()
a = []
for i in range(len(d)-1):
  if d[i]**2==n:
    a.append(d[i], d[i])
    continue
  for j in range(i+1, len(d)):
    if d[i] * d[j] == n:
      a.append([d[i], d[j]])
      break
m = n
ind = 0
for i in a:
  if abs(i[0]-i[1]) < m:
    m = abs(i[0]-i[1])
    ind = a.index(i)

print(a[ind][0]+a[ind][1]-2)
Problem p02831 (python)

Fixed submission:
import fractions

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

print(A * B // fractions.gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math

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

print(int((A * B) / math.gcd(A, B)))

Buggy submission (verdict: Runtime Error):
import math

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

print((A * B) // math.gcd(A, B))
Problem p02835 (python)

Fixed submission:
i = input()

l = i.split()
l = [int(e) for e in l]

if sum(l) >= 22:
    print('bust')
else:
    print('win')

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

l = i.split()

if sum(l) >= 22:
    print('bust')
else:
    print('win')
Problem p03041 (python)

Fixed submission:
a, b = map(int, input().split())
c = input()
c = list(c)
if (c[b-1] == 'A'):
    c[b-1] = 'a'
if (c[b-1] == 'B'):
    c[b-1] = 'b'
if (c[b-1] == 'C'):
    c[b-1] = 'c'
c = ''.join(c)
print('{}'.format(c))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = list(input())
s[b] = s[b].lower()
s = str(s)
print('{}'.format(s))
Problem p02831 (python)

Fixed submission:
A, B = map(int,input().split())
 
n = max(A,B)
m= min(A,B)
count = 1
while True:
    if (n*count)%m == 0:
        print(n*count)
        break
    else:
        count += 1

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

ans = (A * B) // math.gcd(A, B)
print(ans)
Problem p02897 (python)

Fixed submission:
# coding: utf-8
# Your code here!
N = int(input())
 
if N%2 == 0:
     print(0.5)
else:
    print(1-int(N/2)/N)

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int,input().split())

def soinsu(test):
    list_sosu = []
    x = 0
    while x==0:
        for i in range(2,test+1):
            if i > math.sqrt(test):
                list_sosu.append(test)
                x = 1
                break
            elif test % i == 0:
                test = int(test/i)
                if test == 1:
                    x = 1
                list_sosu.append(i)
                break
    return set(list_sosu)

if A == 1 or B == 1:
    print(1)
    
else:
    print(len(soinsu(A)&soinsu(B))+1)
Problem p02987 (python)

Fixed submission:
S = input()

S = list(S)
S.sort()
if S[0] == S[1] and S[2] == S[3]:
    if S[1]!=S[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

N, M = map(int,input().split())
hen = [list(map(int,input().split())) for i in range(M)]
S, T = map(int,input().split())
hen2 = []
for i in range(N):
    a = []
    for j in hen:
        if j[0]==i+1:
            a.append(j[1])
    hen2.append(a)

queue = [[S,0]]
check = []
dist = [0]

while True:
    if queue == []:
        print(-1)
        break
    Now = queue.pop(0)
    ndist = dist.pop(0)
    if Now == [T,0]:
        print(int(ndist/3))
        break
    
    check.append(Now)
    for i in hen2[Now[0]-1]:
        if [i,(Now[1]+1)%3] not in check:
            queue.append([i,(Now[1]+1)%3])
            dist.append(ndist+1)
Problem p02990 (python)

Fixed submission:
import math
N,K = map(int,input().split())
mod = 1000000007

for j in range(K):
    i = j+1
    p = N-K+1-i
    if p <0:
        p = 0
    x = math.factorial(K-1)//(math.factorial(K-i)*math.factorial(i-1))
    y = math.factorial(N-K+1)//(math.factorial(p)*math.factorial(i))
    ans = x*y
    ans = int(ans%mod)
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
mod = 1000000007

for j in range(K):
    i = j+1
    x = math.factorial(K-1)//(math.factorial(K-i)*math.factorial(i-1))
    y = math.factorial(N-K+1)//(math.factorial(N-K+1-i)*math.factorial(i))
    ans = x*y
    ans = int(ans%mod)
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())
mod = 1000000007

for j in range(K):
    i = j+1
    x = math.factorial(K-1)/math.factorial(K-i)//math.factorial(i-1)
    y = math.factorial(N-K+1)/math.factorial(N-K+1-i)//math.factorial(i)
    ans = int(x*y)
    ans = ans%mod
    print(ans)
Problem p03077 (python)

Fixed submission:
N=int(input()) 
A=int(input()) 
B=int(input()) 
C=int(input()) 
D=int(input()) 
E=int(input())

x = [A,B,C,D,E] 
pace = min(x) 
y = int(N/pace)
if pace == 1:
    print(y+4)
else:
    print(y+5)

Buggy submission (verdict: Runtime Error):
N=int(input()) 
A=int(input()) 
B=int(input()) 
C=int(input()) 
D=int(input()) 
E=int(input())

x = [A,B,C,D,E] 
pace = min(x) 
y = int(N/pace)
if pace = 1:
    print(y+4)
else:
    print(y+5)
Problem p03017 (python)

Fixed submission:
N, A, B, C, D = map(int, input().split(' '))
S = input()
blocks = [i+1 for i, s in enumerate([s for s in S]) if s == '#']

if '##' in S[A-1:C] or '##' in S[B-1:D]:
    print('No')
elif C < D:
    if S[C-1] == '.' and S[D-1] == '.':
        print('Yes')
    else:
        print('No')
else:
    if '...' in S[max(0, B - 2):D+1]:
        print('Yes')
    else:
        print('No')

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

N, A, B, C, D = map(int, input().split(' '))
S = input()
blocks = [i+1 for i, s in enumerate([s for s in S]) if s == '#']
flag = False
check_set = set()

que = deque([(A, B)])
while que:
    A, B = que.pop()
    check_list.add((A, B))
    if A == C and B == D:
        flag = True
        break
    for i in range(3):
        for j in range(3):
            if i == j == 0:
                continue
            if A+i <= C and B+j <= D and A+i != B+j and (A+i) not in blocks and (B+j) not in blocks:
                if (A+i, B+j) not in check_set:
                    que.append((A+i, B+j))

if flag:
    print('Yes')
else:
    print('No')
Problem p02860 (python)

Fixed submission:
n = int(input())
t = list(str(input()))
if n%2 == 1:
    print("No")
else:
    ans = True
    a = ["" for i in range(int(n/2))]
    b = ["" for i in range(int(n/2))]
    for i in range(int(n/2)):
        a[i] = t[i]
        b[i] = t[int(n/2)+i]
    for i in range(int(n/2)):
        ans = ans and a[i] == b[i]
    if ans:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
t = list(str(input()))
if n%2 == 1:
    print("No")
else:
    ans = True
    a = ["" for i in range(int(n/2))]
    b = ["" for i in range(int(n/2))]
    for i in range(int(n/2)):
        a[i] = t[i]
        b[i] = t[int(n/2)+i]
    for i in range(int(n/2)):
        ans = ans and a[i] == b[i]
if ans:
    print("Yes")
else:
    print("No")
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
print(a*b//gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(a*b//math.gcd(a,b))
Problem p03127 (python)

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

n=int(input())
x=list(map(int,input().split()))
a=x[0]
for i in range(1,n):
    a=gcd(a,x[i])
print(a)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0: return a
    return gcd(b,a%b)

n=int(input())
x=[*map(int,input().split())]
a=x[0]
for i in range(1,n):
    a=gcd(a,x[i])
print(a)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
x=[*map(int,input().split())]
a=x[0]
for i in range(1,n):
    a=math.gcd(a,x[i])
print(a)
Problem p02831 (python)

Fixed submission:
def GCD(a, b):
    while a:
        a, b = b % a, a
    return b


def main():
    A, B = map(int, input().split())
    print(A // GCD(A, B) * B)


main()

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while a:
        a, b = b % a, a
    return b

A, B = map(int, input().split())
print(A // GCD(A, B) * B)
Problem p02831 (python)

Fixed submission:
import fractions
def lcm(x,y):
	return (x*y)//fractions.gcd(x,y)

def main():
	a,b = map(int,input().split())
	print(lcm(a,b))

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import fractions
def lcm(x,y):
	return (x*y)//math.gcd(x,y)

def main():
	a,b = map(int,input().split())
	print(lcm(a,b))

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import math
def lcm(x,y):
	return (x*y)//math.gcd(x,y)

a,b = map(int,input().split())
print(lcm(a,b))
Problem p03075 (python)

Fixed submission:
s = []
for i in range(5):
  s.append(int(input()))
k = int(input())
if max(s) - min(s) > k:
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
s = []
for i in range(5):
  s.append(int(input()))
k = int(input())
if max(s) - min(s) =< k:
  print("Yay!")
else:
  print(":(")
Problem p03209 (python)

Fixed submission:
n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  if k == 0:
    return 0
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  else:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  if k == 0:
    return 0
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  elif k == a[n-1]+2:
    return p[n-1]+1
  elif k <= a[n]*2+3:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  if k == 0:
    return 0
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  elif k == p[n]:
    return p[n-1]+1
  elif k <= a[n]*2+3:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if k == 0:
    return 0
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  elif k == p[n]:
    return p[n-1]+1
  elif k <= a[n]*2+3:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 1:
    if k == 0:
      return 0
    else:
      return 1
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  elif k == p[n]:
    return p[n-1]+1
  elif k <= a[n]*2+3:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
a,p=[1],[1] for i in range(N):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)
def f(N,X): #X<=0やX>a_Nを許容し解説本文から簡略化
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
a,p=[1],[1] for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
def f(N,X): #X<=0やX>a_Nを許容し解説本文から簡略化
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(x,y):
  if y == 1:
    return 0
  elif y <= a[x-1]+1:
    return f(x-1,y-1)
  elif y == p[x]:
    return p[x-1]+1
  elif y <= a[x]*2+3:
    return p[x-1]+1+f(x-1,y-2-a[x-1])
print(f(n,k))
Problem p02935 (python)

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

for i in range(N-1):
    v[i+1] = (v[i]+v[i+1]) / 2

print(v[N-1])

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

for i in range(N-1):
    v[i+1] = (v[i]+v[i+1]) / 2

print(v[n-1])
Problem p03011 (python)

Fixed submission:
P, Q, R = map(int,input().split())
l = [P+Q, Q+R, R+P]
print(min(l))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
a = list(map(int,input().split()))
p = 10**9 + 7
a.insert(0, -1)
a.append(N+1)

def mod(n,p):
    return n % p

nk = [1]
for i in range(1,N+1):
    nk.append(mod((nk[-1] * i), p))

#ある数をAで割ったとき，その数をpで割ったときの余りを求めるのにかけるべき数を返す
def bunbo(A, p): 
    # p-2を2進数にする
    pp = p-2
    pb = list(str(format(pp, 'b')))
    # ひっくりかえす
    pb.reverse()
    # pbの要素の数lとして，A^1, A^2, A^4, A^8, ..., A^(2^l)をpで割った余りを求める
    lpp = [mod(A,p)]
    for _ in range(len(pb)-1):
        lpp.append(mod((lpp[-1] ** 2), p))
    # 必要なやつだけ足して，x=(A^(p-2)をpで割った余り)を求める
    x = 1
    for i in range(len(pb)):
        if pb[i] == '1':
            x *= lpp[i]
    return mod(x, p)
    
def nckp(a, b, c, p):
    # 0!, 1!, 2!, 3!, ..., n!をリストに入れる
    return mod((a * bunbo(b, p) * bunbo(c, p)),p)



for i in range(M-2):
    if a[i+1] - a[i] == 1:
        print(0)
        break
else:
    ans = 1
    for j in range(len(a)-1):
        if a[j] != N:
            up = a[j+1] - a[j] - 2
            step = 0
            for l in range(up//2 + 1):
                way = nckp(nk[up-l], nk[l], nk[up-2*l], p)
                step += way
            ans *= step
    print(mod(ans, p))
Problem p03315 (python)

Fixed submission:
S = input()
plus = S.count('+')
minus = S.count('-')
print( plus - minus )

Buggy submission (verdict: Runtime Error):
S = input()
plus = count('+')
minus = count('-')
print( plus - minus )
Problem p02832 (python)

Fixed submission:
N = int(input())
li_str = input().split()
li_int = []
for i in li_str:
    li_int.append(int(i))
count= 1
num =  N + 1
for i in li_int:
    if i == count:
        num = count
        count += 1
print(N - num)

Buggy submission (verdict: Runtime Error):
N = int(input())
li_str = input().split()
li_int = []
for i in li_str:
    li_int.append(int(i))
count= 1
for i in li_int:
    if i == count:
        num = count
        count += 1
print(N - num)

Buggy submission (verdict: Runtime Error):
N = int(input())
li_str = input().split()
li_int = []

for i in li_str:
    li_int.append(int(i))
count= 1
for i in li_int:
    if i == count:
        count += 1
        num = count
print(num)
Problem p02891 (python)

Fixed submission:
from itertools import groupby
s = input()
k = int(input())
l = [[k, len(list(g))] for k, g in groupby(s)]
ans = 0
ans2 = 0
for i in range(len(l)):
  if l[i][1] > 1:
    ans += l[i][1] // 2
if len(l) > 1:
  if l[0][0] == l[-1][0]:
    if l[0][1] % 2 == 1 and  l[-1][1] % 2 == 1 :
        ans2 = k - 1
if len(s) == 1:
  print(k // 2)
elif len(l) == 1:
  #if l[0][1] % 2 == 1:
  #  print(((l[0][1] // 2) * k + (k - 1)))
  #else:
  print(len(s) * k // 2)
else:
  print(ans * k + ans2)

Buggy submission (verdict: Runtime Error):
from itertools import groupby
s = input()
k = int(input())
l = [[k, len(list(g))] for k, g in groupby(s)]
ans = 0
ans2 = 0
for i in range(len(l)):
  if l[i][1] > 1:
    ans += l[i][1] // 2
if len(l) > 1:
  if l[0][0] == l[-1][0]:
    if l[0][1] % 2 == 1 and  l[-1][1] % 2 == 1 :
        ans2 = k - 1
if len(s) == 1:
  print(k // 2)
elif len(l) == 1:
  if l[0][1] % 2 == 1:
    print(((l[0][1] // 2) * k + (k - 1))
  else:
    print((l[0][1] // 2) * k)
else:
  print(ans * k + ans2)
Problem p02912 (python)

Fixed submission:
import heapq
import math
n,m=map(int,input().split())
a = list(map(int,input().split()))
h = []
for _a in a:
  heapq.heappush(h,-_a)
for i in range(m):
  heapq.heappush(h,math.ceil(heapq.heappop(h) / 2))
print(sum(h)*(-1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
t = [a.pop(0)//2]

for i in range(0,m - 1):
  l = t.index(max(t))
  if a[0] > t[l]:
    t.append(a.pop(0)//2)
  else:
    t[l] = t[l]//2
print(sum(t) + sum(a))
Problem p03003 (python)

Fixed submission:
mod=1e9+7
import sys
input=sys.stdin.readline

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    S=list(map(int,input().split()))
    T=list(map(int,input().split()))
    sum=[[0 for i in range(M+1)] for j in range(N+1)]
    dp=[[0 for i in range(M+1)] for j in range(N+1)]

    for i in range(N):
        for j in range(M):
            if S[i]==T[j]:
                dp[i+1][j+1]+=sum[i][j]+1
                dp[i+1][j+1]%=mod
            else:
                dp[i + 1][j + 1] =0

            sum[i+1][j+1]=sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1]
            sum[i + 1][j + 1]%=mod


    ans=sum[N][M]+1
    print(int(ans))

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
mod=1e9+7

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    S=list(map(int,input().split()))
    T=list(map(int,input().split()))
    dp=[[0 for i in range(M+1)] for j in range(N+1)]
    for i in range(N+1):
        dp[i][0]=1
    for i in range(M+1):
        dp[0][i]=1


    for i in range(N):
        for j in range(M):
            dp[i + 1][j + 1] = dp[i + 1][j]+dp[i ][j + 1]-dp[i][j]
            if S[i]==T[j]:
                dp[i+1][j+1]+=dp[i][j]

    print(int(dp[N][M]%mod))
Problem p03329 (python)

Fixed submission:

if __name__ == '__main__':
    N=int(input())

    dp=[100000000000]*(N+1)
    for i in range(min(6,N+1)):
        dp[i]=i
    for i in range(N+1):
        for j in range(1,7):
            if i+6**j<=N:
                dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
        for j in range(1, 6):
            if i + 9 ** j <= N:
                dp[i + 9 ** j] = min(dp[i + 9 ** j], dp[i] + 1)


    print(dp[N])

Buggy submission (verdict: Runtime Error):
import math

if __name__ == '__main__':
    N=int(input())
    power_nine=int(math.log(N,9)+1)
    power_six=int(math.log(N,6)+1)

    dp=[math.inf]*(N+1)
    for i in range(min(6,N+1)):
        dp[i]=i
    for i in range(N+1):
        for j in range(1,power_six):
            if i+6**j<=N:
                dp[i+6**j]=min(dp[i+6**j],dp[i]+1)
        for j in range(1, power_nine):
            if i + 9 ** j <= N:
                dp[i + 9 ** j] = min(dp[i + 9 ** j], dp[i] + 1)


    print(dp[N])
Problem p03806 (python)

Fixed submission:
if __name__ == '__main__':
    N,M_a,M_b=list(map(int,input().split()))
    A,B,C=[],[],[]
    for i in range(N):
        a,b,c=list(map(int,input().split()))
        A.append(a)
        B.append(b)
        C.append(c)

    dp=[[[1e10 for i in range(sum(B)+max(B)+1)] for j in range(sum(A)+max(A)+1)] for k in range(N+1)]
    dp[0][0][0]=0

    for i in range(N):
        for c_a in range(sum(A)+1):
            for c_b in range(sum(B)+1):
                if dp[i][c_a][c_b]==1e10:
                    continue
                dp[i+1][c_a][c_b]=min(dp[i+1][c_a][c_b],dp[i][c_a][c_b])
                dp[i+1][c_a+A[i]][c_b+B[i]]=min(dp[i+1][c_a+A[i]][c_b+B[i]],dp[i][c_a][c_b]+C[i])
    ans_list=[1e10]
    for c_a in range(1,sum(A)+1):
        for c_b in range(1,sum(B)+1):
            if c_a*M_b==c_b*M_a:
                ans_list.append(dp[N][c_a][c_b])
    ans=min(ans_list)
    if  ans==1e10:
        print(-1)
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
import numpy

if __name__ == '__main__':
    N,M_a,M_b=list(map(int,input().split()))
    A,B,C=[],[],[]
    for i in range(N):
        a,b,c=list(map(int,input().split()))
        A.append(a)
        B.append(b)
        C.append(c)

    dp=[[[1e10 for i in range(max(B)*(N+1))] for j in range(max(A)*(N+1))] for k in range(N+1)]
    dp[0][0][0]=0

    for i in range(N):
        for c_a in range(max(A)*N):
            for c_b in range(max(B)*N):
                if dp[i][c_a][c_b]==1e10:
                    continue
                dp[i+1][c_a][c_b]=min(dp[i+1][c_a][c_b],dp[i][c_a][c_b])
                dp[i+1][c_a+A[i]][c_b+B[i]]=min(dp[i+1][c_a+A[i]][c_b+B[i]],dp[i][c_a][c_b]+C[i])
    ans_list=[1e10]
    for c_a in A:
        for c_b in B:
            if c_a*M_b==c_b*M_a:
                ans_list.append(dp[N][c_a][c_b])

    ans=min(ans_list)

    if  ans==1e10:
        print(-1)
    else:
        print(ans)
Problem p03013 (python)

Fixed submission:
n,m=list(map(int,input().split()))
a=[False]*100001
for i in range(m):
    a[int(input())]=True

ans=[0]*100001
ans[0]=1
if a[1]:
    ans[1]=0
else:
    ans[1]=1

for i in range(2,n+1):
    if a[i]:
        ans[i]=0
    else:
        ans[i]=ans[i-1]+ans[i-2]
print(ans[n]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=list(map(int,input().split()))
a=[False]*100000
for i in range(m):
    a[int(input())]=True

ans=[0]*100001
ans[0]=1
if a[1]:
    ans[1]=0
else:
    ans[1]=1

for i in range(2,n+1):
    if a[i]:
        ans[i]=0
    else:
        ans[i]=ans[i-1]+ans[i-2]
print(ans[n]%1000000007)