Buggy python submission (verdict: Runtime Error):
currency = list(map(int,input().split()))

gra = [[0 for i in range(n+1)] for i in range(m)]

for i in range(m):
    for j in range(1,n+1):
        if i == 0:
            gra[i][j] = j
        else:
            if j>=currency[i]:
                gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
            else:
                gra[i][j] = gra[i-1][j]

print(gra[m][n+1])

Fixed submission:
n,m = map(int,input().split())

currency = sorted(map(int,input().split()))

gra = [float('inf')]*(n+1)
gra[0] = 0
for i in range(m):
    for j in range(currency[i],n+1):
        gra[j] = min(gra[j],gra[j-currency[i]]+1)

print(gra[n])

Buggy python submission (verdict: Runtime Error):
currency = list(map(int,input().split()))

gra = [[0 for i in range(n+1)] for i in range(m)]

for i in range(m):
    for j in range(1,n+1):
        if i == 0:
            gra[i][j] = j
        else:
            if j>=currency[i]:
                gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
            else:
                gra[i][j] = gra[i-1][j]

print(gra[m][n+1])

Fixed submission:
n,m = map(int,input().split())

currency = sorted(map(int,input().split()))

gra = [float('inf')]*(n+1)
gra[0] = 0
for i in range(m):
    for j in range(currency[i],n+1):
        gra[j] = min(gra[j],gra[j-currency[i]]+1)

print(gra[n])

Buggy python submission (verdict: Runtime Error):
currency = list(map(int,input().split()))

gra = [[0 for i in range(n+1)] for i in range(m)]

for i in range(m):
    for j in range(1,n+1):
        if i == 0:
            gra[i][j] = j
        else:
            if j>=currency[i]:
                gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
            else:
                gra[i][j] = gra[i-1][j]

print(gra[m-1][n])

Fixed submission:
n,m = map(int,input().split())

currency = sorted(map(int,input().split()))

gra = [float('inf')]*(n+1)
gra[0] = 0
for i in range(m):
    for j in range(currency[i],n+1):
        gra[j] = min(gra[j],gra[j-currency[i]]+1)

print(gra[n])

Buggy python submission (verdict: Runtime Error):
currency = list(map(int,input().split()))

gra = [[0 for i in range(n+1)] for i in range(m)]

for i in range(m):
    for j in range(1,n+1):
        if i == 0:
            gra[i][j] = j
        else:
            if j>=currency[i]:
                gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
            else:
                gra[i][j] = gra[i-1][j]

print(gra[m-1][n])

Fixed submission:
n,m = map(int,input().split())

currency = sorted(map(int,input().split()))

gra = [float('inf')]*(n+1)
gra[0] = 0
for i in range(m):
    for j in range(currency[i],n+1):
        gra[j] = min(gra[j],gra[j-currency[i]]+1)

print(gra[n])

Buggy python submission (verdict: Runtime Error):
currency = list(map(int,input().split()))

gra = [[0 for i in range(n+1)] for i in range(m)]

for i in range(m):
    for j in range(1,n+1):
        if i == 0:
            gra[i][j] = j
        else:
            if j>=currency[i]:
                gra[i][j] = min(gra[i-1][j],gra[i][j-currency[i]]+1)
            else:
                gra[i][j] = gra[i-1][j]

print(gra[m-1][n])

Fixed submission:
n,m = map(int,input().split())

currency = sorted(map(int,input().split()))

gra = [float('inf')]*(n+1)
gra[0] = 0
for i in range(m):
    for j in range(currency[i],n+1):
        gra[j] = min(gra[j],gra[j-currency[i]]+1)

print(gra[n])