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())

S = [[0]*2 for i in range(N)]
for i in range(N):
    S[i] = list(map(int, input().split()))
     
S = sorted(S)
print(S)

quantitys = 0
total = 0

for i in range(N):
    
    if((M - quantitys) - S[i][1])>=0:
        quantitys += S[i][1]
        total += S[i][0] * S[i][1]
    else:
        quantity = M - quantitys
        quantitys += quantity
        total += S[i][0] * quantity
    if M-quantitys == 0:
        break

print(str(total))

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

S = [[0]*2 for i in range(N)]
for i in range(N):
    S[i] = list(map(int, input().split()))
     
S = sorted(S)

quantitys = 0
total = 0

for i in range(N):
    
    if((N - quantitys) - S[i][1])>=0:
        quantitys += S[i][1]
        total += S[i][0] * S[i][1]
    else:
        quantity = N - quantitys
        quantitys += quantity
        total += S[i][0] * S[i][1]
    if N-quantitys == 0:
        break

print(str(total))


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

S = [[0]*2 for i in range(N)]
for i in range(N):
    S[i] = list(map(int, input().split()))
     
S = sorted(S)

quantitys = 0
total = 0

for i in range(N):
    
    if((M - quantitys) - S[i][1])>=0:
        quantitys += S[i][1]
        total += S[i][0] * S[i][1]
    else:
        quantity = M - quantitys
        quantitys += quantity
        total += S[i][0] * S[i][1]
    if M-quantitys == 0:
        break

print(str(total))



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

S = [[0]*2 for i in range(N)]
for i in range(N):
    S[i] = list(map(int, input().split()))
     
S = sorted(S)
print(S)

quantitys = 0
total = 0

for i in range(N):
    
    if((M - quantitys) - S[i][1])>=0:
        quantitys += S[i][1]
        total += S[i][0] * S[i][1]
    else:
        quantity = M - quantitys
        quantitys += quantity
        total += S[i][0] * quantity
    if M-quantitys == 0:
        break

print(str(total))

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

S = [[0]*2 for i in range(N)]
for i in range(N):
    S[i] = list(map(int, input().split()))
     
S = sorted(S)

quantitys = 0
total = 0

for i in range(N):
    
    if((M - quantitys) - S[i][1])>=0:
        quantitys += S[i][1]
        total += S[i][0] * S[i][1]
    else:
        quantity = M - quantitys
        quantitys += quantity
        total += S[i][0] * quantity
    if M-quantitys == 0:
        break

print(str(total))

Verdicts: Wrong Answer

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 = map(int, input().split())
A = np.zeros((N, 2))
for i in range(N):
    A[i,:] = list(map(int, input().split()))
A = A[A[:,0].argsort(), :]


count=0
price=0
for i in range(N):
    if A[0,1]>=M-count:
        price+=A[0,0]*(M-count)
        break
    else:
        price+=A[0,0]*A[0,1]
        count+=A[0,1]
    A=np.delete(A,0,0)
    
print(price)

import numpy as np
N,M=map(int,input().split())
A=[]
 
for i in range(N):
    A+=[[i for i in map(int,input().split())]]
A=np.array(A)
A=A[A[:,0].argsort(),:]

count=0
price=0
for i in range(N):
    if A[i,1]>=M-count:
        price+=A[i,0]*(M-count)
        break
    else:
        price+=A[i,0]*A[i,1]
        count+=A[i,1]

print(price)

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())
S = []
for i in range(N):
  a, b = map(int, input().split())
  S.append([a, b])

S.sort(key=lambda x: x[0])
price = 0
count = 0
for s in S:
  if count + s[1] < M:
    price += s[0] * s[1]
    count += s[1]
  else:
    price += s[0] * (M - s[1])
    break

print(price)

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

S.sort(key=lambda x: x[0])
ans = 0
for s in S:
  if ans + s[0] * s[1] < M:
    ans += s[0] * s[1]
  else:
    q = (M - ans + s[0] - 1) // s[0]
    ans += s[0] * q
    break

print(ans)

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

S.sort(key=lambda x: x[0])
price = 0
count = 0
for s in S:
  if count + s[1] < M:
    price += s[0] * s[1]
    count += s[1]
  else:
    price += s[0] * (M - count)
    break

print(price)

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):
from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split)
  l.append([a,b])
