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();
    }
}
fn solve() {
    let (n, m) = get!(usize, u64);
    let aa = get!([u64]);

    let mut h = HashMap::new();
    let mut t = 0;
    for &a in &aa {
        t += a;
        t %= m;
        *h.entry(t).or_insert(0) += 1;
    }

    let mut sum = 0;
    let mut ans = 0u64;
    for a in aa {
        ans += *h.get(&sum).unwrap_or(&0);
        sum += a;
        sum %= m;
        *h.get_mut(&sum).unwrap() -= 1;
    }

    println!("{}", ans);
}


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: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:61:1: error: 'fn' does not name a type
   61 | fn solve() {
      | ^~