Language: C++

#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

struct SegNode {
    lc: Option<Box<SegNode>>,
    rc: Option<Box<SegNode>>,
    beg: usize,
    lst: usize,
    value: i64,
}
impl SegNode {
    fn new(b: usize, e: usize) -> SegNode {
        let piv = (b + e) / 2;
        let (lc, rc) = if b == piv {
            (None, None)
        } else {
            (Some(Box::new(SegNode::new(b, piv))), Some(Box::new(SegNode::new(piv, e))))
        };
        SegNode {
            lc: lc,
            rc: rc,
            beg: b,
            lst: e - 1,
            value: 0,
        }
    }
    fn get(&self, l: usize, r: usize) -> i64 {
        if l <= self.beg && self.lst <= r{
            #[cfg(local)] println!("{}: {:?}", "(self.beg, self.lst, l, r)", (self.beg, self.lst, l, r, self.value));
            self.value
        } else if r < self.beg || self.lst < l {
            0
        } else if let (&Some(ref lc), &Some(ref rc)) = (&self.lc, &self.rc) {
            lc.get(l, r) + rc.get(l, r)
        } else {
            //panic
            -1
        }
    }
    fn add(&mut self, l: usize, r: usize, num: i64) {
        if l <= self.beg && self.lst <= r{
            self.value += num;
            #[cfg(local)] println!("{}: {:?}", "num", (self.beg, self.lst, l, r, num, self.value));
        } else if r < self.beg || self.lst < l {
        } else if let (&mut Some(ref mut lc), &mut Some(ref mut rc)) = (&mut self.lc, &mut self.rc) {
            self.value += num * 1;
            lc.add(l, r, num);
            rc.add(l, r, num);
        }
    }
}
struct SegTree {
    root: SegNode
}
impl SegTree {
    fn new(size: usize) -> SegTree {
        SegTree {
            root: SegNode::new(0, size),
        }
    }
    fn get(&self, l: usize, r: usize) -> i64 {
        self.root.get(l, r)
    }
    fn add(&mut self, l: usize, r: usize, num: i64) {
        self.root.add(l, r, num);
    }
}

fn main() {
    let input = readv::<i32>();
    let (n, k) = (input[0] as usize, input[1]);
    let mut aa: VecDeque<_> = (0..n).map(|_| read::<i32>() - k).collect();
    aa.push_front(k);
    let mut cnt = 0;
    let accs: Vec<_> = aa.into_iter().map(|a| { cnt += a; cnt }).collect();
    #[cfg(local)] println!("{}: {:?}", "accs", accs);
    let mut st = SegTree::new(n);
    let map = accs.iter().collect::<BTreeSet<_>>()
        .into_iter().enumerate().map(|(i, num)| (num, i)).collect::<HashMap<_, _>>();
    let seq = accs.iter().map(|i| map[i]).collect::<Vec<_>>();
    #[cfg(local)] println!("{}: {:?}", "seq", seq);
    let mut ans = 0i64;
    for i in seq.into_iter().rev() {
        ans += st.get(i, n - 1);
        st.add(i, i, 1);
        #[cfg(local)] println!("{}: {:?}", "(i, ans)", (i, ans));
    }
    println!("{}", ans);
}


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #![allow(unused_imports)]
      |  ^
a.cc:5:2: error: invalid preprocessing directive #[
    5 | #[allow(dead_code)]
      |  ^
a.cc:14:2: error: invalid preprocessing directive #[
   14 | #[allow(dead_code)]
      |  ^
a.cc:18:2: error: invalid preprocessing directive #[
   18 | #[allow(dead_code)]
      |  ^
a.cc:48:14: error: invalid preprocessing directive #[
   48 |             #[cfg(local)] println!("{}: {:?}", "(self.beg, self.lst, l, r)", (self.beg, self.lst, l, r, self.value));
      |              ^
a.cc:62:14: error: invalid preprocessing directive #[
   62 |             #[cfg(local)] println!("{}: {:?}", "num", (self.beg, self.lst, l, r, num, self.value));
      |              ^
a.cc:91:32: error: too many decimal points in number
   91 |     let mut aa: VecDeque<_> = (0..n).map(|_| read::<i32>() - k).collect();
      |                                ^~~~
a.cc:95:6: error: invalid preprocessing directive #[
   95 |     #[cfg(local)] println!("{}: {:?}", "accs", accs);
      |      ^
a.cc:100:6: error: invalid preprocessing directive #[
  100 |     #[cfg(local)] println!("{}: {:?}", "seq", seq);
      |      ^
a.cc:105:10: error: invalid preprocessing directive #[
  105 |         #[cfg(local)] println!("{}: {:?}", "(i, ans)", (i, ans));
      |          ^
a.cc:2:1: error: 'use' does not name a type
    2 | use std::io;
      | ^~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::cmp::*;
      | ^~~
a.cc:4:1: error: 'use' does not name a type
    4 | use std::collections::*;
      | ^~~
a.cc:6:8: error: found ':' in nested-name-specifier, expected '::'
    6 | const M: i64 = 1e9 as i64 + 7;
      |        ^
      |        ::
a.cc:6:7: error: 'M' does not name a type
    6 | const M: i64 = 1e9 as i64 + 7;
      |       ^
a.cc:8:1: error: 'fn' does not name a type
    8 | fn read_line() -> String {
      | ^~
a.cc:15:1: error: 'fn' does not name a type
   15 | fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
      | ^~
a.cc:19:1: error: 'fn' does not name a type
   19 | fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
      | ^~
a.cc:24:5: error: 'lc' does not name a type
   24 |     lc: Option<Box<SegNode>>,
      |     ^~
a.cc:30:6: error: expected initializer before 'SegNode'
   30 | impl SegNode {
      |      ^~~~~~~
a.cc:72:5: error: 'root' does not name a type
   72 |     root: SegNode
      |     ^~~~
a.cc:74:6: error: expected initializer before 'SegTree'
   74 | impl SegTree {
      |      ^~~~~~~
a.cc:88:1: error: 'fn' does not name a type
   88 | fn main() {
      | ^~