Language: C

#[derive(Clone)]
struct BitSet {
    size: usize,
    a: Vec<usize>,
}

fn bit_size() -> usize {
    8 * std::mem::size_of::<usize>()
}

fn quot_rem(n: usize) -> (usize, usize) {
    let w = bit_size();
    (n / w, n % w)
}

#[allow(dead_code)]
impl BitSet {
    fn new(size: usize) -> Self {
        let w = bit_size();
        BitSet {
            size: size,
            a: vec![0; (size + w - 1) / w],
        }
    }
    fn set_at(&mut self, x: usize) {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        self.a[q] |= 1 << r;
    }
    fn clear_at(&mut self, x: usize) {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        self.a[q] &= !(1 << r);
    }
    fn get_at(&self, x: usize) -> bool {
        assert!(x < self.size);
        let (q, r) = quot_rem(x);
        (self.a[q] >> r) & 1 == 1
    }
    fn any(&self) -> bool {
        self.a.iter().any(|a| *a != 0)
    }
    fn fix(&mut self) {
        let (q, r) = quot_rem(self.size);
        if r != 0 {
            self.a[q] &= (1 << r) - 1;
        }
    }
    fn clear(&mut self) {
        let len = self.a.len();
        self.a.clear();
        self.a.resize(len, 0);
    }
    fn truncate(&mut self, len: usize) {
        if len >= self.size {
            return;
        }
        let w = bit_size();
        self.a.truncate((len + w - 1) / w);
        self.size = len;
        self.fix();
    }
    fn shift_left(&self, rhs: usize) -> Self {
        let (q, r) = quot_rem(rhs);
        let mut ans = BitSet::new(self.size + rhs);
        if r == 0 {
            for (x, y) in ans.a[q..].iter_mut().zip(self.a.iter()) {
                *x = *y;
            }
        } else {
            let w = bit_size();
            let mut prev = 0;
            for (x, y) in ans.a[q..].iter_mut().zip(self.a.iter()) {
                *x = (*y << r) | (prev >> (w - r));
                prev = *y;
            }
            *ans.a.last_mut().unwrap() |= prev >> (w - r);
        }
        ans.fix();
        ans
    }
    fn bitwise_or(&self, rhs: &Self) -> Self {
        let (x, y) = if self.size >= rhs.size {(self, rhs)} else {(rhs, self)};
        let mut a = x.a.clone();
        for (a, y) in a.iter_mut().zip(y.a.iter()) {
            *a |= *y;
        }
        BitSet {
            size: x.size,
            a: a,
        }
    }
    fn bitwise_and(&self, rhs: &Self) -> Self {
        let (x, y) = if self.size <= rhs.size {(self, rhs)} else {(rhs, self)};
        let mut a = x.a.clone();
        for (a, y) in a.iter_mut().zip(y.a.iter()) {
            *a &= *y;
        }
        BitSet {
            size: x.size,
            a: a,
        }
    }
    fn bitwise_xor(&self, rhs: &Self) -> Self {
        let (x, y) = if self.size >= rhs.size {(self, rhs)} else {(rhs, self)};
        let mut a = x.a.clone();
        for (a, y) in a.iter_mut().zip(y.a.iter()) {
            *a ^= *y;
        }
        BitSet {
            size: x.size,
            a: a,
        }
    }
    fn bitwise_or_assign(&mut self, rhs: &Self) {
        if self.size < rhs.size {
            self.size = rhs.size;
            self.a.resize(rhs.a.len(), 0);
        }
        for (a, b) in self.a.iter_mut().zip(rhs.a.iter()) {
            *a |= *b;
        }
    }
    fn bitwise_and_assign(&mut self, rhs: &Self) {
        if self.size > rhs.size {
            self.size = rhs.size;
            self.a.resize(rhs.a.len(), 0);
        }
        for (a, b) in self.a.iter_mut().zip(rhs.a.iter()) {
            *a &= *b;
        }
    }
    fn bitwise_xor_assign(&mut self, rhs: &Self) {
        if self.size < rhs.size {
            self.size = rhs.size;
            self.a.resize(rhs.a.len(), 0);
        }
        for (a, b) in self.a.iter_mut().zip(rhs.a.iter()) {
            *a ^= *b;
        }
    }
}

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let sum = a.iter().fold(0, |s, a| s + *a);
    a.sort();
    let mut bit = BitSet::new(1);
    bit.set_at(0);
    for a in a {
        let shift = bit.shift_left(a);
        bit.bitwise_or(&shift);
        bit.truncate((sum + 1) / 2 + 2000);
    }
    let mut ans = (sum + 1) / 2;
    while !bit.get_at(ans) {
        ans += 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Compiler output:
main.c:1:2: error: invalid preprocessing directive #[
    1 | #[derive(Clone)]
      |  ^
main.c:3:5: error: expected specifier-qualifier-list before 'size'
    3 |     size: usize,
      |     ^~~~
main.c:7:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'bit_size'
    7 | fn bit_size() -> usize {
      |    ^~~~~~~~
main.c:11:1: error: unknown type name 'fn'
   11 | fn quot_rem(n: usize) -> (usize, usize) {
      | ^~
main.c:11:14: error: expected ')' before ':' token
   11 | fn quot_rem(n: usize) -> (usize, usize) {
      |              ^
      |              )
main.c:16:2: error: invalid preprocessing directive #[
   16 | #[allow(dead_code)]
      |  ^
main.c:17:1: error: unknown type name 'impl'
   17 | impl BitSet {
      | ^~~~
main.c:17:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   17 | impl BitSet {
      |             ^
main.c:144:1: error: unknown type name 'use'
  144 | use std::io::Read;
      | ^~~
main.c:144:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '::' token
  144 | use std::io::Read;
      |        ^~
main.c:146:1: error: unknown type name 'fn'
  146 | fn run() {
      | ^~
main.c: In function 'run':
main.c:147:5: error: unknown type name 'let'
  147 |     let mut s = String::new();
      |     ^~~
main.c:147:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 's'
  147 |     let mut s = String::new();
      |             ^
main.c:148:5: error: 'std' undeclared (first use in this function)
  148 |     std::io::stdin().read_to_string(&mut s).unwrap();
      |     ^~~
main.c:148:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:148:8: error: expected ';' before '::' token
  148 |     std::io::stdin().read_to_string(&mut s).unwrap();
      |        ^~
      |        ;
main.c:149:5: error: unknown type name 'let'
  149 |     let mut it = s.trim().split_whitespace();
      |     ^~~
main.c:149:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'it'
  149 |     let mut it = s.trim().split_whitespace();
      |             ^~
main.c:150:5: error: unknown type name 'let'
  150 |     let n: usize = it.next().unwrap().parse().unwrap();
      |     ^~~
main.c:150:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
  150 |     let n: usize = it.next().unwrap().parse().unwrap();
      |          ^
main.c:151:5: error: unknown type name 'let'
  151 |     let mut a: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
      |     ^~~
main.c:151:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'a'
  151 |     let mut a: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
      |             ^
main.c:151:30: error: too many decimal points in number
  151 |     let mut a: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
      |                              ^~~~
main.c:152:5: error: unknown type name 'let'
  152 |     let sum = a.iter().fold(0, |s, a| s + *a);
      |     ^~~
main.c:152:15: error: 'a' undeclared (first use in this function)
  152 |     let sum = a.iter().fold(0, |s, a| s + *a);
      |               ^
main.c:152:32: error: expected expression before '|' token
  152 |     let sum = a.iter().fold(0, |s, a| s + *a);
      |                                ^
main.c:154:5: error: unknown type name 'let'
  154 |     let mut bit = BitSet::new(1);
      |     ^~~
main.c:154:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'bit'
  154 |     let mut bit = BitSet::new(1);
      |             ^~~
main.c:155:5: error: 'bit' undeclared (first use in this function)
  155 |     bit.set_at(0);
      |     ^~~
main.c:156:9: error: expected '(' before 'a'
  156 |     for a in a {
      |         ^
      |         (
main.c:162:11: error: expected '(' before '!' token
  162 |     while !bit.get_at(ans) {
      |           ^
      |           (
main.c:162:23: error: 'ans' undeclared (first use in this function)
  162 |     while !bit.get_at(ans) {
      |                       ^~~
main.c: At top level:
main.c:168:1: error: unknown type name 'fn'
  168 | fn main() {
      | ^~