qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 19 13:18:23 2020

@author: morihiranaoki
"""

D, G = map(int,input().split())
pc = [list(map(int, input().split())) for i in range(D)]
score = [100*i for i in range(D)]

def reverse(depth, limit, stack, all_stack):
    if depth == limit + 1:
        return stack, all_stack

    for i in range(2):
        stack.append(i)
        reverse(depth+1, limit, stack, all_stack)[0]
        if len(stack) == limit:
            all_stack.append(list(stack))
            print(stack)
        del stack[-1]
    return stack, all_stack

Each_Full = [[pc[i][0], pc[i][0]*100*(i+1) + pc[i][1]] for i in range(D)]
_, AllStack = reverse(1, D, [], [])

chosen_Scores = [sum([Each_Full[i][1] for i in range(D) if AllStack[j][i] == 1]) for j in range(len(AllStack))]
chosen_Costs = [sum([Each_Full[i][0] for i in range(D) if AllStack[j][i] == 1]) for j in range(len(AllStack))]

for j in range(len(AllStack)):
    if chosen_Scores[j] >= G:
        continue
    else:
        kari = 0
        for i,factor in enumerate(AllStack[j]):
            if factor == 0:
                kari = i
        for i in range(pc[kari][0]):
            chosen_Scores[j] += (kari+1)*100
            chosen_Costs[j] += 1
            if chosen_Scores[j] >= G:
                break
        else:
            chosen_Costs[j] = 99999

print(min(chosen_Costs))

Fixed code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 19 13:18:23 2020

@author: morihiranaoki
"""

D, G = map(int,input().split())
pc = [list(map(int, input().split())) for i in range(D)]
score = [100*i for i in range(D)]

def reverse(depth, limit, stack, all_stack):
    if depth == limit + 1:
        return stack, all_stack

    for i in range(2):
        stack.append(i)
        reverse(depth+1, limit, stack, all_stack)[0]
        if len(stack) == limit:
            all_stack.append(list(stack))
            #print(stack)
        del stack[-1]
    return stack, all_stack

Each_Full = [[pc[i][0], pc[i][0]*100*(i+1) + pc[i][1]] for i in range(D)]
_, AllStack = reverse(1, D, [], [])

chosen_Scores = [sum([Each_Full[i][1] for i in range(D) if AllStack[j][i] == 1]) for j in range(len(AllStack))]
chosen_Costs = [sum([Each_Full[i][0] for i in range(D) if AllStack[j][i] == 1]) for j in range(len(AllStack))]

for j in range(len(AllStack)):
    if chosen_Scores[j] >= G:
        continue
    else:
        kari = 0
        for i,factor in enumerate(AllStack[j]):
            if factor == 0:
                kari = i
        for i in range(pc[kari][0]):
            chosen_Scores[j] += (kari+1)*100
            chosen_Costs[j] += 1
            if chosen_Scores[j] >= G:
                break
        else:
            chosen_Costs[j] = 99999

print(min(chosen_Costs))
Buggy code:
D,G = map( int,input().split() )
PC = [ list(map(int,input().split())) for i in range(D) ]
ans = 10**7

for i in range(D):
  score=0
  l=0
  for j in range(PC[i][0]-1):
    score += 100*(i+1)
    l += 1
    if score>=G and ans>l:
      ans=l

for i in range(1,2**D):
  score = 0
  l = 0
  k = -1
  for j,flag in enumerate( list(format(i,"b"))[::-1] ):
    if flag=="1":
      score += PC[j][0]*100*(j+1)  + PC[j][1]
      l += PC[j][0]
    else:
      k=j
  if score<G:
    j=0
    while score<G or j<k:
      score+=100*(j+1)
      l+=1
      j+=1
  if ans>l:
    ans=l
            
print(ans)

Fixed code:
D,G = map( int,input().split() )
PC = [ list(map(int,input().split())) for i in range(D) ]
ans = 10**7

for i in range(D):
  score=0
  l=0
  for j in range(PC[i][0]-1):
    score += 100*(i+1)
    l += 1
    if score>=G and ans>l:
      ans=l