l.sort(key=itemgetter(0))
s=0
for j in range(n):
  s=s+l[j][0]*min(l[j][1],m)
  m=m-l[j][1]
  if m<0:
    break
return s 

from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split)
  l.append([a,b])
l.sort(key=itemgetter(0))
s=0
for j in range(n):
  s=s+l[j][0]*min(l[j][1],m)
  m=m-l[j][1]
  if m<0:
    break
print(s) 

from operator import itemgetter
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  l.append([a,b])
l.sort(key=itemgetter(0))
s=0
for j in range(n):
  s=s+l[j][0]*min(l[j][1],m)
  m=m-l[j][1]
  if m<0:
    break
print(s) 

Verdicts: Runtime Error

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 = [int(x) for x in input().split(' ')]
AB = {}
for i in range(N):
  a,b = [int(x) for x in input().split(' ')]
  AB[a] = b
  
dc = sorted(AB.items())

c = 0
m = M
for s in dc:
  d = m - s[1]
  if d >= 0:
    m -= s[1]
    c += s[0] * s[1]
    #print(m,c)
    if d == 0:
      break
  else:
    print(s[1] + d,"xx")
    c += s[0] * (s[1] + d)
    #print(d)
    break
print(c)

N,M = [int(x) for x in input().split(' ')]
AB = {}
for i in range(N):
  a,b = [int(x) for x in input().split(' ')]
  if a in AB:
    AB[a] += b
  else:
    AB[a] = b
    
dc = sorted(AB.items())

c = 0
m = M
for s in dc:
  price, stock = s
  if stock >= m:
    c += price * m
    break
  else:
    c += stock * price
    m -= stock
    
print(c)
    

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 _ in range(N)]

AB.sort()
count = 0
ans = 0
for i,j in AB:
  if count+j >= M:
    ans += (M-count)*i
    break
  else:
    count += j
    ans += j*i
  print(ans)

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

AB.sort()
count = 0
ans = 0
for i,j in AB:
  if count+j >= M:
    ans += (M-count)*i
    break
  else:
    count += j
    ans += j*i
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 = [list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x:x[0])
print(a)
ans = 0
nokori = M
for j in range(N):
	ans += a[j][0]*min(a[j][1],nokori)
	nokori -= a[j][1]
	if nokori <= 0:
		print(ans)
		exit()



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

A = [x[0] for x in a]
B = [x[1] for x in a]
print(B)
print(A)
A_sorted = sorted(A)
print(A_sorted)
ans = 0
nokori = M
for c in A_sorted:
	print(c)
	for j in range(N):
		if c == A[j]:
			print(j)
			ans += A[j]*min(B[j],nokori)
			nokori -= B[j]
		if nokori <= 0:
			print(ans)
			exit()


N,M = map(int,input().split())
a = [list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x:x[0])
ans = 0
nokori = M
for j in range(N):
	ans += a[j][0]*min(a[j][1],nokori)
	nokori -= a[j][1]
	if nokori <= 0:
		print(ans)
		exit()



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):
from sys import stdin

n,m=map(int,input().split())
l = [stdin.readline().rstrip().split() for _ in range(n)]

l.sort()
a=0
ans=0
for i,j in l:
    aa=int(i)
    aaa=int(j)
    for k in range(aa):
        if a==m:
            print(ans)
            exit()
        else:
            ans+=int(aaa)
            a+=1


n,m=map(int,input().split())
l = [list(map(int,input().split())) for _ in range(n)]
 
l.sort()
a=0
ans=0
for i,j in l:
    for k in range(int(j)):
        if a>=m:
            break
        else:
            ans+=int(i)
            a+=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()) 
z = []
for i in range(n):
  a,b = list(map(int,input().split()))
  z.append((a,b))  
z = sorted(z)
print(z)
sum = 0
for a,b in z:
  if b <= m:
    sum += a * b
    m -= b
  else:
    sum += a * m
    break
print(sum)

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

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())
pairs = [input().split() for _ in range(n)]
pairs.sort(key = lambda x:x[0])
print(pairs)
count = 0
ans = 0
for i in pairs:
    ans += int(i[0])*int(i[1])
    count += int(i[1])
    if count >= m:
        ans -= int(i[0])*(count - m)
        break
print(ans)

