fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(" ").map { it.toInt() }
    val sqrt = Math.sqrt(n.toDouble()).toInt() + 1
    val array = Array(sqrt * sqrt) { 0 }
    val sumQuery = SqrtDecomposition(array, IntMonoid)
    repeat(q) {
        val (com, x, y) = readLine()!!.split(" ").map { it.toInt() }
        when (com) {
            0 -> {
                val sum = y + sumQuery.get(x)
                sumQuery.update(x, sum)
            }
            1 -> { println(sumQuery.query(x, y + 1)) }
            else -> {}
        }
    }
}

interface Monoid<T> {
    fun combine(a: T, b: T): T
    fun empty(): T
}

object IntMonoid : Monoid<Int> {
    override fun combine(a: Int, b: Int): Int = a + b
    override fun empty(): Int = 0
}

class SqrtDecomposition<T>(val array: Array<T>, private val monoid: Monoid<T>) {
    private val divSize = Math.sqrt(array.size.toDouble()).toInt()
    private val bucket = (0 until divSize)
            .map {
                array.slice(it * divSize until (it + 1) * divSize)
                        .reduce { a, b -> monoid.combine(a, b) }
            }
            .toMutableList()

    init {
        require(divSize * divSize == array.size) {
            "array size must be square number. size: ${array.size}"
        }
    }

    fun get(index: Int) = array[index]

    fun query(left: Int, right: Int): T {
        // [left, right)
        require(left in (0 until right) && right <= array.size) {
            "Invalid Range [$left, $right)"
        }
        val bl = left / divSize
        val br = right / divSize
        var res = monoid.empty()
        if (bl == br) {
            (left until right).forEach { res = monoid.combine(res, array[it]) }
        } else {
            (left until (bl + 1) * divSize).forEach { res = monoid.combine(res, array[it]) }
            (bl + 1 until br).forEach { res = monoid.combine(res, bucket[it]) }
            (br * divSize until right).forEach { res = monoid.combine(res, array[it]) }
        }
        return res
    }

    fun update(index: Int, value: T) {
        array[index] = value
        val bi = index / divSize
        bucket[bi] = array.slice(bi * divSize until (bi + 1)*divSize)
                .reduce { a, b -> monoid.combine(a, b) }
    }
}

