Language: C++

#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;


class Shop {
public:
	int Money;
	int Stock;

	Shop(int m, int s) {
		Money = m;
		Stock = s;
	}

	bool operator<(const Shop &otherShop) const {
		return Money < otherShop.Money;
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i] >> B[i];
	}

	vector<Shop> ShopList(N);
	for (int i = 0; i < N; i++)
	{
		ShopList[i] = Shop(A[i], B[i]);
	}
	sort(ShopList.begin(), ShopList.end());

	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		//このお店で購入する数を決める
		int buy = min(M, ShopList[i].Stock);

		//買った金額を加算する
		ans += (long long)buy * ShopList[i].Money;
		//残り本数を減らす
		M -= buy;
	}

	cout << ans << endl;
}



Compiler output:
In file included from /usr/include/c++/14/bits/alloc_traits.h:33,
                 from /usr/include/c++/14/ext/alloc_traits.h:34,
                 from /usr/include/c++/14/bits/basic_string.h:39,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = Shop; _Args = {}]':
/usr/include/c++/14/bits/stl_uninitialized.h:643:18:   required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = Shop*; _Size = long unsigned int; bool _TrivialValueType = false]'
  643 |                 std::_Construct(std::__addressof(*__cur));
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:712:20:   required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = Shop*; _Size = long unsigned int]'
  710 |       return __uninitialized_default_n_1<__is_trivial(_ValueType)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  711 |                                          && __can_fill>::
      |                                          ~~~~~~~~~~~~~~~~
  712 |         __uninit_default_n(__first, __n);
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:779:44:   required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = Shop*; _Size = long unsigned int; _Tp = Shop]'
  779 |     { return std::__uninitialized_default_n(__first, __n); }
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1720:36:   required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = Shop; _Alloc = std::allocator<Shop>; size_type = long unsigned int]'
 1720 |           std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1721 |                                            _M_get_Tp_allocator());
      |                                            ~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:558:9:   required from 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = Shop; _Alloc = std::allocator<Shop>; size_type = long unsigned int; allocator_type = std::allocator<Shop>]'
  558 |       { _M_default_initialize(__n); }
      |         ^~~~~~~~~~~~~~~~~~~~~
a.cc:33:25:   required from here
   33 |         vector<Shop> ShopList(N);
      |                                ^
/usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'Shop::Shop()'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:14:9: note: candidate: 'Shop::Shop(int, int)'
   14 |         Shop(int m, int s) {
      |         ^~~~
a.cc:14:9: note:   candidate expects 2 arguments, 0 provided
a.cc:9:7: note: candidate: 'constexpr Shop::Shop(const Shop&)'
    9 | class Shop {
      |       ^~~~
a.cc:9:7: note:   candidate expects 1 argument, 0 provided
a.cc:9:7: note: candidate: 'constexpr Shop::Shop(Shop&&)'
a.cc:9:7: note:   candidate expects 1 argument, 0 provided