n,m = map(int, input().split())
pairs = []
for _ in range(n):
    l = list(map(int,input().split()))
    pairs.append(l)
pairs.sort()
count = 0
ans = 0
for i in pairs:
    ans += i[0]*i[1]
    count += i[1]
    if count >= m:
        ans -= i[0]*(count - m)
        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):
from operator import itemgetter

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

b.sort(key=itemgetter(0))
print('ソート後(0番目の要素)：{}'.format(b))

c=0
d=0
for i in range(N):
    c+=b[i][1]
    d+=b[i][0]*b[i][1]
    if c>M:
        d-=(c-M)*b[i][0]
print(d)

from operator import itemgetter

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

b.sort(key=itemgetter(0))


c=0 
d=0 
for i in range(N):
    c+=b[i][1]
    d+=b[i][0]*b[i][1]
    if c>M:
        d-=(c-M)*b[i][0]
        break
print(d)
print(c)

from operator import itemgetter

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

b.sort(key=itemgetter(0))


c=0 
d=0 
for i in range(N):
    c+=b[i][1]
    d+=b[i][0]*b[i][1]
    if c>M:
        d-=(c-M)*b[i][0]
        break
print(d)


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 = list(map(int,input().split()))
A = [tuple(map(int,input().split())) for _ in range(N)]
sortA = sorted(A,key= lambda x: x[0])
print(sortA)
ans = 0
for i in range(N):
    if M-sortA[i][1]>0:
        ans += sortA[i][0]*sortA[i][1]
        M = M-sortA[i][1]
    else:
        ans += M*sortA[i][0]
        break
print(ans)

N,M = list(map(int,input().split()))
A = [tuple(map(int,input().split())) for _ in range(N)]
sortA = sorted(A,key= lambda x: x[0])
ans = 0
for i in range(N):
    if M-sortA[i][1]>0:
        ans += sortA[i][0]*sortA[i][1]
        M = M-sortA[i][1]
    else:
        ans += M*sortA[i][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 = map(int,input().split()）
ab = [list(map(int,input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda ab:ab[0])

ans = 0
total = 0
for i in range(n):
  num = m-toal
  if ab[i][1]<=num:
    total += ab[i][1]
    ans += ab[i][0]*ab[i][1]
  else:
    total += num
    ans += num*ab[i][1]
    break
print(ans)


n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda ab:ab[0])

ans = 0
total = 0
for i in range(n):
  num = m-toal
  if ab[i][1]<=num:
    total += ab[i][1]
    ans += ab[i][0]*ab[i][1]
  else:
    total += num
    ans += num*ab[i][1]
    break
print(ans)


n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda ab:ab[0])

ans = 0
total = 0
for i in range(n):
  num = m - total
  if ab[i][1]<num:
    total += ab[i][1]
    ans += ab[i][0]*ab[i][1]
  else:
    total += num
    ans += num*ab[i][0]
    break
print(ans)


Verdicts: Runtime Error

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=sorted([list(map(int,input().split())) for _ in range(n)])

print(a)
pay=0
i=0
while m>0:
    p=min(m,a[i][1])
    m-=p
    pay+=p*a[i][0]
    i+=1
print(pay)




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

a=sorted([list(map(int,input().split())) for _ in range(n)])

#print(a)
pay=0
i=0
while m>0:
    p=min(m,a[i][1])
    m-=p
    pay+=p*a[i][0]
    i+=1
print(pay)




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())
AB = np.empty((N, 2), dtype=np.int64)
for n in range(N):
    AB[n, :] = list(map(int, input().split()))
AB = AB[AB[:, 0].argsort(), :]
print(AB)
n = 0
ans = 0
while M > 0:
    if M > AB[n, 1]:
        ans += AB[n, 0] * AB[n, 1]
        M -= AB[n, 1]
    else:
        ans += AB[n, 0] * M
        M = 0
    n += 1
print(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: 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 = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
C = zip(A,B)
C = sorted(C)
A, B = zip(*C)
index = 0
count = 0

for i in range(N):
      if(count<=M):
        index = i
        sum += A[i]*B[i]
        count += B[i]
sum +=A[index]*(M-count)
print(sum)

N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
C = zip(A,B)
C = sorted(C)
A, B = zip(*C)
index = 0
count = 0
sum = 0
for i in range(N):
      if(count<=M):
        index = i
        sum += A[i]*B[i]
        count += B[i]
sum +=A[index]*(M-count)
print(sum)

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=[],[]
for i in range(N):
    A.append(list(map(int, input().split())))
A.sort(key=lambda x:x[0])
R,S=M,0
for a in A:
    if a[1]>=R:
        print(a[0],R)
        S+=a[0]*R;R=0
    else:
        print(a[0],a[1])
        S+=a[0]*a[1];R-=a[1]
    if R==0: break
print(S)



N,M=map(int, input().split())
A,B=[],[]
for i in range(N):
    A.append(list(map(int, input().split())))
A.sort(key=lambda x:x[0])
R,S=M,0
for a in A:
    if a[1]>=R:
        S+=a[0]*R;R=0
    else:
        S+=a[0]*a[1];R-=a[1]
    if R==0: break
print(S)



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 _ in range(n)], key=lambda x:x[0])

