Language: C++

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
    fn upper_bound(&self, &T) -> usize;
}
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

#[allow(dead_code)]
pub fn bipartite_matching(g: &[Vec<usize>]) -> usize {
    fn dfs(v: usize, g: &[Vec<usize>], mat: &mut [Option<usize>], used: &mut [bool]) -> bool {
        used[v] = true;
        for &u in &g[v] {
            if mat[u].is_none() || !used[mat[u].unwrap()] && dfs(mat[u].unwrap(), g, mat, used) {
                mat[v] = Some(u);
                mat[u] = Some(v);
                return true;
            }
        }
        false
    }
    let mut res = 0;
    let mut mat = vec![None; g.len()];
    for v in 0..g.len() {
        if mat[v].is_none() {
            let mut used = vec![false; g.len()];
            if dfs(v, g, &mut mat, &mut used) {
                res += 1;
            }
        }
    }
    res
}

fn solve() {
    let n = get!(usize);
    let mut aa = get!([u64]);

    aa.sort();
    let mut g = vec![Vec::new(); 2 * n];

    for i in 0..60 {
        let sum = 1u64 << i;

        for j in 0..n {
            if sum > aa[j] {
                let mut k = aa.lower_bound(&(sum - aa[j]));
                while k < n && aa[k] + aa[j] == sum {
                    g[j].push(k);
                    k += 1;
                }
            }
        }
    }

    for i in 0..n {
        g[i].retain(|&x| x > i);
    }

    for v in &mut g {
        for x in v {
            *x += n;
        }
    }

    println!("{}", bipartite_matching(&g));
}


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #[
    1 | #[allow(unused_imports)]
      |  ^
a.cc:3:2: error: invalid preprocessing directive #[
    3 | #[allow(unused_imports)]
      |  ^
a.cc:5:2: error: invalid preprocessing directive #[
    5 | #[allow(unused_imports)]
      |  ^
a.cc:7:2: error: invalid preprocessing directive #[
    7 | #[allow(unused_imports)]
      |  ^
a.cc:13:6: error: invalid preprocessing directive #[
   13 |     #[allow(dead_code)]
      |      ^
a.cc:19:6: error: invalid preprocessing directive #[
   19 |     #[allow(dead_code)]
      |      ^
a.cc:23:6: error: invalid preprocessing directive #[
   23 |     #[allow(dead_code)]
      |      ^
a.cc:34:6: error: invalid preprocessing directive #[
   34 |     #[allow(dead_code)]
      |      ^
a.cc:41:2: error: invalid preprocessing directive #[
   41 | #[allow(unused_macros)]
      |  ^
a.cc:43:2: error: invalid preprocessing directive #[
   43 | #[allow(unused_macros)]
      |  ^
a.cc:46:2: error: invalid preprocessing directive #[
   46 | #[allow(dead_code)]
      |  ^
a.cc:101:2: error: invalid preprocessing directive #[
  101 | #[allow(dead_code)]
      |  ^
a.cc:116:14: error: too many decimal points in number
  116 |     for v in 0..g.len() {
      |              ^~~~~~~~
a.cc:134:14: error: too many decimal points in number
  134 |     for i in 0..60 {
      |              ^~~~~
a.cc:137:18: error: too many decimal points in number
  137 |         for j in 0..n {
      |                  ^~~~
a.cc:148:14: error: too many decimal points in number
  148 |     for i in 0..n {
      |              ^~~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::cmp::{max, min, Ordering};
      | ^~~
a.cc:4:1: error: 'use' does not name a type
    4 | use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
      | ^~~
a.cc:6:1: error: 'use' does not name a type
    6 | use std::io::{stdin, stdout, BufWriter, Write};
      | ^~~
a.cc:8:1: error: 'use' does not name a type
    8 | use std::iter::FromIterator;
      | ^~~
a.cc:9:1: error: 'mod' does not name a type
    9 | mod util {
      | ^~~
a.cc:42:1: error: 'macro_rules' does not name a type
   42 | macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
      | ^~~~~~~~~~~
a.cc:44:1: error: 'macro_rules' does not name a type
   44 | macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
      | ^~~~~~~~~~~
a.cc:45:7: error: 'BIG_STACK_SIZE' does not name a type
   45 | const BIG_STACK_SIZE: bool = true;
      |       ^~~~~~~~~~~~~~
a.cc:47:1: error: 'fn' does not name a type
   47 | fn main() {
      | ^~
a.cc:62:1: error: 'pub' does not name a type
   62 | pub trait BinarySearch<T> {
      | ^~~
a.cc:66:1: error: 'impl' does not name a type
   66 | impl<T: Ord> BinarySearch<T> for [T] {
      | ^~~~
a.cc:102:1: error: 'pub' does not name a type
  102 | pub fn bipartite_matching(g: &[Vec<usize>]) -> usize {
      | ^~~
a.cc:127:1: error: 'fn' does not name a type
  127 | fn solve() {
      | ^~