TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N,m = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append([a,b])

A = sorted(A)
print(A)
money = 0
for n in range(N):
    if m > A[n][1]:
        m -= A[n][1]
        money += A[n][1] * A[n][0]
    elif m <= A[n][1]:
        money += m * A[n][0]
        break

print(money)


N,m = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append([a,b])

A = sorted(A)
money = 0
for n in range(N):
    if m > A[n][1]:
        m -= A[n][1]
        money += A[n][1] * A[n][0]
    elif m <= A[n][1]:
        money += m * A[n][0]
        break

print(money)


Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 21:40:34 2019

@author: iwata
"""

N,M = map(int, input().split())
numlist =[]
num = 0

for i in range(N):
    A,B = map(int, input().split())
    for j in range(B):
        numlist.append(A)

numlist.sort()


sum(numlist[:M])
    
print(num)
    

# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 21:40:34 2019

@author: iwata
"""

N,M = map(int, input().split())
numlist =[]
money = 0
count = 0
count1 = 0
count2 = 0

for i in range(N):
    AB = list(map(int, input().split()))
    numlist.append(AB)

numlist.sort()

while count <= M:
    while numlist[count1][1] <= count2:
        money = money + numlist[count1][0]
        count = count + 1
        count2 = count2 + 1
        if count == M:
            break
    count1 = count1 + 1
    count2 = 0
    
print(money)


# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 21:40:34 2019

