qyliang/CodeNanoFix huggingface dataset:
Buggy code:
d, g = map(int, input().split())
problem = [list(map(int, input().split())) for i in range(d)]

mincost = float('inf')

for i in range(2**d):
    count = 0
    score = 0
    flag = [0 for _ in range(d)]
    for j in range(d):
        if i >> j == 1:
            flag[j] = 1
            count += problem[j][0]
            score += problem[j][0] * 100 * (j+1) + problem[j][1]
    for k in range(d-1, -1, -1):
        if score >= g:
            mincost = min(mincost, count)
            break
        if flag[k] == 0:
            num = 0
            while num <= problem[k][0] - 1:
                num += 1
                count += 1
                score += 100 * (k+1)
                if score >= g:
                    mincost = min(mincost, count)
                    break
            break

print(mincost)

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

mincost = float('inf')

for i in range(2**d):
    count = 0
    score = 0
    flag = [0 for _ in range(d)]
    for j in range(d):
        if i >> j & 1 == 1:
            flag[j] = 1
            count += problem[j][0]
            score += problem[j][0] * 100 * (j+1) + problem[j][1]
    for k in range(d-1, -1, -1):
        if score >= g:
            mincost = min(mincost, count)
            break
        if flag[k] == 0:
            num = 0
            while num <= problem[k][0] - 1:
                num += 1
                count += 1
                score += 100 * (k+1)
                if score >= g:
                    mincost = min(mincost, count)
                    break
            break

print(mincost)
Buggy code:
D, G = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(D)]

for i in range(D):
    b = [[List[i][0], List[i][0]*(i+1)*100+List[i][1]] for i in range(D)]
    
