problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p03103
u235210692
2,000
1,048,576
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.
['n,m=[int(i) for i in input().split()]\n\nmise={}\nfor i in range(n):\n a,b=[int(j) for j in input().split()]\n if a in mise:\n mise[a]+=b\n else:\n mise[a]=b\nnedan=list(mise.keys())\nnedan.sort()\ni=0\nans=0\nwhile m:\n honnsuu=mise[nedan[i]]\n kauno=min(honnsuu,m)\n ans+=kauno*nedan[i]\n i+=1\n m=m-kauno\nprint(mise) \nprint(nedan)\nprint(ans)', 'n,m=[int(i) for i in input().split()]\n\nmise={}\nfor i in range(n):\n a,b=[int(j) for j in input().split()]\n if a in mise:\n mise[a]+=b\n else:\n mise[a]=b\nnedan=list(mise.keys())\nnedan.sort()\ni=0\nans=0\nwhile m:\n honnsuu=mise[nedan[i]]\n kauno=min(honnsuu,m)\n ans+=kauno*nedan[i]\n i+=1\n m=m-kauno\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s852709072', 's053461843']
[22492.0, 17884.0]
[463.0, 432.0]
[367, 339]
p03103
u236536206
2,000
1,048,576
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.
['n,m=map(int,input().split())\ndrink=[list(map(int,input().split())) for i in range(n)]\n#print(drink)\n\ndrink.sort()\n#print(drink)\nmoney=0\nnumber=0\nfor i in range(n):\n if number+drink[i][0]=<m:\n money+=drink[i][0]*drink[i][1]\n number+=drink[i][1]\n elif m<number+drink[i][0]:\n money+=drink[i][0]*(m-number)\n number+=m-number\n break\n if m==number:\n break\nprint(money)', 'n,m=map(int,input().split())\ndrink=[list(map(int,input().split())) for i in range(n)]\n#print(drink)\n\ndrink.sort()\n#print(drink)\nmoney=0\nnumber=0\nfor i in range(n):\n if number+drink[i][1]<=m:\n money+=drink[i][0]*drink[i][1]\n number+=drink[i][1]\n elif m<number+drink[i][1]:\n money+=drink[i][0]*(m-number)\n number+=m-number\n break\n if m==number:\n break\nprint(money)']
['Runtime Error', 'Accepted']
['s571008751', 's160925206']
[8916.0, 27320.0]
[26.0, 351.0]
[413, 413]
p03103
u238084414
2,000
1,048,576
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.
['N, M = map(int, input().split())\nAB = {}\nfor i in range(N):\n a, b = map(int, input().split())\n AB[a] = b\nans = 0\nfor ab in AB:\n if M >= AB[ab]:\n ans += ab * AB[ab]\n M -= AB[ab]\n else:\n ans += ab * M\n break\nprint(ans)', 'N, M = map(int, input().split())\nAB = []\nfor i in range(N):\n a, b = map(int, input().split())\n AB.append([a, b])\n\nans = 0\nfor ab in sorted(AB, key=lambda x: x[0]):\n if M >= ab[1]:\n ans += ab[0] * ab[1]\n M -= ab[1]\n else:\n ans += ab[0] * M\n M = 0\n if M <= 0:\n break\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s694626950', 's951774753']
[17884.0, 21992.0]
[333.0, 401.0]
[232, 296]
p03103
u247554097
2,000
1,048,576
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.
['\nn, m = map(int, input().split())\nh = dict()\nfor _ in range(n):\n k, v = map(int, input().split())\n h[k] = v\nh = sorted(h.items(), key=lambda x: x[0])\n\n\nans = 0\nfor k, v in h:\n while v > 0:\n if m <= 0:\n exit()\n else:\n v -= 1\n ans += k\n m -= 1\n\nprint(ans)\n', '\n\n\nn, m = map(int, input().split())\nh = dict()\nfor _ in range(n):\n k, v = map(int, input().split())\n if k in h:\n h[k] += v\n else:\n h[k] = v\nh = sorted(h.items(), key=lambda x: x[0])\n\n\nans = 0\nfor k, v in h:\n while v > 0:\n if m <= 0:\n print(ans)\n exit()\n else:\n v -= 1\n ans += k\n m -= 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s348333133', 's789785024']
[24152.0, 24144.0]
[404.0, 415.0]
[340, 456]
p03103
u248967559
2,000
1,048,576
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.
["class Shop():\n def __init__(self, a, b):\n self.a = a\n self.b = b\n\nN, M = [ int(x) for x in input().split(' ')]\nshops = []\nfor i in range(N):\n a, b = [int(x) for x in input().split(' ')]\n shops.append(Shop(a, b))\n\nshops.sort(key=lambda x: x.a)\n\ncost = 0\nbought = 0\nfor i in range(N):\n shop = shops[i]\n print(i, cost, bought, shop.a, shop.b)\n if (shop.b <= M - bought):\n cost += shop.a * shop.b\n bought += shop.b\n else:\n cost += shop.a * (M - bought)\n bought += (M - bought)\n if (bought == M):\n break\n\nprint(cost)\n", "class Shop():\n def __init__(self, a, b):\n self.a = a\n self.b = b\n\nN, M = [ int(x) for x in input().split(' ')]\nshops = []\nfor i in range(N):\n a, b = [int(x) for x in input().split(' ')]\n shops.append(Shop(a, b))\n\nshops.sort(key=lambda x: x.a)\n\ncost = 0\nbought = 0\nfor i in range(N):\n shop = shops[i]\n if (shop.b <= M - bought):\n cost += shop.a * shop.b\n bought += shop.b\n else:\n cost += shop.a * (M - bought)\n bought += (M - bought)\n if (bought == M):\n break\n\nprint(cost)\n"]
['Wrong Answer', 'Accepted']
['s381475782', 's763708398']
[28308.0, 28308.0]
[786.0, 549.0]
[585, 542]
p03103
u255943004
2,000
1,048,576
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.
['N,M = map(int,input().split())\nAB = []\nfor _ in range(N):\n AB.append([int(i) for i in input().split()])\nAB_sort = sorted(AB,key=lambda x : x[0])\nmoney = 0\nfor ab in AB_sort:\n if M >= ab[0]:\n money += ab[0] * ab[1]\n M -= ab[1]\n else:\n money += M * ab[1]\n break\nprint(money)', 'N,M = map(int,input().split())\nAB = []\nfor _ in range(N):\n AB.append([int(i) for i in input().split()])\nAB_sort = sorted(AB,key=lambda x : x[0])\nmoney = 0\nfor ab in AB_sort:\n if M >= ab[1]:\n money += ab[0] * ab[1]\n M -= ab[1]\n else:\n money += M * ab[0]\n break\nprint(money)\n']
['Wrong Answer', 'Accepted']
['s816341828', 's200376876']
[23520.0, 23520.0]
[397.0, 406.0]
[309, 310]
p03103
u261646994
2,000
1,048,576
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.
['import re\nimport numpy as np\n\nnp.seterr(over=\'raise\')\n\nN, M = [int(item) for item in re.split(r"\\s", input())]\n\nAB = []\nfor _ in range(N):\n AB.append([int(item) for item in re.split(r"\\s", input())])\n\nAB = np.array(AB)\nA = AB[:, 0]\nB = AB[:, 1]\n\nprint(AB)\n\nsorted_B = B[np.argsort(A)]\nsorted_A = np.sort(A)\n\n\ncumB = np.cumsum(sorted_B)\nindex = np.argmax(cumB > M)\n\nif N > 1:\n total = np.sum(sorted_A[:index] * sorted_B[:index])\n total = total + (M - cumB[index - 1]) * sorted_A[index]\nelse:\n total = M * sorted_A[0]\n\nprint(total)\n', 'import re\nimport numpy as np\n\nnp.seterr(over=\'raise\')\n\nN, M = [int(item) for item in re.split(r"\\s", input())]\n\nAB = []\nfor _ in range(N):\n AB.append([int(item) for item in re.split(r"\\s", input())])\n\nAB = np.array(AB)\nA = AB[:, 0]\nB = AB[:, 1]\n\n\nsorted_B = B[np.argsort(A)]\nsorted_A = np.sort(A)\n\n\ncumB = np.cumsum(sorted_B)\nindex = np.argmax(cumB > M)\n\nif N > 1 and index > 0:\n total = np.sum(sorted_A[:index] * sorted_B[:index])\n total = total + (M - cumB[index - 1]) * sorted_A[index]\nelse:\n total = M * sorted_A[0]\n\nprint(total)\n']
['Wrong Answer', 'Accepted']
['s429018551', 's795018487']
[31616.0, 31668.0]
[715.0, 715.0]
[542, 546]
p03103
u263830634
2,000
1,048,576
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.
['import sys\n\nN, M = map(int, input().split())\nlst = []\nfor i in range(N):\n lst += [list(map(int, input().split()))]\nlst.sort() \nprint (lst)\ncount = M\nyen = 0\n\nfor i in range(N):\n yen += lst[i][0] * min(count, lst[i][1]) \n count -= min(count, lst[i][1])\n# print (count)\n if count <= 0:\n print (yen)\n sys.exit()', 'import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 9)\nMOD = 10 ** 9 + 7\n\nN, M = map(int, input().split())\nAB = [tuple(map(int, input().split())) for _ in range(N)]\nAB.sort(key = lambda x: x[0])\n\nans = 0\nfor i in range(N):\n if AB[i][1] >= M:\n ans += AB[i][0] * M\n print (ans)\n break\n ans += AB[i][0] * AB[i][1]\n M -= AB[i][1]']
['Wrong Answer', 'Accepted']
['s041701988', 's526079569']
[33776.0, 18052.0]
[638.0, 253.0]
[341, 369]
p03103
u267683315
2,000
1,048,576
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.
['N,M = map(int,input().split())\ndrink_dict = {}\nfor i in range(N):\n A,B = map(int,input().split())\n if A not in drink_dict:\n \tdrink_dict[A] = B\n else:\n drink_dict[A] += B \ntotal_number = 0\ntotal_price = 0\nfor price,number in drink_dict.items():\n if total_number + number >= M:\n print(total_price + (M-total_number) * price)\n else:\n total_price+=price*number\n total_number+= number', 'N,M = map(int,input().split())\ndrink_dict = {}\nfor i in range(N):\n A,B = map(int,input().split())\n if A not in drink_dict:\n \tdrink_dict[A] = B\n else:\n drink_dict[A] += B \ndrink_list = sorted(drink_dict.items())\ntotal_number = 0\ntotal_price = 0\nfor i in drink_list:\n if total_number + i[1] >= M:\n print(total_price + (M-total_number) * i[0])\n break;\n else:\n total_price+=i[0]*i[1]\n total_number+= i[1]']
['Wrong Answer', 'Accepted']
['s432007099', 's637659873']
[17880.0, 22992.0]
[402.0, 432.0]
[397, 421]
p03103
u271469978
2,000
1,048,576
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.
['import numpy as np\nimport pandas as pd\n\nn, m = map(int, input().split())\nlines = sys.stdin.readlines()\nlines = [list(map(float, line.strip().split())) for line in lines]\ndf = pd.DataFrame(lines,\n columns = ["price", "stock"],\n dtype = float\n )\ndf = df.sort_values(by="price")\nprice = 0\nfor i in range(n):\n if m - df.iloc[i]["stock"] > 0:\n price += df.iloc[i]["price"] * df.iloc[i]["stock"]\n m -= df.iloc[i]["stock"]\n else:\n price += df.iloc[i]["price"] * m\n break\nprint(int(price))', 'import sys\nimport numpy as np\n\nn, m = map(float, input().split())\nlines = sys.stdin.readlines()\nlines = [list(map(float, line.strip().split())) for line in lines]\nlines.sort()\nprice = 0\nfor line in lines:\n if m - line[1] > 0:\n price += line[0] * line[1]\n m -= line[1]\n else:\n price += line[0] * m\n break\nprint(int(price))']
['Runtime Error', 'Accepted']
['s904739778', 's245206774']
[21924.0, 42584.0]
[349.0, 505.0]
[566, 355]
p03103
u277353449
2,000
1,048,576
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.
['n,m=map(int,input().split())\na=[]\nfor i in range(0,n):\n b,c=map(int,input().split())\n a.append([b,c])\na.sort()\nnumber=0\nfor i in range(0,len(a)):\n while number<m:\n number=number+a[i][1]\n l=i\nprint(l)\nanswer=0\nkosu=0\nfor k in range(0,l+1):\n answer=answer+a[k][0]*a[k][1]\n kosu=kosu+a[k][1]\nprint(answer)\nanswer=answer+a[l+1][0]*(m-kosu)\nprint(answer)', 'n,m=map(int,input().split())\na=[]\nfor i in range(0,n):\n b,c=map(int.input().split())\n a.append[b,c]\na.sort()\nnumber=0\nfor i in range(0,len(a)):\n while number<m:\n number=number+a[i][1]\n l=i\nanswer=0\nkosu=0\nfor k in range(0,l-1):\n answer=answer+a[k][0]*a[k][1]\n kosu=kosu+a[k][1]\nanswer=answer+a[l][0]*(m-kosu)\nprint(answer)', 'n,m=map(int,input().split())\na=[]\nfor i in range(0,n):\n b,c=map(int,input().split())\n a.append([b,c])\na.sort()\nnumber=0\nfor i in range(0,len(a)):\n if number<m:\n number=number+a[i][1]\n l=i\nanswer=0\nkosu=0\nfor k in range(0,l):\n answer=answer+a[k][0]*a[k][1]\n kosu=kosu+a[k][1]\nanswer=answer+a[l][0]*(m-kosu)\nprint(answer)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s579701490', 's683096290', 's238963842']
[20064.0, 3064.0, 20064.0]
[442.0, 17.0, 480.0]
[378, 333, 348]
p03103
u282228874
2,000
1,048,576
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.
['N,M = map(int,input().split())\nAB = sorted([list(map(int,input().split())) for i in range(N)])\nres = 0\nfor a,b in range(N):\n M -= b\n res += a*b\n if M < 0:\n res += a*M\n break\nprint(res)', 'N,M = map(int,input().split())\nAB = sorted([list(map(int,input().split())) for i in range(N)])\nres = 0\nfor a,b in AB:\n M -= b\n res += a*b\n if M < 0:\n res += a*M\n break\nprint(res)']
['Runtime Error', 'Accepted']
['s455249796', 's234500250']
[28652.0, 28652.0]
[455.0, 508.0]
[207, 201]
p03103
u297756089
2,000
1,048,576
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.
['n,m=map(int,input().split())\nsets = {}\ncosts_li=[]\nlimit_li=[]\nbought=0\npay=0\nfor i in range (1,n+1):\n cost,limit=map(int,input().split())\n limit_li.append(cost)\n costs_li.append(cost)\n sets[str(cost)]=limit\ncosts_li.sort()\nfor j in range(0,n+1):\n if bought<m:\n pay=pay+costs_li[j]*sets[str(costs_li[j])]\n bought=bought+sets[str(costs_li[j])]\n elif bought>m:\n pay=pay-costs_li[j-1]*(bought-m)\n bought=m\n else:\n pay=pay\n bought=bought\n print(pay)', 'n,k=map(int,input().split())\nli=[]\nfor i in range (0,n):\n li.append(list(map(int,input().split())))\nli.sort()\nbought=0\npay=0\nt=0\nwhile bought<k:\n pay=pay+(li[t][0])*(li[t][1])\n bought=bought+li[t][1]\n t=t+1\npay=pay-li[t-1][0]*li[t-1][1]\nbought=bought-li[t-1][1]\nbought_2=k-bought\npay_2=li[t-1][0]*bought_2\npay=pay+pay_2\nprint(pay)']
['Wrong Answer', 'Accepted']
['s306383464', 's882073649']
[25980.0, 27884.0]
[593.0, 481.0]
[511, 334]
p03103
u300579805
2,000
1,048,576
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.
['for i in range(N):\n A[i],B[i] = map(int, input().split()) \n\nC = dict(zip(A,B))\n\nc_sorted = sorted(C.items(), key=lambda x:x[0])\n\nans = 0\ncnt = 0\n\nfor k,v in dict(c_sorted).items():\n cnt += v\n if (cnt < M):\n ans += k*v\n else:\n ans += (M-cnt+v) * k\n break\nprint(ans) ', 'N, M = map(int, input().split())\nABs = [tuple(map(int, input().split())) for _ in range(N)]\n \nABs.sort()\n \nans = 0\nfor A, B in ABs:\n ans += A * min(M, B)\n M -= min(M, B)\nprint(ans)']
['Runtime Error', 'Accepted']
['s235873893', 's299530999']
[3064.0, 16964.0]
[17.0, 462.0]
[299, 186]
p03103
u304593245
2,000
1,048,576
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.
['import numpy as np\n\ndef solve():\n cnt = 0\n money = 0\n for i in range(N):\n if cnt >= M:\n break\n if cnt + AB[i][1] >= M:\n money += AB[i][0] * (M - cnt)\n cnt = M \n else:\n money += AB[i][0]*AB[i][1]\n cnt = AB[i][1]\n print(cnt)\n print(money)\n\nif __name__ == "__main__":\n N,M = list(map(int, input().split())) \n AB = [list(map(int, input().split())) for _ in range(N)]\n AB.sort(key=lambda x: x[0])\n\n solve()\n', 'import numpy as np\n\ndef solve():\n cnt = 0\n money = 0\n for i in range(N):\n if cnt >= M:\n break\n if cnt + AB[i][1] >= M:\n money += AB[i][0] * (M - cnt)\n cnt = M \n else:\n money += AB[i][0]*AB[i][1]\n cnt += AB[i][1]\n# print(cnt)\n print(money)\n\nif __name__ == "__main__":\n N,M = list(map(int, input().split())) \n AB = [list(map(int, input().split())) for _ in range(N)]\n AB.sort(key=lambda x: x[0])\n\n solve()\n']
['Wrong Answer', 'Accepted']
['s493535010', 's740525847']
[46596.0, 46420.0]
[366.0, 374.0]
[523, 525]
p03103
u305965165
2,000
1,048,576
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.
['N, M = (int(i) for i in input().split()) \ne = [[int(i) for i in input().split()] for i in range(N)]\n\nresult = 0\nfor x in e:\n if M > x[1]:\n M -= x[1]\n result += x[0] * x[1]\n else:\n result += x[0] * M\n break\n\nprint(result)\n', 'N, M = (int(i) for i in input().split()) \ne = sorted([[int(i) for i in input().split()] for i in range(N)])\n\nresult = 0\nfor x in e:\n if M > x[1]:\n M -= x[1]\n result += x[0] * x[1]\n else:\n result += x[0] * M\n break\n\nprint(result)\n\n\n']
['Wrong Answer', 'Accepted']
['s127336301', 's946446574']
[21164.0, 22376.0]
[324.0, 454.0]
[256, 266]
p03103
u315703650
2,000
1,048,576
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.
['N,M = list(map(int,input().split()))\nab = [list(map(int,input().split())) for _ in range(N)]\n\nprint(ab)\nab.sort(key=lambda ab:(ab[0]))\nprint(ab)\ns = 0\ncnt = 0\nfor i in range(M):\n s += ab[cnt][0]\n if ab[cnt][1]>1:\n ab[cnt][1] -= 1\n else:\n cnt += 1\nprint(s)\n', 'N,M = list(map(int,input().split()))\nab = [list(map(int,input().split())) for _ in range(N)]\n\nab.sort(key=lambda ab:(ab[0]))\ns = 0\ncnt = 0\nfor i in range(M):\n s += ab[cnt][0]\n if ab[cnt][1]>1:\n ab[cnt][1] -= 1\n else:\n cnt += 1\nprint(s)\n']
['Wrong Answer', 'Accepted']
['s337519581', 's617431715']
[38040.0, 29028.0]
[561.0, 455.0]
[279, 259]
p03103
u323125813
2,000
1,048,576
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.
['from pprint import pprint\ndef main():\n N,M = map(int,input().split())\n store_l = []\n for i in range(N):\n store_l.append(tuple(map(int,input().split())))\n\n store_l = sorted(store_l,key=lambda x:x[0])\n pprint(store_l)\n ans = 0\n buynum = 0\n for price,maxnum in store_l:\n if(buynum+maxnum<=M):\n buynum += maxnum\n ans += maxnum*price\n else:\n ans += (M-buynum)*price\n break\n print(ans)\n\nif __name__=="__main__":\n main()\n', 'def main():\n N,M = map(int,input().split())\n store_l = []\n for i in range(N):\n store_l.append(tuple(map(int,input().split())))\n\n store_l = sorted(store_l,key=lambda x:x[0])\n ans = 0\n buynum = 0\n for price,maxnum in store_l:\n if(buynum+maxnum<=M):\n buynum += maxnum\n ans += maxnum*price\n else:\n ans += (M-buynum)*price\n break\n print(ans)\n\nif __name__=="__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s902761325', 's684274060']
[29296.0, 18864.0]
[1660.0, 356.0]
[509, 463]
p03103
u325956328
2,000
1,048,576
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.
['import heapq\n\nN, M = map(int, input().split())\nL = []\nfor i in range(N):\n a, b = map(int, input().split())\n L.append((a, b))\n\nheapq.heapify(L)\n\nprint(L)\ndrink = 0\nyen = 0\nwhile drink < M:\n a, b = heapq.heappop(L)\n if drink + b <= M:\n yen += a * b\n drink += b\n else:\n yen += a * (M - drink)\n break\nprint(yen)\n', 'import heapq\n\nN, M = map(int, input().split())\nL = []\nfor i in range(N):\n a, b = map(int, input().split())\n L.append((a, b))\n\nheapq.heapify(L)\n\n# print(L)\ndrink = 0\nyen = 0\nwhile drink < M:\n a, b = heapq.heappop(L)\n if drink + b <= M:\n yen += a * b\n drink += b\n else:\n yen += a * (M - drink)\n break\nprint(yen)\n\n']
['Wrong Answer', 'Accepted']
['s435816332', 's885902557']
[23108.0, 16696.0]
[513.0, 488.0]
[397, 400]
p03103
u327532412
2,000
1,048,576
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.
['from operator import itemgetter\nN, M = map(int, input().split())\nAB = sorted([list(map(int, input().split())) for i in range(N)], key=itemgetter(0))\nans, tmp = 0, 0\nprint(AB)\nfor ab in AB:\n if ab[1] + tmp < M:\n tmp += ab[1]\n ans += ab[0] * ab[1]\n print(tmp, ans)\n else:\n ans += (M - tmp) * ab[0]\n break\nprint(ans)', 'from operator import itemgetter\nN, M = map(int, input().split())\nAB = sorted([list(map(int, input().split())) for i in range(N)], key=itemgetter(0))\nans, tmp = 0, 0\nfor ab in AB:\n if ab[1] + tmp < M:\n tmp += ab[1]\n ans += ab[0] * ab[1]\n else:\n ans += (M - tmp) * ab[0]\n break\nprint(ans)']
['Wrong Answer', 'Accepted']
['s751091215', 's702592191']
[34768.0, 29864.0]
[637.0, 446.0]
[354, 320]
p03103
u329865314
2,000
1,048,576
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.
['n,m=map(int,input().split())\nlis = []\nfor _ in range(n):\n lis.append(list(map(int,input().split())))\nlis.sort()\nwhile(1):\n x,y = lis[0]\n if y >= m:\n ans += x*m\n break\n ans += x * y\n m -= y\n del(lis[0])\nprint(ans)', 'n,m=map(int,input().split())\nlis = []\nfor _ in range(n):\n lis.append(list(map(int,input().split())))\nlis.sort()\nans=0\nfor i in range(n):\n x,y = lis[i]\n if y >= m:\n ans += x*m\n print(ans)\n quit()\n ans += x * y\n m -= y\nprint(ans)']
['Runtime Error', 'Accepted']
['s088836538', 's089002815']
[27760.0, 27760.0]
[508.0, 510.0]
[224, 241]
p03103
u336624604
2,000
1,048,576
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.
["n,m = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(n)]\nab.sort()\ncost=0\namount=m\nfor i in range(n):\n if amount>0:\n print('am:',amount)\n if amount > ab[i][1]:\n cost+=ab[i][0]*ab[i][1]\n amount-=ab[i][1]\n else:\n cost+=ab[i][0]*amount\n break\nprint(cost)\n", "n,m = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(n)]\nab.sort()\ncost=0\namount=m\nfor i in range(n):\n if amount>0:\n #print('am:',amount)\n if amount > ab[i][1]:\n cost+=ab[i][0]*ab[i][1]\n amount-=ab[i][1]\n else:\n cost+=ab[i][0]*amount\n break\nprint(cost)\n"]
['Wrong Answer', 'Accepted']
['s294347419', 's157780396']
[27756.0, 27760.0]
[586.0, 497.0]
[352, 353]
p03103
u337080722
2,000
1,048,576
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.
['n, m = map(int, input().split())\na = []\nfor i in range(n):\n a.append(list(map(int, input().split())))\n\na = sorted(a, key=lambda x: x[0])\nprint(a)\npurchase_price = 0\n\n\nfor price, count in a:\n if count < m:\n purchase_price += price * count\n m -= count\n\n else:\n purchase_price += price * m\n m = 0\n\nprint(purchase_price)\n', 'n, m = map(int, input().split())\na = []\nfor i in range(n):\n a.append(list(map(int, input().split())))\n\na = sorted(a, key=lambda x: x[0])\npurchase_price = 0\n\n\nfor price, count in a:\n if count < m:\n purchase_price += price * count\n m -= count\n\n else:\n purchase_price += price * m\n m = 0\n\nprint(purchase_price)\n']
['Wrong Answer', 'Accepted']
['s079470747', 's867862803']
[34640.0, 29792.0]
[529.0, 497.0]
[354, 345]
p03103
u339550873
2,000
1,048,576
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.
['#! /usr/bin/env python3\n# -*- coding: utf-8 -*-\nN,M = [int(x) for x in input().split()]\nABdict = {}\nfor _ in range (N):\n A,B = [int(x) for x in input().split()]\n if A in ABdict.keys():\n ABdict[A] += B\n else:\n ABdict[A] = B\n\nprint(ABdict)\ndct = sorted(ABdict.items())\nls = []\nans = 0\nfor i in dct:\n if M >= 0:\n ans += min(M,i[1])*i[0] \n M -= i[1] \n\nprint(ans)\n', '#! /usr/bin/env python3\n# -*- coding: utf-8 -*-\nN,M = [int(x) for x in input().split()]\nABdict = {}\nfor _ in range (N):\n A,B = [int(x) for x in input().split()]\n if A in ABdict.keys():\n ABdict[A] += B\n else:\n ABdict[A] = B\n\ndct = sorted(ABdict.items())\nls = []\nans = 0\nfor i in dct:\n if M >= 0:\n ans += min(M,i[1])*i[0] \n M -= i[1] \n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s352817360', 's825754788']
[26976.0, 23004.0]
[487.0, 475.0]
[403, 389]
p03103
u341914122
2,000
1,048,576
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.
['N,M=map(int, input().split(" "))\n\nA=[]\nB=[]\n\nbought = 0\nprice = 0\nfor i in range(0, N):\n a,b=list(map(int, input().split(" ")))\n A.append((a, i))\n B.append(b)\n\nprint(A)\nA.sort()\nprint(B)\n\ni = 0\np=0\nn=0\nwhile bought < M:\n p,n = A[i]\n price += p*B[n]\n bought += B[n]\n print("buy {} yen * {}".format(p, B[n]))\n i += 1\n\nif bought > M:\n price -= (bought-M)*p\n\nprint(price)', 'N,M=map(int, input().split(" "))\n\nA=[]\nB=[]\n\nbought = 0\nprice = 0\nfor i in range(0, N):\n a,b=list(map(int, input().split(" ")))\n A.append((a, i))\n B.append(b)\n\nA.sort()\n\ni = 0\np=0\nn=0\nwhile bought < M:\n p,n = A[i]\n price += p*B[n]\n bought += B[n]\n i += 1\n\nif bought > M:\n price -= (bought-M)*p\n\nprint(price)']
['Wrong Answer', 'Accepted']
['s183961169', 's914693598']
[26660.0, 20972.0]
[659.0, 494.0]
[394, 331]
p03103
u342051078
2,000
1,048,576
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.
['n,m = map(int,input().split())\nab = [0]\nnum = m\nfor i in range(n):\n a,b = map(int,input().split())\n ab.append([a,b])\nab.sort()\nans = 0\nfor i in ab:\n if i[1] >= num:\n ans += i[0]*num\n break\n else:\n ans += i[0]*i[1]\n num -= i[1]\nprint(ans)\n ', 'n,m = map(int,input().split())\nab = []\nnum = m\nfor i in range(n):\n a,b = map(int,input().split())\n ab.append([a,b])\nab.sort()\nans = 0\nfor i in ab:\n if i[1] >= num:\n ans += i[0]*num\n break\n else:\n ans += i[0]*i[1]\n num -= i[1]\nprint(ans)\n ']
['Runtime Error', 'Accepted']
['s523951667', 's028966541']
[19552.0, 20048.0]
[317.0, 467.0]
[286, 285]
p03103
u348868667
2,000
1,048,576
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.
['from operator import itemgetter\nN,M = map(int,input().split())\nls = [list(map(int,input().split())) for _ in range(N)]\nls = sorted(ls,key=itemgetter(0))\nans = 0\npon = 0\nfor i in range(N):\n if pon < M:\n pon += ls[i][1]\n ans += ls[i][1]*ls[i][0]\n else:\n break\nif pon == M:\n print(ans)\nelse:\n ans -= ls[i-1][0]*(pon - M)\n print(ans)', 'from operator import itemgetter\nN,M = map(int,input().split())\nls = [list(map(int,input().split())) for _ in range(N)]\nls = sorted(ls,key=itemgetter(0))\nans = 0\npon = 0\nfor i in range(N):\n if pon < M:\n pon += ls[i][1]\n ans += ls[i][1]*ls[i][0]\n else:\n i = i-1\n break\nif pon == M:\n print(ans)\nelse:\n ans -= ls[i][0]*(pon - M)\n print(ans)']
['Wrong Answer', 'Accepted']
['s378183477', 's260605434']
[29864.0, 29864.0]
[443.0, 442.0]
[365, 379]
p03103
u349091349
2,000
1,048,576
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.
['import sys\nN,M=map(int,input().split())\nA=[0]*N\nB=[0]*N\nfor i in range(0,N):\n A[i],B[i]=map(int,input().split())\nindex=sorted(range(len(A)), key=lambda k: A[k])\n\ncost=0\nget=0\nfor i in index:\n if get+B[i]<=M:\n get += B[i]\n cost += A[i]*B[i]\n else:\n cost += A[i]*(M-get)\n print(cost)\n\tsys.exit()', 'import sys\nN,M=map(int,input().split())\nA=[0]*N\nB=[0]*N\nfor i in range(0,N):\n A[i],B[i]=map(int,input().split())\nindex=sorted(range(len(A)), key=lambda k: A[k])\ncost=0\nget=0\nfor i in index:\n if get+B[i]<M:\n get += B[i]\n cost += A[i]*B[i]\n else:\n cost += A[i]*(M-get)\n print(cost)\n sys.exit()']
['Runtime Error', 'Accepted']
['s393412872', 's773636835']
[3064.0, 16540.0]
[17.0, 376.0]
[308, 309]
p03103
u354567428
2,000
1,048,576
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.
['n,m = map(int,input().split())\nab = [list(map(int,input().split())) for i in range(n)]\n\nc = sorted(ab, key= lambda x:x[0])\ns = [0]\nfor i in range(n):\n s.append(s[i] + c[i][1])\n if s[i] <= m <= s[i+1]:\n stop = i\n\nans=0\nfor i in range(stop):\n ans += c[i][0]*c[i][1]\n print(ans)\nwhile s[stop] < m:\n ans += c[stop][0]\n s[stop] += 1\nprint(ans)\n', 'n,m = map(int,input().split())\nab = [list(map(int,input().split())) for i in range(n)]\n\nc = sorted(ab, key= lambda x:x[0])\ns = [0]\nfor i in range(n):\n s.append(s[i] + c[i][1])\n if s[i] <= m <= s[i+1]:\n stop = i\n\nans=0\nfor i in range(stop):\n ans += c[i][0]*c[i][1]\nwhile s[stop] < m:\n ans += c[stop][0]\n s[stop] += 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s069290764', 's916752805']
[33380.0, 33252.0]
[523.0, 512.0]
[364, 349]
p03103
u360090862
2,000
1,048,576
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.
['import numpy as np\nN,M=[int(i) for i in input().split()]\na=[]\nfor j in range(N):\n a.append([int(i) for i in input().split()])\n\na.sort(key=lambda x:x[0])\n\ncost=0\nshop=0\nfor j in range(M):\n if a[shop][1]==0:\n shop+=1\n else:\n a[shop][1]-=1\n cost+=a[0][0]\nprint(cost)', 'import numpy as np\nN,M=[int(i) for i in input().split()]\na=[]\nfor j in range(N):\n a.append([int(i) for i in input().split()])\n \na.sort(key=lambda x:x[0])\n \ncost=0\nshop=0\nfor j in range(M):\n if a[shop][1]==0:\n shop+=1\n a[shop][1]-=1\n cost+=a[shop][0]\nprint(cost)']
['Wrong Answer', 'Accepted']
['s495267513', 's007353686']
[31868.0, 31868.0]
[580.0, 554.0]
[275, 268]
p03103
u367130284
2,000
1,048,576
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.
['a,b=map(int,input().split())\ndef f(x):\n if x%4==3:\n return 0\n elif x%4==0:\n return x\n else:\n base=x-x%3\n ans=base\n for s in range(1,x%3+1):\n # print(base+s)\n ans^=(base+s)\n # print(ans)\n return ans\nprint(f(a-1)^f(b))', 'n,m=map(int,input().split())\nx=sorted([list(map(int,input().split()))for i in range(n)],key=lambda x:x[0])\nans=0\nfor s,t in x:\n# print(s,t,m)\n if m>=t:\n m-=t\n ans+=s*t\n else:\n ans+=m*s\n break\nprint(ans)']
['Wrong Answer', 'Accepted']
['s912109853', 's812241964']
[3060.0, 29788.0]
[17.0, 440.0]
[298, 239]
p03103
u375282392
2,000
1,048,576
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.
['n,m = map(int,input().split())\nab = []\nfor i in range(n):\n\tab.append(list(map(int,input().split())))\nsab = sorted(ab,key=lambda x:x[0])\n\n', 'n,m = map(int,input().split())\nab = []\nfor i in range(n):\n\tab.append(list(map(int,input().split())))\n \nsab = sorted(ab,key=lambda x:x[0])\ncost = 0\nfor i in sab:\n\tprint(cost,m)\n\tif m - i[1] > 0:\n\t\tm -= i[1]\n\t\tcost += i[0] * i[1]\n\telse:\n\t\tfor j in range(m):\n\t\t\tcost += i[0]\n\t\tbreak\nprint(cost)', 'n,m = map(int,input().split())\nab = []\nfor i in range(n):\n\tab.append(list(map(int,input().split())))\n \nsab = sorted(ab,key=lambda x:x[0])\ncost = 0\nfor i in sab:\n\tif m - i[1] > 0:\n\t\tm -= i[1]\n\t\tcost += i[0] * i[1]\n\telse:\n\t\tfor j in range(m):\n\t\t\tcost += i[0]\n\t\tbreak\nprint(cost)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s004958739', 's187794140', 's658070246']
[29800.0, 29792.0, 29792.0]
[420.0, 543.0, 429.0]
[137, 294, 279]
p03103
u378752007
2,000
1,048,576
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.
['N, M = map(int, input().split())\ndic = {}\ncount = 0\ngoukei = 0\n\nfor i in range(N):\n price,honsu = map(int, input().split())\n dic[price] = honsu\ndic = sorted(dic.items()) \nfor kakaku, number in dic:\n nokori = M-count\n count += number\n if count >= M:\n print(goukei)\n goukei += nokori*kakaku\n break\n else:\n goukei += number*kakaku\nprint (goukei) \n \n \n \n \n\n ', 'N, M = map(int, input().split())\ndic = {}\ncount = 0\ngoukei = 0\n \nfor i in range(N):\n price,honsu = map(int, input().split())\n if price in dic:\n dic[price] += honsu\n else:\n dic[price] = honsu\ndic = sorted(dic.items())\nfor kakaku, number in dic:\n nokori = M-count\n count += number\n if count >= M:\n goukei += nokori*kakaku\n break\n else:\n goukei += number*kakaku\nprint (goukei) ']
['Wrong Answer', 'Accepted']
['s892393783', 's312688789']
[22992.0, 22984.0]
[418.0, 438.0]
[414, 412]
p03103
u391533749
2,000
1,048,576
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.
['N, M = map(int, input().split())\nA = [list(map(int, input().split())) for i in range(N)]\nA.sort()\nsumcost = 0\nk = 0\nt = 0\nwhile M-k>0:\n buy = min(M-k, A[t][0])\n sumcost += A[t][0]*buy\n k += buy\n t += 1\n\n\nprint(sumcost)', 'N, M = map(int, input().split())\nA = [list(map(int, input().split())) for i in range(N)]\nA.sort()\nsumcost = 0\nk = 0\nt = 0\nwhile M-k>0:\n buy = min(M-k, A[t][0])\n sumcost += A[t][1]*buy\n k += buy\n t += 1\n\n\nprint(sumcost)', 'N, M = map(int, input().split())\nA = []\nfor i in range(N):\n A.append(list(map(int, input().split())) for i in range(N))\nA.sort()\nsumcost = 0\nk = 0\nt = 0\nwhile M-k>0:\n buy = min(M-k, A[t][1])\n sumcost += A[t][0]*buy\n k += buy\n t += 1\n\n\nprint(sumcost)', 'N, M = map(int, input().split())\nA = [list(map(int, input().split())) for i in range(N)]\nA.sort()\nsumcost = 0\nk = 0\nfor i in range(M):\n if M-k>A[0][1]:\n sumcost += A[0][0]*A[0][1]\n k -= A[0][1]\n A.pop(0)\n else:\n sumcost += A[0][0]*(M-k)\n break\n\nprint(sumcost)', 'N, M = map(int, input().split())\nA = []\nfor i in range(N):\n A.append(list(map(int, input().split())))\nA.sort()\nsumcost = 0\nk = 0\nt = 0\nwhile M-k>0:\n buy = min(M-k, A[t][1])\n sumcost += A[t][0]*buy\n k += buy\n t += 1\n\n\nprint(sumcost)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s476217686', 's582891417', 's606544747', 's901553113', 's331916378']
[27880.0, 27880.0, 65840.0, 27884.0, 27760.0]
[453.0, 498.0, 241.0, 2050.0, 523.0]
[230, 230, 264, 300, 246]
p03103
u393481615
2,000
1,048,576
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.
['import numpy as np\n\nN, M = list(map(int, input().split()))\nA = np.zeros(N) \nB = np.zeros(N) # B hon\nfor i in range(N):\n A[i], B[i] = list(map(int, input().split()))\n\nrequire = M\nprice = 0\nwhile(require > 0):\n\n minidx = np.where(A == A.min())[0][0]\n# print("found idx = " + str(minidx))\n if(require >= B[minidx]):\n\n price = price + A[minidx] * B[minidx]\n require = require - B[minidx]\n A = np.delete(A, [minidx])\n B = np.delete(B, [minidx])\n else:\n\n price = price + A[minidx] * require\n require = 0\n\nprint(price)\n', 'YEN = 0\nNUM = 1\n\nN, M = list(map(int, input().split()))\nshop = list([])\nfor i in range(N):\n a, b = list(map(int, input().split()))\n shop.append([a, b])\nshop.sort()\n\nrequire = M\nprice = 0\nminidx = 0\nwhile(require > 0):\n\n\n if(require >= shop[minidx][NUM]):\n price = price + shop[minidx][YEN] * shop[minidx][NUM]\n require = require - shop[minidx][NUM]\n minidx = minidx + 1\n else:\n\n price = price + shop[minidx][YEN] * require\n require = 0\n\nprint(price)\n']
['Wrong Answer', 'Accepted']
['s107659319', 's508550902']
[16508.0, 20456.0]
[2109.0, 572.0]
[773, 720]
p03103
u395202850
2,000
1,048,576
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.
['N, M = map(int, input().split())\nA = []\nB = []\n\na, b = map(int, input().split())\n\nA.append(a)\nB.append(b)\n\nif N != 1:\n for n in range(N-1):\n a, b = map(int, input().split())\n swi = 0\n BSum = 0\n for j in range(len(A)):\n if BSum > M:\n swi = 1\n break\n else:\n if A[j] > a:\n A.insert(j, a)\n B.insert(j, b)\n swi = 1\n break\n elif A[j] == a:\n B[j] += b\n swi = 1\n break\n BSum += b\n if swi == 0:\n A.append(a)\n B.append(b)\n\ncntSum = 0\nmoneySum = 0\n\nprint(A, B)\n\nfor n in range(N):\n if cntSum + B[n] > M:\n moneySum += A[n] * (M - cntSum)\n cntSum += M - cntSum\n break\n else:\n cntSum += B[n]\n moneySum += A[n] * B[n]\n\nprint(moneySum)\n', 'n, m = map(int, input().split())\nabList = [list(map(int, input().split())) for _ in range(n)]\nabList.sort()\nabSum = 0\nabNum = m\nfor ab in abList:\n a, b = ab[0], ab[1]\n if b < abNum:\n abSum += b * a\n abNum -= b\n else:\n abSum += abNum * a\n break\nprint(abSum)\n']
['Runtime Error', 'Accepted']
['s212583426', 's600752288']
[3316.0, 27880.0]
[2104.0, 477.0]
[947, 294]
p03103
u396971285
2,000
1,048,576
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.
['N,M=map(int,input().split())\n\n\nAB=[]\nfor i in range(N):\n ab=list(map(int,input().split()))\n AB.append(ab)\n\n\nlist.sort(AB,key=lambda x:x[0])\n\n\nm=0 \ncost=0 \nfor i in range(N):\n \n if M-m==AB[i][1]:\n m+=AB[i][1]\n cost+=AB[i][0]*AB[i][1]\n break\n\n elif M-m<AB[i][1] :\n for j in range(AB[i][1]+1):\n cost=cost+AB[i][0]*j\n m=m+j\n if m==M:\n break\n else:\n cost=cost-AB[i][0]*j\n else:\n cost+=AB[i][0]*AB[i][1]\n m+=AB[i][1]\n \nprint(cost)', 'N,M=map(int,input().split())\n\n\nAB=[]\nfor i in range(N):\n ab=list(map(int,input().split()))\n AB.append(ab)\n\n\nlist.sort(AB,key=lambda x:x[0])\n\n\nm=0 \ncost=0 \nfor i in range(N):\n \n if M-m==A[i][1]\n m+=A[i][1]\n cost+=AB[i][0]*AB[i][1]\n break\n\n elif M-m<A[i][1] :\n for j in range(AB[i][1]+1):\n cost=cost+AB[i][0]*j\n m=m+j\n if m==M:\n break\n\n cost+=AB[i][0]*AB[i][1]\n m+=A[i][1]\n \nprint(cost)', 'N,M=map(int,input().split())\n\n\nAB=[]\nfor i in range(N):\n ab=list(map(int,input().split()))\n AB.append(ab)\n\n\nlist.sort(AB,key=lambda x:x[0])\n\n\nm=0 \ncost=0 \nfor i in range(N):\n \n if M-m==AB[i][1]:\n m+=AB[i][1]\n cost+=AB[i][0]*AB[i][1]\n break\n elif M-m<AB[i][1] :\n for j in range(AB[i][1]+1):\n cost=cost+AB[i][0]*j\n m=m+j\n if m==M:\n break\n elif m<M:\n cost=cost-AB[i][0]*j\n m=m-j\n else:\n cost+=AB[i][0]*AB[i][1]\n m+=AB[i][1]\n \nprint(cost)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s040751939', 's749157767', 's862157824']
[3064.0, 2940.0, 29024.0]
[17.0, 17.0, 564.0]
[618, 537, 641]
p03103
u397953026
2,000
1,048,576
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.
['n,m = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(n)]\nab.sort()\nans = 0\ncnt = 0\ni = 0\nwhile cnt < m:\n ans += ab[i][0]*ab[i][1]\n cnt += ab[i][1]\n i += 1\nprint(ans - (cnt - m)*ab[i][0])', 'n,m = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(n)]\nab.sort()\nans = 0\ncnt = 0\ni = 0\nwhile cnt < m:\n ans += ab[i][0]*ab[i][1]\n cnt += ab[i][1]\n i += 1\nprint(num - (cnt - m)*ab[i][0])', 'n,m = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(n)]\nab.sort()\nans = 0\ncnt = 0\ni = 0\nwhile cnt < m:\n ans += ab[i][0]*ab[i][1]\n cnt += ab[i][1]\n i += 1\nprint(ans - (cnt - m)*ab[i-1][0])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s162515288', 's845554616', 's133346509']
[27424.0, 27512.0, 27520.0]
[341.0, 388.0, 350.0]
[225, 225, 227]
p03103
u400221789
2,000
1,048,576
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.
['n,m=map(int,input().split())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\na.sort() \ni=0\ncost=0\nwhile m>0:\n if a[i][1]<m:\n cost+=a[i][0]*a[i][1]\n M-=a[i][1]\n i+=1\n else:\n cost+=a[i][0]*m\n print(cost)\n break', 'n,m=map(int,input().split())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\na.sort() \ni=0\ncost=0\nwhile m>0:\n if a[i][1]<m:\n cost+=a[i][0]*a[i][1]\n m-=a[i][1]\n i+=1\n else:\n cost+=a[i][0]*m\n break\nprint(cost)\n ']
['Runtime Error', 'Accepted']
['s902370446', 's079829629']
[27760.0, 27756.0]
[477.0, 529.0]
[248, 249]
p03103
u409542115
2,000
1,048,576
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.
['N, M = map(int, input().split())\n\nS = [[0]*2 for i in range(N)]\nfor i in range(N):\n S[i] = list(map(int, input().split()))\n \nS = sorted(S)\nprint(S)\n\nquantitys = 0\ntotal = 0\n\nfor i in range(N):\n \n if((M - quantitys) - S[i][1])>=0:\n quantitys += S[i][1]\n total += S[i][0] * S[i][1]\n else:\n quantity = M - quantitys\n quantitys += quantity\n total += S[i][0] * quantity\n if M-quantitys == 0:\n break\n\nprint(str(total))', 'N, M = map(int, input().split())\n\nS = [[0]*2 for i in range(N)]\nfor i in range(N):\n S[i] = list(map(int, input().split()))\n \nS = sorted(S)\n\nquantitys = 0\ntotal = 0\n\nfor i in range(N):\n \n if((N - quantitys) - S[i][1])>=0:\n quantitys += S[i][1]\n total += S[i][0] * S[i][1]\n else:\n quantity = N - quantitys\n quantitys += quantity\n total += S[i][0] * S[i][1]\n if N-quantitys == 0:\n break\n\nprint(str(total))\n', 'N, M = map(int, input().split())\n\nS = [[0]*2 for i in range(N)]\nfor i in range(N):\n S[i] = list(map(int, input().split()))\n \nS = sorted(S)\n\nquantitys = 0\ntotal = 0\n\nfor i in range(N):\n \n if((M - quantitys) - S[i][1])>=0:\n quantitys += S[i][1]\n total += S[i][0] * S[i][1]\n else:\n quantity = M - quantitys\n quantitys += quantity\n total += S[i][0] * S[i][1]\n if M-quantitys == 0:\n break\n\nprint(str(total))\n\n', 'N, M = map(int, input().split())\n\nS = [[0]*2 for i in range(N)]\nfor i in range(N):\n S[i] = list(map(int, input().split()))\n \nS = sorted(S)\nprint(S)\n\nquantitys = 0\ntotal = 0\n\nfor i in range(N):\n \n if((M - quantitys) - S[i][1])>=0:\n quantitys += S[i][1]\n total += S[i][0] * S[i][1]\n else:\n quantity = M - quantitys\n quantitys += quantity\n total += S[i][0] * quantity\n if M-quantitys == 0:\n break\n\nprint(str(total))', 'N, M = map(int, input().split())\n\nS = [[0]*2 for i in range(N)]\nfor i in range(N):\n S[i] = list(map(int, input().split()))\n \nS = sorted(S)\n\nquantitys = 0\ntotal = 0\n\nfor i in range(N):\n \n if((M - quantitys) - S[i][1])>=0:\n quantitys += S[i][1]\n total += S[i][0] * S[i][1]\n else:\n quantity = M - quantitys\n quantitys += quantity\n total += S[i][0] * quantity\n if M-quantitys == 0:\n break\n\nprint(str(total))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s165662591', 's422810267', 's819965688', 's970431512', 's700978182']
[34656.0, 28588.0, 28588.0, 34656.0, 28588.0]
[609.0, 564.0, 575.0, 660.0, 563.0]
[547, 538, 539, 547, 538]
p03103
u416773418
2,000
1,048,576
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.
['import numpy as np\n \nN, M = map(int, input().split())\nA = np.zeros((N, 2))\nfor i in range(N):\n A[i,:] = list(map(int, input().split()))\nA = A[A[:,0].argsort(), :]\n\n\ncount=0\nprice=0\nfor i in range(N):\n if A[0,1]>=M-count:\n price+=A[0,0]*(M-count)\n break\n else:\n price+=A[0,0]*A[0,1]\n count+=A[0,1]\n A=np.delete(A,0,0)\n \nprint(price)', 'import numpy as np\nN,M=map(int,input().split())\nA=[]\n \nfor i in range(N):\n A+=[[i for i in map(int,input().split())]]\nA=np.array(A)\nA=A[A[:,0].argsort(),:]\n\ncount=0\nprice=0\nfor i in range(N):\n if A[i,1]>=M-count:\n price+=A[i,0]*(M-count)\n break\n else:\n price+=A[i,0]*A[i,1]\n count+=A[i,1]\n\nprint(price)']
['Wrong Answer', 'Accepted']
['s359745398', 's715857480']
[16380.0, 31696.0]
[2109.0, 789.0]
[374, 339]
p03103
u426764965
2,000
1,048,576
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.
['N, M = map(int, input().split())\nS = []\nfor i in range(N):\n a, b = map(int, input().split())\n S.append([a, b])\n\nS.sort(key=lambda x: x[0])\nprice = 0\ncount = 0\nfor s in S:\n if count + s[1] < M:\n price += s[0] * s[1]\n count += s[1]\n else:\n price += s[0] * (M - s[1])\n break\n\nprint(price)', 'N, M = map(int, input().split())\nS = []\nfor i in range(N):\n a, b = map(int, input().split())\n S.append([a, b])\n\nS.sort(key=lambda x: x[0])\nans = 0\nfor s in S:\n if ans + s[0] * s[1] < M:\n ans += s[0] * s[1]\n else:\n q = (M - ans + s[0] - 1) // s[0]\n ans += s[0] * q\n break\n\nprint(ans)', 'N, M = map(int, input().split())\nS = []\nfor i in range(N):\n a, b = map(int, input().split())\n S.append([a, b])\n\nS.sort(key=lambda x: x[0])\nprice = 0\ncount = 0\nfor s in S:\n if count + s[1] < M:\n price += s[0] * s[1]\n count += s[1]\n else:\n price += s[0] * (M - count)\n break\n\nprint(price)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s035565157', 's568579042', 's551610660']
[21204.0, 21204.0, 21204.0]
[417.0, 385.0, 405.0]
[301, 298, 302]
p03103
u430508516
2,000
1,048,576
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.
['from operator import itemgetter\nn,m=map(int,input().split())\nl=[]\nfor i in range(n):\n a,b=map(int,input().split)\n l.append([a,b])\nl.sort(key=itemgetter(0))\ns=0\nfor j in range(n):\n s=s+l[j][0]*min(l[j][1],m)\n m=m-l[j][1]\n if m<0:\n break\nreturn s ', 'from operator import itemgetter\nn,m=map(int,input().split())\nl=[]\nfor i in range(n):\n a,b=map(int,input().split)\n l.append([a,b])\nl.sort(key=itemgetter(0))\ns=0\nfor j in range(n):\n s=s+l[j][0]*min(l[j][1],m)\n m=m-l[j][1]\n if m<0:\n break\nprint(s) ', 'from operator import itemgetter\nn,m=map(int,input().split())\nl=[]\nfor i in range(n):\n a,b=map(int,input().split())\n l.append([a,b])\nl.sort(key=itemgetter(0))\ns=0\nfor j in range(n):\n s=s+l[j][0]*min(l[j][1],m)\n m=m-l[j][1]\n if m<0:\n break\nprint(s) ']
['Runtime Error', 'Runtime Error', 'Accepted']
['s841501401', 's992419615', 's401263010']
[3064.0, 3064.0, 21272.0]
[17.0, 18.0, 466.0]
[253, 253, 255]
p03103
u434664398
2,000
1,048,576
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.
['N,M = [int(x) for x in input().split(\' \')]\nAB = {}\nfor i in range(N):\n a,b = [int(x) for x in input().split(\' \')]\n AB[a] = b\n \ndc = sorted(AB.items())\n\nc = 0\nm = M\nfor s in dc:\n d = m - s[1]\n if d >= 0:\n m -= s[1]\n c += s[0] * s[1]\n #print(m,c)\n if d == 0:\n break\n else:\n print(s[1] + d,"xx")\n c += s[0] * (s[1] + d)\n #print(d)\n break\nprint(c)', "N,M = [int(x) for x in input().split(' ')]\nAB = {}\nfor i in range(N):\n a,b = [int(x) for x in input().split(' ')]\n if a in AB:\n AB[a] += b\n else:\n AB[a] = b\n \ndc = sorted(AB.items())\n\nc = 0\nm = M\nfor s in dc:\n price, stock = s\n if stock >= m:\n c += price * m\n break\n else:\n c += stock * price\n m -= stock\n \nprint(c)\n "]
['Wrong Answer', 'Accepted']
['s182277830', 's819864960']
[23008.0, 23008.0]
[452.0, 484.0]
[378, 350]
p03103
u442877951
2,000
1,048,576
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.
['N,M = map(int,input().split())\nAB = [list(map(int,input().split())) for _ in range(N)]\n\nAB.sort()\ncount = 0\nans = 0\nfor i,j in AB:\n if count+j >= M:\n ans += (M-count)*i\n break\n else:\n count += j\n ans += j*i\n print(ans)', 'N,M = map(int,input().split())\nAB = [list(map(int,input().split())) for _ in range(N)]\n\nAB.sort()\ncount = 0\nans = 0\nfor i,j in AB:\n if count+j >= M:\n ans += (M-count)*i\n break\n else:\n count += j\n ans += j*i\nprint(ans)\n\n']
['Wrong Answer', 'Accepted']
['s773709717', 's381134897']
[27760.0, 27760.0]
[549.0, 473.0]
[233, 233]
p03103
u444732068
2,000
1,048,576
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.
['N,M = map(int,input().split())\na = [list(map(int,input().split())) for i in range(N)]\na.sort(key=lambda x:x[0])\nprint(a)\nans = 0\nnokori = M\nfor j in range(N):\n\tans += a[j][0]*min(a[j][1],nokori)\n\tnokori -= a[j][1]\n\tif nokori <= 0:\n\t\tprint(ans)\n\t\texit()\n\n', 'N,M = map(int,input().split())\na = [list(map(int,input().split())) for i in range(N)]\n\nA = [x[0] for x in a]\nB = [x[1] for x in a]\nprint(B)\nprint(A)\nA_sorted = sorted(A)\nprint(A_sorted)\nans = 0\nnokori = M\nfor c in A_sorted:\n\tprint(c)\n\tfor j in range(N):\n\t\tif c == A[j]:\n\t\t\tprint(j)\n\t\t\tans += A[j]*min(B[j],nokori)\n\t\t\tnokori -= B[j]\n\t\tif nokori <= 0:\n\t\t\tprint(ans)\n\t\t\texit()\n', 'N,M = map(int,input().split())\na = [list(map(int,input().split())) for i in range(N)]\na.sort(key=lambda x:x[0])\nans = 0\nnokori = M\nfor j in range(N):\n\tans += a[j][0]*min(a[j][1],nokori)\n\tnokori -= a[j][1]\n\tif nokori <= 0:\n\t\tprint(ans)\n\t\texit()\n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s102208922', 's366805108', 's453857661']
[34656.0, 36404.0, 29028.0]
[533.0, 2105.0, 441.0]
[254, 374, 245]
p03103
u449473917
2,000
1,048,576
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.
['from sys import stdin\n\nn,m=map(int,input().split())\nl = [stdin.readline().rstrip().split() for _ in range(n)]\n\nl.sort()\na=0\nans=0\nfor i,j in l:\n aa=int(i)\n aaa=int(j)\n for k in range(aa):\n if a==m:\n print(ans)\n exit()\n else:\n ans+=int(aaa)\n a+=1\n', 'n,m=map(int,input().split())\nl = [list(map(int,input().split())) for _ in range(n)]\n \nl.sort()\na=0\nans=0\nfor i,j in l:\n for k in range(int(j)):\n if a>=m:\n break\n else:\n ans+=int(i)\n a+=1\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s127750342', 's264369145']
[33452.0, 27752.0]
[306.0, 577.0]
[313, 249]
p03103
u454735747
2,000
1,048,576
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.
['n,m = map(int,input().split()) \nz = []\nfor i in range(n):\n a,b = list(map(int,input().split()))\n z.append((a,b)) \nz = sorted(z)\nprint(z)\nsum = 0\nfor a,b in z:\n if b <= m:\n sum += a * b\n m -= b\n else:\n sum += a * m\n break\nprint(sum)', 'n,m = map(int,input().split()) \nz = []\nfor i in range(n):\n a,b = list(map(int,input().split()))\n z.append((a,b)) \nz = sorted(z)\nsum = 0\nfor a,b in z:\n if b <= m:\n sum += a * b\n m -= b\n else:\n sum += a * m\n break\nprint(sum)']
['Wrong Answer', 'Accepted']
['s111959784', 's678880739']
[23816.0, 17736.0]
[512.0, 444.0]
[249, 240]
p03103
u460468647
2,000
1,048,576
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.
['n,m = map(int, input().split())\npairs = [input().split() for _ in range(n)]\npairs.sort(key = lambda x:x[0])\nprint(pairs)\ncount = 0\nans = 0\nfor i in pairs:\n ans += int(i[0])*int(i[1])\n count += int(i[1])\n if count >= m:\n ans -= int(i[0])*(count - m)\n break\nprint(ans)', 'n,m = map(int, input().split())\npairs = []\nfor _ in range(n):\n l = list(map(int,input().split()))\n pairs.append(l)\npairs.sort()\ncount = 0\nans = 0\nfor i in pairs:\n ans += i[0]*i[1]\n count += i[1]\n if count >= m:\n ans -= i[0]*(count - m)\n break\nprint(ans)']
['Wrong Answer', 'Accepted']
['s020805736', 's134367653']
[41440.0, 27760.0]
[501.0, 509.0]
[289, 282]
p03103
u466143662
2,000
1,048,576
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.
["from operator import itemgetter\n\nN,M =map(int, input().split())\nb=[]\nfor _ in range(N):\n a=list(map(int, input().split()))\n b.append(a)\n\nb.sort(key=itemgetter(0))\nprint('ソート後(0番目の要素):{}'.format(b))\n\nc=0\nd=0\nfor i in range(N):\n c+=b[i][1]\n d+=b[i][0]*b[i][1]\n if c>M:\n d-=(c-M)*b[i][0]\nprint(d)", 'from operator import itemgetter\n\nN,M =map(int, input().split())\nb=[]\nfor _ in range(N):\n a=list(map(int, input().split()))\n b.append(a)\n\nb.sort(key=itemgetter(0))\n\n\nc=0 \nd=0 \nfor i in range(N):\n c+=b[i][1]\n d+=b[i][0]*b[i][1]\n if c>M:\n d-=(c-M)*b[i][0]\n break\nprint(d)\nprint(c)', 'from operator import itemgetter\n\nN,M =map(int, input().split())\nb=[]\nfor _ in range(N):\n a=list(map(int, input().split()))\n b.append(a)\n\nb.sort(key=itemgetter(0))\n\n\nc=0 \nd=0 \nfor i in range(N):\n c+=b[i][1]\n d+=b[i][0]*b[i][1]\n if c>M:\n d-=(c-M)*b[i][0]\n break\nprint(d)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s007391621', 's415229109', 's991676597']
[36804.0, 28976.0, 28976.0]
[592.0, 470.0, 451.0]
[335, 375, 367]
p03103
u466331465
2,000
1,048,576
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.
['N,M = list(map(int,input().split()))\nA = [tuple(map(int,input().split())) for _ in range(N)]\nsortA = sorted(A,key= lambda x: x[0])\nprint(sortA)\nans = 0\nfor i in range(N):\n if M-sortA[i][1]>0:\n ans += sortA[i][0]*sortA[i][1]\n M = M-sortA[i][1]\n else:\n ans += M*sortA[i][0]\n break\nprint(ans)', 'N,M = list(map(int,input().split()))\nA = [tuple(map(int,input().split())) for _ in range(N)]\nsortA = sorted(A,key= lambda x: x[0])\nans = 0\nfor i in range(N):\n if M-sortA[i][1]>0:\n ans += sortA[i][0]*sortA[i][1]\n M = M-sortA[i][1]\n else:\n ans += M*sortA[i][0]\n break\nprint(ans)']
['Wrong Answer', 'Accepted']
['s422025419', 's730542905']
[24556.0, 18892.0]
[435.0, 390.0]
[323, 310]
p03103
u472696272
2,000
1,048,576
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.
['n,m = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(n)]\nab = sorted(ab, key=lambda ab:ab[0])\n\nans = 0\ntotal = 0\nfor i in range(n):\n num = m-toal\n if ab[i][1]<=num:\n total += ab[i][1]\n ans += ab[i][0]*ab[i][1]\n else:\n total += num\n ans += num*ab[i][1]\n break\nprint(ans)\n', 'n,m = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(n)]\nab = sorted(ab, key=lambda ab:ab[0])\n\nans = 0\ntotal = 0\nfor i in range(n):\n num = m-toal\n if ab[i][1]<=num:\n total += ab[i][1]\n ans += ab[i][0]*ab[i][1]\n else:\n total += num\n ans += num*ab[i][1]\n break\nprint(ans)\n', 'n,m = map(int,input().split())\nab = [list(map(int,input().split())) for _ in range(n)]\nab = sorted(ab, key=lambda ab:ab[0])\n\nans = 0\ntotal = 0\nfor i in range(n):\n num = m - total\n if ab[i][1]<num:\n total += ab[i][1]\n ans += ab[i][0]*ab[i][1]\n else:\n total += num\n ans += num*ab[i][0]\n break\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s150236059', 's201546380', 's271984956']
[2940.0, 29796.0, 29796.0]
[17.0, 422.0, 463.0]
[320, 318, 320]
p03103
u474925961
2,000
1,048,576
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.
['n,m=map(int,input().split())\n\na=sorted([list(map(int,input().split())) for _ in range(n)])\n\nprint(a)\npay=0\ni=0\nwhile m>0:\n p=min(m,a[i][1])\n m-=p\n pay+=p*a[i][0]\n i+=1\nprint(pay)\n\n\n', 'n,m=map(int,input().split())\n\na=sorted([list(map(int,input().split())) for _ in range(n)])\n\n#print(a)\npay=0\ni=0\nwhile m>0:\n p=min(m,a[i][1])\n m-=p\n pay+=p*a[i][0]\n i+=1\nprint(pay)\n\n\n']
['Wrong Answer', 'Accepted']
['s697217515', 's471926198']
[34656.0, 28652.0]
[581.0, 493.0]
[193, 194]
p03103
u475503988
2,000
1,048,576
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.
['import numpy as np\nN, M = map(int, input().split())\nAB = np.empty((N, 2), dtype=np.int64)\nfor n in range(N):\n AB[n, :] = list(map(int, input().split()))\nAB = AB[AB[:, 0].argsort(), :]\nprint(AB)\nn = 0\nans = 0\nwhile M > 0:\n if M > AB[n, 1]:\n ans += AB[n, 0] * AB[n, 1]\n M -= AB[n, 1]\n else:\n ans += AB[n, 0] * M\n M = 0\n n += 1\nprint(ans)', 'import numpy as np\nn,m=map(int,input().split())\na=np.zeros(n)\nb=np.zeros(n)\nfor i in range(n):\n a[i],b[i]=map(int,input().split())\nx=np.argsort(a)\nans=0\ni=0\nwhile m>0:\n ans+=a[x[i]]*min(b[x[i]],m)\n m-=b[x[i]]\n i+=1\nprint(int(ans))']
['Wrong Answer', 'Accepted']
['s577679627', 's759926964']
[16404.0, 14812.0]
[1143.0, 805.0]
[375, 242]
p03103
u476124554
2,000
1,048,576
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.
['N, M = map(int, input().split())\nA = []\nB = []\nfor _ in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\nC = zip(A,B)\nC = sorted(C)\nA, B = zip(*C)\nindex = 0\ncount = 0\n\nfor i in range(N):\n if(count<=M):\n index = i\n sum += A[i]*B[i]\n count += B[i]\nsum +=A[index]*(M-count)\nprint(sum)', 'N, M = map(int, input().split())\nA = []\nB = []\nfor _ in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\nC = zip(A,B)\nC = sorted(C)\nA, B = zip(*C)\nindex = 0\ncount = 0\nsum = 0\nfor i in range(N):\n if(count<=M):\n index = i\n sum += A[i]*B[i]\n count += B[i]\nsum +=A[index]*(M-count)\nprint(sum)']
['Runtime Error', 'Accepted']
['s260610748', 's503492632']
[26916.0, 26924.0]
[441.0, 484.0]
[337, 344]
p03103
u487342868
2,000
1,048,576
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.
['N,M=map(int, input().split())\nA,B=[],[]\nfor i in range(N):\n A.append(list(map(int, input().split())))\nA.sort(key=lambda x:x[0])\nR,S=M,0\nfor a in A:\n if a[1]>=R:\n print(a[0],R)\n S+=a[0]*R;R=0\n else:\n print(a[0],a[1])\n S+=a[0]*a[1];R-=a[1]\n if R==0: break\nprint(S)\n\n', 'N,M=map(int, input().split())\nA,B=[],[]\nfor i in range(N):\n A.append(list(map(int, input().split())))\nA.sort(key=lambda x:x[0])\nR,S=M,0\nfor a in A:\n if a[1]>=R:\n S+=a[0]*R;R=0\n else:\n S+=a[0]*a[1];R-=a[1]\n if R==0: break\nprint(S)\n\n']
['Wrong Answer', 'Accepted']
['s308482305', 's687060680']
[29024.0, 29024.0]
[569.0, 442.0]
[304, 257]
p03103
u489959379
2,000
1,048,576
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.
['n, m = map(int, input().split())\nab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[0])\n\nans = 0\nfor i in range(n):\n print(ab[i][1], m)\n if ab[i][1] < m:\n ans += ab[i][0] * ab[i][1]\n m -= ab[i][1]\n else:\n ans += ab[i][0] * m\n break\n\nprint(ans)\n', 'n, m = map(int, input().split())\nab = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x:x[0])\n\nans = 0\nfor i in range(n):\n if ab[i][1] < m:\n ans += ab[i][0] * ab[i][1]\n m -= ab[i][1]\n else:\n ans += ab[i][0] * m\n break\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s686089197', 's826922039']
[29788.0, 29788.0]
[569.0, 442.0]
[310, 287]
p03103
u502028059
2,000
1,048,576
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.
['N,M = map(int,input().split())\nAB = []\nans = 0\nfor i in range(N):\n A,B = map(int,input().split())\n t = A,B\n AB.append(t)\n \nAB.sort()\n\nfor i in range(len(AB)):\n if M > 0:\n break\n for x in range(AB[i][1]):\n if M > 0:\n ans += AB[i][0]\n M -= 1\n \n\nprint(ans)\n\n', 'import sys\ninput = sys.stdin.readline\nN,M=[int(x) for x in input().strip().split()]\nAN=[]\nBN=[]\nval={}\nfor i in range(N):\n Ai,Bi=[int(x) for x in input().strip().split()]\n val[Ai]=Bi+val.get(Ai,0)\n AN.append(Ai)\n \nAN=sorted(set(AN))\nm=0\nans=0\nfor Ai in AN:\n ans+=Ai*min(M-m,val[Ai])\n m+=min(M-m,val[Ai])\n if m==M:\n break\nprint(ans)']
['Wrong Answer', 'Accepted']
['s952726704', 's945321346']
[16908.0, 23044.0]
[387.0, 322.0]
[316, 356]
p03103
u518042385
2,000
1,048,576
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.
['n,m=map(int,input().split())\nl=[]\nfor i in range(n):\n a,s=map(int,input().split())\n l.append([a,s])\nl=sorted(l)\np=0\nc=0\nfor i in l:\n if c+l[i][1]>m:\n p+=l[i][0]*(m-c)\n break\n else:\n p+=l[i][0]*l[i][1]\n c+=l[i][1]\nprint(p)', 'n,m=map(int,input().split())\nl=[]\nfor i in range(n):\n a,s=map(int,input().split())\n l.append([a,s])\nl=sorted(l)\np=0\nc=0\nfor i in range(len(l)):\n if c+l[i][1]>m:\n p+=l[i][0]*(m-c)\n break\n else:\n p+=l[i][0]*l[i][1]\n c+=l[i][1]\nprint(p)']
['Runtime Error', 'Accepted']
['s157215209', 's482692568']
[20816.0, 20832.0]
[439.0, 484.0]
[237, 249]
p03103
u519996359
2,000
1,048,576
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.
['N,M = list(map(int, input().split()))\nA = []\nB = []\n\nfor i in range(N):\n\tA[i],B[i]=list(map(int, input().split()))\n\nsum = 0\nans = 0\nfor i in range(N):\n\tidx = num_list.index(min(A))\n\tsum += A[idx]*B[idx]\n\tA[idx] = 10000000\n\tans += 1\n\tif(sum >= M):\n\t\tbreak\n\nprint(ans)\n', 'import numpy as np\n\nN,M = list(map(int, input().split()))\nA = [0] * N\nB = [0] * N\n\nfor i in range(N):\n\tA[i],B[i]=list(map(int, input().split()))\n\nsum = 0\nans = 0\n\nidx = np.argsort(A)\n\nfor i in range(N):\n\tif(sum+B[idx[i]] >= M):\n\t\tfor j in range(B[idx[i]]):\n\t\t\tans += A[idx[i]]\n\t\t\tsum += 1\n\t\t\tif(sum >= M):\n\t\t\t\tbreak\n\t\tbreak\n\tans += A[idx[i]]*B[idx[i]]\n\tsum += B[idx[i]]\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s741019680', 's392739096']
[3064.0, 21432.0]
[17.0, 582.0]
[267, 381]
p03103
u521271655
2,000
1,048,576
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.
['n,m = map(int,input().split())\nlis = [list(map(int,input().split())) for i in range(n)]\nlis.sort()\ncnt = 0\nmon = 0\ni = 0\nif n >= 2:\n while cnt <= m:\n if lis[i][1] + cnt <= m:\n cnt += lis[i][1]\n mon += lis[i][0]*lis[i][1]\n i += 1\n else:\n break\n print(mon + (m-cnt) * lis[i][0])\nprint(m*lis[0][0])\n', 'n,m = map(int,input().split())\nlis = [list(map(int,input().split())) for i in range(n)]\nlis.sort()\ncnt = 0\nmon = 0\ni = 0\nif n >= 2:\n while cnt < m:\n if lis[i][1] + cnt < m:\n cnt += lis[i][1]\n mon += lis[i][0]*lis[i][1]\n i += 1\n else:\n break\n print(mon + (m-cnt) * lis[i][0])\nelse:\n print(m*lis[0][0])']
['Runtime Error', 'Accepted']
['s721243704', 's180644106']
[27592.0, 27672.0]
[362.0, 388.0]
[360, 367]
p03103
u522726434
2,000
1,048,576
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.
['N, M = [int(x) for x in input().split()]\nV = [tuple(map(int, innput().split())) for i in range(N)]\nV.sort()\n\nmoney = 0\ncount = 0\n\nfor a, b in V:\n if count + b < M:\n count += b\n money += a * b\n else:\n money += (M - b) * a\n break\nprint(money)', 'N, M = [int(x) for x in input().split()]\nV = [tuple(map(int, input().split())) for i in range(N)]\nV.sort()\n\nmoney = 0\ncount = 0\n\nfor a, b in V:\n if count + b < M:\n count += b\n money += a * b\n else:\n money += (M - b) * a\n break\nprint(money)', 'N, M = [int(x) for x in input().split()]\nV = [tuple(map(int, input().split())) for i in range(N)]\nV.sort()\n\nmoney = 0\ncount = 0\n\nfor a, b in V:\n if count + b < M:\n count += b\n money += a * b\n else:\n money += (M - count) * a\n break\nprint(money)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s064470064', 's147062795', 's456179676']
[3064.0, 16976.0, 16976.0]
[17.0, 403.0, 407.0]
[254, 253, 257]
p03103
u527261492
2,000
1,048,576
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.
['n,m=map(int,input().split())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\na.sort()\ntotl=0\nx=0\nfor j,k in range(a):\n if x+j<m:\n totl+=j*k\n x+=k\n else:\n totl+=j*(x-m)\n break\nprint(totl)\n \n \n \n ', 'n,m=map(int,input().split())\nd={}\nfor i in range(n):\n a,b=map(int,input().split())\n d[b]=a\nD=sorted(d.items(),key=lambda x:x[1])\nval=0\ncnt=0\nj=0\nwhile cnt<=m:\n cnt+=int(D[j][0])\n val+=int(D[j][1])\n j+=1\nval-=int(D[j][1])*(cnt-m)\nprint(val)\n', 'n,m=map(int,input().split())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\na.sort()\ntotl=0\nx=0\nfor j,k in a:\n if x+k<m:\n totl+=j*k\n x+=k\n else:\n totl+=j*(x+k-m)\n break\nprint(totl)\n \n \n \n \n', 'n,m=map(int,input().split())\nd={}\nfor i in range(n):\n a,b=map(int,input().split())\n d[b]=a\nD=sorted(d.items())\nval=0\ncnt=0\nj=0\nwhile cnt<=m:\n cnt+=D[j][0]\n val+=D[j][1]\n j+=1\nval-=D[j][1]*(cnt-m)\nprint(val)\n', 'n,m=map(int,input().split())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\na.sort()\ntotl=0\nx=0\nfor j,k in a:\n if x+k<m:\n totl+=j*k\n x+=k\n else:\n totl+=j*(x-m)\n break\nprint(totl)\n \n \n \n \n', 'n,m=map(int,input().split())\nd={}\nfor i in range(n):\n a,b=map(int,input().split())\n d[b]=a\nD=sorted(d.items())\nval=0\ncnt=0\nj=0\nwhile cnt<=m:\n cnt+=int(D[j][0])\n val+=int(D[j][1])\n j+=1\nval-=int(D[j][1])*(cnt-m)\nprint(val)\n', 'n,m=map(int,input().split())\na=[]\nb=[]\nfor i in range(n):\n s,t=map(int,input().split())\n a.append(s)\n b.append(t)\nc=sorted(a)\nd=[0]*n\nfor j in range(n):\n d[j]=b[a.index(c[j])]\ncnt=0\ntotl=0\nfor l in range(n):\n if cnt==m:\n print(totl)\n break\n if cnt>m:\n print(totl-(cnt-m)*c[l-1])\n break\n else:\n totl+=c[l]\n cnt+=d[l]\n \n \n \n ', 'n,m=map(int,input().split())\na=[]\nb=[]\nfor i in range(n):\n s,t=map(int,input().split())\n a.append(s)\n b.append(t)\nc=sorted(a)\nd=[0]*n\nfor j in range(n):\n d[j]=b[a.index(c[j])]\ncnt=0\ntotl=0\nfor l in range(n):\n if cnt==m:\n print(totl)\n break\n elif cnt>m:\n if l==0:\n print(c[0]*m)\n break\n else:\n print(totl-(cnt-m)*c[l-1])\n break\n else:\n totl+=c[l]\n cnt+=d[l]\n \n \n \n \n', 'n,m=map(int,input().split())\na=[]\nfor i in range(n):\n a.append(list(map(int,input().split())))\na.sort()\ntotl=0\nx=0\nfor j,k in a:\n if x+k<m:\n totl+=j*k\n x+=k\n else:\n totl+=j*(m-x)\n break\nprint(totl)\n \n \n \n \n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s026364029', 's044789956', 's359540670', 's399245155', 's701974107', 's738746779', 's811698467', 's963209176', 's057279014']
[27760.0, 15588.0, 27760.0, 14556.0, 27760.0, 14564.0, 12560.0, 12632.0, 27760.0]
[500.0, 341.0, 496.0, 318.0, 495.0, 308.0, 2105.0, 2104.0, 473.0]
[235, 245, 231, 212, 229, 227, 376, 434, 229]
p03103
u529012223
2,000
1,048,576
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.
['N, M = map(int, input().split())\np_list = []\n\n\n# a, b = map(int, input().split())\n# p_list.append([a, b])\n \n\n\n# price = 0\n\n# while num < M:\n\n# price += p_sort[1][i] * p_sort[0][i]\n\n\n\n# print(price)\nres = M\nfor i in range(N):\n a, b = map(int, input().split())\n p_list.append(a, b)\n\nfor price, amount in sorted(zip(p_list[::2], p_list[1::2])):\n total_p += price * min(res, amount)\n res -= amount\n if res <= 0:\n break\n \nprint(total_p)\n ', 'N, M = map(int, input().split())\np_list = []\n\nres = M\ntotal_p = 0\nfor i in range(N):\n a, b = map(int, input().split())\n p_list.append(a)\n p_list.append(b)\n\nfor price, amount in sorted(zip(p_list[::2], p_list[1::2])):\n total_p += price * min(res, amount)\n res -= amount\n if res <= 0:\n break\n \nprint(total_p)\n\n']
['Runtime Error', 'Accepted']
['s876680982', 's761666565']
[3060.0, 19796.0]
[17.0, 445.0]
[657, 340]
p03103
u536325690
2,000
1,048,576
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.
['N, M = map(int, input().split())\nAB = []\nfor i in range(N):\n a, b = map(int, input().split())\n AB.append([a,b])\n\nsortedAB = sorted(AB, key=lambda x:x[0])\n\nans = 0\nfor i in range(N):\n a = sortedAB[i][0]\n b = sortedAB[i][1]\n if M == 0:\n print(ans)\n exit()\n if b <= M:\n M -= b\n ans += a*b\n else:\n ans += a*M\n', 'N, M = map(int, input().split())\nAB = []\nfor i in range(N):\n a, b = map(int, input().split())\n AB.append([a,b])\n\nsortedAB = sorted(AB, key=lambda x:x[0])\n\nans = 0\nfor i in range(N):\n a = sortedAB[i][0]\n b = sortedAB[i][1]\n if M == 0:\n exit()\n if b <= M:\n M -= b\n ans += a*b\n else:\n ans += a*M\n', 'N, M = map(int, input().split())\nAB = []\nfor i in range(N):\n a, b = map(int, input().split())\n AB.append([a,b])\n\nsortedAB = sorted(AB, key=lambda x:x[0])\n\nans = 0\nfor i in range(N):\n a = sortedAB[i][0]\n b = sortedAB[i][1]\n if M == 0:\n print(ans)\n exit()\n if b <= M:\n ans += a*b\n M -= b\n else:\n ans += a*M\n M = 0\n', 'N, M = map(int, input().split())\nAB = []\nfor i in range(N):\n a, b = map(int, input().split())\n AB.append([a,b])\n\nsortedAB = sorted(AB, key=lambda x:x[0])\n\nans = 0\nfor i in range(N):\n a = sortedAB[i][0]\n b = sortedAB[i][1]\n if M == 0:\n print(ans)\n exit()\n if b <= M:\n ans += a*b\n M -= b\n else:\n ans += a*M\n M = 0\n\nprint(ans) ']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s378176943', 's608422251', 's950839243', 's496354589']
[21984.0, 21972.0, 21984.0, 21984.0]
[449.0, 436.0, 430.0, 417.0]
[361, 342, 375, 392]
p03103
u549757728
2,000
1,048,576
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.
['n,m = map(int, input().split(" "))\na = []\nb = []\nfor i in range(n):\n temp = list(map(int,input().split(" ")))\n a.append(temp[0])\n b.append(temp[1])\n\nsort_a = sorted(set(a))\nmoney = 0\n\nfor ai in sort_a:\n ind = [i for i, x in enumerate(a) if x == ai]\n print(ind)\n for i in ind:\n x = min(m,b[i])\n m = m - x\n money = money + a[i]*x\n if m <= 0:\n break\n\nprint(money)', 'def key_func(n):\n return n[0]\n\nn,m = map(int, input().split(" "))\na_b = []\nfor i in range(n):\n a_b.append(list(map(int,input().split(" "))))\n\na_b.sort(key=key_func)\n\nmoney = 0\n\nfor item in a_b:\n i = min(m,item[1])\n money = money + item[0]*i\n m = m - i\n if m <= 0:\n break\n\nprint(money)']
['Wrong Answer', 'Accepted']
['s265461446', 's253076219']
[17152.0, 29020.0]
[2104.0, 496.0]
[409, 309]
p03103
u552357043
2,000
1,048,576
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.
['N, M= map(int, input().split())\nA = []\nB = []\ncount = 0\ncost = 0\nfor i in range(N):\n a,b = map(int, input().split())\n A.append(a)\n B.append(b)\n count += b\n cost += a * b\n while count > M:\n pos = A.index(max(A))\n if count - B[pos] > 0:\n count -= B[pos]\n cost -= A[pos] * B[pos]\n A.pop(pos)\n B.pop(pos)\n else:\n cost -= A[pos] * (M - count)\n B[pos] -= M - count\n count = M\n\nprint(cost)', 'N, M= map(int, input().split())\nA = []\nfor i in range(N):\n a = list(map(int, input().split()))\n A.append(a)\nA = sorted(A)\ncount = 0\ncost = 0\ni = 0\nwhile count < M:\n cost += A[i][0] * min(A[i][1],M-count)\n count += min(A[i][1],M-count)\n \nprint(cost)', 'N, M= map(int, input().split())\nA = []\nB = []\nfor i in range(N):\n a,b = map(int, input().split())\n A.append(a)\n B.append(b)\ncount = 0\ncost = 0\nwhile count < M:\n pos = A.index(min(A))\n count += min(B[pos],M-count)\n cost += A[pos] * min(B[pos],M-count)\n A.pop(pos)\n B.pop(pos)\n \nprint(cost)', 'N, M= map(int, input().split())\nA = []\nfor i in range(N):\n a = list(map(int, input().split()))\n A.append(a)\nA = sorted(A)\ncount = 0\ncost = 0\ni = 0\nwhile count < M:\n cost += A[i][0] * min(A[i][1],M-count)\n count += min(A[i][1],M-count)\n i += 1 \nprint(cost)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s159212536', 's302083134', 's740718276', 's543758218']
[7860.0, 28656.0, 11040.0, 28656.0]
[2104.0, 556.0, 2104.0, 559.0]
[498, 267, 319, 273]
p03103
u560889512
2,000
1,048,576
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.
['N,M=map(int,input().split())\nstore=[list(map(int,input().split())) for _ in range(N)]\nsorted(store,cmp=lambda x,y:x[0]-y[0] if x[0]!=y[0] else x[1]-y[1])\nres=0\nfor i in range(len(store)):\n if M-store[i][1]<=0:\n res+=store[i][0]*M\n break\n else:\n res+=store[i][0]*store[i][1]\n M=M-store[i][1]\nprint(res)', 'N,M=map(int,input().split())\nstore=[map(int,input().split()) for _ in range(N)]\nstore.sort(key=lambda x: x[0])\nres=0\nfor i in range(len(store)):\n price=store[i][0]\n num=store[i][1]\n if M>num:\n res+=price*num\n M-=num\n else:\n res+=price*M\n break\nprint(res)', 'N,M=map(int,input().split())\nstore=[]\nfor _ in range(M):\n store.append([map(int,input().split())])\nstore.sort(key=lambda x: x[0])\nres=0\nfor i in range(len(store)):\n if M-store[i][1]<=0:\n res+=store[i][0]*M\n break\n else:\n res+=store[i][0]*store[i][1]\n M-=store[i][1]\nprint(res)\n', 'N,M=map(int,input().split())\nstore=[]\nfor _ in range(N):\n store.append([map(int,input().split())])\nstore.sort(key=lambda x: x[0])\nres=0\nfor i in range(len(store)):\n price=store[i][0]\n num=store[i][1]\n if M>num:\n res+=price*num\n M-=num\n else:\n res+=price*M\n break\nprint(res)\n', 'N,M=map(int,input().split())\nstore=[]\nfor _ in range(M):\n store.append([map(int,input().split())])\nsorted(store,key=lambda x: x[0])\nres=0\nfor i in range(len(store)):\n if M-store[i][1]<=0:\n res+=store[i][0]*M\n break\n else:\n res+=store[i][0]*store[i][1]\n M=M-store[i][1]\nprint(res)\n', 'N, M = map(int, input().split())\nshop = []\nfor i in range(N):\n a, b = map(int, input().split())\n shop.append([a, b])\nshop.sort(key=lambda x: x[0])\n\namount = 0\nquantity = 0\nfor s in shop:\n if quantity + s[1] < M:\n amount += s[0] * s[1]\n quantity += s[1]\n else:\n amount += (M - quantity) * s[0]\n quantity = M\n break\n\nprint(amount)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s012738653', 's238582442', 's254170973', 's260012279', 's817917329', 's157731789']
[27380.0, 49652.0, 59892.0, 59892.0, 60660.0, 21216.0]
[328.0, 365.0, 480.0, 478.0, 484.0, 414.0]
[315, 270, 292, 291, 295, 376]
p03103
u562753067
2,000
1,048,576
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.
["n,m=[int(i) for i in input().split(' ')]\nclass P:\n def __init__(self, a, b)\n \tself.a = a\n self.b = b\n\np = []\nfor i in range(n):\n a,b=[int(i) for i in input().split(' ')]\n p.append(P(a, b))\n\n \nmon = 0\np.sort(key=lambda x: x.a)\nfor e in p:\n if m <= e.b:\n mon += e.q * m\n m = 0\n else:\n m -= e.b\n mon += e.a * e.b\n\nprint(mon)", "n,m=[int(i) for i in input().split(' ')]\nclass P:\n def __init__(self, a, b):\n self.a = a\n self.b = b\n\np = []\nfor i in range(n):\n a,b=[int(i) for i in input().split(' ')]\n p.append(P(a, b))\n\n \nmon = 0\np.sort(key=lambda x: x.a)\nfor e in p:\n if m <= e.b:\n mon += e.a * m\n m = 0\n else:\n m -= e.b\n mon += e.a * e.b\n\nprint(mon)"]
['Runtime Error', 'Accepted']
['s149148278', 's895615800']
[2940.0, 28288.0]
[17.0, 533.0]
[343, 345]
p03103
u576432509
2,000
1,048,576
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.
['n,m=map(int,input().split())\na=[]\nb=[]\nai,bi=map(int,input().split())\na.append(ai)\nb.append(bi)\nfor i in range(1:n):\n ai,bi=map(int,input().split())\n for ii in range(i-1):\n if ai<a[ii]:\n a.insert(ii,ai)\n b.insert(ii,bi)\n break\n if len(a)==i-1:\n a.append(ai)\n b.append(bi)\n#print(ai)\nmsum=0\nasum=0\nfor i in range(n):\n asum=asum+a[i]*b[i]\n msum=msum+b[i] \n if msum>=m:\n break\nasum=asum-a[i]*(msum-m)\nprint(asum)\n \n \n', 'n,m=map(int,input().split())\na=[]\nb=[]\nai,bi=map(int,input().split())\na.append(ai)\nb.append(bi)\nfor i in range(1,n):\n ai,bi=map(int,input().split())\n for ii in range(i-1):\n if ai<a[ii]:\n a.insert(ii,ai)\n b.insert(ii,bi)\n break\n if len(a)== i:\n a.append(ai)\n b.append(bi)\n#print(a)\n#print(b)\nmsum=0\nasum=0\nfor i in range(n):\n asum=asum+a[i]*b[i]\n msum=msum+b[i] \n if msum>=m:\n break\nasum=asum-a[i]*(msum-m)\nprint(asum)\n#print(i,msum,m)\n ', 'n,m=map(int,input().split())\na=[]\nb=[]\nfor i in range(n):\n ai,bi=map(int,input().split())\n a.append(ai)\n b.append(bi)\n for ii in range(i-1):\n if ai<a[ii]:\n a.insert(ii)=ai\n b.insert(ii)=bi\n break\n else:\n a.append(ai)\n b.append(bi)\nprint(ai)\n ', '\nn,m=map(int,input().split())\nab=[[0]*2 for i in range(n)]\nfor i in range(n):\n ab[i]=list(map(int,input().split()))\n \nab.sort()\n\nmm=0\ny=0\nfor i in range(n):\n mm+=ab[i][1]\n y+=ab[i][0]*ab[i][1]\n if mm>=m:\n break\ny=y-(mm-m)*ab[i][0]\nprint(y)\n ']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s437887320', 's519050134', 's995378066', 's036290240']
[2940.0, 3812.0, 2940.0, 27820.0]
[17.0, 2104.0, 17.0, 510.0]
[508, 523, 324, 266]
p03103
u578489732
2,000
1,048,576
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.
["# -*- coding: utf-8 -*- \nimport sys, heapq \n# ---------------------------------------------------------------- \n# Use Solve Function \n \ndef solve(lines): \n N,M = map(int, lines.pop(0).split(' ')) \n NLIST = [] \n for i in range(N): \n A,B = map(int, lines.pop(0).split(' ')) \n heapq.heappush(NLIST, (A, B)) \n \n res = 0 \n while(True): \n p = heapq.heappop(NLIST) \n if ( p[1] >= M ): \n res += M * p[0] \n break \n else: \n res += p[0] * p[1] \n M -= p[1] \n \n \n print(res) \nlines = contents.split('\\n') \n \n\n \nlines = [x.strip() for x in sys.stdin.readlines()] \n \n# \n# solve !! \n# \nsolve(lines) ", "# -*- coding: utf-8 -*- \nimport sys, heapq \n# ---------------------------------------------------------------- \n# Use Solve Function \n \ndef solve(lines): \n N,M = map(int, lines.pop(0).split(' ')) \n NLIST = [] \n for i in range(N): \n A,B = map(int, lines.pop(0).split(' ')) \n heapq.heappush(NLIST, (A, B)) \n \n res = 0 \n while(True): \n p = heapq.heappop(NLIST) \n if ( p[1] >= M ): \n res += M * p[0] \n break \n else: \n res += p[0] * p[1] \n M -= p[1] \n \n \n print(res) \n \nlines = [x.strip() for x in sys.stdin.readlines()] \n \n# \n# solve !! \n# \nsolve(lines) "]
['Runtime Error', 'Accepted']
['s084910624', 's932669767']
[3064.0, 19028.0]
[18.0, 1837.0]
[3478, 3163]
p03103
u580697892
2,000
1,048,576
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.
['#coding: utf-8\nimport numpy as np\nN, M = map(int, input().split())\nAB = np.array([list(map(int, input().split())) for _ in range(N)])\nmoney = 0\ncol_num = 0\nAB = AB[np.argsort(AB[:, col_num])]\nprint(AB)\nif M <= AB[np.argmin(AB[:, 0]), 1]:\n money += AB[0, 0] * M\nelse:\n i = 0\n while M >= 0:\n money += AB[i, 0] * AB[i, 1]\n M -= AB[i, 1]\n if M < 0:\n money += AB[i, 0] * M\n i += 1\nprint(money)', 'N, M = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(N)]\nmoney = 0\nAB = sorted(AB, key=lambda x: x[0])\nif M <= AB[0][1]:\n money += AB[0][0] * M\nelse:\n i = 0\n while M > 0:\n money += AB[i][0] * AB[i][1]\n M -= AB[i][1]\n if M <= 0:\n money += AB[i][0] * M\n break\n i += 1\nprint(money)']
['Runtime Error', 'Accepted']
['s294576225', 's536745660']
[37872.0, 29788.0]
[789.0, 481.0]
[434, 336]
p03103
u582396808
2,000
1,048,576
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.
[' N, M = map(int, input().split(" "))\nA_list = []\nB_list = []\ntotal = 0\n\nfor i in range(N):\n A, B = map(int, input().split(" "))\n A_list.append(A)\n B_list.append(B)\n\nz = list(zip(A_list, B_list))\nz.sort()\n\nfor a, b in z:\n if b > M:\n total += M * a\n break\n else:\n total += b * a\n M -= b\n\nprint(total)', 'N, M = map(int, input().split(" "))\nA_list = []\nB_list = []\ntotal = 0\n\nfor i in range(N):\n A, B = map(int, input().split(" "))\n A_list.append(A)\n B_list.append(B)\n\nz = list(zip(A_list, B_list))\nz.sort()\n\nfor a, b in z:\n if b > M:\n total += M * a\n break\n else:\n total += b * a\n M -= b\n\nprint(total)']
['Runtime Error', 'Accepted']
['s803242048', 's263953293']
[2940.0, 18488.0]
[17.0, 432.0]
[341, 340]
p03103
u587199081
2,000
1,048,576
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.
['from sys import stdin\nimport numpy as np\nn, m = map(int, raw_input().split())\n# print(n)\nvals_list = np.zeros((n, 2))\n# print(vals_list)\nfor itr in range(n):\n a, b = map(int, raw_input().split())\n vals_list[itr][0], vals_list[itr][1] = a, b\nsorted_vals_list = vals_list[np.argsort(vals_list[:, 0])]\n\n\ncnt = m\ntotal_money = 0\nfor itr in range(n):\n if (cnt - sorted_vals_list[itr][1]) <= 0:\n total_money += sorted_vals_list[itr][0] * cnt\n break\n else:\n cnt -= sorted_vals_list[itr][1]\n total_money += sorted_vals_list[itr][0] * sorted_vals_list[itr][1]\nprint(total_money)', 'from sys import stdin\nimport numpy as np\nn, m = (int(i) for i in input().rstrip().split())\n# print(n)\nvals_list = np.zeros((n, 2))\n# print(vals_list)\nfor itr in range(n):\n a, b = (int(i) for i in input().rstrip().split())\n vals_list[itr][0], vals_list[itr][1] = a, b\nsorted_vals_list = vals_list[np.argsort(vals_list[:, 0])]\n\n\ncnt = m\ntotal_money = 0\nfor itr in range(n):\n if (cnt - sorted_vals_list[itr][1]) <= 0:\n total_money += sorted_vals_list[itr][0] * cnt\n break\n else:\n cnt -= sorted_vals_list[itr][1]\n total_money += sorted_vals_list[itr][0] * sorted_vals_list[itr][1]\nprint(int(total_money))\n']
['Runtime Error', 'Accepted']
['s753462431', 's190516601']
[12500.0, 18020.0]
[149.0, 982.0]
[634, 666]
p03103
u588081069
2,000
1,048,576
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.
['#!/usr/bin/env python\n# -*- conding: utf-8 -*-\nimport numpy as np\n\nN, M = map(int, input().split())\nli = [list(map(int, input().split())) for i in range(N)]\nli = sorted(li, key=lambda x: x[0])\nm_sum = 0\nfor i in li:\n buy = min(M, i[i])\n m_sum += i[0]*buy\n M -= buy\nprint(m_sum)\n# A = []\n# B = []\n\n# A_i, B_i = map(int, input().split())\n# A.append(A_i)\n# B.append(B_i)\n\n# min_value_index_list = np.argsort(A)\n\n# cnt = 0\n# result = 0\n\n# cnt += B[min_value_index_list[i]]\n# if M - cnt >= 0:\n# result += A[min_value_index_list[i]] * B[min_value_index_list[i]]\n# goal = M - cnt\n# else:\n# result += A[min_value_index_list[i]] * goal\n# break\n# print(result)\n', '#!/usr/bin/env python\n# -*- conding: utf-8 -*-\nimport numpy as np\n\nN, M = map(int, input().split())\nA = []\nB = []\nfor i in range(N):\n A_i, B_i = map(int, input().split())\n A.append(A_i)\n B.append(B_i)\n\nmin_value_index_list = np.argsort(A)\n\ncnt = 0\nfor i in range(len(min_value_index_list)):\n if cnt+B[min_value_index_list[i]] < M:\n result = A[min_value_index_list[i]] * B[min_value_index_list[i]]\n cnt += B[min_value_index_list[i]]\n elif cnt+B[min_value_index_list[i]] >= M:\n result = A[min_value_index_list[i]] * M\nprint(result)\n', '#!/usr/bin/env python\n# -*- conding: utf-8 -*-\nimport numpy as np\n\nN, M = map(int, input().split())\nA = []\nB = []\nfor i in range(N):\n A_i, B_i = map(int, input().split())\n A.append(A_i)\n B.append(B_i)\n\nmin_value_index_list = np.argsort(A)\n\ncnt = 0\nfor i in range(len(min_value_index_list)):\n if cnt+B[min_value_index_list[i]] < M:\n result = A[min_value_index_list[i]] * B[min_value_index_list[i]]\n cnt += B[min_value_index_list[i]]\n elif cnt+B[min_value_index_list[i]] > M:\n result = A[min_value_index_list[i]] * M\nprint(result)', '#!/usr/bin/env python\n# -*- conding: utf-8 -*-\nimport numpy as np\n\nN, M = map(int, input().split())\nA = []\nB = []\nfor i in range(N):\n A_i, B_i = map(int, input().split())\n A.append(A_i)\n B.append(B_i)\n\nmin_value_index_list = np.argsort(A)\n\ncnt = 0\nresult = 0\nfor i in range(N):\n cnt += B[min_value_index_list[i]]\n print(cnt)\n if M - cnt >= 0:\n result += A[min_value_index_list[i]] * B[min_value_index_list[i]]\n goal = M - cnt\n else:\n result += A[min_value_index_list[i]] * goal\n break\nprint(result)\n', '#!/usr/bin/env python\n# -*- conding: utf-8 -*-\nimport numpy as np\n\nN, M = map(int, input().split())\nA = []\nB = []\nfor i in range(N):\n A_i, B_i = map(int, input().split())\n A.append(A_i)\n B.append(B_i)\n\nmin_value_index_list = np.argsort(A)\n\ncnt = 0\nresult = 0\nfor i in range(N):\n cnt += B[min_value_index_list[i]]\n if cnt <= M:\n result += A[min_value_index_list[i]] * B[min_value_index_list[i]]\n else:\n result += A[min_value_index_list[i]] * (cnt-M)\nprint(result)\n', 'N,M = map(int,input().split())\nli = [list(map(int,input().split())) for i in range(N)]\nli=sorted(li,key=lambda x: x[0])\nm_sum=0\nfor i in li:\n\tbuy=min(M,i[1])\n\tm_sum+=i[0]*buy\n\tM-=buy\nprint(m_sum)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s342704789', 's410995069', 's613097287', 's667513844', 's842082787', 's837118564']
[38896.0, 21640.0, 21624.0, 21636.0, 21556.0, 29796.0]
[556.0, 539.0, 538.0, 636.0, 524.0, 502.0]
[756, 566, 564, 548, 496, 195]
p03103
u588829932
2,000
1,048,576
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.
['n, m = list(map(int, input().split()))\n\ndata =[]\nfor i in range(n):\n tmp_a, tmp_b = list(map(int, input().split()))\n data.append((tmp_a, tmp_b))\n\n\ntotal =0\ncost = 0\nfor a, b in sorted(data, key=lambda x:x[0]):\n print(a, b)\n if total + b < m:\n total += b\n cost += a*b\n else:\n cost += a*(m-total)\n break\nprint(cost)', 'n, m = list(map(int, input().split()))\n\ndata =[]\nfor i in range(n):\n tmp_a, tmp_b = list(map(int, input().split()))\n data.append((tmp_a, tmp_b))\n\n\ntotal =0\ncost = 0\nfor a, b in sorted(data, key=lambda x:x[0]):\n #print(a, b)\n if total + b < m:\n total += b\n cost += a*b\n else:\n cost += a*(m-total)\n break\nprint(cost)']
['Wrong Answer', 'Accepted']
['s935937247', 's657494764']
[18888.0, 18888.0]
[540.0, 436.0]
[356, 357]
p03103
u599170882
2,000
1,048,576
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.
[' def get_input_row():\n return [int(i) for i in input().split(" ")]\n \n inp = get_input_row()\n N = inp[0]\n M = inp[1]\n item_dict = {}\n num = 0\n for i in range(N):\n a, b = get_input_row()\n if a in item_dict:\n item_dict[a] += b\n else:\n \titem_dict[a] = b\n sorted_list = [k for k in item_dict.keys()]\n sorted_list.sort()\n money = 0\n for price in sorted_list:\n if M > item_dict[price]:\n M -= item_dict[price]\n money += price * item_dict[price]\n else:\n money += price * M\n break\n print(money)', 'def get_input_row():\n return [int(i) for i in input().split(" ")]\n \ninp = get_input_row()\nN = inp[0]\nM = inp[1]\nitem_dict = {}\nnum = 0\nfor i in range(N):\n a, b = get_input_row()\n if a in item_dict:\n item_dict[a] += b\n else:\n item_dict[a] = b\n\nsorted_list = [k for k in item_dict.keys()]\nsorted_list.sort()\nmoney = 0\nfor price in sorted_list:\n if M > item_dict[price]:\n M -= item_dict[price]\n money += price * item_dict[price]\n else:\n money += price * M\n break\nprint(money)']
['Runtime Error', 'Accepted']
['s075731164', 's160767239']
[2940.0, 17892.0]
[19.0, 416.0]
[594, 500]
p03103
u600261652
2,000
1,048,576
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.
['N, M = map(int, input().split())\nA = []\nB = []\nfor _ in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\nC = sorted(A)\nwhile M > 0:\n ', 'def resolve():\n N, M = map(int, input().split())\n A = []\n for _ in range(N):\n a = list(map(int, input().split()))\n A.append(a)\n ans = 0\n for i, j in sorted(A, key=lambda x: x[0]):\n if j >= M:\n ans += M * i\n print(ans)\n exit()\n ans += i * j\n M -= j\nresolve()']
['Runtime Error', 'Accepted']
['s542651118', 's857166928']
[9032.0, 29444.0]
[26.0, 252.0]
[166, 340]
p03103
u606090886
2,000
1,048,576
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.
['2 3\n1 32\n2 63\n1 12', 'n,m = map(int,input().split())\na = []\nb = []\nfor i in range(n):\n P,Y = map(int,input().split())\n a.append(P)\n b.append(Y)\n\n\n\n\n\ncount = 0\nans = 0\ni = 0\nA = sorted(a)\nif n-m < n//2:\n while i < n:\n if m-b[a.index(A[i])] > 0:\n m -= b[a.index(A[i])]\n ans += A[i] * b[a.index(A[i])]\n else:\n ans += A[i]* m\n break\n i+=1\nelse:\n while i < n:\n if m-b[a.index(A[(i+1)*(-1)])] > 0:\n m -= b[a.index(A[(i+1)*(i-1)])]\n ans += A([i+1)*(-1)] * b[a.index(A[(i+1)*(-1)])]\n else:\n ans += A[(i+1)*(-1)] * m\n break\n i+=1\nprint(ans)', 'n,m = map(int,input().split())\nmat = []\nfor i in range(n):\n mat.append(list(map(int,input().split())))\n\n\n\n\n\nans = 0\ni = 0\nmat.sort()\n\nwhile True:\n if m - mat[i][1] > 0:\n ans += mat[i][1]*mat[i][0]\n m -= mat[i][1]\n i += 1\n else:\n ans += mat[i][0] *m\n break\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s392410965', 's421472805', 's864941335']
[2940.0, 3064.0, 27756.0]
[17.0, 17.0, 515.0]
[18, 897, 570]
p03103
u607072045
2,000
1,048,576
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.
['N, M = map(int, input().split())\n\nmoney = float(0)\n\nkakaku = []\nhonsuu = []\nnokori_honsuu = M\n\nfor i in range(N):\n\tA, B = map(int, input().split())\n\tkakaku.append(A)\n\thonsuu.append(B)\n\nwhile nokori_honsuu > 0:\n\tmin_kakaku_pos = kakaku.index(min(kakaku))\n\tif honsuu[min_kakaku_pos] <= nokori_honsuu:\n\t\tmoney += honsuu[min_kakaku_pos] * kakaku[min_kakaku_pos]\n\t\tnokori_honsuu -= honsuu[min_kakaku_pos]\n\telse:\n\t\tmoney += nokori_honsuu * kakaku[min_kakaku_pos]\n\t\tnokori_honsuu -= nokori_honsuu\n\tkakaku.pop(min_kakaku_pos)\n\thonsuu.pop(min_kakaku_pos)\nprint(money)', 'N, M = map(int, input().split())\nS = []\n\nmoney = 0\n\nfor i in range(N):\n\tA, B = map(int, input().split())\n\tS.append([A, B])\n\t\nS.sort()\n\nwhile M > 0:\n\tfor i in range(N):\n\t\tif S[i][1] <= M:\n\t\t\tmoney += S[i][0] * S[i][1]\n\t\t\tM -= S[i][1]\n\t\telse:\n\t\t\tmoney += S[i][0] * M\n\t\t\tM -= M\n\t\t\tbreak\nprint(money)']
['Wrong Answer', 'Accepted']
['s769661622', 's027031503']
[10980.0, 20056.0]
[2104.0, 467.0]
[558, 296]
p03103
u617037231
2,000
1,048,576
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.
['import sys\nN,M = map(int,input().split())\nshops = dict()\nprice = []\ntakahashi = 0\nmoney = 0\nfor i in range(N):\n bottle,stock = map(int,input().split())\n if bottle not in shops:\n shops[bottle] = 0\n shops[bottle] += stock\n if bottle not in price:\n price.append(bottle)\nprice.sort()\nfor y in price:\n while takahashi != M:\n if shops[y] <= (M-takahashi):\n takahashi += shops[y]\n money += shops[y]*y\n shops[y] = 0\n break\n else:\n takahashi += (M-takahashi)\n shops[y] -= (M-takahashi)\n money += y*(M-takahashi)\n break\n if takahashi == M:\n print(money)\n sys.exit(0)', 'N,M = map(int,input().split())\nshops = []\nfor i in range(N):\n price,B = map(int,input().split())\n shops.append([price,B])\nshops.sort()\ni = 0\nmoney = 0\nwhile M > 0:\n if shops[i][1] > M:\n money += M*shops[i][0]\n break\n else:\n money += shops[i][1] * shops[i][0]\n M -= shops[i][1]\n i += 1\nprint(money)']
['Wrong Answer', 'Accepted']
['s844756634', 's278517266']
[5016.0, 20056.0]
[2104.0, 473.0]
[704, 340]
p03103
u623687794
2,000
1,048,576
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.
['n,m=map(int,input().split())\nedr=[]\nfor i in range(n):\n edr.append(list(map(int,input().split())))\nedr.sort(key =lambda x:x[0])\ncnt=0\nans=0\nfor i in range(n):\n cnt+=0\n ans+=edr[i][0]*edr[i][1]\n if cnt>=m:\n ans-=(cnt-m)*edr[i][0]\n break\nprint(ans)', 'n,m=map(int,input().split())\nedr=[]\nfor i in range(n):\n edr.append(list(map(int,input().split())))\nedr.sort(key =lambda x:x[0])\ncnt=0\nans=0\nfor i in range(n):\n cnt+=edr[i][1]\n ans+=edr[i][0]*edr[i][1]\n if cnt>=m:\n ans-=(cnt-m)*edr[i][0]\n break\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s670437883', 's172124057']
[29024.0, 29024.0]
[467.0, 461.0]
[256, 265]
p03103
u625554679
2,000
1,048,576
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.
["def find_AC(S):\n ret = []\n for i in range(len(S)-1):\n if S[i] == 'A' and S[i+1] == 'C':\n ret.append(i)\n return ret\n\nN, Q = [int(x) for x in input().split()]\nS = input()\nresult = find_AC(S)\nprint(result)\npos = [res+1 for res in result]\n\nfor _ in range(Q):\n l, r = [int(x) for x in input().split()]\n ans = 0\n for p in pos:\n if p>=l and p<=r-1:\n ans += 1\n print(ans)\n", 'N, M = [int(x) for x in input().split()]\n\nAB = []\n\nfor _ in range(N):\n\n AB.append([int(x) for x in input().split()])\n\nAB = sorted(AB, key=lambda x: x[0])\n\ncurrent_drinks = 0\n\ncurrent_buget = 0\n\nfor a, b in AB:\n\n num_buy = min(b, (M-current_drinks))\n\n current_drinks += num_buy\n\n current_buget += num_buy*a\n\n # print(current_drinks, current_buget)\n\n if current_drinks == M:\n\n break\n\nprint(current_buget)']
['Runtime Error', 'Accepted']
['s199744401', 's884028883']
[3188.0, 23524.0]
[810.0, 434.0]
[387, 427]
p03103
u638282348
2,000
1,048,576
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.
['M, N = map(int, input().split())\nCOST, STOCK = range(2)\nenergy_drinks = sorted((tuple(map(int, input().split())) for _ in range(N)), key=lambda tuple_: tuple_[COST])\n\ncost = 0\nfor energy_drink in energy_drinks:\n buy = min(energy_drink[STOCK], N)\n N -= buy\n cost += buy * energy_drink[COST]\nprint(cost)\n', 'M, N = map(int, input().split())\nCOST, STOCK = range(2)\nenergy_drinks = sorted((tuple(map(int, input().split())) for _ in range(M)), key=lambda tuple_: tuple_[COST])\n\ncost = 0\nfor energy_drink in energy_drinks:\n buy = min(energy_drink[STOCK], N)\n N -= buy\n cost += buy * energy_drink[COST]\nprint(cost)\n']
['Runtime Error', 'Accepted']
['s630299623', 's166373978']
[18060.0, 18188.0]
[428.0, 433.0]
[311, 311]
p03103
u644360640
2,000
1,048,576
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.
['n,m = map(int,input().split())\nab = [list(map(int,input().split())) for i in range(n)]\nab.sort(key=lambda x: x[1])\nans = 0\nprint(ab)\nfor i in range(n):\n if m == 0:\n break\n if m - ab[i][1] >= 0:\n ans += ab[i][0] * ab[i][1]\n m -= ab[i][1]\n #print(ans)\n else:\n ans += m * ab[i][0]\n #print(ans)\n break\nprint(ans)\n', 'n,m = map(int,input().split())\nab = [list(map(int,input().split())) for i in range(n)]\nab.sort()\nans = 0\n\nfor i in range(n):\n if m == 0:\n break\n if m - ab[i][1] >= 0:\n ans += ab[i][0] * ab[i][1]\n m -= ab[i][1]\n else:\n ans += m * ab[i][0]\n break\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s596597524', 's059058419']
[34656.0, 27756.0]
[470.0, 498.0]
[367, 300]
p03103
u645538982
2,000
1,048,576
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.
['N,M=(map(int,input().split()))\n\nC=[input().split() for i in range(N)]\n\nCX=[]\nfor i in C:\n for j in i:\n try:CX.append(int(j))\n\n except ValueError:\n pass\n\nCA=[]\nCB=[]\ni=0\n\nfor k in CX:\n\n if (i+2)%2==0:\n CA.append(CX[i])\n else:\n CB.append(CX[i])\n i+=1\n\n\n\nk=0\nl=0\nm=0\nmoney=0\nX=0\n\nwhile M>X:\n Min=int(C[0][0])\n for i in C:\n if Min>=int(i[0]):\n Min=int(i[0])\n l=k\n k+=1\n print(Min)\n for x in range(int(C[l][1])):\n\n m+=1\n if M==X+m:#max\n money+=m*Min\n print(money)\n break\n\n\n money+=m*Min\n X+=m\n\n C.pop(l)\n \n k=0\n l=0\n m=0\n', 'N,M=(map(int,input().split()))\n\nC=[input().split() for i in range(N)]\nB=[]\nfor i in C:\n B.append(list(map(int,i)))\n\nB.sort()\n\nk=0\nl=0\nm=0\nmoney=0\nX=0\n\nwhile M>X:\n money+=B[0][0]*B[0][1]\n X+=B[0][1]\n if M<X:\n money-=B[0][0]*B[0][1]\n X-=B[0][1]\n for x in range(B[0][1]):\n m+=1\n if M=X+m:\n money+=B[0][0]*m\n print(money)\n break\n\n B.pop(l)\n', 'N,M=(map(int,input().split()))\n\nC=[input().split() for i in range(N)]\n\nk=0\nl=0\nm=0\nmoney=0\nX=0\n\nwhile M>X:\n Min=int(C[0][0])\n for i in C:\n if Min>=int(i[0]):\n Min=int(i[0])\n l=k\n k+=1\n money+=int(C[l][1])*Min\n X+=m\n if X>M:\n for x in range(int(C[l][1])):\n m+=1\n if M==X+m:#max\n money+=m*Min\n print(money)\n break\n\n\n C.pop(l)\n \n k=0\n l=0\n m=0\n', 'N,M=(map(int,input().split()))\n\nC=[input().split() for i in range(N)]\n\nk=0\nl=0\nm=0\nmoney=0\nX=0\n\nwhile M>X:\n Min=int(C[0][0])\n for i in C:\n if Min>=int(i[0]):\n Min=int(i[0])\n l=k\n k+=1\n money+=int(C[l][1])*Min\n X+=m\n if X>M:\n money-=int(C[l][1])*Min\n X-=m\n for x in range(int(C[l][1])):\n m+=1\n if M==X+m:#max\n money+=m*Min\n print(money)\n break\n\n\n C.pop(l)\n \n k=0\n l=0\n m=0\n', 'N,M=(map(int,input().split()))\n\nC=[input().split() for i in range(N)]\nB=[]\nfor i in C:\n B.append(list(map(int,i)))\n\nB.sort()\n\nk=0\nl=0\nm=0\nmoney=0\nX=0\nfor a,b in B:\n if(M<=0):\n break\n if(b<=M):\n money+=a*b\n else:\n money+=M*a\n M-=b\nprint(money)\n']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s182831928', 's188391186', 's619344400', 's754017293', 's072121692']
[42516.0, 3064.0, 35060.0, 35060.0, 57772.0]
[2107.0, 18.0, 2106.0, 2106.0, 495.0]
[820, 500, 618, 663, 327]
p03103
u647796955
2,000
1,048,576
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.
['N, M = list(map(int, input().spliit()))\nC = []\nfor n in range(N):\n A, B = list(map(int, input().spliit()))\n C.append([A,B])\n \nC = sorted(C, key=lambda x:x[0])\n\nS = 0\nn = 0\nwhilie S <= M:\n S += C[0][1]\n n += 1\nprint(S)\n \n \n ', 'N, M = list(map(int, input().split()))\nC = []\nfor n in range(N):\n A, B = list(map(int, input().split()))\n C.append([A,B])\n \nC = sorted(C, key=lambda x:x[0])\n\nS = 0\nn = 0\nwhile S <= M:\n S += C[0][1]\n n += 1\nprint(S)\n ', 'N, M = list(map(int, input().split()))\nC = []\nfor n in range(N):\n A, B = list(map(int, input().split()))\n C.append([A,B])\n \nC = sorted(C, key=lambda x:x[0])\n\nS = 0\nnum = 0\nn1 = 0\nn2 = 0\nwhile num < M:\n if n2 == C[n1][1]:\n n1 += 1\n n2 = 0\n S += C[n1][0]\n num += 1\n n2 += 1\n \nprint(S)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s225485200', 's837159714', 's122077420']
[2940.0, 22368.0, 22492.0]
[17.0, 466.0, 481.0]
[250, 222, 295]
p03103
u652057333
2,000
1,048,576
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.
['# C\nn, m = map(int, input().split())\nab = [0, 0] * n\nfor i in range(n):\n ab[i] = map(int, input().split())\nab.sort(key=lambda x:x[0])\n\ncost = 0\nfor i in range(n):\n value = ab[i][0]\n num = ab[i][1]\n if num > m:\n cost += value * m\n break\n else:\n cost += value * num\n m -= num\nprint(cost)', '# C\nn, m = map(int, input().split())\nab = [[int(i) for i in input().split()] for i in range(n)]\n\nab.sort(key=lambda x:x[0])\n\ncost = 0\nfor i in range(n):\n value = ab[i][0]\n num = ab[i][1]\n if num > m:\n cost += value * m\n break\n else:\n cost += value * num\n m -= num\nprint(cost)']
['Runtime Error', 'Accepted']
['s347316715', 's746173086']
[50420.0, 22756.0]
[381.0, 401.0]
[328, 315]
p03103
u655110382
2,000
1,048,576
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.
['nm, left = map(int, input().split())\nshops = []\nfor _ in range(nm):\n shops.append([int(x) for x in input().split()])\nshops.sort(key=lambda x: x[0])\n#print(shops)\ntotal_cost = 0\nfor cost, stock in shops:\n if stock >= left:\n print("final : " + str(total_cost + cost * left))\n exit(0)\n else:\n left = left - stock\n total_cost += cost * stock\n #print("current : " + str(total_cost))\n', 'nm, left = map(int, input().split())\nshops = []\nfor _ in range(nm):\n shops.append([int(x) for x in input().split()])\nshops.sort(key=lambda x: x[0])\n#print(shops)\ntotal_cost = 0\nfor cost, stock in shops:\n if stock >= left:\n print(total_cost + cost * left)\n exit(0)\n else:\n left = left - stock\n total_cost += cost * stock\n #print("current : " + str(total_cost))\n']
['Wrong Answer', 'Accepted']
['s573137406', 's062025028']
[22752.0, 22748.0]
[390.0, 403.0]
[422, 404]
p03103
u657901243
2,000
1,048,576
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.
['n, m = map(int, input().split())\narr = []\nfor i in range(n):\n a, b = map(int, input().split())\n arr.append([a, b])\na.sort()\nans = 0\nidx = 0\nwhile True:\n if m <= 0:\n break\n ans += arr[idx][0] * min(arr[idx][1], m)\n m -= min(arr[idx][1], m)\n idx += 1\nprint(ans)\n', 'n, m = map(int, input().split())\narr = []\nfor i in range(n):\n a, b = map(int, input().split())\n arr.append([a, b])\narr.sort()\nans = 0\nidx = 0\nwhile True:\n if m <= 0:\n break\n ans += arr[idx][0] * min(arr[idx][1], m)\n m -= min(arr[idx][1], m)\n idx += 1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s963285415', 's366440469']
[19532.0, 20064.0]
[326.0, 502.0]
[286, 288]
p03103
u658627575
2,000
1,048,576
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.
['N, M = map(int, input().split())\nX = []\nfor i in range(N):\n\tX.append(list(map(int, input().split())))\n\n#Sorted by first element\nX.sort(key=lambda x:x[0])\ni = 0\ntotal = 0\nans = 0\n\nwhile i <= N-1:\n\tnum += X[i][1]\n\tans += X[i][0] * X[i][1]\n\tif num > M:\n\t\tans -= X[i][0] * (num-M)\n\t\tbreak\n\ti += 1\nprint(ans)', 'N, M = map(int, input().split())\n#N = 1\n#M = 1\nl1 = []\nl2 = []\nans = 0\nrest = M\nfor i in range(N):\n\ttemp1, temp2 = map(int, input().split())\n\t#temp1 = 1\n\t#temp2 = 1\n\tl1.append(temp1)\n\tl2.append(temp2)\n\nwhile True:\n\tmin_index = l1.index(min(l1))\n\tans += (min(l1) * l2[min_index])\n\trest -= l2[min_index]\n\tif rest <= 0:\n\t\tbreak\n\tl1.pop(min_index)\n\nprint(ans)', 'N, M = map(int, input().split())\n#N = 1\n#M = 1\nl1 = []\nl2 = []\nans = 0\nrest = M\nfor i in range(N):\n\ttemp1, temp2 = map(int, input().split())\n\t#temp1 = 1\n\t#temp2 = 1\n\tl1.append(temp1)\n\tl2.append(temp2)\n\nwhile True:\n\tmin_index = l1.index(min(l1))\n\tif(rest >= l2[min_index])\n\t\tans += (min(l1) * l2[min_index])\n\t\trest -= l2[min_index]\n\telse :\n\t\tans += (min(l1) * rest)\n\t\tbreak\n\tl1.pop(min_index)\n\nprint(ans)', 'N, M = map(int, input().split())\nl1 = []\nl2 = []\nans = 0\nrest = M\nfor i in N+1:\n\tl1[i],l2[i] = map(int, input().split())\n\nwhile true:\n\tmin_index = l1.index(min(l1))\n\tans += min(l1) * l2[min_index]\n\trest -= l2[min_index]\n\tif rest == 0:\n\t\tbreak\n\tl1.pop(min_index)\n\nprint(ans)', 'N, M = map(int, input().split())\n#N = 1\n#M = 1\nl1 = []\nl2 = []\nans = 0\nrest = M\nfor i in range(N):\n\ttemp1, temp2 = map(int, input().split())\n\t#l1[i],l2[i] = map(int, input().split())\n\tl1.append(temp1)\n\tl2.append(temp2)\n\nwhile true:\n\tmin_index = l1.index(min(l1))\n\tans += (min(l1) * l2[min_index])\n\trest -= l2[min_index]\n\tif rest <= 0:\n\t\tbreak\n\tl1.pop(min_index)\n\nprint(ans)', 'N, M = map(int, input().split())\n#N = 1\n#M = 1\nl1 = []\nl2 = []\nans = 0\nrest = M\nfor i in range(N):\n\tl1[i],l2[i] = map(int, input().split())\n\t#l1[0],l2[0] = 3,1\n\nwhile true:\n\tmin_index = l1.index(min(l1))\n\tans += (min(l1) * l2[min_index])\n\trest -= l2[min_index]\n\tif rest <= 0:\n\t\tbreak\n\tl1.pop(min_index)\n\nprint(ans)', 'N, M = map(int, input().split())\nX = []\nfor i in range(N):\n\tX.append(list(map(int, input().split())))\n\n#Sorted by first element\nX.sort(key=lambda x: x[0])\ni = 0\ntotal = 0\nans = 0\n\nwhile i <= N-1:\n\ttotal += X[i][1]\n\tans += X[i][0] * X[i][1]\n\tif total > M:\n\t\tans -= X[i][0] * (total-M)\n\t\tbreak\n\ti += 1\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s226290040', 's452649064', 's549478719', 's749185615', 's852775140', 's909374249', 's825920517']
[29024.0, 10996.0, 2940.0, 3064.0, 11048.0, 3064.0, 29024.0]
[406.0, 2104.0, 17.0, 17.0, 307.0, 17.0, 460.0]
[303, 355, 403, 274, 374, 315, 310]
p03103
u665038048
2,000
1,048,576
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.
['N, M = map(int, input().split())\nA_B = []\nfor i in range(N):\n A_B.append(list(map(int, input().split())))\nA_B.sort()\nprint(A_B)\nsum = 0\nmoney = 0\ni = 0\nwhile sum <= M:\n money += A_B[i][0] * A_B[i][1]\n sum += A_B[i][1]\n print(sum)\n i += 1\nmoney -= A_B[i-1][0] * (sum - M)\nprint(money)\n', 'N, M = map(int, input().split())\nA_B = []\nfor i in range(N):\n A_B.append(list(map(int, input().split())))\nA_B.sort()\nsum = 0\nmoney = 0\ni = 0\nwhile sum <= M and i < N:\n money += A_B[i][0] * A_B[i][1]\n sum += A_B[i][1]\n i += 1\nmoney -= A_B[i-1][0] * (sum - M)\nprint(money)']
['Runtime Error', 'Accepted']
['s554720320', 's823866151']
[33776.0, 27760.0]
[645.0, 565.0]
[299, 282]
p03103
u667024514
2,000
1,048,576
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.
['n,m = map(int,input().split())\nlis = list(map(int,input().split()))\nlis.sort(key = lambda x:x[1])\nans = 0\ncou = 0\nnum = 0\nwhile cou < m:\n nu = min(lis[num],m-cou)\n cou += nu\n ans += lis[num] * nu\n num += 1\nprint(ans)\n ', 'n, m = map(int, input().split())\nlis = [list(map(int,input().split())) for i in range(n)]\nlis.sort(key=lambda x:x[0])\nans = 0\ncou = 0\nnum = 0\nwhile cou < m:\n nu = min(lis[num][1], m - cou)\n cou += nu\n ans += lis[num][0] * nu\n num += 1\nprint(ans)']
['Runtime Error', 'Accepted']
['s851227845', 's064595424']
[3060.0, 29028.0]
[17.0, 462.0]
[223, 257]
p03103
u670567845
2,000
1,048,576
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.
['N, M = map(int, input().split())\narray = []\nfor i in range(N):\n elm = list(map(int, input().split()))\n array.append(elm)\n\narray.sort(key=lambda x: x[0])\nprint(array)\nans = 0\ncnt = 0\nfor i in range(N):\n \n buy = min([array[i][1], M-cnt])\n cnt += buy\n ans += array[i][0]*buy\n\nprint(ans)', 'N, M = map(int, input().split())\narray = []\nfor i in range(N):\n elm = list(map(int, input().split()))\n array.append(elm)\n\narray.sort(key=lambda x: x[0])\nans = 0\ncnt = 0\nfor i in range(N):\n \n buy = min([array[i][1], M-cnt])\n cnt += buy\n ans += array[i][0]*buy\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s168235389', 's933525150']
[34656.0, 29020.0]
[579.0, 485.0]
[305, 292]
p03103
u671239754
2,000
1,048,576
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.
['li = list(input())\na = li.count("0")\nimport math\nif a < math.ceil(len(li)/2):\n print(2*a)\nelse:\n print(2*(len(li)-a))\n', 'n,m = map(int, input().split())\nli = [list(map(int, input().split())) for i in range(n)]\nli.sort(key=lambda x:x[0])\nans = 0\n\nwhile True:\n if m == 0:\n print(ans)\n quit()\n if li[0][1] == 0:\n li.pop(0)\n ans += li[0][0]\n li[0][1] -= 1\n m -= 1\n']
['Wrong Answer', 'Accepted']
['s310063356', 's289771926']
[3060.0, 29024.0]
[17.0, 1911.0]
[124, 275]
p03103
u674588203
2,000
1,048,576
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.
['import numpy as np\n\nN,M=map(int,input().split())\nl=[]\nfor n in range(N):\n A,B=map(int,input().split())\n temp_l=[A,B]\n l.append(temp_l)\narr=np.array(l,dtype=np.int64)\n# print(l)\n# print(arr)\n\nneed=M\nans=0\n\n\ncol_num=0\n\nroute=arr[np.argsort(arr[:,col_num])]\nprint(route)\nfor i in range(N):\n if need >= route[i,1]:\n ans+=route[i,0]*route[i,1]\n need-=route[i,1]\n if need==0:\n break\n else:\n continue\n else:\n ans+=route[i,0]*need\n need=0\nprint(ans)', 'import numpy as np\n\nN,M=map(int,input().split())\nl=[]\nfor n in range(N):\n A,B=map(int,input().split())\n temp_l=[A,B]\n l.append(temp_l)\narr=np.array(l,dtype=np.int64)\n# print(l)\n# print(arr)\n\nneed=M\nans=0\n\n\ncol_num=0\n\nroute=arr[np.argsort(arr[:,col_num])]\n# print(route)\nfor i in range(N):\n if need >= route[i,1]:\n ans+=route[i,0]*route[i,1]\n need-=route[i,1]\n if need==0:\n break\n else:\n continue\n else:\n ans+=route[i,0]*need\n need=0\nprint(ans)']
['Wrong Answer', 'Accepted']
['s585739912', 's961258118']
[45592.0, 45492.0]
[474.0, 452.0]
[588, 590]
p03103
u674885198
2,000
1,048,576
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.
['N,M = list(map(int, input().split()))\nlis=[]\nfor i in range(N):\n a,b = list(map(int, input().split()))\n lis.append([a,b])\n\nlis.sort()\n\ncount=0\nmoney=0\nind=0\nwhile count+lis[ind][1]<=M:\n count+=lis[ind][1]\n money+=lis[ind][0]*lis[ind][1]\n ind+=1\n print(ind)\n \n\nmoney+=(M-count)*lis[ind][0]\nprint(int(money))', 'N,M = list(map(int, input().split()))\nlis=[]\nfor i in range(N):\n a,b = list(map(int, input().split()))\n lis.append([a,b])\n\nlis.sort()\n\ncount=0\nmoney=0\nind=0\nwhile count+lis[ind][1]<M:\n count+=lis[ind][1]\n money+=lis[ind][0]*lis[ind][1]\n ind+=1\n print(ind)\n \n\nmoney+=(M-count)*lis[ind][0]\nprint(money)', 'N,M = list(map(int, input().split()))\nlis=[]\nfor i in range(N):\n a,b = list(map(int, input().split()))\n lis.append([a,b])\n\nlis.sort()\n\ncount=0\nmoney=0\nind=0\nwhile count+lis[ind][1]<M:\n count+=lis[ind][1]\n money+=lis[ind][0]*lis[ind][1]\n ind+=1\n #print(ind)\n \n\nmoney+=(M-count)*lis[ind][0]\nprint(int(money))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s365214645', 's765594715', 's814175089']
[20460.0, 20460.0, 20460.0]
[604.0, 580.0, 547.0]
[327, 321, 327]
p03103
u679888753
2,000
1,048,576
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.
['n, m = map(int, input().split())\na, b = zip(*(map(int, input().split()) for _ in range(n)))\nc = sorted(zip(a, b))\n\ncost = 0\nrest = m\nfor a, b in c:\n if m >= b: \n cost += a * b\n rest -= b\n else: \n cost += a * m\n break\nprint(cost)', 'n, m = map(int, input().split())\na, b = zip(*(map(int, input().split()) for _ in range(n)))\nc = sorted(zip(a, b))\ncost = 0\nrest = m\nfor a, b in c:\n if rest >= b: \n cost += a * b\n rest -= b\n else: \n cost += a * rest\n break\nprint(cost)\n']
['Wrong Answer', 'Accepted']
['s013687093', 's788875804']
[58328.0, 58328.0]
[646.0, 507.0]
[352, 358]
p03103
u681150536
2,000
1,048,576
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.
['from sys import exit\n\nN, M = map(int, input().split())\n\nshops = {}\n\nfor _ in range(N):\n A, B = map(int, input().split())\n shops[A] = B\n\nshops = sorted(shops.items())\nprint(shops)\nans = 0\n\nfor k in shops:\n if M - k[1] <= 0:\n ans += k[0] * M\n print(ans)\n exit()\n else:\n ans += k[0] * k[1]\n M -= k[1]\n', 'from sys import exit\n\nN, M = map(int, input().split())\n\nshops = {}\n\nfor _ in range(N):\n A, B = map(int, input().split())\n if shops[A]:\n shops[A] += B\n else:\n shops[A] = B\n\nshops = sorted(shops.items())\nans = 0\n\nfor k in shops:\n if M - k[1] <= 0:\n ans += k[0] * M\n break\n else:\n ans += k[0] * k[1]\n M -= k[1]\n\nprint(ans)\n', 'from sys import exit\n\nN, M = map(int, input().split())\n\nshops = {}\n\nfor _ in range(N):\n A, B = map(int, input().split())\n if A in shops.keys():\n shops[A] += B\n else:\n shops[A] = B\n\nshops = sorted(shops.items())\nans = 0\n\nfor k in shops:\n if M - k[1] <= 0:\n ans += k[0] * M\n break\n else:\n ans += k[0] * k[1]\n M -= k[1]\n\nprint(ans)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s086034283', 's595248442', 's635600990']
[23000.0, 3064.0, 23000.0]
[491.0, 17.0, 453.0]
[345, 377, 386]
p03103
u682730715
2,000
1,048,576
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.
['# coding: UTF-8\nimport sys\n\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\na, b = map(int, input().split())\nd = defaultdict(int)\narray = []\nfor i in range(a):\n x, y = map(int, input().split())\n d[x] = y\n array.append(x)\narray.sort()\n\n\ncount = 0\nfor i in array:\n break\n if b <= d[i]:\n count += min(b, 0) * i\n break\n else:\n t = d[i]\n b -= t\n count += t * i\nprint(count)', '# coding: UTF-8\nimport sys\n\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\na, b = map(int, input().split())\nd = defaultdict(int)\narray = []\nfor i in range(a):\n x, y = map(int, input().split())\n d[x] = y\n array.append(x)\narray.sort()\n\n\ncount = 0\nfor i in array:\n if b <= d[i]:\n count += min(b, 0) * i\n break\n else:\n t = d[i]\n b -= t\n count += t * i\nprint(count)', '# coding: UTF-8\nimport sys\n\nimport heapq\nimport re\nimport bisect\nimport random\nimport math\nimport itertools\nfrom collections import defaultdict, deque\nfrom copy import deepcopy\nfrom decimal import *\n\na, b = map(int, input().split())\nd = []\nfor i in range(a):\n x, y = map(int, input().split())\n d.append((x, y))\nd.sort()\ncount = 0\nfor i in range(a):\n if b <= d[i][1]:\n count += b * d[i][0]\n break\n else:\n b -= d[i][1]\n count += d[i][0] * d[i][1]\nprint(count)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s069399633', 's651642519', 's831622541']
[2940.0, 20744.0, 19448.0]
[17.0, 410.0, 453.0]
[574, 560, 522]