for i in range(1,2**D):
  score = 0
  l = 0
  for j,flag in enumerate( list(format(i,"b").zfill(D))[::-1] ):
    if flag=="1":
      score += PC[j][0]*100*(j+1) + PC[j][1]
      l += PC[j][0]
    else:
      k=j
    
  j=0
  while score<G and j<PC[k][0]-1:
    score+=100*(k+1)
    l+=1
    j+=1
  if score>=G and ans>l:
    ans=l
  
print(ans)
Buggy code:
import itertools

D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]
print(pc)

ans = 10**5

for v in itertools.product([0,1],repeat=D):
    p = 0
    t = 0
    for i in range(D):
        if v[i] == 1:
            p += (i+1)*100*pc[i][0] + pc[i][1]
            t += pc[i][0]
    w = G-p
    if w > 0:
        for i in range(D):
            if v[i] == 0 and w <= (i+1)*100*(pc[i][0]-1):
                a = (i+1)*100
                tt = t+(w+a-1)//a
                ans = min(ans,tt)
    else:
        ans = min(ans,t)
print(ans)


Fixed code:
import itertools

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

ans = 10**5

for v in itertools.product([0,1],repeat=D):
    p = 0
    t = 0
    for i in range(D):
        if v[i] == 1:
            p += (i+1)*100*pc[i][0] + pc[i][1]
            t += pc[i][0]
    w = G-p
    if w > 0:
        for i in range(D):
            if v[i] == 0 and w <= (i+1)*100*(pc[i][0]-1):
                a = (i+1)*100
                tt = t+(w+a-1)//a
                ans = min(ans,tt)
    else:
        ans = min(ans,t)
print(ans)
Buggy code:
import math

D, G = list(map(int, input().split()))
pc = [list(map(int, input().split())) for _ in range(D)]

digit = '0'+str(D)+'b'
minimam = float("inf")

for i in range(2**D):
    pattern = list(str(format(i, digit)))
    point = 0
    count = 0
    tmp = -1
    for j in range(D):
        if pattern[j] == "1":
            p = pc[j][0]
            c = pc[j][1]
            point += p*100*(j+1)+c
            count += p
        else:
            tmp = j
    r = G - point
    if r > 0 and tmp > -1:
        countTmp = math.ceil(r/(100*(tmp+1)))
        count += countTmp
        # if countTmp < pc[tmp][0]:
        #     count += countTmp
        # else:
        #     continue
    minimam = min(count, minimam)

print(minimam)


Fixed code:
import math

D, G = list(map(int, input().split()))
pc = [list(map(int, input().split())) for _ in range(D)]

digit = '0'+str(D)+'b'
minimam = float("inf")

for i in range(2**D):
    pattern = list(str(format(i, digit)))
    point = 0
    count = 0
    tmp = -1
    for j in range(D):
        if pattern[j] == "1":
            p = pc[j][0]
            c = pc[j][1]
            point += p*100*(j+1)+c
            count += p
        else:
            tmp = j
    r = G - point
    if r > 0 and tmp > -1:
        countTmp = math.ceil(r/(100*(tmp+1)))
        # count += countTmp
        if countTmp < pc[tmp][0]:
            count += countTmp
        else:
            continue
    minimam = min(count, minimam)

print(minimam)
Buggy code:
d, g = map(int, input().split())
scores = [list(map(int, input().split())) for i in range(d)]
pod = []

for i in range(2 ** d):
    # sep = [0] * n
    # nums = []
    cnt = 0
    point = 0
    for j in range(d):
        if (i >> j) & 1:
            point += 100 * (j + 1) * scores[j][0]
            point += scores[j][1]
            cnt += scores[j][0]
    if point >= g:
        pod.append(cnt)
        continue
    else:
        for p in range(d - 1, -1, -1):
            if not (i >> p) & 1:
                for q in range(1, scores[p][0]):
                    if point < g:
                        point += (p + 1) * 100
                        cnt += 1
    pod.append(cnt)

print(min(pod))

Fixed code:
d, g = map(int, input().split())
scores = [list(map(int, input().split())) for i in range(d)]
pod = []

