/* algebra */

pub trait Magma: Sized + Clone {
  fn op(&self, rhs: &Self) -> Self;
}

pub trait Associative: Magma {}

pub trait Unital: Magma {
  fn identity() -> Self;
}

pub trait Monoid: Magma + Associative + Unital {}

impl<T: Magma + Associative + Unital> Monoid for T {}

use std::rc::Rc;

type Link<T> = Option<Rc<Node<T>>>;

struct Node<T: Monoid> {
    data: T,
    left: Link<T>,
    right: Link<T>,
}

impl<T: Monoid> Node<T> {
    fn new(data: T) -> Self {
        Node { data: data, left: None, right: None }
    }
    fn build(l: usize, r: usize) -> Self {
        if l + 1 >= r { Node::new(T::identity()) }
        else {
            Node {
                data: T::identity(),
                left: Some(Rc::new(Node::build(l, (l + r) >> 1))),
                right: Some(Rc::new(Node::build((l + r) >> 1, r))),
            }
        }
    }
    fn update(&self, i: usize, x: T, l: usize, r: usize) -> Self {
        assert!(l <= i && i < r);
        if i == l && i + 1 == r { Node::new(x) }
        else if l <= i && i < ((l + r) >> 1) {
            let left = Some(Rc::new(self.left.as_ref().unwrap().update(i, x, l, (l + r) >> 1)));
            let right = self.right.clone();
            Node {
                data: match left.as_ref() { Some(n) => n.data.clone(), None => T::identity() }
                      .op(& match right.as_ref() { Some(n) => n.data.clone(), None => T::identity() }),
                left: left,
                right: right,
            }
        }
        else {
            let left = self.left.clone();
            let right = Some(Rc::new(self.right.as_ref().unwrap().update(i, x, (l + r) >> 1, r)));
            Node {
                data: match left.as_ref() { Some(n) => n.data.clone(), None => T::identity() }
                      .op(& match right.as_ref() { Some(n) => n.data.clone(), None => T::identity() }),
                left: left,
                right: right,
            }
        }
    }
    fn fold(&self, a: usize, b: usize, l: usize, r: usize) -> T {
        if a <= l && r <= b { self.data.clone() }
        else if r <= a || b <= l { T::identity() }
        else {
            match self.left.as_ref() { Some(n) => n.fold(a, b, l, (l + r) >> 1), None => T::identity() }
                .op(& match self.right.as_ref() { Some(n) => n.fold(a, b, (l + r) >> 1, r), None => T::identity() })
        }
    }
}

impl<T: Monoid> Drop for Node<T> {
    fn drop(&mut self) {
        if let Some(left) = self.left.take() {
            if let Ok(_) = Rc::try_unwrap(left) {}
        }
        if let Some(right) = self.right.take() {
            if let Ok(_) = Rc::try_unwrap(right) {}
        }
    }
}

pub struct PersistentSegmentTree<T: Monoid> {
    root: Node<T>,
    sz: usize,
}

impl<T: Monoid> PersistentSegmentTree<T> {
    pub fn new(n: usize) -> Self {
        Self { root: Node::build(0, n), sz: n }
    }
    pub fn update(&self, i: usize, x: T) -> Self {
        Self { root: self.root.update(i, x, 0, self.sz), sz: self.sz }
    }
    pub fn fold(&self, l: usize, r: usize) -> T {
        self.root.fold(l, r, 0, self.sz)
    }
}

#[derive(Clone)]
struct Am(usize);

impl Magma for Am {
    fn op(&self, right: &Self) -> Self { Am(self.0 + right.0) }
}
impl Associative for Am {}

impl Unital for Am {
    fn identity() -> Self { Am(0) }
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v:Vec<usize> = s.trim().split_whitespace()
        .map(|e|e.parse().unwrap()).collect();
    let (n,m) = (v[0] , v[1]);
    let mut seg = PersistentSegmentTree::<Am>::new(n);
    for _ in 0..m {
        let mut t = String::new();
        std::io::stdin().read_line(&mut t).unwrap();
        let x:Vec<usize> = t.trim().split_whitespace()
            .map(|e|e.parse().unwrap()).collect();
        match x[0] {
            0 => {
                let new_val = seg.fold(x[1] - 1, x[1]).op(&Am(x[2] as usize));
                seg = seg.update(x[1] - 1, new_val);
            }
            _ => {
                println!("{}", seg.fold(x[1] - 1, x[2]).0);
            }
        }
    }
}



Measured memory_bytes: 13224