Language: C++

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n;cin>>n;
  vector<ll>a(n);
  multiset<ll>set;
  rep(i,n){
    cin>>a[i];
    set.insert(a[i]);
  }

  vector<ll>v(40);
  for(int i=0;i<40++i)v[i]=(1LL<<i);
  
  sort(all(v),greater<ll>());
  ll ans=0;
  {rep(i,n){
    for(auto&&p:v){
      auto itr=set.find(a[i]);
      if(itr==set.end())continue;
      set.erase(itr);
      auto itr2=set.find(p-a[i]);
      if(itr2!=set.end()){
        ans++;
        set.erase(itr2);
      }else set.insert(a[i]);
    }
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Compiler output:
a.cc: In function 'bool solve()':
a.cc:101:17: error: lvalue required as increment operand
  101 |   for(int i=0;i<40++i)v[i]=(1LL<<i);
      |                 ^~
a.cc:101:21: error: expected ';' before 'i'
  101 |   for(int i=0;i<40++i)v[i]=(1LL<<i);
      |                     ^
      |                     ;
a.cc:121:12: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  121 | signed main(){
      |            ^~
a.cc:121:12: note: remove parentheses to default-initialize a variable
  121 | signed main(){
      |            ^~
      |            --
a.cc:121:12: note: or replace parentheses with braces to value-initialize a variable
a.cc:121:14: error: a function-definition is not allowed here before '{' token
  121 | signed main(){
      |              ^
a.cc:127:2: error: expected '}' at end of input
  127 | }
      |  ^
a.cc:91:13: note: to match this '{'
   91 | bool solve(){
      |             ^