Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<ll,ll>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const long double eps = 1e-10;
//const double PI = M_PI; 
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space. */

// dinic
struct max_flow {
    struct edge { int to, cap, rev; };
    int V;
    vector<vector<edge>> G;
    vector<int> itr, level;

    max_flow(int V) : V(V) { G.assign(V,vector<edge>()); }

    void add_edge(int from, int to, int cap) {
        G[from].push_back((edge) {to, cap, (int) G[to].size()});
        G[to].push_back((edge) {from, 0, (int) G[from].size()-1});
    }

    void bfs(int s) {
        level.assign(V,-1);
        queue<int> q;
        level[s] = 0; q.push(s);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for(auto &e: G[v]){
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int& i = itr[v]; i < (int) G[v].size(); ++i) {
            edge& e = G[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int run(int s, int t) {
        int ret = 0, f;
        while (bfs(s), level[t] >= 0) {
            itr.assign(V,0);
            while ((f = dfs(s, t, INF)) > 0) ret += f;
        }
        return ret;
    }
};
const int DELTA = 300002;
max_flow Gra(700005);

// 座標圧縮(map実装)
unordered_map<ll,int> zip; // zipではない 定数倍重めなので二分探索が必要ないならunordered_map実装を
unordered_map<int,ll> un_zip;
void zip_in(vector<ll>& a){
  for(auto &i:a) zip[i] = 1;
  int cnt = 1; // 好みだけど0はエラー検出のために利用しない方がよさげ
  for(auto &p:zip){ // ちゃんと参照渡しにしよう（2敗）
    p.second = cnt++;
    un_zip[p.second] = p.first;
  }
  /*
  DEB;
  for(auto a: zip) SHOW(a.first,a.second);
  for(auto a: un_zip) SHOW(a.first,a.second);
  */
}
unordered_map<ll,int> cnt;
int main(){
  int n; cin >> n;
  vt<ll> a(n); rep(i,n) cin >> a[i];
  zip_in(a);
  sort(ALL(a));
  rep(i,n) cnt[a[i]]++;
  
  rep(j,un_zip.size()){
    if(un_zip.count(j+1) == 0) break;
    rep(i,40){
    ll ne = pow(2,i+1,LLINF);
    if(cnt.count(ne-un_zip[j+1])){
      ll next = ne - un_zip[j+1];
      if(next  == un_zip[j+1]){
        Gra.add_edge(j+1, zip[next] + DELTA, cnt[next]);
        //cerr << j+1 << " " << zip[next] + DELTA << " " << cnt[next] << endl;
      }else{
        Gra.add_edge(j+1, zip[next] + DELTA, min(cnt[un_zip[j+1]],cnt[next]));
        //cerr << j+1 << " " << zip[next] << " " << cnt[next] << endl;
      }
    }
    }
  }
  //DEB;
  rep(i,zip.size()){
    Gra.add_edge(0,i+1,cnt[un_zip[i+1]]);
    Gra.add_edge(i+DELTA+1,700000,cnt[un_zip[i+1]]);
  }
  if(Gra.run%2)  exit(-1);
  cout << Gra.run(0,700000)/2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:129:10: error: invalid use of member function 'int max_flow::run(int, int)' (did you forget the '()' ?)
  129 |   if(Gra.run%2)  exit(-1);
      |      ~~~~^~~