Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    dpList = []
    if n + m < 1:
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
        dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    for i in range(n):
        if m - dpList[i][0] <= 0:
            num = (dpList[i][0] - m) * dpList[i][1]
            for j in range(i + 1, n):
                num += dpList[j][0] * dpList[j][1] 
            print(num)
            break
        else:
            m -= dpList[i][0]

Fixed submission:
while True:
    n, m = map(int, input().split())
    dpList = []
    if (n,m) == (0,0):
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
    dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num += (dpList[i][0] - m) * dpList[i][1]
            m = 0
    print(num)

Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    dpList = []
    if n + m < 1:
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
        dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num = (dpList[i][0] - m) * dpList[i][1]
    print(num)

Fixed submission:
while True:
    n, m = map(int, input().split())
    dpList = []
    if (n,m) == (0,0):
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
    dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num += (dpList[i][0] - m) * dpList[i][1]
            m = 0
    print(num)

Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    if (n, m) == (0, 0):
        break
    dp = [list(map(int, input().split())) for i in range(n)]
    dp = sorted(dp, key=lambda kv:kv[1], reverse=True)
    r = 0
    for d,p in dp:
        if m >= d:
            m -= d
        else:
            r += p*(d-m)
            m = 0
    print(r

Fixed submission:
while True:
    n, m = map(int, input().split())
    dpList = []
    if (n,m) == (0,0):
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
    dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num += (dpList[i][0] - m) * dpList[i][1]
            m = 0
    print(num)

Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    dpList = []
    if n + m < 1:
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
        dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num += (dpList[i][0] - m) * dpList[i][1]
    print(num)

Fixed submission:
while True:
    n, m = map(int, input().split())
    dpList = []
    if (n,m) == (0,0):
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
    dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num += (dpList[i][0] - m) * dpList[i][1]
            m = 0
    print(num)

Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    dpList = []
    if (n,m) == (0,0):
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
        dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num += (dpList[i][0] - m) * dpList[i][1]
    print(num)

Fixed submission:
while True:
    n, m = map(int, input().split())
    dpList = []
    if (n,m) == (0,0):
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
    dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num += (dpList[i][0] - m) * dpList[i][1]
            m = 0
    print(num)