for i in range(2 ** d):
    cnt = 0
    point = 0
    for j in range(d):
        if (i >> j) & 1:
            point += 100 * (j + 1) * scores[j][0]
            point += scores[j][1]
            cnt += scores[j][0]
    if point >= g:
        pod.append(cnt)
        continue
    else:
        for p in range(d - 1, -1, -1):
            if not (i >> p) & 1:
                for q in range(scores[p][0]):
                    if point < g:
                        point += (p + 1) * 100
                        cnt += 1
                    else:
                        continue
    pod.append(cnt)

print(min(pod))
Buggy code:
import sys
from math import ceil
inputs = sys.stdin.readlines()

d, g = map(int, inputs[0].split())
P = list(map(int, map(lambda x: x.split()[0], inputs[1:])))
C = list(map(int, map(lambda x: x.split()[1], inputs[1:])))

ans = float('inf')
for bit in range(1 << d):
    count, total, rest = 0, 0, set(range(1, d+1))
    for i in range(d):
        if bit & (1 << i):
            total += P[i] * (i + 1) * 100 + C[i]
            count += P[i]
            rest.discard(i + 1)

    if total < g:
        use = max(rest)
#         n = min(P[use-1], ceil((g - total) / (use * 100)))
#         count += n
#         total += n * use * 100
        n = ceil((g - total) / (use * 100))
        if P[use-1] > n:
            count += n
            total += n * use * 100
            ans = min(ans, count)
#     if total >= g:
#         ans = min(ans, count)
print(ans) 



Fixed code:
import sys
from math import ceil
inputs = sys.stdin.readlines()

d, g = map(int, inputs[0].split())
P = list(map(int, map(lambda x: x.split()[0], inputs[1:])))
C = list(map(int, map(lambda x: x.split()[1], inputs[1:])))

ans = float('inf')
for bit in range(1 << d):
    count, total, rest = 0, 0, set(range(1, d+1))
    for i in range(d):
        if bit & (1 << i):
            total += P[i] * (i + 1) * 100 + C[i]
            count += P[i]
            rest.discard(i + 1)

    if total < g:
        use = max(rest)
        n = min(P[use-1], ceil((g - total) / (use * 100)))
        count += n
        total += n * use * 100
    if total >= g:
        ans = min(ans, count)
print(ans)
Buggy code:
import  itertools

d,g=map(int,input().split())
p=[]
c=[]

for i in range(d):
    x,y=map(int,input().split())
    p.append(x)
    c.append(y)

ans=float('inf')

