Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	long long v[n+10];
	for(int i=0;i<n;i++)
	cin>>v[i];
	sort(v,v+n);
	multiset<long long> ssi;
	for(int i=0;i<n;i++)
	{
	    ssi.insert(v[i]);
	}
	int res=0;
	while(!ssi.empty())
	{
	    long long x=*ssi.rbegin();
	   
	   while (!ssi.empty()) {
		long long x = *ssi.rbegin();
		ssi.erase(ssi.rbegin());
		long long now = 1;
		while (now <= x)
			now *= 2;
		auto it = ssi.find(now - x);
		if (it == ssi.end())
			continue;
		ssi.erase(it);
		++res;
	}
	}
	cout<<res<<'\n';
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:26: error: no matching function for call to 'std::multiset<long long int>::erase(std::multiset<long long int>::reverse_iterator)'
   25 |                 ssi.erase(ssi.rbegin());
      |                 ~~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/set:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_multiset.h:641:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::erase(const_iterator) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator; const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator]'
  641 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_multiset.h:641:28: note:   no known conversion for argument 1 from 'std::multiset<long long int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<long long int> >'} to 'std::multiset<long long int>::const_iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'}
  641 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_multiset.h:671:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::size_type std::multiset<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; size_type = long unsigned int; key_type = long long int]'
  671 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/14/bits/stl_multiset.h:671:29: note:   no known conversion for argument 1 from 'std::multiset<long long int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<long long int> >'} to 'const std::multiset<long long int>::key_type&' {aka 'const long long int&'}
  671 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_multiset.h:693:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::erase(const_iterator, const_iterator) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator; const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator]'
  693 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_multiset.h:693:7: note:   candidate expects 2 arguments, 1 provided