Problem:
Score : 100 points

Problem Statement

You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types.

0 p x: a_p \gets a_p + x

1 l r: Print \sum_{i = l}^{r - 1}{a_i}.

Constraints

1 \leq N, Q \leq 500,000

0 \leq a_i, x \leq 10^9

0 \leq p < N

0 \leq l_i < r_i \leq N

All values in Input are integer.

Input

Input is given from Standard Input in the following format:

N Q
a_0 a_1 ... a_{N - 1}
\textrm{Query}_0
\textrm{Query}_1
:
\textrm{Query}_{Q - 1}

Output

For each query of the latter type, print the answer.

Sample Input 1

5 5
1 2 3 4 5
1 0 5
1 2 4
0 3 10
1 0 5
1 0 3

Sample Output 1

15
7
25
6

Solution in Rust (1.42.0) (judge verdict: Wrong Answer)

#![doc = " # Bundled libraries"]
#![doc = ""]
#![doc = " ## `kyopro_lib` (private)"]
#![doc = ""]
#![doc = " ### Modules"]
#![doc = ""]
#![doc = " - `::__kyopro_lib::fewnick_tree` → `$crate::fewnick_tree`"]
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
fn main() {
    input! { n : usize , q : usize , a : [i64 ; n] }
    let mut ft = FewnickTree::from_slice(&a);
    for _ in 0..q {
        input! { t : i32 }
        if t == 0 {
            input! { p : usize , x : i64 }
            ft.add(p, x);
        } else {
            input! { l : usize , r : usize }
            println!("{}", ft.sum_range(l..r));
        }
    }
}
use self::fewnick_tree::FewnickTree;
pub mod fewnick_tree {
    pub struct FewnickTree<T>(Vec<T>);
    impl<T: Clone + num::Num + std::ops::AddAssign> FewnickTree<T> {
        pub fn new(n: usize) -> Self {
            Self(vec![T::zero(); n + 1])
        }
        pub fn from_slice(dat: &[T]) -> Self {
            let mut v = vec![T::zero()];
            v.extend_from_slice(dat);
            for i in 1..dat.len() {
                let j = i + i & i.wrapping_neg();
                if j < v.len() {
                    let x = v[i].clone();
                    v[j] += x;
                }
            }
            Self(v)
        }
        pub fn clear(&mut self) {
            for x in &mut self.0 {
                *x = T::zero();
            }
        }
        pub fn add(&mut self, mut i: usize, x: T) {
            i += 1;
            while i < self.0.len() {
                (self.0)[i] += x.clone();
                i += i & i.wrapping_neg();
            }
        }
        pub fn sum(&self, mut i: usize) -> T {
            let mut res = T::zero();
            while 0 < i {
                res += (self.0)[i].clone();
                i ^= i & i.wrapping_neg();
            }
            res
        }
    }
    impl<T: Clone + num::Num + std::ops::AddAssign + std::ops::Sub> FewnickTree<T> {
        pub fn sum_range(&self, r: std::ops::Range<usize>) -> T {
            self.sum(r.end) - self.sum(r.start)
        }
    }
}