ans = 0
for i in range(n):
    print(ab[i][1], m)
    if ab[i][1] < m:
        ans += ab[i][0] * ab[i][1]
        m -= ab[i][1]
    else:
        ans += ab[i][0] * m
        break

print(ans)


n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[0])

ans = 0
for i in range(n):
    if ab[i][1] < m:
        ans += ab[i][0] * ab[i][1]
        m -= ab[i][1]
    else:
        ans += ab[i][0] * m
        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 = []
ans = 0
for i in range(N):
    A,B = map(int,input().split())
    t = A,B
    AB.append(t)
    
AB.sort()

for i in range(len(AB)):
    if M > 0:
        break
    for x in range(AB[i][1]):
        if M > 0:
            ans += AB[i][0]
            M -= 1
        

print(ans)



import sys
input = sys.stdin.readline
N,M=[int(x) for x in input().strip().split()]
AN=[]
BN=[]
val={}
for i in range(N):
    Ai,Bi=[int(x) for x in input().strip().split()]
    val[Ai]=Bi+val.get(Ai,0)
    AN.append(Ai)
 
AN=sorted(set(AN))
m=0
ans=0
for Ai in AN:
    ans+=Ai*min(M-m,val[Ai])
    m+=min(M-m,val[Ai])
    if m==M:
        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())
l=[]
for i in range(n):
  a,s=map(int,input().split())
  l.append([a,s])
l=sorted(l)
p=0
c=0
for i in l:
  if c+l[i][1]>m:
    p+=l[i][0]*(m-c)
    break
  else:
    p+=l[i][0]*l[i][1]
    c+=l[i][1]
print(p)

n,m=map(int,input().split())
l=[]
for i in range(n):
  a,s=map(int,input().split())
  l.append([a,s])
l=sorted(l)
p=0
c=0
for i in range(len(l)):
  if c+l[i][1]>m:
    p+=l[i][0]*(m-c)
    break
  else:
    p+=l[i][0]*l[i][1]
    c+=l[i][1]
print(p)

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 = list(map(int, input().split()))
A = []
B = []

for i in range(N):
	A[i],B[i]=list(map(int, input().split()))

sum = 0
ans = 0
for i in range(N):
	idx = num_list.index(min(A))
	sum += A[idx]*B[idx]
	A[idx] = 10000000
	ans += 1
	if(sum >= M):
		break

print(ans)


import numpy as np

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

for i in range(N):
	A[i],B[i]=list(map(int, input().split()))

sum = 0
ans = 0

idx = np.argsort(A)

for i in range(N):
	if(sum+B[idx[i]] >= M):
		for j in range(B[idx[i]]):
			ans += A[idx[i]]
			sum += 1
			if(sum >= M):
				break
		break
	ans += A[idx[i]]*B[idx[i]]
	sum += B[idx[i]]
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())
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort()
cnt = 0
mon = 0
i = 0
if n >= 2:
    while cnt <= m:
        if lis[i][1] + cnt <= m:
            cnt += lis[i][1]
            mon += lis[i][0]*lis[i][1]
            i += 1
        else:
            break
    print(mon + (m-cnt) * lis[i][0])
print(m*lis[0][0])


n,m = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort()
cnt = 0
mon = 0
i = 0
if n >= 2:
    while cnt < m:
        if lis[i][1] + cnt < m:
            cnt += lis[i][1]
            mon += lis[i][0]*lis[i][1]
            i += 1
        else:
            break
    print(mon + (m-cnt) * lis[i][0])
