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: Accepted)

//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

mod  binary_indexed_tree{

type VecType = usize;

///Binary Indexed Tree
pub struct BIT {
    v: Vec<VecType>,
}

impl BIT {
    ///BIT木を構築する。
    ///
    ///n:要素数
    pub fn new(n: usize) -> BIT {
        let v = vec![0; n + 1];
        BIT { v: v }
    }

    ///任意の要素に値を加算する。
    ///
    /// index:加算する場所(0-indexed)
    /// value:加算する値
    pub fn add(&mut self, index: usize, value: VecType) {
        let mut i = (index + 1) as isize;
        while i <= (self.v.len() - 1) as isize {
            self.v[i as usize] += value;
            i += i & -i;
        }
    }

    ///[0,index]の区間和を求める。
    pub fn get(&mut self, index: usize) -> VecType {
        let mut i = (index + 1) as isize;
        let mut res = 0 as VecType;
        while i > 0 {
            res += self.v[i as usize];
            i -= i & -i;
        }
        res
    }
}

}

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

use binary_indexed_tree::*;

#[fastout]
fn main() {
    input! {
        n:usize,q:usize,
    }
    let mut bit = BIT::new(n);
    for i in 0..n {
        input! {
            ai:usize
        }
        bit.add(i, ai);
    }
    for _ in 0..q {
        input! {
            t:usize,p:usize,x:usize
        }
        if t == 0 {
            bit.add(p, x);
        } else {
            let res = bit.get(x - 1) - if p == 0 { 0 } else { bit.get(p - 1) };
            println!("{}", res);
        }
    }
}