def judge(tmp):
    ss=g
    count=0
    for i in range(d):
        if tmp[i]==1:
            ss-=(i+1)*p[i]*100+c[i]
            count+=p[i]
    if ss>0:
        for i in range(d-1,0,-1):
            if tmp[i]==0:
                if ss<=(i+1)*100*p[i]:
                    if ss%(i+1)*100:
                        count+=ss//((i+1)*100)
                    else:
                        count+=(ss//(i+1)*100)+1
                else:
                    count+=p[i]
                    ss-=(i+1)*100*p[i]+c[i]
    return  count

nums=[0,1]
for sd in itertools.product(nums,repeat=d):
    pat=list(sd)
    sdf=judge(pat)
    ans=min(ans,sdf)

print(ans)

Fixed code:
import  itertools

d,g=map(int,input().split())
p=[]
c=[]

for i in range(d):
    x,y=map(int,input().split())
    p.append(x)
    c.append(y)

ans=float('inf')

def judge(tmp):
    ss=g
    count=0

    for i in range(d):
        if tmp[i]==1:
            ss-=((i+1)*p[i]*100+c[i])
            count+=p[i]
    if ss<=0:

        return count
    else:
        for i in range(d-1,-1,-1):
            if tmp[i]==0:
                if ss%((i+1)*100)==0:
                    fgh=ss//((i+1)*100)
                else:
                    fgh=1+ss//((i+1)*100)

                if fgh>=p[i]:
                    count+=float('inf')
                else:
                    count+=fgh

                ss -= fgh * ((i + 1) * 100)
            if ss<=0:
                
                return count
       
        return count+float('inf')

nums=[0,1]
for sd in itertools.product(nums,repeat=d):
    pat=list(sd)
    sdf=judge(pat)
    ans=min(ans,sdf)

print(ans)
Buggy code:
D,G=[ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(D) ]

import itertools as ite
cmin = 100000000000000000
for cli in ite.product( *([[0,1]]*D) ):
  
  s = 0
  c = 0
  for i in range(D):
    if cli[i]==1:
      s +=  li[i][1] + (i+1)*100*li[i][0]
      c +=  li[i][0]
  #print ( s ,c )
  
  ds = G-s
  
  for i in range(D-1,-1,-1):
    if (ds<=0):
      break
    if cli[i]==0:
      toku = (ds-1)//((i+1)*100)+1
      toku = min(toku,li[i][0])
      c += toku
      ds -= toku*(i+1)*100
    if (ds<=0):
      cmin = min(cmin,c)
print (cmin)

Fixed code:
D,G=[ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(D) ]

import itertools as ite
cmin = 100000000000000000
for cli in ite.product( *([[0,1]]*D) ):
  
  s = 0
  c = 0
  for i in range(D):
    if cli[i]==1:
      s +=  li[i][1] + (i+1)*100*li[i][0]
      c +=  li[i][0]
  
  ds = G-s
  
  for i in range(D-1,-1,-1):
    if (ds<=0):
      break
    if cli[i]==0:
      toku = (ds-1)//((i+1)*100)+1
      toku = min(toku,li[i][0])
      c += toku
      ds -= toku*(i+1)*100
    if (ds<=0):
      break
  if (ds<=0):
    cmin = min(cmin,c)
  else:
    pass
print (cmin)
Buggy code:
def main():
  ans = 1000
  d,g  = map(int,input().split())
  pc = [list(map(int,input().split())) for i in range(d)]
  pc.reverse()
  #print(pc)
  for i in range(1, 2 ** d):
    score = 0
    count = 0
    for j in range(d):
      if i & (1<<j):
        score += pc[j][0] * (d-j) * 100 + pc[j][1]
        count += pc[j][0]
    if score >= g:
      if ans > count:
        ans = count
      #print(bin(i),count,score)
      continue
    for j in range(d):
      if not(i &(1<<j)):
        #print("nokori"+str(j))
        c = 0
        for k in range(1,pc[j][0]):
          score += (d-j) * 100
          count += 1
          c += 1
          if score >= g:
            if ans > count:
              ans = count
            #print(bin(i),j,c,count,score)
            break
        break
  print(ans)

if __name__ == '__main__':
  ans = 0
  main()

Fixed code:
def main():
  ans = 1000
  d,g  = map(int,input().split())
  pc = [list(map(int,input().split())) for i in range(d)]
  pc.reverse()
  #print(pc)
  for i in range( 2 ** d):
    score = 0
    count = 0
    for j in range(d):
      if i & (1<<j):
        score += pc[j][0] * (d-j) * 100 + pc[j][1]
        count += pc[j][0]
    if score >= g:
      if ans > count:
        ans = count
      #print(bin(i),count,score)
      continue
    for j in range(d):
      if not(i &(1<<j)):
        #print("nokori"+str(j))
        c = 0
        for k in range(1,pc[j][0]):
          score += (d-j) * 100
          count += 1
          c += 1
          if score >= g:
            if ans > count:
              ans = count
            #print(bin(i),j,c,count,score)
            break
        break
  print(ans)

if __name__ == '__main__':
  ans = 0
  main()
Buggy code:
D,G = map(int,input().split())
ab = []
for _ in range(D):
    p, c = (int(x) for x in input().split())
    ab.append([p,c])

ans = 10000000

pick_num = []

for i in range(D):
    pick_num.append(i)

for i in range(0,D+1):
    for v in itertools.combinations(pick_num, i):      
        tmp_point = 0
        tmp_count = 0
        for j in v:
            tmp_point += ab[j][0]*(j+1)*100+ab[j][1]
            tmp_count += ab[j][0]
        if tmp_point < G:
            nokori = G-tmp_point
            for k in range(D-1, -1,-1):
                if k not in v:
                    if nokori%(100*(k+1)) == 0:
                        if nokori//(100*(k+1)) < ab[k][0]:
                            tmp_count += nokori//(100*(k+1))
                            tmp_point += nokori
                    else:
                        if nokori//(100*(k+1))+1 < ab[k][0]:
                            tmp_count += nokori//(100*(k+1))+1
                            tmp_point += nokori
                    break
        if G <= tmp_point:
            ans = min(ans, tmp_count)
print(ans)

Fixed code:
import itertools

D,G = map(int,input().split())
ab = []
for _ in range(D):
    p, c = (int(x) for x in input().split())
    ab.append([p,c])

ans = 10000000

pick_num = []

for i in range(D):
    pick_num.append(i)

for i in range(0,D+1):
    for v in itertools.combinations(pick_num, i):      
        tmp_point = 0
        tmp_count = 0
        for j in v:
            tmp_point += ab[j][0]*(j+1)*100+ab[j][1]
            tmp_count += ab[j][0]
        if tmp_point < G:
            nokori = G-tmp_point
            for k in range(D-1, -1,-1):
                if k not in v:
                    if nokori%(100*(k+1)) == 0:
                        if nokori//(100*(k+1)) < ab[k][0]:
                            tmp_count += nokori//(100*(k+1))
                            tmp_point += nokori
                    else:
                        if nokori//(100*(k+1))+1 < ab[k][0]:
                            tmp_count += nokori//(100*(k+1))+1
                            tmp_point += nokori
                    break
        if G <= tmp_point:
            ans = min(ans, tmp_count)
print(ans)
Buggy code:
d,g=map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(d)]
ans = float("inf")