else:
    print(m*lis[0][0])

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 = [int(x) for x in input().split()]
V = [tuple(map(int, innput().split())) for i in range(N)]
V.sort()

money = 0
count = 0

for a, b in V:
  if count + b < M:
    count += b
    money += a * b
  else:
    money += (M - b) * a
    break
print(money)

N, M = [int(x) for x in input().split()]
V = [tuple(map(int, input().split())) for i in range(N)]
V.sort()

money = 0
count = 0

for a, b in V:
  if count + b < M:
    count += b
    money += a * b
  else:
    money += (M - b) * a
    break
print(money)

N, M = [int(x) for x in input().split()]
V = [tuple(map(int, input().split())) for i in range(N)]
V.sort()

money = 0
count = 0

for a, b in V:
  if count + b < M:
    count += b
    money += a * b
  else:
    money += (M - count) * a
    break
print(money)

Verdicts: Runtime Error

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=[]
for i in range(n):
  a.append(list(map(int,input().split())))
a.sort()
totl=0
x=0
for j,k in range(a):
  if x+j<m:
    totl+=j*k
    x+=k
  else:
    totl+=j*(x-m)
    break
print(totl)
    
    
  
  

n,m=map(int,input().split())
d={}
for i in range(n):
  a,b=map(int,input().split())
  d[b]=a
D=sorted(d.items(),key=lambda x:x[1])
val=0
cnt=0
j=0
while cnt<=m:
  cnt+=int(D[j][0])
  val+=int(D[j][1])
  j+=1
val-=int(D[j][1])*(cnt-m)
print(val)


n,m=map(int,input().split())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
a.sort()
totl=0
x=0
for j,k in a:
  if x+k<m:
    totl+=j*k
    x+=k
  else:
    totl+=j*(x+k-m)
    break
print(totl)
    
    
  
  


n,m=map(int,input().split())
d={}
for i in range(n):
  a,b=map(int,input().split())
  d[b]=a
D=sorted(d.items())
val=0
cnt=0
j=0
while cnt<=m:
  cnt+=D[j][0]
  val+=D[j][1]
  j+=1
val-=D[j][1]*(cnt-m)
print(val)


n,m=map(int,input().split())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
a.sort()
totl=0
x=0
for j,k in a:
  if x+k<m:
    totl+=j*k
    x+=k
  else:
    totl+=j*(x-m)
    break
print(totl)
    
    
  
  


n,m=map(int,input().split())
d={}
for i in range(n):
  a,b=map(int,input().split())
  d[b]=a
D=sorted(d.items())
val=0
cnt=0
j=0
while cnt<=m:
  cnt+=int(D[j][0])
  val+=int(D[j][1])
  j+=1
val-=int(D[j][1])*(cnt-m)
print(val)


n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  s,t=map(int,input().split())
  a.append(s)
  b.append(t)
c=sorted(a)
d=[0]*n
for j in range(n):
  d[j]=b[a.index(c[j])]
cnt=0
totl=0
for l in range(n):
  if cnt==m:
      print(totl)
      break
  if cnt>m:
      print(totl-(cnt-m)*c[l-1])
      break
  else:
    totl+=c[l]
    cnt+=d[l]
    
     
           
    

n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  s,t=map(int,input().split())
  a.append(s)
  b.append(t)
c=sorted(a)
d=[0]*n
for j in range(n):
  d[j]=b[a.index(c[j])]
cnt=0
totl=0
for l in range(n):
  if cnt==m:
      print(totl)
      break
  elif cnt>m:
    if l==0:
      print(c[0]*m)
      break
    else:
      print(totl-(cnt-m)*c[l-1])
      break
  else:
    totl+=c[l]
    cnt+=d[l]
    
     
           
    


n,m=map(int,input().split())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
a.sort()
totl=0
x=0
for j,k in a:
  if x+k<m:
    totl+=j*k
    x+=k
  else:
    totl+=j*(m-x)
    break
print(totl)
    
    
  
  


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

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())
p_list = []


#     a, b = map(int, input().split())
#     p_list.append([a, b])
    


# price = 0

# while num < M:

#     price += p_sort[1][i] * p_sort[0][i]



