Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[map(int,input().split()) for _ in range(N)]
store.sort(key=lambda x: x[0])
res=0
for i in range(len(store)):
  price=store[i][0]
  num=store[i][1]
  if M>num:
    res+=price*num
    M-=num
  else:
    res+=price*M
    break
print(res)

Fixed submission:
N, M = map(int, input().split())
shop = []
for i in range(N):
    a, b = map(int, input().split())
    shop.append([a, b])
shop.sort(key=lambda x: x[0])

amount = 0
quantity = 0
for s in shop:
    if quantity + s[1] < M:
        amount += s[0] * s[1]
        quantity += s[1]
    else:
        amount += (M - quantity) * s[0]
        quantity = M
        break

print(amount)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[]
for _ in range(N):
  store.append([map(int,input().split())])
store.sort(key=lambda x: x[0])
res=0
for i in range(len(store)):
  price=store[i][0]
  num=store[i][1]
  if M>num:
    res+=price*num
    M-=num
  else:
    res+=price*M
    break
print(res)


Fixed submission:
N, M = map(int, input().split())
shop = []
for i in range(N):
    a, b = map(int, input().split())
    shop.append([a, b])
shop.sort(key=lambda x: x[0])

amount = 0
quantity = 0
for s in shop:
    if quantity + s[1] < M:
        amount += s[0] * s[1]
        quantity += s[1]
    else:
        amount += (M - quantity) * s[0]
        quantity = M
        break

print(amount)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[]
for _ in range(M):
  store.append([map(int,input().split())])
store.sort(key=lambda x: x[0])
res=0
for i in range(len(store)):
  if M-store[i][1]<=0:
    res+=store[i][0]*M
    break
  else:
    res+=store[i][0]*store[i][1]
    M-=store[i][1]
print(res)


Fixed submission:
N, M = map(int, input().split())
shop = []
for i in range(N):
    a, b = map(int, input().split())
    shop.append([a, b])
shop.sort(key=lambda x: x[0])

amount = 0
quantity = 0
for s in shop:
    if quantity + s[1] < M:
        amount += s[0] * s[1]
        quantity += s[1]
    else:
        amount += (M - quantity) * s[0]
        quantity = M
        break

print(amount)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[]
for _ in range(M):
  store.append([map(int,input().split())])
sorted(store,key=lambda x: x[0])
res=0
for i in range(len(store)):
  if M-store[i][1]<=0:
    res+=store[i][0]*M
    break
  else:
    res+=store[i][0]*store[i][1]
    M=M-store[i][1]
print(res)


Fixed submission:
N, M = map(int, input().split())
shop = []
for i in range(N):
    a, b = map(int, input().split())
    shop.append([a, b])
shop.sort(key=lambda x: x[0])

amount = 0
quantity = 0
for s in shop:
    if quantity + s[1] < M:
        amount += s[0] * s[1]
        quantity += s[1]
    else:
        amount += (M - quantity) * s[0]
        quantity = M
        break

print(amount)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
store=[list(map(int,input().split())) for _ in range(N)]
sorted(store,cmp=lambda x,y:x[0]-y[0] if x[0]!=y[0] else x[1]-y[1])
res=0
for i in range(len(store)):
  if M-store[i][1]<=0:
    res+=store[i][0]*M
    break
  else:
    res+=store[i][0]*store[i][1]
    M=M-store[i][1]
print(res)

Fixed submission:
N, M = map(int, input().split())
shop = []
for i in range(N):
    a, b = map(int, input().split())
    shop.append([a, b])
shop.sort(key=lambda x: x[0])

amount = 0
quantity = 0
for s in shop:
    if quantity + s[1] < M:
        amount += s[0] * s[1]
        quantity += s[1]
    else:
        amount += (M - quantity) * s[0]
        quantity = M
        break

print(amount)