Language: C++

#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int64 INF = 1LL << 40 - 1;
constexpr int64 LINF = 1LL << 60 + 1;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)


signed main() {
  INIT;
	VAR(int, n);
	map< int, int > mp;
	vector< PAIR > a;
	REP(i, n) {
		VAR(int, j);
        int p;
        REP(k, 31)
          if (p = (1 << k) > j) break;
		a.push_back(make_pair(j, p));
		mp[j]++;
	}

	sort(ALL(a));
	a.erase(unique(ALL(a)), a.end());

	int ans = 0;
	RREP(i, a.size()) {
			if (mp[a[i].first] == 0) break;
			int target = a[i].second;
			if (target == a[i].first) {
				int tmp = mp[target] / 2;
				mp[target] -= tmp * 2;
				ans += tmp;
			} else {
				int tmp1 = mp[target];
				int tmp2 = mp[a[i]];
				mp[target] -= min(tmp1, tmp2);
				mp[a[i].first] -= min(tmp1, tmp2);
				ans += min(tmp1, tmp2);
			}
	}

	OUT(ans)BR;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:46: error: no match for 'operator[]' (operand types are 'std::map<long int, long int>' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'})
   63 |                                 int tmp2 = mp[a[i]];
      |                                              ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = long int; _Tp = long int; _Compare = std::less<long int>; _Alloc = std::allocator<std::pair<const long int, long int> >; mapped_type = long int; key_type = long int]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'} to 'const std::map<long int, long int>::key_type&' {aka 'const long int&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = long int; _Tp = long int; _Compare = std::less<long int>; _Alloc = std::allocator<std::pair<const long int, long int> >; mapped_type = long int; key_type = long int]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'} to 'std::map<long int, long int>::key_type&&' {aka 'long int&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~