# print(price)
res = M
for i in range(N):
    a, b = map(int, input().split())
    p_list.append(a, b)

for price, amount in sorted(zip(p_list[::2], p_list[1::2])):
    total_p += price * min(res, amount)
    res -= amount
    if res <= 0:
        break
        
print(total_p)
    

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

res = M
total_p = 0
for i in range(N):
    a, b = map(int, input().split())
    p_list.append(a)
    p_list.append(b)

for price, amount in sorted(zip(p_list[::2], p_list[1::2])):
    total_p += price * min(res, amount)
    res -= amount
    if res <= 0:
        break
        
print(total_p)



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.append([a,b])

sortedAB = sorted(AB, key=lambda x:x[0])

ans = 0
for i in range(N):
    a = sortedAB[i][0]
    b = sortedAB[i][1]
    if M == 0:
        print(ans)
        exit()
    if b <= M:
        M -= b
        ans += a*b
    else:
        ans += a*M


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

sortedAB = sorted(AB, key=lambda x:x[0])

ans = 0
for i in range(N):
    a = sortedAB[i][0]
    b = sortedAB[i][1]
    if M == 0:
        exit()
    if b <= M:
        M -= b
        ans += a*b
    else:
        ans += a*M


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

sortedAB = sorted(AB, key=lambda x:x[0])

ans = 0
for i in range(N):
    a = sortedAB[i][0]
    b = sortedAB[i][1]
    if M == 0:
        print(ans)
        exit()
    if b <= M:
        ans += a*b
        M -= b
    else:
        ans += a*M
        M = 0


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

sortedAB = sorted(AB, key=lambda x:x[0])

ans = 0
for i in range(N):
    a = sortedAB[i][0]
    b = sortedAB[i][1]
    if M == 0:
        print(ans)
        exit()
    if b <= M:
        ans += a*b
        M -= b
    else:
        ans += a*M
        M = 0

print(ans)      

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):
n,m = map(int, input().split(" "))
a = []
b = []
for i in range(n):
    temp = list(map(int,input().split(" ")))
    a.append(temp[0])
    b.append(temp[1])

sort_a = sorted(set(a))
money = 0

for ai in sort_a:
    ind = [i for i, x in enumerate(a) if x == ai]
    print(ind)
    for i in ind:
        x = min(m,b[i])
        m = m - x
        money = money + a[i]*x
    if m <= 0:
        break

print(money)

def key_func(n):
    return n[0]

n,m = map(int, input().split(" "))
a_b = []
for i in range(n):
    a_b.append(list(map(int,input().split(" "))))

a_b.sort(key=key_func)

money = 0

for item in a_b:
    i = min(m,item[1])
    money = money + item[0]*i
    m = m - i
    if m <= 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):
N, M= map(int, input().split())
A = []
B = []
count = 0
cost = 0
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)
    count += b
    cost += a * b
    while count > M:
        pos = A.index(max(A))
        if count - B[pos] > 0:
            count -= B[pos]
            cost -= A[pos] * B[pos]
            A.pop(pos)
            B.pop(pos)
        else:
            cost -= A[pos] * (M - count)
            B[pos] -= M - count
            count = M

print(cost)

N, M= map(int, input().split())
A = []
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
A = sorted(A)
count = 0
cost = 0
i = 0
while count < M:
    cost += A[i][0] * min(A[i][1],M-count)
    count += min(A[i][1],M-count)
        
print(cost)

N, M= map(int, input().split())
A = []
B = []
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)
count = 0
cost = 0
while count < M:
    pos = A.index(min(A))
    count += min(B[pos],M-count)
    cost += A[pos] * min(B[pos],M-count)
    A.pop(pos)
    B.pop(pos)
        
print(cost)

N, M= map(int, input().split())
A = []
for i in range(N):
    a = list(map(int, input().split()))
    A.append(a)
A = sorted(A)
count = 0
cost = 0
i = 0
while count < M:
    cost += A[i][0] * min(A[i][1],M-count)
    count += min(A[i][1],M-count)
    i += 1    
print(cost)

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):
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)

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)

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)


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)


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)


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)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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=[int(i) for i in input().split(' ')]
class P:
  def __init__(self, a, b)
  	self.a = a
    self.b = b

p = []
for i in range(n):
  a,b=[int(i) for i in input().split(' ')]
  p.append(P(a, b))

  
