qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import math
D,G=[int(s) for s in input().split()]
ls=[[int(s) for s in input().split()] for i in range(D)]
maxD=2**D-1
def need(num):
  val=num
  score=0
  prob=0
  for i in range(D):
    if val%2==1:
      score+=ls[i][0]*(i+1)*100+ls[i][1]
      prob+=ls[i][0]
    val//=2
  if score>=G:
    return prob
  else:
 #   print(score)
    k=int(math.log2(num^maxD))
    x=(score-G)//((k+1)*100)
    if -x<=ls[k][0]:
      return -x+prob
    else:
      return 10000
print(min([need(i+1) for i in range(maxD)]))    
      

Fixed code:
import math
D,G=[int(s) for s in input().split()]
ls=[[int(s) for s in input().split()] for i in range(D)]
maxD=2**D-1
def need(num):
  val=num
  score=0
  prob=0
  for i in range(D):
    if val%2==1:
      score+=ls[i][0]*(i+1)*100+ls[i][1]
      prob+=ls[i][0]
    val//=2
  if score>=G:
    return prob
  else:
 #   print(score)
    k=int(math.log2(num^maxD))
    x=(score-G)//((k+1)*100)
    if -x<=ls[k][0]:
      return -x+prob
    else:
      return 10000
print(min([need(i) for i in range(2**D)]))
Buggy code:
import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

def flag(point,P,now):
    if point+100*(now+1)*P >= g: return 1
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    temp = max(remain)
    if m <= n: return
    elif point >= g: m = n
    elif flag(point,P[temp],temp):
        n += math.ceil((g-point)/(100*(temp+1)))
        if m > n: m = n
    else:
        if now == -1:
            for i in remain:
                score(point, n, i, remain)
        elif m <= n+P[now]: return
        else:
            nxtp = point + P[now]*100*(now+1) + C[now]
            remain = remain[:]
            remain.remove(now)
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)

Fixed code:
import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
Buggy code:
import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
    else:
        if now == -1:
            for i in remain:
                score(point, n, i, remain)
        elif m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)


Fixed code:
import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
Buggy code:
d, g = map(int, input().split())
p = [0] * d
c = [0] * d
ans = 1000000000000
for i in range(d):
    p[i], c[i] = map(int, input().split())

for i in range(2**d):
    sum = 0
    num = 0
    for j in range(d):
        if i & (1 << j):
            sum += c[j]+p[j]*100*(j+1)
            num += p[j]
    if sum >= g:
        ans = min(ans, num)
    else:
        for j in range(d-1, 0, -1):
            if i & (1 << j):
                continue
            for k in range(p[j]):
                if sum >= g:
                    break
                sum += 100*(j+1)
                num += 1
        ans = min(ans, num)
print(ans)


Fixed code:
d, g = map(int, input().split())
p = [0] * d
c = [0] * d
ans = 10000000000000000000000000000
for i in range(d):
    p[i], c[i] = map(int, input().split())

for i in range(2**d):
    sum = 0
    num = 0
    for j in range(d):
        if i & (1 << j):
            sum += c[j]+p[j]*100*(j+1)
            num += p[j]
    if sum >= g:
        ans = min(ans, num)
    else:
        for j in range(d-1, -1, -1):
            if i & (1 << j):
                continue
            for k in range(p[j]):
                if sum >= g:
                    break
                sum += 100*(j+1)
                num += 1
        ans = min(ans, num)
print(ans)
Buggy code:
# coding: utf-8
# Your code here!
from itertools import product

ans = 10**9

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

for p in product([True, False], repeat=D):
    
    point = 0
    num = 0
    
    for i in range(D):
        if p[i]:
            point += (i+1) * 100 * problem[i][0] + problem[i][1]
            num += problem[i][0]
    
    for i in reversed(range(D)):
        if p[i] == False:
            if point >= G:
                ans = min(ans, num)
                break
            for j in range(problem[i][0]):
                point += (i+1) * 100
                num += 1
                if point >= G:
                    break
