Language: C++

#[allow(unused_imports)]
use std::cmp::{max, min};

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    // from kenkoooooo
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

fn minmax<T: Ord>(a: T, b: T) -> (T, T) {
    if a < b {
        (a, b)
    } else {
        (b, a)
    }
}

fn solve2(a: &Vec<i64>) -> Vec<(i64, i64)> {
    let n = a.len();
    let mut ret = vec![(0i64, 1i64 << 50); n];
    let mut j = 1;
    let mut sum_j = a[0];
    let mut sum_i = a[0];
    for i in 2..n {
        sum_i += a[i - 1];
        while j + 1 < i && sum_j + a[j] < sum_i - a[j] - sum_j {
            sum_j += a[j];
            j += 1;
        }
        ret[i] = minmax(sum_i - sum_j, sum_j);
        if j + 1 < i {
            let tmp = minmax(sum_i - sum_j - a[j], sum_j + a[j]);
            if ret[i].0 < tmp.0 {
                ret[i] = tmp
            }
        }
    }
    ret
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut a: Vec<i64> = sc.read_vec(n);
    let from_left = solve2(&a);
    a.reverse();
    let mut from_right = solve2(&a);
    from_right.reverse();
    let mut ret = std::i64::MAX;
    for (&(x, y), &(z, w)) in from_left.iter().skip(1).zip(from_right.iter()) {
        ret = min(ret, max(y, w) - min(x, z));
    }
    println!("{}", ret);
}


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #[
    1 | #[allow(unused_imports)]
      |  ^
a.cc:11:2: error: invalid preprocessing directive #[
   11 | #[allow(dead_code)]
      |  ^
a.cc:52:10: error: too many decimal points in number
   52 |         (0..n).map(|_| self.read()).collect()
      |          ^~~~
a.cc:69:20: error: too many decimal points in number
   69 |         for pos in 0..self.small_cache.len() {
      |                    ^~~~~~~~~~~~~~~~~~~~~~~
a.cc:73:66: error: too many decimal points in number
   73 |                 return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
      |                                                                  ^~~
a.cc:102:14: error: too many decimal points in number
  102 |     for i in 2..n {
      |              ^~~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::cmp::{max, min};
      | ^~~
a.cc:5:5: error: 'ptr' does not name a type
    5 |     ptr: usize,
      |     ^~~
a.cc:12:6: error: expected initializer before 'Scanner'
   12 | impl Scanner {
      |      ^~~~~~~
a.cc:88:1: error: 'fn' does not name a type
   88 | fn minmax<T: Ord>(a: T, b: T) -> (T, T) {
      | ^~
a.cc:96:1: error: 'fn' does not name a type
   96 | fn solve2(a: &Vec<i64>) -> Vec<(i64, i64)> {
      | ^~
a.cc:119:1: error: 'fn' does not name a type
  119 | fn main() {
      | ^~