mon = 0
p.sort(key=lambda x: x.a)
for e in p:
  if m <= e.b:
    mon += e.q * m
    m = 0
  else:
    m -= e.b
    mon += e.a * e.b

print(mon)

n,m=[int(i) for i in input().split(' ')]
class P:
  def __init__(self, a, b):
    self.a = a
    self.b = b

p = []
for i in range(n):
  a,b=[int(i) for i in input().split(' ')]
  p.append(P(a, b))

  
mon = 0
p.sort(key=lambda x: x.a)
for e in p:
  if m <= e.b:
    mon += e.a * m
    m = 0
  else:
    m -= e.b
    mon += e.a * e.b

print(mon)

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=[]
ai,bi=map(int,input().split())
a.append(ai)
b.append(bi)
for i in range(1:n):
    ai,bi=map(int,input().split())
    for ii in range(i-1):
        if ai<a[ii]:
            a.insert(ii,ai)
            b.insert(ii,bi)
            break
    if len(a)==i-1:
        a.append(ai)
        b.append(bi)
#print(ai)
msum=0
asum=0
for i in range(n):
    asum=asum+a[i]*b[i]
    msum=msum+b[i]  
    if msum>=m:
        break
asum=asum-a[i]*(msum-m)
print(asum)
        
        


n,m=map(int,input().split())
a=[]
b=[]
ai,bi=map(int,input().split())
a.append(ai)
b.append(bi)
for i in range(1,n):
    ai,bi=map(int,input().split())
    for ii in range(i-1):
        if ai<a[ii]:
            a.insert(ii,ai)
            b.insert(ii,bi)
            break
    if len(a)== i:
        a.append(ai)
        b.append(bi)
#print(a)
#print(b)
msum=0
asum=0
for i in range(n):
    asum=asum+a[i]*b[i]
    msum=msum+b[i]  
    if msum>=m:
        break
asum=asum-a[i]*(msum-m)
print(asum)
#print(i,msum,m)
        

n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
    for ii in range(i-1):
        if ai<a[ii]:
            a.insert(ii)=ai
            b.insert(ii)=bi
            break
        else:
            a.append(ai)
            b.append(bi)
print(ai)
  


n,m=map(int,input().split())
ab=[[0]*2 for i in range(n)]
for i in range(n):
    ab[i]=list(map(int,input().split()))
    
ab.sort()

mm=0
y=0
for i in range(n):
    mm+=ab[i][1]
    y+=ab[i][0]*ab[i][1]
    if mm>=m:
        break
y=y-(mm-m)*ab[i][0]
print(y)
    

Verdicts: Runtime Error

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):
#coding: utf-8
import numpy as np
N, M = map(int, input().split())
AB = np.array([list(map(int, input().split())) for _ in range(N)])
money = 0
col_num = 0
AB = AB[np.argsort(AB[:, col_num])]
print(AB)
if M <= AB[np.argmin(AB[:, 0]), 1]:
    money += AB[0, 0] * M
else:
    i = 0
    while M >= 0:
        money += AB[i, 0] * AB[i, 1]
        M -= AB[i, 1]
        if M < 0:
          money += AB[i, 0] * M
        i += 1
print(money)

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
money = 0
AB = sorted(AB, key=lambda x: x[0])
if M <= AB[0][1]:
  money += AB[0][0] * M
else:
  i = 0
  while M > 0:
    money += AB[i][0] * AB[i][1]
    M -= AB[i][1]
    if M <= 0:
      money += AB[i][0] * M
      break
    i += 1
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(" "))
A_list = []
B_list = []
total = 0

for i in range(N):
    A, B = map(int, input().split(" "))
    A_list.append(A)
    B_list.append(B)

z = list(zip(A_list, B_list))
z.sort()

for a, b in z:
    if b > M:
        total += M * a
        break
    else:
        total += b * a
        M -= b

print(total)

N, M = map(int, input().split(" "))
A_list = []
B_list = []
total = 0

for i in range(N):
    A, B = map(int, input().split(" "))
    A_list.append(A)
    B_list.append(B)

z = list(zip(A_list, B_list))
z.sort()

for a, b in z:
    if b > M:
        total += M * a
        break
    else:
        total += b * a
        M -= b

print(total)

Verdicts: Runtime Error

Accepted