print(ans)



Fixed code:
# coding: utf-8
# Your code here!
from itertools import product

ans = 10**9

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

for p in product([True, False], repeat=D):
    
    point = 0
    num = 0
    
    for i in range(D):
        if p[i]:
            point += (i+1) * 100 * problem[i][0] + problem[i][1]
            num += problem[i][0]
            
    if point >= G:
        ans = min(ans, num)
    
    for i in reversed(range(D)):
        if p[i] == False:
            if point >= G:
                ans = min(ans, num)
                break
            for j in range(problem[i][0]):
                point += (i+1) * 100
                num += 1
                if point >= G:
                    break
    if point >= G:
        ans = min(ans, num)
print(ans)
Buggy code:
import itertools
import math
d,g=map(int,input().split())
x=[list(map(int,input().split())) for i in range(d)]
y=[]
z=[x[i][0]-1 for i in range(d)]
z.reverse()
zz=[]
ans=10**10

pin=0
for i in range(d):
  pin+=100
  y.append(x[i][0]*pin+x[i][1])
  zz+=[pin]

zz.reverse()

for lst in itertools.product(range(2),repeat=d):
  sum=0
  cnt=0
  for i in range(d):
    if lst[i]==1:
      cnt+=x[i][0]
      sum+=y[i]
  if sum>=g:
      ans=min(ans,cnt)
  else:
    lack=g-sum
    for j in range(d):
      if lst[-d]==0:  
        if z[j]*zz[j]>=lack:
            cnt+=math.ceil(lack/zz[j])
            break
        else:
            cnt+=z[j]
            lack-=z[j]*zz[j]
    ans=min(ans,cnt)

print(ans)
  

Fixed code:
import itertools
import math
d,g=map(int,input().split())
x=[list(map(int,input().split())) for i in range(d)]
y=[]
z=[x[i][0]-1 for i in range(d)]
zz=[]
ans=10**10

pin=0
for i in range(d):
  pin+=100
  y.append(x[i][0]*pin+x[i][1])
  zz+=[pin]

for lst in itertools.product(range(2),repeat=d):
  sum=0
  cnt=0
  for i in range(d):
    if lst[i]==1:
      cnt+=x[i][0]
      sum+=y[i]
  if sum>=g:
      ans=min(ans,cnt)
  else:
    lack=g-sum
    for j in range(d-1,-1,-1):
      if lst[j]==0:  
        if z[j]*zz[j]>=lack:
            cnt+=math.ceil(lack/zz[j])
            lack=0
            break
        else:
            cnt+=z[j]
            lack-=z[j]*zz[j]
    if lack<=0:
      ans=min(ans,cnt)

print(ans)
Buggy code:
d,g = map(int,input().split())
P,C=[],[]
ans = 10**9
for i in range(d):
  p,c = map(int,input().split())
  P.append(p)
  C.append(c)

for i in range(2**d):
  score,solved_num,max_unsolve = 0,0,0
  for j in range(d):
    if i>>j&1:
      point = (j+1)*100
      simple_sum = point * P[j]
      add_bonus_sum = simple_sum + C[j]
      score += add_bonus_sum
      solved_num += P[j]
    else:
      max_unsolve = max(max_unsolve, j)
  if score >= g:
    ans = min(ans, solved_num)
  else:
    dif = abs(g-score)
    max_unsolve_point = (max_unsolve+1)*100
    nece_num = (dif+max_unsolve_point-1)//max_unsolve_point
    ans = min(ans, solved_num+nece_num)
print(ans)

Fixed code:
d,g = map(int,input().split())
P,C=[],[]
ans = 10**9
for i in range(d):
  p,c = map(int,input().split())
  P.append(p)
  C.append(c)