@author: iwata
"""

N,M = map(int, input().split())
numlist =[]
money = 0
count = 0
count1 = 0
count2 = 0

for i in range(N):
    AB = list(map(int, input().split()))
    numlist.append(AB)

numlist.sort()

while count < M:
    while numlist[count1][1] > count2:
        money = money + numlist[count1][0]
        count = count + 1
        count2 = count2 + 1
        if count == M:
            break
    count1 = count1 + 1
    count2 = 0
    
print(money)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
shop=[]
for i in range(n):
    shop.append(map(int,input().split()))
shop_sorted=sorted(shop,key=lambda x :x[0])
ans=0
cnt=0
for a,b in shop_sorted:
    tmp=cnt
    cnt=min(m,cnt+b)
    ans+=a*(cnt-tmp)
    if cnt==m:
        break
print(ans)

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]
AB=sorted(AB,key=lambda x:x[0])
cnt=0
ans=0
for a,b in AB:
    tmp=cnt
    cnt=min(m,cnt+b)
    ans+=a*(cnt-tmp)
    if cnt==m:
        break
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
import numpy as np

N, M = map(int, input().split())
a = [input().split() for i in range(N)]

a = np.array(a, dtype='int64')
a = a[a[:, 0].argsort(), :]
print(a)

mysum = 0
coin = 0
for c in a:
    if mysum + c[1] < M:
        mysum += c[1]
        coin += c[0] * c[1]
    else:
        d = M - mysum
        coin += d * c[0]
        break

print(coin)

import numpy as np

N, M = map(int, input().split())
a = [input().split() for i in range(N)]

a = np.array(a, dtype='int64')
a = a[a[:, 0].argsort(), :]

mysum = 0
coin = 0
for c in a:
    if mysum + c[1] < M:
        mysum += c[1]
        coin += c[0] * c[1]
    else:
        d = M - mysum
        coin += d * c[0]
        break

print(coin)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m=map(int,input().split())
a=[]
b=[]
ans=0
for _ in range(n):
    c,d=map(int,input().split())
    a.append(c)
    b.append(d)
e=sorted(a)
for i in range(n):
    m=m-b[a.index(e[i])]
    if(m=<0):
        ans+=e[i]*(b[a.index(e[i])]+m)
        break
    else:
        ans+=b[a.index(e[i])]*e[i]
print(ans)

n,m=map(int,input().split())
a=[]
ans=0
for i in range(n):
    a.append(list(map(int,input().split())))
a=sorted(a)
for i in range(n):
    m=m-a[i][1]
    if(m<=0):
        ans+=a[i][0]*(a[i][1]+m)
        break
    else:
        ans+=a[i][1]*a[i][0]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
s=0 
t=0 
for i in range(N):
  s+=A[i][1]
  if M>s:
    t+=A[i][0]*A[i][1]
  else:
    over=s-M
    t-=A[i][0]*over
print(t)

N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
for i in range(N):
  while k>0:
    if k>A[i][1]:
      k=k-A[i][1]
      s+=A[i][0]*A[i][1]
    else:
      k=0
      s+=A[i][0]*k
print(s)
  

N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
for i in range(N):
while k>0:
  for i in range(N):
    if k>A[i][1]:
      s+=A[i][0]*A[i][1]
      k=k-A[i][1]
    else:
      s+=A[i][0]*k
      k=0
print(s)

N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
cnt=0 
ans=0 
for i in range(N):
  cnt+=A[i][1]
  if cnt>=m:
    over=cnt-m
    ans+=over*A[i][0]
    cnt+=over
  else:
    ans+=A[i][0]*A[i][1]
print(ans)

N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
s=0 
t=0 
for i in range(N):
  if M>s:
    s+=A[i][1]
    t+=A[i][0]*A[i][1]
  else:
    over=s-M
    t-=A[i-1][0]*over
print(t)

N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
for i in range(N):
  while k>0:
    if k>A[i][1]:
      s+=A[i][0]*A[i][1]
      k=k-A[i][1]
    else:
      s+=A[i][0]*k
      k=0
print(s)
      

N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
for i in range(N):
  while k>0:
    if k>A[i][1]:
      s+=A[i][0]*A[i][1]
      k=k-A[i][1]
    else:
      s+=A[i][0]*k
      k=0
print(s)
  

N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
s=0 
t=0 
for i in range(N):
  s+=A[i][1]
  if M>s:
    t+=A[i][0]*A[i][1]
  else:
    over=s-M
    t+=A[i][0]*A[i][1]-A[i][0]*over
    break
print(t)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N,M = map(int, input().split())
a = []
b = []
ans = 0

for i in range(N):
    store = input().split()
    a.append(int(store[0]))
    b.append(int(store[1]))

nokori = M
for i in range(M):
    if nokori > 1:
        index = a.index(min(a))
        if nokori - (b[index]) >= 0:
            ans += a[index] * b[index]
            nokori -= b[index]
            a.pop(index)
            b.pop(index)
        else:
            ans += a[index] * nokori
            break
    else:
        break
print(ans)

N,M = map(int, input().split())
ab = []
ans = 0

for i in range(N):
    ab.append(list(map(int, input().split())))
ab = sorted(ab)
nokori = M
for i in ab:
    if nokori - i[1] >= 0:
        ans += i[0] * i[1]
        nokori -= i[1]
    else:
        ans += i[0] * nokori
        break

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ab_sorted = sorted(ab, key=lambda x:(x[0], -x[1]))
print(ab_sorted)

num = 0
amount_of_money = 0
for i in range(n):
  buy = min(ab_sorted[i][1], m-num)
  num += buy
  amount_of_money += ab_sorted[i][0] * buy
    
  if num >= m:
    print(amount_of_money)


n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ab_sorted = sorted(ab, key=lambda x:(x[0], -x[1]))

num = 0
amount_of_money = 0
for i in range(n):
  buy = min(ab_sorted[i][1], m-num)
  num += buy
  amount_of_money += ab_sorted[i][0] * buy
    
  if num >= m:
    print(amount_of_money)
    exit(0)


Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n, m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
a = a.sort()
ans = 0
i = 0
while m > 0:
  if a[i][1] > 0:
    a[i][1] -= 1
    ans += a[i][0]
    m -= 1
  else:
    i += 1
print(ans)


n, m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
a.sort()
ans = 0
i = 0
while m > 0:
  if a[i][1] > 0:
    a[i][1] -= 1
    ans += a[i][0]
    m -= 1
  else:
    i += 1
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
import numpy as np

N,M = map(int,input().split())
A = []
for i in range(N):
    A.append([int(x) for x in input().split()])

AB = np.array(A)

AB = AB[np.argsort(AB[:,0])]

yen = 0
cnt = 0
i = 0
while(1):
    cnt_ = cnt + AB[i,1]
    if(cnt_ >= M):
        yen += (M - cnt)*AB[i,0]
        break
    yen += AB[i,0]*AB[i,1]
    print(cnt_,yen)
    cnt = cnt_
    i += 1


print(yen)

import numpy as np

N,M = map(int,input().split())
A = []
for i in range(N):
    A.append([int(x) for x in input().split()])

AB = np.array(A)

AB = AB[np.argsort(AB[:,0])]

yen = 0
cnt = 0
i = 0
while(1):
    cnt_ = cnt + AB[i,1]
    if(cnt_ >= M):
        yen += (M - cnt)*AB[i,0]
        break
    yen += AB[i,0]*AB[i,1]
    cnt = cnt_
    i += 1


print(yen)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m=map(int,input().split())
A=[list(map(int,input().split()))for i in range(n)]
print(A)
A=sorted(A,key=lambda y:y[0])
print(A)
cnt=0
ans=0
for i in range(n):
    cnt+=A[i][1]
    if m<=cnt:
        over=cnt-m 
        ans+=(A[i][0]*A[i][1])-(over*A[i][0])
        break
    else:
        ans+=A[i][0]*A[i][1]
print(ans)

n,m=map(int,input().split())
A=[list(map(int,input().split()))for i in range(n)]
A=sorted(A,key=lambda y:y[0])
cnt=0
ans=0
for i in range(n):
    cnt+=A[i][1]
    if m<=cnt:
        over=cnt-m 
        ans+=(A[i][0]*A[i][1])-(over*A[i][0])
        break
    else:
        ans+=A[i][0]*A[i][1]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N,M = map(int,input().split())
A = [0] * N
B = [0] * N
C = [[0,0] for i in range(N)]
check = 0
money = 0
a = 0
k = 0

for i in range(N):

    A[i],B[i] = map(int,input().split())
    C[i] = [A[i],B[i]]

C.sort()

while a == 0:

    if check + C[k][1] <= M:

        check += C[k][1]
        money += C[k][0]*C[k][1]

        if check + C[k][1] < M:

            k += 1

    else:

        money += C[k][0] * (M-check)
        a += 1

print(money)

N,M = map(int,input().split())
A = [0] * N
B = [0] * N
C = [[0,0] for i in range(N)]
check = 0
money = 0
a = 0
k = 0

for i in range(N):

    A[i],B[i] = map(int,input().split())
    C[i] = [A[i],B[i]]

C.sort()

while a == 0:

    if check + C[k][1] < M:

        check += C[k][1]
        money += C[k][0]*C[k][1]
        k += 1

        
    else:

        money += C[k][0] * (M-check)
        a += 1

print(money)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N, M = map(int, input().split())
drink = 0
max_drink = M
sum = 0
dal = {}
for n in range(N):
    A, B = map(int, input().split())
    dal[A] = B
sorted_d = sorted(dal.items())
for sd, sd2 in sorted_d:
    for bottle in range(sd2):
        if drink <= M:
            sum += sd
            drink += 1
        else:
            break
print(sum)

N, M = map(int, input().split())
AB = []
p = 0

for n in range(N):
  AB.append(list(map(int, input().split())))
  print(AB)
  AB.sort()
  for s, b in AB:
    print('M',M)
    p += s * min(M, b)
    M -= min(M, b)
print(p)

N, M = map(int, input().split())
AB = []
p = 0
for n in range(N):
    AB.append(list(map(int, input().split())))
AB.sort()
for s, b in AB:
    print('M',M)
    p += s * min(M, b)
    M -= min(M, b)
print(p)

N, M = map(int, input().split())
AB = []
p = 0
for n in range(N):
    AB.append(list(map(int, input().split())))
AB.sort()
for s, b in AB:
    p += s * min(M, b)
    M -= min(M, b)
print(p)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
import numpy as np
#N,M=2,5
#AB=np.array([[4,9],[2,4]])
N,M=map(int,input().split())
AB=np.zeros((N,2))
for i in range(N):
    AB[i,0],AB[i,1]=map(int,input().split())
AB = AB[np.argsort(AB[:, 0])]
print(AB)
numd=0
ans=0
for i in range(len(AB)):
    if numd==M:
        break
    else:
        if AB[i][1] < M-numd:
            ans+=AB[i][0]*AB[i][1]
            numd+=AB[i][1]
        else:
            ans+=AB[i][0]*(M-numd)
            numd+=M-numd
print(int(ans))

import numpy as np
#N,M=2,5
#AB=np.array([[4,9],[2,4]])
N,M=map(int,input().split())
AB=np.zeros((N,2))
for i in range(N):
    AB[i,0],AB[i,1]=map(int,input().split())
AB = AB[np.argsort(AB[:, 0])]
numd=0
ans=0
for i in range(len(AB)):
    if numd==M:
        break
    else:
        if AB[i][1] < M-numd:
            ans+=AB[i][0]*AB[i][1]
            numd+=AB[i][1]
        else:
            ans+=AB[i][0]*(M-numd)
            numd+=M-numd
print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(n)])

count = 0
buy = 0
for a, b in ab:
    print(a,b)
    for i in range(b):
        buy += a
        count += 1

        if count >= m:
            print(buy)
            exit()

n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(n)])

count = 0
buy = 0
for a, b in ab:
    for i in range(b):
        buy += a
        count += 1

        if count >= m:
            print(buy)
            exit()

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m = map(int,input().split())
li = [list(map(int,input().split()))for i in range(n)]

li.sort()
n = 0
ans = 0
for i in range(n):
    a = min(m,li[i][1])
    m-=a
    ans += li[i][0]*a
    if a ==0:
        break
print(ans)


n,m = map(int,input().split())
li = [list(map(int,input().split()))for i in range(n)]

li.sort()

ans = 0
for i in range(n):
    a = min(m,li[i][1])
    m -= a
    ans += li[i][0]*a
    if a == 0:
        break
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N, M = list(map(int, input().split()))
sh_li = []
for i in range(N):
    a, b = list(map(int, input().split()))
    sh_li.append([a, b])
sh_li.sort(key=lambda x:x[0],reverse=False)

def calc(li, m):
    total = 0
    for sh in li:
        print(sh)
        if sh[1] < m:
            total += sh[0] * sh[1]
            m -= sh[1]
        else:
            total += sh[0] * m
            return total

print(calc(sh_li, M))

N, M = list(map(int, input().split()))
sh_li = []
for i in range(N):
    a, b = list(map(int, input().split()))
    sh_li.append([a, b])
sh_li.sort(key=lambda x:x[0],reverse=False)

def calc(li, m):
    total = 0
    for sh in li:
        if sh[1] < m:
            total += sh[0] * sh[1]
            m -= sh[1]
        else:
            total += sh[0] * m
            return total

print(calc(sh_li, M))

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m = map(int, input().split())
l = [list(map(int,input().split)) for _ in range(n)]
cnt = 0
ans = 0
l.sort(key=lambda x:x[0])
for i in range(n):
    cnt += l[i][1]
    ans += l[i][0] * l[i][1]
    if cnt > m:
        ans -= l[i][0] * l[i][1]
        ans += l[i][0]*(m-(cnt-l[i][1]))
print(ans)

n,m = map(int, input().split())
l = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
ans = 0
l.sort(key=lambda x:x[0])
for i in range(n):
    cnt += l[i][1]
    ans += l[i][0] * l[i][1]
    if cnt > m:
        ans -= l[i][0] * l[i][1]
        ans += l[i][0]*(m-(cnt-l[i][1]))
        break
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N,M = map(int,input().split())
X =[]
for i in range(N):
    a,b = map(int,input().split())
    X.append([a,b])
X.sort(key=lambda x: x[0])
count = 0
ans = 0
for i in X:
    if M - count > i[1]:
        count += i[1]
        ans += i[0] * i[1]
        print(ans,count)
    else:
        x = M - count
        ans += i[0] * x
        break
print(ans)

N,M = map(int,input().split())
X =[]
for i in range(N):
    a,b = map(int,input().split())
    X.append([a,b])
X.sort(key=lambda x: x[0])
count = 0
ans = 0
for i in X:
    if M - count > i[1]:
        count += i[1]
        ans += i[0] * i[1]
        #print(ans,count)
    else:
        x = M - count
        ans += i[0] * x
        break
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N,M = map(int, input().split())
data = [input().split() for i in range(N)]

data.sort()
num = 0
for x in data:
    print(x)
    
for x in data:
    for xx in range(int(x[1])):
        M -= 1
        num += int(x[0])
        if(M == 0):
            break
    if(M == 0):
        break
print(num)        

N,M = map(int, input().split())
data = [list(map(int, input().split())) for i in range(N)]

data.sort()
num = 0
# for x in data:
#     print(x)
    
for x in data:
    for xx in range(int(x[1])):
        M -= 1
        num += int(x[0])
        if(M == 0):
            break
    if(M == 0):
        break
print(num)        

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
#import pysnooper

#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n,m=map(int,input().split())
a=sorted([list(map(int,input().split())) for _ in range(n)])
print(a)
cnt,can=0,0
for i in range(n):
    if can+a[i][1]<m:
        cnt+=a[i][0]*a[i][1]
        can+=a[i][1]
    else:
        cnt+=a[i][0]*(m-can)
        break
    #print(cnt)
print(cnt)

#import pysnooper

#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

n,m=map(int,input().split())
a=sorted([list(map(int,input().split())) for _ in range(n)])
#print(a)
cnt,can=0,0
for i in range(n):
    if can+a[i][1]<m:
        cnt+=a[i][0]*a[i][1]
        can+=a[i][1]
    else:
        cnt+=a[i][0]*(m-can)
        break
    #print(cnt)
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N, M = map(int, input().split())
*storeList = map(int, open().read().split())
ans = 0
for a, b in sorted(zip(storeList[::2], storeList[1::2])):
    ans += a * min(m, b) ; m = max(0, m - b)
print(ans)


n, m = map(int, input().split())
tupList = []
for i in range(n):
    a, b = [int(i) for i in input().split()]
    tupList.append((a, b))

def tupVal(tup):
    return tup[0]
tupList.sort(key = tupVal)
ans = 0
for i in tupList:
    if m >= i[1]:
        ans += i[0] * i[1]
        m -= i[1]
    else:
        ans += i[0] * m
        break
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N, M = map(int,input().split())

A = []
for i in range(N):
  a,b = map(int,input().split())
  A.append([a,b])

A.sort()
print(A)

nokori = M
yen = 0
mise = 0
while nokori > 0:
  if A[mise][1] >= nokori: 
    yen += A[mise][0]*nokori
    break
  else:
    yen += A[mise][0]*A[mise][1]
    nokori -= A[mise][1]
    mise += 1
print(yen)
  

N, M = map(int,input().split())

A = []
for i in range(N):
  a,b = map(int,input().split())
  A.append([a,b])

A.sort()
#print(A)

nokori = M
yen = 0
mise = 0
while nokori > 0:
  if A[mise][1] >= nokori: 
    yen += A[mise][0]*nokori
    break
  else:
    yen += A[mise][0]*A[mise][1]
    nokori -= A[mise][1]
    mise += 1
print(yen)
  

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
import numpy as np

N, M = map(int, input().split())
A = []
B = []

for i in range(0, N):
    a, b = np.array(list(map(float, input().split())))
    A.append(a)
    B.append(b)

print(A)

cnt = 0
sum = 0
flag = 0
inf = float('inf')
arrayA = np.array(A)
arrayB = np.array(B)
for j in range(0, N):
    idx = A.index(min(arrayA))
    pay = arrayA[idx]
    num = arrayB[idx]
    arrayA[idx]=inf
    if cnt + num < M :
        cnt += num
        sum += pay*num
    else :
        diff = int(M - cnt)
        for t in range(0, diff):
            sum += pay
            cnt += 1
            if cnt == M :
                flag = 1
                print(int(sum))
                break
    if flag == 1:
        break


import numpy as np

N, M = map(int, input().split())
A = []

for i in range(0, N):
    a, b = np.array(list(map(float, input().split())))
    A.append((a, b))

dtype = [('key', int), ('value', int)]
arrayA = np.array(A, dtype=dtype)
arrayA = np.sort(arrayA, order=['key'])
cnt = 0
sum = 0
flag = 0
for j in range(0, N):
    pay = arrayA[j][0]
    num = arrayA[j][1]
    if cnt + num < M :
        cnt += num
        sum += pay*num
    else :
        diff = int(M - cnt)
        for t in range(0, diff):
            sum += pay
            cnt += 1
            if cnt == M :
                flag = 1
                print(int(sum))
                break
    if flag == 1:
        break

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N,M = map(int,input().split())
AB = [tuple(int(i) for i in input().split()) for j in range(N)]
AB.sort()
ans = 0
for i in range(N):
	a,b = AB[i]
	if M-b > 0:
		ans += a*b
		M -= b
    else:
		ans += M*b
		break
print(ans)

N,M = map(int,input().split())
AB = [tuple(int(i) for i in input().split()) for j in range(N)]
AB.sort()
ans = 0
for i in range(N):
    a,b = AB[i]
    if M -b > 0:
        ans += a*b
        M -= b
    else:
        ans += M*a
        break
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m = map(int,input().split())
a = []
b = []
raw = []
ans = 0
for i in range(n):
  raw.append(input())
raw.sort()
for i in range(n):
  raw[i] = raw[i].split()
  ans = ans + float(raw[i][0])*min(m,float(raw[i][1]))
  m = m - min(m,float(raw[i][1]))
  if m == 0:
    break
      
print(ans)

n,m = map(int,input().split())
a = []
b = []
ans = 0
for i in range(n):
  aa, bb = map(int,input().split())
  a.append(aa)
  b.append(bb)
ans = 0
mini = 10000000000
while(1):
  for i in range(n):
    if a[i] < mini:
      mini = a[i]
      index = i
  ans = ans + float(a[index]*min(m,b[index]))
  m = m - min(m,b[index])
  if m == 0:
    break
  a.pop(index)
  b.pop(index)
  n = n - 1
  mini = 10000000000
  
print(ans)

n,m = map(int,input().split())
a = []
b = []
raw = []
ans = 0
for i in range(n):
  raw.append(list(map(int,input().split())))
raw.sort(key=lambda x:x[0])
for i in range(n):
  ans = ans + raw[i][0] * min(raw[i][1],m)
  m = m - min(raw[i][1],m)
  if m == 0:
    break
print(ans)

      


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m=map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
acsd=sorted(ab,key=lambda a:a[0])
print(n,m);print(acsd)
yen_tot=0
n_b=m
def count_p(store,n_v):
    yen,num=store
    return yen*min(n_v,num),max(n_v-num,0)
for s in acsd:
    cost,rem=count_p(s,n_b)
    yen_tot+=cost
    n_b=rem
    if rem==0: break
print(yen_tot)


n,m=map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
acsd=sorted(ab,key=lambda a:a[0])
yen_tot=0
n_b=m
def count_p(store,n_v):
    yen,num=store
    return yen*min(n_v,num),max(n_v-num,0)
for s in acsd:
    cost,rem=count_p(s,n_b)
    yen_tot+=cost
    n_b=rem
    if rem==0: break
print(yen_tot)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m=map(int,input().split())

X=[]

for i in range(n):
    X.append(list(map(int,input().split())))

Y=sorted(X,key=lambda x:x[0])

cnt=0
ans=0
for i in range(n):
    ad=Y[i][1]
    temp=cnt
    cnt+=ad
    if cnt+ad>m:
        ad=m-temp
        ans+=Y[i][0]*ad
        break
    ans+=Y[i][0]*ad

print(ans)

n,m=map(int,input().split())

X=[]

for i in range(n):
    X.append(list(map(int,input().split())))

Y=sorted(X,key=lambda x:x[0])

cnt=0
ans=0
for i in range(n):
    cnt+=Y[i][1]
    if cnt>m:
        ad=m-(cnt-Y[i][1])
        ans+=Y[i][0]*ad
        break
    ans+=Y[i][0]*Y[i][1]

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m  =map(int,input().split())
lm = []
for _ in range(n):
    lm.append(list(map(int,input().split())))
s = 0
mon = 0
lm.sort(key = lambda x:x[0])
while s < m:
    s += 1
    print(s)
    mon += lm[0][0]
    lm[0][1] -= 1
    print(lm)
    if lm[0][1] == 0:
        lm = lm[1::]
print(mon)

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
 
AB.sort()
Ans = 0
for i in AB:
  if i[1] >= M:
    Ans += i[0] * M
    break
  else:
    Ans += i[0] * i[1]
    M -= i[1]
 
print(Ans)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
import numpy as np
n,m=map(int,input().split())
a=np.zeros(n)
b=np.zeros(n)
for i in range(n):
    a[i],b[i]=map(int,input().split())
x=np.argsort(a)
ans=0
i=0
while m>0:
    ans+=a[x[i]]*min(b[x[i]],m)
    i+=1
    m-=b[x[i]]
print(round(ans))
    

import numpy as np
n,m=map(int,input().split())
a=np.zeros(n)
b=np.zeros(n)
for i in range(n):
    a[i],b[i]=map(int,input().split())
x=np.argsort(a)
ans=0
i=0
while m>0:
    ans+=a[x[i]]*min(b[x[i]],m)
    m-=b[x[i]]
    i+=1
print(int(ans))
    


Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m=map(int,input().split());d,ans=[],0
for i in range(n):d.append(list(map(int,input().split())))
d.sort()
for i in range(n):
  if d[i][1]<=m:
    ans+=i*d[i][1]
    m-=d[i][1]
  else:
    ans+=d[i][0]*m
    m=0
  if m<=0:break
print(ans)

n,m=map(int,input().split());dd,d,ans={},{},0
for i in range(n):
  a,b=map(int,input().split())
  if a in dd:dd[a]+=b
  else:dd[a]=b
for i,j in sorted(dd.items()):d[i]=j
for i in d:
  if d[i]<=m:
    ans+=i*d[i]
    m-=d[i]
  else:
    a+=i*m
    m=0
  if m==0:break
print(ans)

n,m=map(int,input().split());d,ans=[],0
for i in range(n):d.append(list(map(int,input().split())))
d.sort()
for i in range(n):
  if d[i][1]<=m:
    ans+=d[i][0]*d[i][1]
    m-=d[i][1]
  else:
    ans+=d[i][0]*m
    m=0
  if m<=0:break
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
import numpy as np

N, M = map(int, input().split())
num_dict = dict()
A_list = []

for n in range(N):
  A, B = map(int, input().split())
  num_dict[A] = B
  A_list.append(A)

A_list.sort()
b_accum = 0
all_pay = 0

for a in A_list:
  if M <= b_accum:
    break

  if b_accum + num_dict[a] <= M:
    all_pay += num_dict[a] * a
    b_accum += num_dict[a]
    
    if M == b_accum:
		
  
  else:
    all_pay += (M - b_accum) * a 
    b_accum += num_dict[a]
    
print(all_pay)

 

import numpy as np

N, M = map(int, input().split())
num_dict = dict()
A_list = []
B_list = []

for n in range(N):
  A, B = map(int, input().split())
  num_dict.setdefault(A, 0)
  num_dict[A] += B
  A_list.append(A)

A_list = list(set(A_list))
A_list.sort()
b_accum = 0
all_pay = 0

for a in A_list:
  if M <= b_accum:
    break

  if b_accum + num_dict[a] <= M:
    all_pay += num_dict[a] * a
    b_accum += num_dict[a]    
  
  else:
    all_pay += (M - b_accum) * a 
    b_accum += num_dict[a]
    break
    
print(all_pay)

 

Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N, M = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
X.sort1(key=lambda x: x[0])
i = 0
num = 0
ans = 0
while i <= N - 1:
    num += X[i][1]
    ans += X[i][0] * X[i][1]
    if num > M:
        ans -= X[i][0] * (num - M)
        break
    i += 1
print(ans)

N, M = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
X.sort(key=lambda x: x[0])
i = 0
num = 0
ans = 0
while i <= N - 1:
    num += X[i][1]
    ans += X[i][0] * X[i][1]
    if num > M:
        ans -= X[i][0] * (num - M)
        break
    i += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N,M = map(int,input().split())
AB=[[int(j) for j in input().split()] for i in range(N)]
ans=0
AB = sorted(AB)
num, ans, i,j =0,0,0,1
while num<M:
    if j<=AB[i][1]:
        ans += AB[i][0]
        num+=1
        j+=1
        print("num",num)
    else:
        i+=1
        j=1
print(ans)

N,M = map(int,input().split())
AB=[[int(j) for j in input().split()] for i in range(N)]
ans=0
AB = sorted(AB)
num, ans, i,j =0,0,0,1
while num<M:
    if j<=AB[i][1]:
        ans += AB[i][0]
        num+=1
        j+=1
    else:
        i+=1
        j=1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m=[int(i) for i in input().split()]

mise={}
for i in range(n):
    a,b=[int(j) for j in input().split()]
    if a in mise:
        mise[a]+=b
    else:
        mise[a]=b
nedan=list(mise.keys())
nedan.sort()
i=0
ans=0
while m:
    honnsuu=mise[nedan[i]]
    kauno=min(honnsuu,m)
    ans+=kauno*nedan[i]
    i+=1
    m=m-kauno
print(mise)    
print(nedan)
print(ans)

n,m=[int(i) for i in input().split()]

mise={}
for i in range(n):
    a,b=[int(j) for j in input().split()]
    if a in mise:
        mise[a]+=b
    else:
        mise[a]=b
nedan=list(mise.keys())
nedan.sort()
i=0
ans=0
while m:
    honnsuu=mise[nedan[i]]
    kauno=min(honnsuu,m)
    ans+=kauno*nedan[i]
    i+=1
    m=m-kauno

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
n,m=map(int,input().split())
drink=[list(map(int,input().split())) for i in range(n)]
#print(drink)

drink.sort()
#print(drink)
money=0
number=0
for i in range(n):
    if number+drink[i][0]=<m:
        money+=drink[i][0]*drink[i][1]
        number+=drink[i][1]
    elif m<number+drink[i][0]:
        money+=drink[i][0]*(m-number)
        number+=m-number
        break
    if m==number:
        break
print(money)

n,m=map(int,input().split())
drink=[list(map(int,input().split())) for i in range(n)]
#print(drink)

drink.sort()
#print(drink)
money=0
number=0
for i in range(n):
    if number+drink[i][1]<=m:
        money+=drink[i][0]*drink[i][1]
        number+=drink[i][1]
    elif m<number+drink[i][1]:
        money+=drink[i][0]*(m-number)
        number+=m-number
        break
    if m==number:
        break
print(money)

Verdicts: Runtime Error

Accepted
Problem: Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.  There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each.  What is the minimum amount of money with which he can buy M cans of energy drinks?  It is guaranteed that, in the given inputs, a sufficient amount of money can always buy M cans of energy drinks.

Submission attempts (in order):
N, M = map(int, input().split())
AB = {}
for i in range(N):
  a, b = map(int, input().split())
  AB[a] = b
ans = 0
for ab in AB:
  if M >= AB[ab]:
    ans += ab * AB[ab]
    M -= AB[ab]
  else:
    ans += ab * M
    break
print(ans)

N, M = map(int, input().split())
AB = []
for i in range(N):
  a, b = map(int, input().split())
  AB.append([a, b])

ans = 0
for ab in sorted(AB, key=lambda x: x[0]):
  if M >= ab[1]:
    ans += ab[0] * ab[1]
    M -= ab[1]
  else:
    ans += ab[0] * M
    M = 0
  if M <= 0:
    break

print(ans)

Verdicts: Wrong Answer

Accepted