Language: C++

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

const int MAX_N = 2e5+10;
int a[MAX_N];

void solve()
{
	sort(a, a+N);
	int ans = 0;
	multiset<int> have;
	for(int i=0;i<N;++i) have.emplace(a[i]);
	while(!have.empty()){
		long long biggest = *have.rbegin();
		have.erase(have.rbegin());
		long long sum = 1;
		while(sum <= biggest) sum <<= 1;
		auto it = have.find(sum-biggest);
		if(it != have.end()){
			ans++;
			have.erase(it);
		}
	}
	cout << ans << endl;
}

int main()
{
	cin >> N;
	for(int i=0;i<N;++i) cin >> a[i];
	solve();
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:15:19: error: 'N' was not declared in this scope
   15 |         sort(a, a+N);
      |                   ^
a.cc:21:27: error: no matching function for call to 'std::multiset<int>::erase(std::multiset<int>::reverse_iterator)'
   21 |                 have.erase(have.rbegin());
      |                 ~~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/set:64,
                 from a.cc:7:
/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 = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<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<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'std::multiset<int>::const_iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<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 = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; size_type = long unsigned int; key_type = 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<int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >'} to 'const std::multiset<int>::key_type&' {aka 'const 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 = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<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
a.cc: In function 'int main()':
a.cc:35:16: error: 'N' was not declared in this scope
   35 |         cin >> N;
      |                ^