for i in range(2**d):
  score,solved_num,max_unsolve = 0,0,0
  for j in range(d):
    if i>>j&1:
      point = (j+1)*100
      simple_sum = point * P[j]
      add_bonus_sum = simple_sum + C[j]
      score += add_bonus_sum
      solved_num += P[j]
    else:
      max_unsolve = max(max_unsolve, j)
  if score >= g:
    ans = min(ans, solved_num)
  else:
    dif = abs(g-score)
    max_unsolve_point = (max_unsolve+1)*100
    nece_num = (dif+max_unsolve_point-1)//max_unsolve_point
    if nece_num<=P[max_unsolve]:
      ans = min(ans, solved_num+nece_num)
print(ans)
Buggy code:
d, g = map(int, input().split())

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

ans = 1e9
for i in range(2 ** d):
    sum_ = 0
    num = 0
    rest_max = -1
    for j in range(d):
        if ((i >> j) & 1):
            sum_ += 100 * (j + 1) * p[j] + c[j]
            num += p[j]
        else:
            rest_max = j
    if (sum_ < g):
        s1 = 100 * (rest_max + 1)
        need = (g - sum_ + s1 - 1) / s1
        if need >= p[rest_max]:
            continue
        num += need
    ans = min(ans, num)
print(ans)


Fixed code:
d, g = map(int, input().split())

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

ans = 1e9
for i in range(2 ** d):
    sum_ = 0
    num = 0
    rest_max = -1
    for j in range(d):
        if ((i >> j) & 1):
            sum_ += 100 * (j + 1) * p[j] + c[j]
            num += p[j]
        else:
            rest_max = j
    if (sum_ < g):
        s1 = 100 * (rest_max + 1)
        need = (g - sum_ + s1 - 1) // s1
        if need >= p[rest_max]:
            continue
        num += need
    ans = min(ans, num)
print(ans)
Buggy code:
import itertools
import math

D, G = map(int, input().split())
p, c = [0]*D, [0]*D
for i in range(D):
    p[i], c[i] = map(int, input().split())

ls = []
for i in itertools.product([0, 1], repeat=D):
    sum = 0
    ans = 0
    for j, x in enumerate(i):
        if x == 1:
            sum += c[j] + (100*(j+1))*p[j]
            ans += p[j]
    if sum >= G:
        ls.append(ans)
    else:
        for j, x in enumerate(i[::-1]):
            if x != 1:
                if math.ceil((G-sum)/(100*(D-j))) <= p[D-1-j] - 1:
                    ans += math.ceil((G-sum)/(100*(D-j)))
                    ls.append(ans)
                    break
                else:
                    sum += (100*(D-j))*(p[D-1-j] - 1)
                    ans += p[D-1-j] - 1
print(ls)


Fixed code:
import itertools
import math

D, G = map(int, input().split())
p, c = [0]*D, [0]*D
for i in range(D):
    p[i], c[i] = map(int, input().split())

ls = []
for i in itertools.product([0, 1], repeat=D):
    sum = 0
    ans = 0
    for j, x in enumerate(i):
        if x == 1:
            sum += c[j] + (100*(j+1))*p[j]
            ans += p[j]
    if sum >= G:
        ls.append(ans)
    else:
        for j, x in enumerate(i[::-1]):
            if x != 1:
                if math.ceil((G-sum)/(100*(D-j))) <= p[D-1-j] - 1:
                    ans += math.ceil((G-sum)/(100*(D-j)))
                    ls.append(ans)
                    break
                else:
                    sum += (100*(D-j))*(p[D-1-j] - 1)
                    ans += p[D-1-j] - 1
print(min(ls))
Buggy code:
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]
count_list = []

for i in range(2**D):
  point = 0
  count = 0
  i_data = i
  for j in range(D):
    if i & 1:
      point += 100 * (j+1) * pc[j][0] + pc[j][1]
      count += pc[j][0]
      i >>= 1
  if point >= G:
    count_list.append(count)
    break
  else:
    bin_i = bin(i_data)[2:].zfill(D)
    index = bin_i.index('0')
    for j in range(pc[index][0]-1):
        point += 100 * (D-index)
        count += 1
        if point >= G:
          count_list.append(count)
          break
          