m = 10**9
for j in range(1, 2**D):
    cnt = 0
    score = 0
    flg = 0
    for k in range(D):
        if ((j>>k)&1):
            cnt+=b[k][0]
            score+=b[k][1]
            flg+=1
            used = k
        else:
            unused = k
    if G<=score:
        if flg==1:
            cnt = -(-G//((used+1)*100))
            if cnt<m:
                m = cnt
        else:
            if cnt<m:
                m = cnt
                
    else: 
        diff = G-score
        offset = -(-diff//((unused+1)*100))
        cnt += offset
        if offset<List[unused][0]:
            if cnt<m:
                m = cnt
print(m)

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

for i in range(D):
    b = [[List[i][0], List[i][0]*(i+1)*100+List[i][1]] for i in range(D)]
    
m = 10**9
for j in range(2**D):
    cnt = 0
    score = 0
    flg = 0
    for k in range(D):
        if ((j>>k)&1):
            cnt+=b[k][0]
            score+=b[k][1]
            flg+=1
            used = k
        else:
            unused = k
    if G<=score:
        if flg==1:
            cnt = min(-(-G//((used+1)*100)), cnt)
            if cnt<m:
                m = cnt
        else:
            if cnt<m:
                m = cnt
                
    else: 
        diff = G-score
        offset = -(-diff//((unused+1)*100))
        cnt += offset
        if offset<List[unused][0]:
            if cnt<m:
                m = cnt
print(m)
Buggy code:
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]

ans = float("inf")

for bit in range(1 << D):
    count = 0
    sum = 0
    rest = list(range(1, D+1))

    for i in range(D):
        if bit & (1 << i):
            sum += 100 * i * pc[i][0] + pc[i][1]
            count += pc[i][0]
            rest.remove(i+1)
    if sum < G:
        max_num = max(rest)
        n = min(pc[max_num - 1][0], (G - sum) // (max_num * 100))
        count += n
        sum += n*max_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 i in range(D)]

ans = float("inf")

for bit in range(1 << D):
    count = 0
    sum = 0
    rest = list(range(1, D+1))

    for i in range(D):
        if bit & (1 << i):
            sum += (i + 1) * pc[i][0] * 100 + pc[i][1]
            count += pc[i][0]
            rest.remove(i + 1)

    if sum < G:
        max_num = max(rest)
        n = min(pc[max_num - 1][0], -(-(G - sum) // (max_num * 100)))
        count += n
        sum += n * max_num * 100

    if sum >= G:
        ans = min(ans, count)

print(ans)
Buggy code:
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]
ans = 10**9
for i in range(2**D):
  score=0
  n=0
  done=""
  for j in range(D):
    if (i>>j)&1:
      score += 100*(j+1)*pc[j][0]+pc[j][1]
      n += pc[j][0]
      done+=str(j)
  if score < G:
    for k in range(D):
      if str(k) in done:
        continue
      for l in range(pc[D-k-1][0]):
        score += 100*(D-k)
        n += 1
        if score >= G:
          break
      if score >= G:
        break
  ans = min(ans,n)
print(ans)

Fixed code:
D,G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]
ans = 10**9
for i in range(2**D):
  score=0
  n=0
  done=""
  for j in range(D):
    if (i>>j)&1:
      score += 100*(j+1)*pc[j][0]+pc[j][1]
      n += pc[j][0]
      done+=str(j)
  if score < G:
    for k in range(D):
      if str(D-k-1) in done:
        continue
      for l in range(pc[D-k-1][0]):
        score += 100*(D-k)
        n += 1
        if score >= G:
          break
      if score >= G:
        break
  ans = min(ans,n)
print(ans)
Buggy code:
d,g = map(int,input().split())
info = [list(map(int,input().split())) for i in range(d)]

complete=[None]*d
for i in range(d):
  complete[i] = info[i][0]*(100*i+100) + info[i][1]
  #print(complete[i])

ans = 1000

for i in range(1,2**(d)):
  bin_i = str("0"*(d+2-len(bin(i)))+str(bin(i))[2:])
  #print(bin_i)
  
  summation=0
  count=0
  index_0=-1
  
  for j in range(d):
    if bin_i[j]=="1":
      summation += complete[j]
      count +=info[j][0]
    else:
      index_0 = j
      
  if summation >= g:
    ans = min(ans,count)
  elif summation < g:
    tmp_g = g
    for j in range(info[index_0][0]):
      tmp_g = tmp_g-100*(index_0+1)
      count +=1
      if summation >= tmp_g:
        ans = min(ans,count)
        break
  #print(ans)
  
print(ans)



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

complete=[None]*d
for i in range(d):
  complete[i] = info[i][0]*(100*i+100) + info[i][1]
  #print(complete[i])

ans = 1000

for i in range(2**(d)):
  bin_i = str("0"*(d+2-len(bin(i)))+str(bin(i))[2:])
  #print(bin_i)
  
  summation=0
  count=0
  index_0=-1
  
  for j in range(d):
    if bin_i[j]=="1":
      summation += complete[j]
      count +=info[j][0]
    else:
      index_0 = j
      
  if summation >= g:
    ans = min(ans,count)
  elif summation < g:
    tmp_g = g
    for j in range(info[index_0][0]):
      tmp_g = tmp_g-100*(index_0+1)
      count +=1
      if summation >= tmp_g:
        ans = min(ans,count)
        break
  #print(count)
  
print(ans)
Buggy code:
D,G = list(map(int,input().split()))
L=[]
for i in range(D):
    L.append(list(map(int,input().split())))
for i in range(D):
    L[i].append(L[i][0]*(i+1)*100)
    L[i].append(L[i][2]+L[i][1])
print(L)
answer = 10**4
for bits in range(1<<D):
    point_sum = 0
    n = 0
    j = -1
    for i in range(D):
        if bits & 1<<i:
            point_sum += L[i][3]
            n += L[i][0]
        else:
            j = max(j, i)
    if point_sum >= G:
        answer = min(answer, n)
    elif j >=0 and (point_sum+L[j][2])-(j+1)*100 >= G:
        a = G - point_sum
        b = (j+1)*100
        answer = min(answer, n+int((a+b-1)/b))
    else:
        pass
print(answer)


Fixed code:
D,G = list(map(int,input().split()))
L=[]
for i in range(D):
    L.append(list(map(int,input().split())))
for i in range(D):
    L[i].append(L[i][0]*(i+1)*100)
    L[i].append(L[i][2]+L[i][1])
answer = 10**4
for bits in range(1<<D):
    point_sum = 0
    n = 0
    j = -1
    for i in range(D):
        if bits & 1<<i:
            point_sum += L[i][3]
            n += L[i][0]
        else:
            j = max(j, i)
    if point_sum >= G:
        answer = min(answer, n)
    elif j >=0 and (point_sum+L[j][2])-(j+1)*100 >= G:
        a = G - point_sum
        b = (j+1)*100
        answer = min(answer, n+int((a+b-1)/b))
    else:
        pass
print(answer)
Buggy code:
import math
length, goal = map(int, input().split(" "))
problems, bonus = [], []
for i in range(length):
    a, b = map(int, input().split(" "))
    problems.append(a)
    bonus.append(b)
problems = problems[::-1]
bonus = bonus[::-1]
answer = float("inf")
for bit in range(length ** 2):
    temp_ans = 0
    temp_sum = 0
    for i in range(length):
        temp_score = (length - i) * 100
        if bit & (1 << i):
            temp_ans += problems[i]
            temp_sum += bonus[i] + temp_score * problems[i]
    # print(bit, temp_ans, temp_sum)
    if temp_sum >= goal:
        answer = min(answer, temp_ans)
    else:
        for i in range(length):
            temp_score = (length - i) * 100
            if not(bit & i):
                if temp_score * (problems[i] - 1) + temp_sum >= goal:
                    temp_ans += int(math.ceil((goal - temp_sum) / temp_score))
                    answer = min(answer, temp_ans)
                    break
                else:
                    temp_ans += problems[i] - 1
                    temp_sum += temp_score * (problems[i] - 1)
print(answer)

Fixed code:
import math
length, goal = map(int, input().split(" "))
problems, bonus = [], []
for i in range(length):
    a, b = map(int, input().split(" "))
    problems.append(a)
    bonus.append(b)
problems = problems[::-1]
bonus = bonus[::-1]
answer = float("inf")
for bit in range(2 ** length):
    temp_ans = 0
    temp_sum = 0
    for i in range(length):
        temp_score = (length - i) * 100
        if bit & (1 << i):
            temp_ans += problems[i]
            temp_sum += bonus[i] + temp_score * problems[i]
    # print(bit, temp_ans, temp_sum)
    if temp_sum >= goal:
        answer = min(answer, temp_ans)
    else:
        for i in range(length):
            temp_score = (length - i) * 100
            if not(bit & (1 << i)):
                if temp_score * (problems[i] - 1) + temp_sum >= goal:
                    temp_ans += int(math.ceil((goal - temp_sum) / temp_score))
                    # print(math.ceil((goal - temp_sum) / temp_score))
                    answer = min(answer, temp_ans)
                    break
                else:
                    temp_ans += problems[i] - 1
                    temp_sum += temp_score * (problems[i] - 1)
        if temp_sum >= goal:
            answer = min(answer, temp_ans)
print(answer)
Buggy code:
d, g = map(int, input().split())
src = [list(map(int, input().split())) for _ in range(d)]

ans = 10**10
for b in range(2**d):
  score = 0
  ac = 0
  for k in range(d):
    if b&(1<<k):
      p,c = src[k]
      score += c
      ac += p
      score += p*(k+1)*100
  if score >= g:
    ans = min(ans, ac)
    continue
  for k in range(d-1, -1, -1):
    if b&(1<<k)==0:
      p, c = src[k]
      if score +p*(k+1)*100 < g:
        score += p*(k+1)*100
        print('!')
        ac += p
      else:
        rem = g-score
        ac += -(-rem // (k+1) // 100)
        ans = min(ans, ac)
        break
print(ans)

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

ans = 10**10
for b in range(2**d):
  score = 0
  ac = 0
  for k in range(d):
    if b&(1<<k):
      p,c = src[k]
      score += c
      ac += p
      score += p*(k+1)*100
  if score >= g:
    ans = min(ans, ac)
    continue
  for k in range(d-1, -1, -1):
    if b&(1<<k)==0:
      p, c = src[k]
      if score +p*(k+1)*100 < g:
        score += p*(k+1)*100
        ac += p
      else:
        rem = g-score
        ac += -(-rem // (k+1) // 100)
        ans = min(ans, ac)
        break
print(ans)
Buggy code:
d,g = map(int,input().split())
li = [list(map(int,input().split())) for i in range(d)]

ans = 10 ** 9
for i in range(2**d -1):
  ch = bin(i)[2:]
  ch = ch.zfill(d)
  tmpsum = 0
  cnt = 0
  for j in range(d):
    if ch[j] == "1":
      tmpsum += li[j][0]*100*(j+1) + li[j][1]
      cnt += li[j][0]
  if tmpsum >= g:
    ans = min(ans,cnt)
  else:
    ind = d-ch.rfind("0")-1
    if tmpsum + (li[ind][0]-1)*100*(ind+1) >= g:
      ans = min(ans,cnt+(g-tmpsum-1)//(100*(ind+1))+1)
print(ans)

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

ans = 10 ** 9
for i in range(2**d):
  ch = bin(i)[2:]
  ch = ch.zfill(d)
  tmpsum = 0
  cnt = 0
  for j in range(d):
    if ch[j] == "1":
      tmpsum += li[j][0]*100*(j+1) + li[j][1]
      cnt += li[j][0]
  if tmpsum >= g:
    ans = min(ans,cnt)
    #print("{} {}".format(bin(i),cnt))
  else:
    ind = ch.rfind("0")
    if tmpsum + (li[ind][0]-1)*100*(ind+1) >= g:
      ans = min(ans,cnt+(g-tmpsum-1)//(100*(ind+1))+1)
      #print("{} {} {}".format(bin(i),cnt,ans))
print(ans)
Buggy code:
D, G = map(int, input().split())
prob = [list(map(int, input().split())) for i in range(D)]
tmp = 100*10

for i in range(1<<D):
    grade = 0
    cnt = 0
    judge = list(range(1, D+1))

    for j in range(D):
        if (i>>j & 1):
            grade += (100*(j+1)*prob[j][0] + prob[j][1])
            cnt += prob[j][0]
            judge[j] = 0

    if grade >= G and tmp > cnt:
        tmp = cnt

    num = prob[(max(judge))-1][0]

    if G > grade and num > int((G - grade) // (max(judge)*100)) - 1:
        cnt += int((G - grade) // (max(judge)*100)) - 1 
        if tmp > cnt:
            tmp = cnt

print(tmp)

Fixed code:
import math

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

for i in range(1<<D):
    grade = 0
    cnt = 0
    judge = list(range(1, D+1))

    for j in range(D):
        if (i>>j & 1):
            grade += (100*(j+1)*prob[j][0] + prob[j][1])
            cnt += prob[j][0]
            judge[j] = 0

    if grade >= G and tmp > cnt:
        tmp = cnt
        
    num = prob[(max(judge))-1][0]

    if G > grade and num > math.ceil((G - grade)/(max(judge)*100)):
        cnt += math.ceil((G - grade)/(max(judge)*100)) 
        if tmp > cnt:
            tmp = cnt

print(tmp)
Buggy code:

d,g = map(int,input().split(' '))
pc = []
for _ in range(d):
    p,c = map(int,input().split(' '))
    pc.append((p,c))

ans = 10000000

for i in range(2**d):
    cnt = 0
    score = 0
    max_flg = 0
    for j in range(d):
        #print(str(i) + ' ' + str(j))
        if((i>>j)&1 == 1):
            score += pc[j][0]*(j+1)*100+pc[j][1]
            cnt += pc[j][0]
        else:
            max_flg = j
    
    print(str(score) + ' '+ str(cnt))
    if(score >= g):
        ans = min(ans,cnt)
    elif(score + (pc[max_flg][0]-1)*(max_flg+1)*100 < g):
        continue
    else:
        for k in range(pc[max_flg][0]):
            if(score + k*(max_flg+1)*100 >= g):
                ans = min(ans,cnt+k)
            else:
                continue

print(str(ans))

Fixed code:

d,g = map(int,input().split(' '))
pc = []
for _ in range(d):
    p,c = map(int,input().split(' '))
    pc.append((p,c))

ans = 10000000

for i in range(2**d):
    cnt = 0
    score = 0
    max_flg = 0
    for j in range(d):
        #print(str(i) + ' ' + str(j))
        if((i>>j)&1 == 1):
            score += pc[j][0]*(j+1)*100+pc[j][1]
            cnt += pc[j][0]
        else:
            max_flg = j
    
    #print(str(score) + ' '+ str(cnt))
    if(score >= g):
        ans = min(ans,cnt)
    elif(score + (pc[max_flg][0]-1)*(max_flg+1)*100 < g):
        continue
    else:
        for k in range(pc[max_flg][0]):
            if(score + k*(max_flg+1)*100 >= g):
                ans = min(ans,cnt+k)
            else:
                continue

print(str(ans))
Buggy code:
import itertools
D, G = map(int, input().split())
#ans = 10000000000
ans = []
list_pro = [list(map(int, input().split())) for _ in range(D)]
for ptr in itertools.product([0,1], repeat=D):
  cnt_pro = 0
  res = 0
  for i,k in enumerate(ptr):
    if k == 1:
      cnt_pro += list_pro[i][0]
      res += 100 * (i+1) * list_pro[i][0] + list_pro[i][1]
  if res < G:
    for j, l in enumerate(reversed(ptr)):
      if l == 0:
        for _ in range(list_pro[D-1-j][0]):
          if res >= G:
            break
          res += 100 * (D-j)
          cnt_pro += 1      
  if res >= G:
    ans.append((cnt_pro, ptr))
print(ans)

Fixed code:
import itertools
D, G = map(int, input().split())
ans = 10000000000
list_pro = [list(map(int, input().split())) for _ in range(D)]
for ptr in itertools.product([0,1], repeat=D):
  cnt_pro = 0
  res = 0
  for i,k in enumerate(ptr):
    if k == 1:
      cnt_pro += list_pro[i][0]
      res += 100 * (i+1) * list_pro[i][0] + list_pro[i][1]
  if res < G:
    for j, l in enumerate(reversed(ptr)):
      if l == 0:
        for _ in range(list_pro[D-1-j][0]):
          if res >= G:
            break
          res += 100 * (D-j)
          cnt_pro += 1      
  if res >= G:
    ans = min(ans, cnt_pro)
print(ans)
Buggy code:
import math


def main():

    num, goal = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    ans = 10 ** 10

    for i in range(2 ** num):
        toku_flg = list(map(int, list(bin(i)[2:])))
        toku_flg = [0 for i in range(num - len(toku_flg))] + toku_flg

        now_score = 0
        now_mondai = 0
        for i in range(num):
            if toku_flg[i] == 1:
                now_score += (i + 1) * 100 * data[i][0] + data[i][1]
                now_mondai += data[i][0]

        if now_score < goal:
            for i in range(num)[::-1]:
                if toku_flg[i] == 0:
                    if now_score + (i + 1) * 100 * (data[i][0] - 1) < goal:
                        break
                    nokori = goal - now_score
                    add_num = math.ceil(nokori / ((i + 1) * 100))
                    now_score += (i + 1) * 100 * add_num
                    now_mondai += add_num
                    break

        if now_score >= goal:
            if now_mondai < ans:
                ans = now_mondai
                break

    print(ans)





if __name__ == '__main__':
    main()


Fixed code:
import math


def main():

    num, goal = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    ans = 10 ** 10

    for i in range(2 ** num):
        toku_flg = list(map(int, list(bin(i)[2:])))
        toku_flg = [0 for i in range(num - len(toku_flg))] + toku_flg

        now_score = 0
        now_mondai = 0
        for i in range(num):
            if toku_flg[i] == 1:
                now_score += (i + 1) * 100 * data[i][0] + data[i][1]
                now_mondai += data[i][0]

        if now_score < goal:
            for i in range(num)[::-1]:
                if toku_flg[i] == 0:
                    if now_score + (i + 1) * 100 * (data[i][0] - 1) < goal:
                        break
                    nokori = goal - now_score
                    add_num = math.ceil(nokori / ((i + 1) * 100))
                    now_score += (i + 1) * 100 * add_num
                    now_mondai += add_num
                    break

        if now_score >= goal:
            if now_mondai < ans:
                ans = now_mondai

    print(ans)





if __name__ == '__main__':
    main()
Buggy code:
d,g=map(int,input().split())
num=[0 for _ in range(d)]
com=[0 for _ in range(d)]
ans=10**9+7
for i in range(d):
    num[i],com[i]=map(int,input().split())
for i in range(2++d):
    tmp_get=0
    tmp_ans=0
    for j in range(d):
        if((i>>j)&1):
            tmp_get+=(num[-j-1]*(100*(d-j)))
            tmp_get+=com[-j-1]
            tmp_ans+=num[-j-1]
    for j in range(d):
        if not((i>>j)&1):
            tmp_cnt=min(-(-(g-tmp_get)//(100*(d-j))),num[-j-1])
            tmp_ans+=tmp_cnt
            tmp_get+=tmp_cnt*(100*(d-j))
            if tmp_cnt==num[-j-1]:
                tmp_get+=com[-j-1]
        if tmp_get>g:
            break
    ans=min(ans,tmp_ans)
print(ans)

Fixed code:
d,g=map(int,input().split())
num=[0 for _ in range(d)]
com=[0 for _ in range(d)]
hum=[100*(i+1) for i in range(d)]
ans=10**9+7
for i in range(d):
    num[i],com[i]=map(int,input().split())
for i in range(2**d):
    tmp_get=0
    tmp_ans=0
    for j in range(d):
        if((i>>j)&1):
            tmp_get+=num[-j-1]*hum[-j-1]
            tmp_get+=com[-j-1]
            tmp_ans+=num[-j-1]
    for j in range(d):
        if tmp_get>=g:
            break        
        if not((i>>j)&1):
            tmp_cnt=min(-(-(g-tmp_get)//hum[-j-1]),num[-j-1])
            tmp_ans+=tmp_cnt
            tmp_get+=tmp_cnt*hum[-j-1]
            if tmp_cnt==num[-j-1]:
                tmp_get+=com[-j-1]
    ans=min(ans,tmp_ans)
print(ans)
Buggy code:
D,G=map(int,input().split())
p=[]
c=[]
for i in range(D):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
ten=0
mondaisu=0
ans=100000

for i in range(2**D):
    for j in range(D):
        if ((i>>j)&1):
            ten+=(j+1)*100*p[j]+c[j]
            mondaisu+=p[j]
        else:
            k=j
    if ten>=G:
        if ans>mondaisu:
            ans=mondaisu
    else:
        if G-ten<=(k+1)*100*p[k]:
            mondaisu+=(G-ten-1)//(k+1)*100+1
            if ans>mondaisu:
                ans=mondaisu
print(ans)

Fixed code:
D,G=map(int,input().split())
p=[]
c=[]
for i in range(D):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)

ans=100000

for i in range(2**D):
    ten=0
    mondaisu=0
    for j in range(D):
        if ((i>>j)&1):
            ten+=(j+1)*100*p[j]+c[j]
            mondaisu+=p[j]
        else:
            k=j
    if ten>G:
        if ans>mondaisu:
            ans=mondaisu
    else:
        if G-ten<=(k+1)*100*p[k]:
            mondaisu+=(G-ten-1)//((k+1)*100)+1
            if ans>mondaisu:
                ans=mondaisu
print(ans)