for bit in range(1<<d):
  sum=0
  count=0
  nokori=set(range(1,d+1))
  for i in range(d):
    if bit&(1<<i):
      sum += pc[i][0]*100*(i+1)+pc[i][1]
      count+= pc[i][0]
  if sum<g:
    a=g-sum
    num=max(nokori)
    n=min(pc[num-1][0],-(-a//(num*100)))
    count+=n
    sum+=n*num*100
  if sum>=g:
    ans=min(ans,count)
print(ans)

Fixed code:
d,g=map(int,input().split())
pc = [list(map(int,input().split())) for _ in range(d)]
ans = float("inf")

for bit in range(1<<d):
  sum=0
  count=0
  nokori=set(range(1,d+1))
  for i in range(d):
    if bit&(1<<i):
      sum += pc[i][0]*100*(i+1)+pc[i][1]
      count+= pc[i][0]
      nokori.discard(i + 1)
  if sum<g:
    a=g-sum
    num=max(nokori)
    n=min(pc[num-1][0],-(-a//(num*100)))
    count+=n
    sum+=n*num*100
  if sum>=g:
    ans=min(ans,count)
print(ans)
Buggy code:
D, G = map(int, input().split())
pc = [[i + 1] + [int(x) for x in input().split()] for i in range(D)]

import math, functools
def f(cur, n, left):
    if left <= 0:
        return n
    def g(cur, n, left):
        if cur in m: return m[cur]
        r = m[cur] = f(cur, n, left)
        return r
    ret = 10**9
    for x in pc:
        i, p, c = x
        if (1 << i) & cur: continue
        ip = i*100*p
        if ip > left:
            h = math.ceil(left / (i*100))
            ret = min(ret, n + h)
        else:
            if n + p >= ret: continue
            h = g(cur | (1 << i), n + p, left - ip - c)
            ret = min(ret, h)
    return ret

print(f(0, 0, G))

Fixed code:
D, G = map(int, input().split())
pc = [[i + 1] + [int(x) for x in input().split()] for i in range(D)]

import math
m = {}
def f(cur, n, left):
    if left <= 0:
        return n
    def g(cur, n, left):
        if cur in m: return m[cur]
        r = m[cur] = f(cur, n, left)
        return r
    ret = 10**9
    for x in pc:
        i, p, c = x
        if (1 << i) & cur: continue
        ip = i*100*p
        if ip > left:
            h = math.ceil(left / (i*100))
            ret = min(ret, n + h)
        else:
            if n + p >= ret: continue
            h = g(cur | (1 << i), n + p, left - ip - c)
            ret = min(ret, h)
    return ret

print(f(0, 0, G))
Buggy code:
# -*- coding: utf-8 -*-
D, G = map(int, input().split(' '))
p_c_pairs = [((i+1) * 100, list(map(int, input().split(' ')))) for i in range(D)]

import math
ans = float('inf')
p_c_pairs.sort(key=lambda x: -x[0])
for d in range((D+1)**2):
    print(bin(d))

    cnt = 0
    g = G
    for i in range(D):
        if 1 & (d >> i):
            score, (p, c) = p_c_pairs[i]
            g -= score * p + c
            cnt += p

    if g > 0:
        for i in range(D):
            if not (1 & (d >> i)):
                score, (p, c) = p_c_pairs[i]
                n = min(p, int(math.ceil(g/score)))
                g -= score * n
                cnt += n
                break

    # print(bin(d), g)
    if g <= 0:
        ans = min(ans, cnt)

print(ans)

Fixed code:
# -*- coding: utf-8 -*-
D, G = map(int, input().split(' '))
p_c_pairs = [((i+1) * 100, list(map(int, input().split(' ')))) for i in range(D)]

import math
ans = float('inf')
p_c_pairs.sort(key=lambda x: -x[0])
for d in range(1<<D):
    # print(bin(d))

    cnt = 0
    g = G
    for i in range(D):
        if 1 & (d >> i):
            score, (p, c) = p_c_pairs[i]
            g -= score * p + c
            cnt += p

    if g > 0:
        for i in range(D):
            if not (1 & (d >> i)):
                score, (p, c) = p_c_pairs[i]
                n = min(p, int(math.ceil(g/score)))
                g -= score * n
                cnt += n
                break

    # print(bin(d), g)
    if g <= 0:
        ans = min(ans, cnt)

print(ans)
Buggy code:
D,G = list(map(int,input().split()))
pc = []
for i in range(D):
    pc.append(list(map(int,input().split())))

scoreList = [0 for i in range(D)]

for i in range(D):
    scoreList[i] = (i + 1) * 100 * pc[i][0] + pc[i][1]

choiceList = [[] for i in range(2 ** D)]
for i in range(2 ** D):
    for j in range(D):
        choiceList[i].append(i // (2 ** j) % 2)

minCount = 10 ** 8
for choice in choiceList:
    score = 0
    count = 0
    for i in range(len(choice)):
        if choice[i] == 1:
            score += scoreList[i]
            count += pc[i][0]
    for j in range(D):
        countTmp = count
        extraScore = (j + 1) * 100 * pc[j][0]
        delta = G - score
        if delta < 0 or choice[j] == 1:
            countTmp = 10 ** 8
        elif delta == 0:
            countTmp = count
        elif delta > 0:
            if delta <= extraScore:
                countTmp += delta // ((j + 1) * 100)
                if delta % ((j + 1) * 100) > 0:
                    countTmp += 1
            else:
                countTmp = 10 ** 8
        if countTmp < minCount:
            minCount = countTmp
print(minCount)

Fixed code:
D,G = list(map(int,input().split()))
pc = []
for i in range(D):
    pc.append(list(map(int,input().split())))

scoreList = [0 for i in range(D)]

for i in range(D):
    scoreList[i] = (i + 1) * 100 * pc[i][0] + pc[i][1]

choiceList = [[] for i in range(2 ** D)]
for i in range(2 ** D):
    for j in range(D):
        choiceList[i].append(i // (2 ** j) % 2)

minCount = 10 ** 8
for choice in choiceList:
    score = 0
    count = 0
    for i in range(len(choice)):
        if choice[i] == 1:
            score += scoreList[i]
            count += pc[i][0]
    for j in range(D):
        countTmp = count
        extraScore = (j + 1) * 100 * pc[j][0]
        delta = G - score
        if delta < 0:
            countTmp = count
        elif delta == 0:
            countTmp = count
        elif delta > 0:
            if delta <= extraScore and choice[j] == 0:
                countTmp += delta // ((j + 1) * 100)
                if delta % ((j + 1) * 100) > 0:
                    countTmp += 1
            else:
                countTmp = 10 ** 8
        if countTmp < minCount:
            minCount = countTmp
print(minCount)