print(min(count_list))

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

for i in range(2**D):
  point = 0
  count = 0
  bin_i = bin(i)[2:].zfill(D)
  for j in range(D):
    if bin_i[j] == '1':
      point += 100 * (j+1) * pc[j][0] + pc[j][1]
      count += pc[j][0]
  if point >= G:
    count_list.append(count)
  else:
    index = bin_i.rindex('0')
    for j in range(pc[index][0]-1):
        point += 100 * (index+1)
        count += 1
        if point >= G:
          count_list.append(count)
          break
          
print(min(count_list))
Buggy code:
D,G=map(int, input().split())
li = []
for i in range(D):
  li.append(list(map(int, input().split())))

min_n=10**9
n = 0
s=0
for ind in range(2**D):
  n=0
  s=0
  if ind==0:
    continue
  for j in range(D):
    if ind>>j & 1:
      s += (j+1)*100*li[j][0]+li[j][1]
      n+=li[j][0]
  print(s)
  if s < G:
    for j in range(D-1,-1,-1):
      if ind>>j & 1 == 0:
        tmp = (G-s) / ((j+1)*100)
        if (G-s) % ((j+1)*100) != 0:
          tmp += 1
        if tmp > 0:
          if tmp==li[j][1]:
            tmp -=1
          s += (j+1)*100*tmp
          n+= tmp
      if s >= G:
        break
  if s >= G:
    if n<min_n:
      # print(ind)
      min_n=n

print(int(min_n))
      

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

min_n=10**9
n = 0
s=0
for ind in range(2**D):
  n=0
  s=0
  for j in range(D):
    if ind>>j & 1:
      s += (j+1)*100*li[j][0]+li[j][1]
      n+=li[j][0]
  # print(s)
  if s < G:
    for j in range(D-1,-1,-1):
      if ind>>j & 1 == 0:
        tmp = (G-s) / ((j+1)*100)
        if (G-s) % ((j+1)*100) != 0:
          tmp += 1
        if tmp > 0:
          if tmp>=li[j][0]:
            tmp=li[j][0]-1
          s += (j+1)*100*tmp
          n+= tmp
      if s >= G:
        # print(tmp)
        break
  if s >= G:
    if n<min_n:
      # print(ind)
      min_n=n

print(int(min_n))
Buggy code:
d, g = map(int, input().split())
p = []
c = []
for i in range(d):
    e1, e2 = map(int, input().split())
    p.append(e1)
    c.append(e2)


ans = float('inf')
for i in range(2**d):
    total = 0
    num = 0
    for j in range(d):
        if (i >> j) & 1:
            total += c[-(j+1)] + p[-(j+1)] * (d - j) * 100
            num += p[-(j+1)]
    if total >= g:
        ans = min(ans, num)
    else:
        for j in range(d):
            if (i >> j) & 1:
                continue
            for k in range(p[-(j+1)]):
                total += (d-j) * 100
                num += 1
                if total >= g:
                    break
    ans = min(ans, num)

print(ans)

Fixed code:
d, g = map(int, input().split())
p = []
c = []
for i in range(d):
    e1, e2 = map(int, input().split())
    p.append(e1)
    c.append(e2)

ans = float('inf')
for i in range(2**d):
    total = 0
    num = 0
    for j in range(d):
        if (i >> j) & 1:
            total += c[-(j+1)] + p[-(j+1)] * (d - j) * 100
            num += p[-(j+1)]
    if total >= g:
        ans = min(ans, num)
    else:
        for j in range(d):
            if (i >> j) & 1:
                continue
            for k in range(p[-(j+1)]):
                if total >= g:
                    break
                total += (d-j) * 100
                num += 1
    ans = min(ans, num)

print(ans)
Buggy code:
D, G = [int(s) for s in input().split()]
problems = [[int(s) for s in input().split()] for _ in range(D)]

result = 10 ** 8

