Problem p03290 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  5 19:16:59 2018
ABC104C
@author: maezawa
"""
import math

d, g = list(map(int, input().split()))
p = []
c = []
for i in range(d):
    pi, ci = list(map(int, input().split()))
    p.append(pi)
    c.append(ci)
 
min_cnt = 10**11 
    
for i in range(2**d):
    istr = '0'*d + format(i,'b')
    used = []
    cnt = 0
    maney = 0   
    for j in range(d):
        if istr[-1-j] == '1':
            maney += c[j]+p[j]*(j+1)*100
            cnt += p[j]
            used.append(j)
    if maney >= g:
        if min_cnt > cnt:
            min_cnt = cnt
            #print(istr)
            continue
    else:
        k = d-1
        while k>=0:
            if k not in used:
                break 
            k -= 1
        rem = math.ceil((g-maney)/(100*(k+1)))
        if rem >= p[k]:
            continue
        else:
            cntp = cnt + rem
            if min_cnt > cntp:
                min_cnt = cntp
                #print(istr, rem)
                continue
    #print(min_cnt, istr)
print(min_cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  5 19:16:59 2018
ABC104C
@author: maezawa
"""
import math

d, g = list(map(int, input().split()))
p = []
c = []
for i in range(d):
    pi, ci = list(map(int, input().split()))
    p.append(pi)
    c.append(ci)
 
min_cnt = 10**11 
    
for i in range(2**d):
    istr = '0'*d + format(i,'b')
    used = []
    cnt = 0
    maney = 0   
    for j in range(d):
        if istr[-1-j] == '1':
            maney += c[j]+p[j]*(j+1)*100
            cnt += p[j]
            used.append(j)
    if maney > g:
        if min_cnt > cnt:
            min_cnt = cnt
            #print(istr)
            continue
    else:
        k = d-1
        while k>=0:
            if k not in used:
                break 
            k -= 1
        rem = math.ceil((g-maney)/(100*(k+1)))
        if rem >= p[k]:
            continue
        else:
            cntp = cnt + rem
            if min_cnt > cntp:
                min_cnt = cntp
                #print(istr, rem)
                continue
    #print(min_cnt, istr)
print(min_cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  5 19:16:59 2018
ABC104C
@author: maezawa
"""
import math

d, g = list(map(int, input().split()))
p = []
c = []
for i in range(d):
    pi, ci = list(map(int, input().split()))
    p.append(pi)
    c.append(ci)
 
min_cnt = 10**11 
    
for i in range(2**d):
    istr = '0'*d + format(i,'b')
    used = []
    cnt = 0
    maney = 0   
    for j in range(d):
        if istr[-1-j] == '1':
            maney += c[j]+p[j]*(j+1)*100
            cnt += p[j]
            used.append(j)
    if maney > g:
        if min_cnt > cnt:
            min_cnt = cnt
            #print(istr)
            continue
    else:
        k = d-1
        while k<d:
            if k not in used:
                break 
            k -= 1
        rem = math.ceil((g-maney)/(100*(k+1)))
        if rem >= p[k]:
            continue
        else:
            cntp = cnt + rem
            if min_cnt > cntp:
                min_cnt = cntp
                #print(istr, rem)
                continue
    #print(min_cnt, istr)
print(min_cnt)