Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
	int M, N;
	cin >> M >> N;
	vector<vector<int>> data(N, vector<int>(2));
	for (int i = 0; i < N; i++) {
		cin >> data.at(i).at(0) >> data.at(i).at(1);
	}
	vector<int> copy(N);
	for (int i = 0; i < N; i++) {
		copy.at(i) = data.at(i).at(0);
	}
	sort(copy.begin(), copy.end());
	for (int i = 0; i < N; i++) {
		for (int k = i; k < N; k++) {
			if (copy.at(i) = copy.at(i) = data.at(i).at(0)) {
				swap(data.at(i).at(0) = data.at(k).at(0));
				swap(data.at(i).at(1) = data.at(k).at(1));
				break;
			}
		}
	}
	long sum_1 = 0;
	long sum_2 = 0;
	long sum_3 = 0;
	int count = 0;
	for (int i = 0; i < N; i++) {
		count++;
		sum_2 = sum_1;
		sum_1 += data.at(i).at(1)
			if (sum_1 > M) {
				break;
			}
	}
	for (int i = 0; i < count - 1; i++) {
		sum_3 += data.at(i).at(0) * data.at(i).at(1);
	}
	sum_3 += data.at(count - 1).at(0) * (M - sum_2);
	cout >> sum_3 >> endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:37: error: no matching function for call to 'swap(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   19 |                                 swap(data.at(i).at(0) = data.at(k).at(0));
      |                                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
                 from a.cc:1:
/usr/include/c++/14/sstream:1204:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringbuf<_CharT, _Traits, _Alloc>&, basic_stringbuf<_CharT, _Traits, _Alloc>&)'
 1204 |     swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/14/sstream:1204:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/sstream:1212:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_istringstream<_CharT, _Traits, _Allocator>&, basic_istringstream<_CharT, _Traits, _Allocator>&)'
 1212 |     swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/14/sstream:1212:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/sstream:1219:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_ostringstream<_CharT, _Traits, _Allocator>&, basic_ostringstream<_CharT, _Traits, _Allocator>&)'
 1219 |     swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/14/sstream:1219:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/sstream:1226:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringstream<_CharT, _Traits, _Allocator>&, basic_stringstream<_CharT, _Traits, _Allocator>&)'
 1226 |     swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/14/sstream:1226:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:896:5: note: candidate: 'template<class _Ch_type, class _Rx_traits> void std::__cxx11::swap(basic_regex<_Ch_type, _Rx_traits>&, basic_regex<_Ch_type, _Rx_traits>&)'
  896 |     swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
      |     ^~~~
/usr/include/c++/14/bits/regex.h:896:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/regex.h:2230:5: note: candidate: 'template<class _Bi_iter, class _Alloc> void std::__cxx11::swap(match_results<_BiIter, _Alloc>&, match_results<_BiIter, _Alloc>&)'
 2230 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/14/bits/regex.h:2230:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'template<class _Tp> std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&)'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
  250 |     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
      |     ^~~~
/usr/include/c++/14/bits/move.h:250:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
 1089 |     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
 1106 |     swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
      |     ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 4039 |     swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)'
 2805 |     swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
      |     ^~~~
/usr/include/c++/14/tuple:2805:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted)
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
/usr/include/c++/14/tuple:2823:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/functional:59,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/std_function.h:782:5: note: candidate: 'template<class _Res, class ... _Args> void std::swap(function<_Res(_ArgTypes ...)>&, function<_Res(_ArgTypes ...)>&)'
  782 |     swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept
      |     ^~~~
/usr/include/c++/14/bits/std_function.h:782:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63:
/usr/include/c++/14/bits/unordered_map.h:2130:5: note: candidate: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> void std::swap(unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&)'
 2130 |     swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/unordered_map.h:2130:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/unordered_map.h:2137:5: note: candidate: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> void std::swap(unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&, unordered_multimap<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&)'
 2137 |     swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^~~~
/usr/include/c++/14/bits/unordered_map.h:2137:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64:
/usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(vector<_Tp, _Alloc>&, vector<_Tp, _Alloc>&)'
 2122 |     swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
      |     ^~~~
/usr/include/c++/14/bits/stl_vector.h:2122:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/functional:65:
/usr/include/c++/14/array:377:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)typename std::__array_traits<_Tp, _Nm>::_Is_swappable::value)> std::swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&)'
  377 |     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
      |     ^~~~
/usr/include/c++/14/array:377:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/array:384:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)(! typename std::__array_traits<_Tp, _Nm>::_Is_swappable::value))> std::swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&)' (deleted)
  384 |     swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete;
      |     ^~~~
/usr/include/c++/14/array:384:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/memory:78,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56:
/usr/include/c++/14/bits/unique_ptr.h:822:5: note: candidate: 'template<class _Tp, class _Dp> typename std::enable_if<std::__is_swappable<_T2>::value>::type std::swap(unique_ptr<_Tp, _Dp>&, unique_ptr<_Tp, _Dp>&)'
  822 |     swap(unique_ptr<_Tp, _Dp>& __x,
      |     ^~~~
/usr/include/c++/14/bits/unique_ptr.h:822:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/unique_ptr.h:829:5: note: candidate: 'template<class _Tp, class _Dp> typename std::enable_if<(! std::__is_swappable<_T2>::value)>::type std::swap(unique_ptr<_Tp, _Dp>&, unique_ptr<_Tp, _Dp>&)' (deleted)
  829 |     swap(unique_ptr<_Tp, _Dp>&,
      |     ^~~~
/usr/include/c++/14/bits/unique_ptr.h:829:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/bits/shared_ptr.h:53,
                 from /usr/include/c++/14/memory:80:
/usr/include/c++/14/bits/shared_ptr_ba