for i in range(2 ** D):
    cnt_problem = 0
    cnt_score = 0
    for j in range(D):
        if i << j:
            cnt_score += problems[j][1] + 100 * (j + 1) * problems[j][0]
            cnt_problem += problems[j][0]

    for j in reversed(range(D)):
        if not i << j:
            for k in range(1, problems[j][0]):
                if cnt_score >= G:
                    break
                else:
                    cnt_score += problems[j][1]
                    cnt_problem += 1
    result = min(cnt_problem, result)

print(result)


Fixed code:
D, G = [int(s) for s in input().split()]
problems = [[int(s) for s in input().split()] for _ in range(D)]

result = 10 ** 8

for i in range(2 ** D):
    cnt_problem = 0
    cnt_score = 0
    for j in range(D):
        if i >> j & 1:
            cnt_score += problems[j][1] + 100 * (j + 1) * problems[j][0]
            cnt_problem += problems[j][0]

    for j in reversed(range(D)):
        if not i >> j & 1:
            for _ in range(problems[j][0]):
                if cnt_score >= G:
                    break
                else:
                    cnt_score += 100 * (j + 1)
                    cnt_problem += 1
    result = min(cnt_problem, result)

print(result)
Buggy code:
#ABC104C - All Green
import math
def dfs(i,s,c,r):
    global ans
    if i == d:
        if s < g:
            use = max(r)
            n = min(pc[use -1][0], math.ceil((g-s)/(use*100)))
            c += n
            s += n+use*100
        if s >= g:
            ans = min(ans,c)
    
    else:
        dfs(i+1, s, c, r)
        dfs(i+1, s+ pc[i][0]*(1+1)*100+pc[i][1],c+pc[i][0],r-{i+1})
        
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for i in range(d)]

ans = float("inf")

dfs(0,0,0,set(range(1,d+1)))
print(ans)

Fixed code:
#ABC104C - All Green
import math
def dfs(i,s,c,r):
    global ans
    if i == d:
        if s < g:
            use = max(r)
            n = min(pc[use -1][0], math.ceil((g-s)/(use*100)))
            c += n
            s += n*use*100
        if s >= g:
            ans = min(ans,c)
    
    else:
        dfs(i+1, s, c, r)
        dfs(i+1, s+ pc[i][0]*(i+1)*100+pc[i][1],c+pc[i][0],r-{i+1})
        
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for i in range(d)]

ans = float("inf")

dfs(0,0,0,set(range(1,d+1)))
print(ans)
Buggy code:
d,g = map(int,input().split())
answer = 0
Q = []
for i in range(d):
    p,c=map(int,input().split())
    answer += p
    Q.append((i+1,p,c))
print(answer)

dp = [-10**9]*(answer+1) 
dp[0] = 0
for i,p,c in Q:
    for j in range(answer,-1,-1):
        for k in range(1,p+1):
            cc = i*100*k
            if k == p:
                cc += c
            if j-k >= 0:
                dp[j]=max(dp[j],dp[j-k]+cc)
        
for i in range(answer+1):
    if dp[i] >= g:
        print(i)
        exit()

Fixed code:
d,g = map(int,input().split())
answer = 0
Q = []
for i in range(d):
    p,c=map(int,input().split())
    answer += p
    Q.append((i+1,p,c))

dp = [-10**9]*(answer+1) 
dp[0] = 0
for i,p,c in Q:
    for j in range(answer,-1,-1):
        for k in range(1,p+1):
            cc = i*100*k
            if k == p:
                cc += c
            if j-k >= 0:
                dp[j]=max(dp[j],dp[j-k]+cc)
        
for i in range(answer+1):
    if dp[i] >= g:
        print(i)
        exit()
Buggy code:
import math

n,g=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
comp=[(100*(i+1)*arr[i][0]+arr[i][1]) for i in range(n)]
ans=10**10
for i in range(2**n):
  flag=format(i,'b')
  if len(flag)<n:
    flag='0'*(n-len(flag))+flag
  tsum=0
  tans=0
  for i in range(n):
    if flag[i]=='1':
      tsum+=comp[i]
      tans+=arr[i][0]
  if tsum>=g:
    ans=min(ans,tans)
  else:
    pos=flag[::-1].index('0')
    tq=math.ceil(g-tsum)/(100*(n-pos)))
    if tq<=arr[n-pos-1][0]:
      ans=min(ans,tans+tq)
print(ans)

Fixed code:
import math

n,g=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
comp=[(100*(i+1)*arr[i][0]+arr[i][1]) for i in range(n)]
ans=10**10
for i in range(2**n):
  flag=format(i,'b')
  if len(flag)<n:
    flag='0'*(n-len(flag))+flag
  tsum=0
  tans=0
  for i in range(n):
    if flag[i]=='1':
      tsum+=comp[i]
      tans+=arr[i][0]
  if tsum>=g:
    ans=min(ans,tans)
  else:
    pos=flag[::-1].index('0')
    tq=math.ceil((g-tsum)/(100*(n-pos)))
    if tq<=arr[n-pos-1][0]:
      ans=min(ans,tans+tq)
print(ans)
Buggy code:
from math import ceil
D,G=map(int,input().split())
p=[0]*D
c=[0]*D

for i in range(D):
    p[i],c[i]=map(int,input().split())
_min=101*D

flag=1
while(flag < 2**D):
    
    _G=G
    tmp=0
    max_ind=0
    for i in range(D):
        if(flag & 1<<i):
            _G-=p[i]*(i+1)*100 + c[i]
            tmp+=p[i]
        else:
            max_ind=i
    k=ceil(max([(_G),0])/(100*(max_ind+1)))  
    if(k < p[max_ind]):
        tmp+=k
        _min=min([tmp,_min])
    flag+=1
print(_min)  

Fixed code:
from math import ceil
D,G=map(int,input().split())
p=[0]*D
c=[0]*D

for i in range(D):
    p[i],c[i]=map(int,input().split())
_min=101*D

flag=0
while(flag < 2**D):
    
    _G=G
    tmp=0
    max_ind=0
    for i in range(D):
        if(flag & 1<<i):
            _G-=p[i]*(i+1)*100 + c[i]
            tmp+=p[i]
        else:
            max_ind=i
    k=ceil( max([(_G),0]) / (100*(max_ind+1)) )  
    if(k < p[max_ind] or k==0):
        tmp+=k
        _min=min([tmp,_min])
    flag+=1
print(_min)
Buggy code:
N=input()
if N[0]==N[1] and N[1]==N[2]:
	print("yes")
elif N[1]==N[2] and N[2]==N[3]:
	print("Yes")
else:
	print("No")

Fixed code:
N=input()
if N[0]==N[1] and N[1]==N[2]:
	print("Yes")
elif N[1]==N[2] and N[2]==N[3]:
	print("Yes")
else:
	print("No")
Buggy code:
N =list(str(input()))

flag = 0
for i in range(len(N) - 2):
    if(N[i] == N[i + 1] and N[i + 1] == N[i + 2]):
        print("Yes")
        flag = 1
        
if(flag == 0):
    print("No")

Fixed code:
N =list(str(input()))

flag = 0
for i in range(len(N) - 2):
    if(N[i] == N[i + 1] and N[i + 1] == N[i + 2]):
        print("Yes")
        flag = 1
        break;
        
if(flag == 0):
    print("No")
Buggy code:
N = input()

cnt = max(N[:4].count(N[0]), N[1:].count(N[1]))

if cnt == 3:
    print('Yes')
else:
    print('No')

Fixed code:
N = input()

cnt = max(N[:3].count(N[0]), N[1:].count(N[1]))

if cnt == 3:
    print('Yes')
else:
    print('No')
Buggy code:
def main():
    n = input()
    if n[0] == [1] == n[2] or n[1] == n[2] == n[3]:
        print('yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = input()
    if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()