Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:

* add(i, x): add x to ai.
* getSum(s, t): print the sum of as, as+1,...,at.



Note that the initial values of ai (i = 1, 2, . . . , n) are 0.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* If comi is 0, then 1 ≤ xi ≤ n, 0 ≤ yi ≤ 1000.
* If comi is 1, then 1 ≤ xi ≤ n, 1 ≤ yi ≤ n.

Input


n q
com1 x1 y1
com2 x2 y2
...
comq xq yq


In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).

Output

For each getSum operation, print the sum in a line.

Example

Input

3 5
0 1 1
0 2 2
0 3 3
1 1 2
1 2 2


Output

3
2

Source: aizu | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
from array import array
import bisect
import collections
import heapq
import itertools
import operator
import sys

class BIT:

	def __init__(self, n):
		self.n = n
		self.arr = array('l', [0] * (n + 1))

	def __str__(self):
		return str(self.arr.tolist())

	def add(self, i, x):
		while i <= self.n:
			self.arr[i] += x
			i += i & -i

	def sum(self, i, j=None):
		if j is None:
			s = 0
			while i > 0:
				s += self.arr[i]
				i -= i & -i
			return s
		if i > j:
			raise ValueError
		return self.sum(j) - self.sum(i - 1)

def main():
	(n, q) = map(int, sys.stdin.readline().split())
	bit = BIT(n)
	for _ in range(q):
		(query, x, y) = map(int, sys.stdin.readline().split())
		if query == 0:
			bit.add(x, y)
		elif query == 1:
			print(bit.sum(x, y))
		else:
			raise ValueError
main()


from math import sqrt, floor
(n, q) = map(int, input().split())
A = [0] * (n + 1)
b = floor(sqrt(n + 1))
k = (n + b) // b
B = [0] * k

def add(x, y):
	A[x] += y
	B[x // b] += y

def get_sum(x, y):
	res = 0
	while x % b and x < y:
		res += A[x]
		x += 1
	while y % b and x < y:
		res += A[y]
		y -= 1
	res += A[y]
	res += sum(B[x // b:y // b])
	print(res)
for i in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		add(x, y)
	else:
		get_sum(x, y)


import math

def update(numlist, i):
	if i < 0:
		return
	if i == 0:
		numlist[i] = numlist[2 * i + 1] + numlist[2 * i + 2]
		return
	numlist[i] = numlist[2 * i + 1] + numlist[2 * i + 2]
	update(numlist, (i - 1) // 2)
	return

def find(numlist, x, y, k, minimum, maximum):
	if x >= maximum or y < minimum:
		return 0
	if x <= minimum and maximum - 1 <= y:
		return numlist[k]
	else:
		L = find(numlist, x, y, k * 2 + 1, minimum, (maximum + minimum) // 2)
		R = find(numlist, x, y, k * 2 + 2, (maximum + minimum) // 2, maximum)
		return L + R
(n, q) = map(int, input().split())
L2n = math.ceil(math.log2(n))
zero = 2 ** L2n - 1
MAX = 2 ** 31 - 1
numlist = [0] * (2 ** (L2n + 1) - 1)
resultlist = []
for _ in range(0, q):
	(com, x, y) = map(int, input().split())
	if com:
		resultlist.append(find(numlist, x - 1, y - 1, 0, 0, 2 ** L2n))
	else:
		numlist[zero + x - 1] += y
		update(numlist, (zero + x - 2) // 2)
for x in resultlist:
	print(x)


class SegmentTree:

	def __init__(self, N_, element, function_=lambda l, r: l + r):
		self.N = 1
		while self.N < N_:
			self.N *= 2
		self.element = element
		self.dat = [element for _ in range(self.N * 2)]
		self.function = function_

	def update(self, k, a):
		k += self.N - 1
		self.dat[k] = a
		while k > 0:
			k = (k - 1) // 2
			self.dat[k] = self.function(self.dat[2 * k + 1], self.dat[2 * k + 2])

	def query(self, begin, end, k=None, l=None, r=None):
		if k is None:
			return self.query(begin, end, 0, 0, self.N)
		if r <= begin or end <= l:
			return self.element
		if begin <= l and r <= end:
			return self.dat[k]
		vl = self.query(begin, end, k * 2 + 1, l, (l + r) // 2)
		vr = self.query(begin, end, k * 2 + 2, (l + r) // 2, r)
		return self.function(vl, vr)
(n, q) = map(int, input().split())
n += 1
treeone = SegmentTree(n, 0, lambda l, r: l + r)
while q > 0:
	q -= 1
	tmp = list(map(int, input().split()))
	if tmp[0] is 0:
		treeone.update(tmp[1], treeone.query(tmp[1], tmp[1] + 1) + tmp[2])
	else:
		print(treeone.query(tmp[1], tmp[2] + 1))


import sys
input = sys.stdin.readline

class SegmentTree:

	def __init__(self, num, ide_ele=0):
		tmp = 1
		while tmp < num:
			tmp *= 2
		self.n = tmp
		self.ide_ele = ide_ele
		self.l = [ide_ele] * (2 * self.n - 1)

	def func(self, x, y):
		return x + y

	def update(self, i, val):
		i = self.n - 1 + i
		self.l[i] += val
		while i > 0:
			i = (i - 1) // 2
			self.l[i] = self.func(self.l[i * 2 + 1], self.l[i * 2 + 2])

	def query(self, a, b, k, l, r):
		if r <= a or b <= l:
			return self.ide_ele
		if a <= l and r <= b:
			return self.l[k]
		vl = self.query(a, b, k * 2 + 1, l, (l + r) // 2)
		vr = self.query(a, b, k * 2 + 2, (l + r) // 2, r)
		return self.func(vl, vr)

def main():
	(N, Q) = map(int, input().split())
	segt = SegmentTree(N)
	for _ in range(Q):
		(c, x, y) = map(int, input().split())
		if c == 0:
			segt.update(x - 1, y)
		else:
			print(segt.query(x - 1, y, 0, 0, segt.n))
main()


import sys, collections, math
sys.setrecursionlimit(1000000)
INF = 2 ** 31 - 1
(N, Q) = map(int, sys.stdin.readline().split())
COM = tuple((tuple(map(int, sys.stdin.readline().rstrip().split())) for _ in range(Q)))
i = 1
while i < N:
	i *= 2
N = i
MAX_N = 1 << math.ceil(math.log2(N))
SEG = [0] * (2 * MAX_N - 1)

def update(k, a):
	k += N - 1
	SEG[k] += a
	while k > 0:
		k = (k - 1) // 2
		SEG[k] = SEG[k * 2 + 1] + SEG[k * 2 + 2]

def find(a, b, i=0, l=0, r=N):
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return SEG[i]
	vl = find(a, b, 2 * i + 1, l, (r + l) // 2)
	vr = find(a, b, 2 * i + 2, (r + l) // 2, r)
	return vl + vr
for (com, x, y) in COM:
	if com == 0:
		update(x - 1, y)
	else:
		print(find(x - 1, y))


class SegmentTree:

	def __init__(self, lst, op, e):
		self.n = len(lst)
		self.N = 2 ** (self.n - 1).bit_length()
		self.op = op
		self.e = e
		self.v = [None] * (2 * self.N - 1)
		for i in range(self.N):
			self.v[i + self.N - 1] = lst[i] if i < self.n else self.e
		for i in range(self.N - 2, -1, -1):
			self.v[i] = self.op(self.v[2 * i + 1], self.v[2 * i + 2])

	def update(self, i, x):
		i += self.N - 1
		self.v[i] += x
		while i > 0:
			i -= 1
			i >>= 1
			self.v[i] = self.op(self.v[2 * i + 1], self.v[2 * i + 2])

	def query(self, l, r):
		assert l < r
		left = l + self.N - 1
		right = r + self.N - 1
		L = self.e
		R = self.e
		while left < right:
			if left % 2 == 0:
				L = self.op(L, self.v[left])
				left += 1
			if right % 2 == 0:
				right -= 1
				R = self.op(self.v[right], R)
			left -= 1
			left >>= 1
			right >>= 1
		return self.op(L, R)
(n, q) = map(int, input().split())
A = [0] * n
st = SegmentTree(A, lambda x, y: x + y, 0)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		st.update(x - 1, y)
	else:
		print(st.query(x - 1, y))


class SegmentTree:

	def __init__(self, array, seg_func, ide_ele):
		n = len(array)
		self.size = 2 ** (n - 1).bit_length()
		self.seg_func = seg_func
		self.ide_ele = ide_ele
		self.seg = [self.ide_ele] * (2 * self.size - 1)
		for i in range(n):
			self.seg[i + self.size - 1] = array[i]
		for i in range(self.size - 2, -1, -1):
			self.seg[i] = self.seg_func(self.seg[2 * i + 1], self.seg[2 * i + 2])

	def update(self, index, sbn):
		index += self.size - 1
		self.seg[index] += sbn
		while index:
			index = (index - 1) // 2
			self.seg[index] = self.seg_func(self.seg[index * 2 + 1], self.seg[index * 2 + 2])

	def query(self, lower_ep, upper_ep):
		if upper_ep <= lower_ep:
			return self.ide_ele
		lower_ep += self.size - 1
		upper_ep += self.size - 2
		res = self.ide_ele
		while upper_ep - lower_ep > 1:
			if lower_ep & 1 == 0:
				res = self.seg_func(res, self.seg[lower_ep])
			if upper_ep & 1 == 1:
				res = self.seg_func(res, self.seg[upper_ep])
				upper_ep -= 1
			lower_ep //= 2
			upper_ep = (upper_ep - 1) // 2
		if lower_ep == upper_ep:
			res = self.seg_func(res, self.seg[lower_ep])
		else:
			res = self.seg_func(self.seg_func(res, self.seg[lower_ep]), self.seg[upper_ep])
		return res

def add(a, b):
	return a + b
(n, q) = map(int, input().split())
seg = SegmentTree([0] * n, add, 0)
for i in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		seg.update(x - 1, y)
	else:
		print(seg.query(x - 1, y))


import math

class segment_tree:

	def __init__(self, dat, query, default=0):
		self.offset = 2 ** math.ceil(math.log(len(dat), 2))
		self.table = [default] * self.offset + dat + [default] * (self.offset - len(dat))
		self.query = query
		for i in reversed(range(1, self.offset)):
			self.table[i] = self.query((self.table[2 * i], self.table[2 * i + 1]))

	def find(self, l, r):
		return self.query(self.__range(l, r))

	def __range(self, l, r):
		l += self.offset
		r += self.offset
		while l <= r:
			if l & 1:
				yield self.table[l]
				l += 1
			l >>= 1
			if r & 1 == 0:
				yield self.table[r]
				r -= 1
			r >>= 1

	def update(self, i, x, function=lambda a, b: b):
		i += self.offset
		self.table[i] = function(self.table[i], x)
		while 1 < i:
			i >>= 1
			self.table[i] = self.query((self.table[2 * i], self.table[2 * i + 1]))
from sys import stdin
readline = stdin.readline
(n, q) = map(int, readline().split())
rmq = segment_tree([0] * n, sum, default=0)
from operator import add
function = (lambda x, y: rmq.update(x - 1, y, add), lambda x, y: print(rmq.find(x - 1, y - 1)))
for (com, x, y) in (map(int, readline().split()) for _ in range(q)):
	function[com](x, y)


class BIT:

	def __init__(self, n):
		self.n = n
		self.bit = [0] * (n + 1)

	def add(self, i, x):
		i += 1
		while i <= self.n:
			self.bit[i] += x
			i += i & -i

	def acc(self, i):
		i += 1
		s = 0
		while i > 0:
			s += self.bit[i]
			i -= i & -i
		return s
(n, q) = map(int, input().split())
bit = BIT(n)
for _ in range(q):
	(c, x, y) = map(int, input().split())
	if c == 0:
		bit.add(x - 1, y)
	else:
		print(bit.acc(y - 1) - bit.acc(x - 2))


(n, q) = map(int, input().split())
size = 1
while size < n:
	size *= 2
size = size
seg_tree = [0] * (size * 2)

def update(i, x):
	ind = size - 1 + i
	seg_tree[ind] += x
	while ind > 1:
		ind = ind // 2
		left = seg_tree[ind * 2]
		right = seg_tree[ind * 2 + 1]
		seg_tree[ind] = left + right

def _find(s, t, i, l, r):
	if r < s or t < l:
		return 0
	if s <= l and r <= t:
		return seg_tree[i]
	else:
		left = _find(s, t, i * 2, l, (l + r) // 2)
		right = _find(s, t, i * 2 + 1, (l + r) // 2 + 1, r)
		return left + right

def find(s, t):
	return _find(s, t, 1, 1, size)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if not com:
		update(x, y)
	else:
		print(find(x, y))


import sys

class BinaryIndexedTree(object):
	__slots__ = ('length', 'dat')

	def __init__(self, n):
		self.length = int(n)
		self.dat = [0] * (self.length + 1)

	def __init_sum(self, i):
		_sum = 0
		while i > 0:
			_sum += self.dat[i]
			i &= i - 1
		return _sum

	def sum_st(self, s, t):
		return self.__init_sum(t) - self.__init_sum(s - 1)

	def assign_ix(self, i, x):
		while i <= self.length:
			self.dat[i] += x
			i += i & -i
		return None

def action():
	_input = sys.stdin.readlines()
	(n_num, q_num) = map(int, _input[0].split())
	queries = map(lambda x: x.split(), _input[1:])
	case = BinaryIndexedTree(n_num)
	for query in queries:
		(cmd, ele_1, ele_2) = map(int, query)
		if cmd == 0:
			case.assign_ix(ele_1, ele_2)
		elif cmd == 1:
			res = case.sum_st(ele_1, ele_2)
			print(res)
	return case
action()


class SegmentTree:

	def __init__(self, A, dot, e):
		n = 2 ** (len(A) - 1).bit_length()
		self.__n = n
		self.__dot = dot
		self.__e = e
		self.__node = [e] * (2 * n)
		for i in range(len(A)):
			self.__node[i + n] = A[i]
		for i in range(n - 1, 0, -1):
			self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])

	def update(self, i, c):
		i += self.__n
		node = self.__node
		node[i] = c
		while i > 1:
			i //= 2
			node[i] = self.__dot(node[2 * i], node[2 * i + 1])

	def get(self, l, r):
		(vl, vr) = (self.__e, self.__e)
		l += self.__n
		r += self.__n
		while l < r:
			if l & 1:
				vl = self.__dot(vl, self.__node[l])
				l += 1
			l //= 2
			if r & 1:
				r -= 1
				vr = self.__dot(vr, self.__node[r])
			r //= 2
		return self.__dot(vl, vr)

def AOJ_DSL_2_A():
	(n, q) = map(int, input().split())
	e = (1 << 31) - 1
	A = [e] * n
	seg = SegmentTree(A, min, e)
	for i in range(q):
		(t, x, y) = map(int, input().split())
		if t == 0:
			seg.update(x, y)
		else:
			print(seg.get(x, y + 1))

def AOJ_DSL_2_B():
	from operator import add
	import sys
	(n, q) = map(int, input().split())
	e = 0
	A = [e] * n
	seg = SegmentTree(A, add, e)
	query = sys.stdin.readlines()
	for i in range(q):
		(t, x, y) = map(int, query[i].split())
		x -= 1
		if t == 0:
			A[x] += y
			seg.update(x, A[x])
		else:
			y -= 1
			print(seg.get(x, y + 1))

def ABC125_C():
	from fractions import gcd
	N = int(input())
	A = list(map(int, input().split()))
	seg = SegmentTree(A, gcd, 0)
	ans = 0
	for i in range(N):
		ans = max(ans, gcd(seg.get(0, i), seg.get(i + 1, N)))
	print(ans)
AOJ_DSL_2_B()


class Bit:

	def __init__(self, n):
		self.size = n
		self.tree = [0] * (n + 1)

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.tree[i]
			i -= i & -i
		return s

	def sum_range(self, x, y):
		return self.sum(y) - self.sum(x - 1)

	def add(self, i, x):
		while i <= self.size:
			self.tree[i] += x
			i += i & -i
(n, q) = map(int, input().split())
bit = Bit(n)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		bit.add(x, y)
	else:
		print(bit.sum_range(x, y))


def add(i, x):
	i += n - 1
	sg[i] += x
	while i > 0:
		i = (i - 1) // 2
		sg[i] += x

def getSum(a, b):
	return _getSum(a, b + 1, 0, 0, n)

def _getSum(a, b, k, l, r):
	if b <= l or r <= a:
		return 0
	if a <= l and r <= b:
		return sg[k]
	ll = _getSum(a, b, k * 2 + 1, l, (r + l) / 2)
	rr = _getSum(a, b, k * 2 + 2, (r + l) / 2, r)
	return ll + rr
(_n, q) = map(int, input().split())
n = 1
while n <= _n:
	n *= 2
sg = [0] * (2 * n - 1)
for i in range(q):
	(c, x, y) = map(int, input().split())
	if c:
		print(getSum(x, y))
	else:
		add(x, y)


class Bit:

	def __init__(self, n):
		self.size = n
		self.tree = [0] * (n + 1)

	def __iter__(self):
		psum = 0
		for i in range(self.size):
			csum = self.sum(i + 1)
			yield (csum - psum)
			psum = csum
		raise StopIteration()

	def __str__(self):
		return str(list(self))

	def sum(self, i: int):
		if not 0 <= i <= self.size:
			raise ValueError('error!')
		s = 0
		while i > 0:
			s += self.tree[i]
			i -= i & -i
		return s

	def add(self, i: int, x):
		if not 0 <= i < self.size:
			raise ValueError('error!')
		i += 1
		while i <= self.size:
			self.tree[i] += x
			i += i & -i

	def __getitem__(self, key):
		if not 0 <= key < self.size:
			raise IndexError('error!')
		return self.sum(key + 1) - self.sum(key)

	def __setitem__(self, key, value):
		if not 0 <= key < self.size:
			raise IndexError('error!')
		self.add(key, value - self[key])
(N, Q) = map(int, input().split())
bit = Bit(N + 1)
for i in range(Q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		bit.add(x, y)
	else:
		print(bit.sum(y + 1) - bit.sum(x))


class SegmentTree:

	def __init__(self, n):
		self.dat = [0 for _ in range(n * 2 - 1)]
		self.n = n

	def update(self, node_index, value):
		index = node_index + (self.n - 1)
		self.dat[index] += value
		while index > 0:
			index = (index - 1) // 2
			self.dat[index] = self.dat[index * 2 + 1] + self.dat[index * 2 + 2]

	def querry(self, left, right, nowNode, nowLeft, nowRight):
		if nowRight < left or nowLeft > right:
			return 0
		if left <= nowLeft and nowRight <= right:
			return self.dat[nowNode]
		else:
			value_left = self.querry(left, right, 2 * nowNode + 1, nowLeft, (nowLeft + nowRight) // 2)
			value_right = self.querry(left, right, 2 * nowNode + 2, (nowLeft + nowRight) // 2 + 1, nowRight)
			return value_left + value_right

	def DEBUG_dat(self):
		print(self.dat)
(n, q) = map(int, input().split(' '))
result = []
for i in range(1, 20):
	if 2 ** i >= n:
		min_pow2 = 2 ** i
		break
tree = SegmentTree(min_pow2)
for i in range(q):
	(com, x, y) = map(int, input().split(' '))
	if com == 0:
		tree.update(x - 1, y)
	else:
		result.append(tree.querry(x - 1, y - 1, 0, 0, min_pow2 - 1))
for ans in result:
	print(ans)


import sys
input = sys.stdin.readline
(n, q) = map(int, input().split())

class RMQ:

	def __init__(self, n, e):
		self.e = e
		self.num_min = 2 ** (n - 1).bit_length()
		self.seg = [self.e] * 2 * self.num_min

	def initialize(self, init):
		for i in range(n):
			self.seg[i + self.num_min - 1] = init[i]
		for i in range(self.num_min - 2, -1, -1):
			self.seg[i] = min(self.seg[2 * i + 1], self.seg[2 * i + 2])

	def update(self, k, x):
		k += self.num_min - 1
		self.seg[k] += x
		while k:
			k = (k - 1) // 2
			self.seg[k] = self.seg[k * 2 + 1] + self.seg[k * 2 + 2]

	def query(self, p, q):
		q += 1
		if q <= p:
			return self.e
		p += self.num_min - 1
		q += self.num_min - 2
		res = self.e
		while q - p > 1:
			if p & 1 == 0:
				res += self.seg[p]
			if q & 1 == 1:
				res += self.seg[q]
				q -= 1
			p = p // 2
			q = (q - 1) // 2
		if p == q:
			res += self.seg[p]
		else:
			res += self.seg[p] + self.seg[q]
		return res
e = 0
rmq = RMQ(n, e)
for i in range(q):
	(com, x, y) = map(int, input().split())
	x -= 1
	if com == 0:
		rmq.update(x, y)
	else:
		y -= 1
		ans = rmq.query(x, y)
		print(ans)


class RSQ:

	def __init__(self, length, ini_num=float('inf')):
		self.length = 1
		self.ini_num = ini_num
		if length == 1:
			length = 2
		while self.length < length:
			self.length <<= 1
		self.segtree = [ini_num] * (2 * self.length - 1)

	def update(self, index, num):
		leaf_index = index + self.length - 1
		self.segtree[leaf_index] = num
		while leaf_index > 0:
			leaf_index = (leaf_index - 1) // 2
			self.segtree[leaf_index] = self.segtree[2 * leaf_index + 1] + self.segtree[2 * leaf_index + 2]

	def add(self, index, num):
		leaf_index = index + self.length - 1
		self.segtree[leaf_index] += num
		while leaf_index > 0:
			leaf_index = (leaf_index - 1) // 2
			self.segtree[leaf_index] = self.segtree[2 * leaf_index + 1] + self.segtree[2 * leaf_index + 2]

	def call_search(self, a, b):
		return self.search(a, b, index=0, l=0, r=self.length - 1)

	def search(self, a, b, index, l, r):
		if a <= l <= r <= b:
			return self.segtree[index]
		elif r < a or b < l:
			return self.ini_num
		else:
			return self.search(a, b, index * 2 + 1, l, (l + r) // 2) + self.search(a, b, index * 2 + 2, (l + r) // 2 + 1, r)
(v_num, query) = map(int, input().split(' '))
rsq = RSQ(v_num, 0)
for _ in range(query):
	(comm, index, num) = map(int, input().split(' '))
	if comm == 0:
		rsq.add(index - 1, num)
	else:
		print(rsq.call_search(index - 1, num - 1))


class BIT:

	def __init__(self, n):
		self.array = [0] * n
		self.N = n

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.array[i - 1]
			i -= i & -i
		return s

	def sum2(self, i, j):
		return self.sum(j) - self.sum(i - 1)

	def add(self, i, x):
		while i <= self.N:
			self.array[i - 1] += x
			i += i & -i
(N, Q) = map(int, input().split())
bit = BIT(N)
for i in range(Q):
	(com, x, y) = map(int, input().split())
	if com:
		res = bit.sum2(x, y)
		print(res)
	else:
		bit.add(x, y)


(n, q) = map(int, input().split())
s = 1
while s < n:
	s *= 2
A = [0] * (2 * s - 1)

def query(a, b, k, l, r):
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return A[k]
	else:
		c1 = query(a, b, 2 * k + 1, l, (l + r) // 2)
		c2 = query(a, b, 2 * k + 2, (l + r) // 2, r)
		return c1 + c2
for _ in range(q):
	(c, x, y) = map(int, input().split())
	if not c:
		x += s - 1
		x -= 1
		A[x] += y
		while x > 0:
			x = (x - 1) // 2
			A[x] = A[x * 2 + 1] + A[x * 2 + 2]
	else:
		print(query(x - 1, y, 0, 0, s))


import sys

class BinaryIndexedTree(object):
	__slots__ = ('length', 'dat')

	def __init__(self, n):
		self.length = int(n)
		self.dat = [0] * (self.length + 1)

	def __init_sum(self, i):
		_sum = 0
		while i > 0:
			_sum += self.dat[i]
			i -= i & -i
		return _sum

	def get_sum(self, s, t):
		return self.__init_sum(t) - self.__init_sum(s - 1)

	def get_add(self, i, x):
		while i <= self.length:
			self.dat[i] += x
			i += i & -i
		return None

def action(cmd_list):
	case = BinaryIndexedTree(n_num)
	for query in cmd_list:
		(cmd, ele_1, ele_2) = map(int, query)
		if cmd == 0:
			case.get_add(ele_1, ele_2)
		elif cmd == 1:
			res = case.get_sum(ele_1, ele_2)
			print(res)
	return case
_input = sys.stdin.readlines()
(n_num, q_num) = map(int, _input[0].split())
q_list = map(lambda x: x.split(), _input[1:])
ans = action(q_list)


class BIT:

	def __init__(self, n):
		self.node = [0 for _ in range(n + 1)]

	def add(self, idx, w):
		i = idx
		while i < len(self.node) - 1:
			self.node[i] += w
			i |= i + 1

	def sum_(self, idx):
		(ret, i) = (0, idx - 1)
		while i >= 0:
			ret += self.node[i]
			i = (i & i + 1) - 1
		return ret

	def sum(self, l, r):
		return self.sum_(r) - self.sum_(l)
(n, q) = map(int, input().split())
tree = BIT(n)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		tree.add(x - 1, y)
	if com == 1:
		print(tree.sum(x - 1, y))


class BIT:

	def __init__(self, n):
		self.n = n
		self.array = [0 for i in range(n + 1)]

	def sum(self, i):
		result = 0
		while i > 0:
			result = result + self.array[i]
			i -= i & -i
		return result

	def range_sum(self, i, j):
		tmp_i = self.sum(i - 1)
		tmp_j = self.sum(j)
		return tmp_j - tmp_i

	def add(self, i, x):
		while i <= self.n:
			self.array[i] += x
			i += i & -i
init = [int(n) for n in input().split()]
a = []
bit = BIT(init[0])
for i in range(init[1]):
	line = [int(n) for n in input().split()]
	if line[0] == 0:
		bit.add(line[1], line[2])
	else:
		print(bit.range_sum(line[1], line[2]))


class TemplateTree:

	def __init__(self, iterable):
		self.iter_size = self.get_size(iterable)
		self.size = self.iter_size * 2 - 1
		self.value = [None] * self.size
		for (i, v) in enumerate(iterable):
			self.value[self.iter_size + i - 1] = v
		self.set_value(0)
		self.range = [None] * self.size
		self.set_range(0, 0, self.iter_size - 1)

	def get_size(self, iterable):
		ret = 1
		x = len(iterable)
		while ret < x:
			ret *= 2
		return ret

	def set_range(self, x, left, right):
		self.range[x] = (left, right)
		if left != right:
			self.set_range(x * 2 + 1, left, (right + left) // 2)
			self.set_range(x * 2 + 2, (right + left) // 2 + 1, right)

	def set_value(self, x):
		if x >= self.iter_size - 1:
			return self.value[x]
		a = self.set_value(x * 2 + 1)
		b = self.set_value(x * 2 + 2)
		if a == None and b == None:
			self.value[x] = None
		elif a == None:
			self.value[x] = b
		elif b == None:
			self.value[x] = a
		else:
			self.value[x] = a + b
		return self.value[x]

	def update(self, i, x):
		target = self.iter_size + i - 1
		while target >= 0:
			self.value[target] += x
			target = (target - 1) // 2

	def query(self, x, left, right):
		(x_left, x_right) = self.range[x]
		if right < x_left or x_right < left:
			return 0
		if x_left < left and right < x_right:
			return self.query(x * 2 + 1, left, right) + self.query(x * 2 + 2, left, right)
		if x_left < left and x_right <= right:
			return self.query(x * 2 + 1, left, right) + self.query(x * 2 + 2, left, right)
		if left <= x_left and right < x_right:
			return self.query(x * 2 + 1, left, right) + self.query(x * 2 + 2, left, right)
		if left <= x_left and x_right <= right:
			return self.value[x]

	def print_tree(self):
		print(self.value)
		print(self.range)
(n, q) = map(int, input().split())
tree = TemplateTree([0] * n)
for _ in range(q):
	(c, x, y) = map(int, input().split())
	if c == 0:
		tree.update(x - 1, y)
	else:
		print(tree.query(0, x - 1, y - 1))


import sys
iim = lambda : map(int, input().rstrip().split())

def resolve():
	(N, Q) = iim()
	A = [0] * (N + 1)
	la = N + 1

	def add(i, x):
		while i < la:
			A[i] += x
			i += i & -i

	def getSum(i):
		ans = 0
		while i:
			ans += A[i]
			i -= i & -i
		return ans
	ans = []
	for (com, *arg) in (map(int, line.split()) for line in sys.stdin):
		if com == 0:
			add(*arg)
		else:
			ans.append(getSum(arg[1]) - getSum(arg[0] - 1))
	print(*ans, sep='\n')
resolve()


def func(x, y):
	return x + y

class SegmentTree:

	def __init__(self, n):
		n_ = 1
		while n_ < n:
			n_ *= 2
		self.n = n_
		self.arr = [0] * (2 * self.n - 1)

	def update(self, k, a):
		k += self.n - 1
		self.arr[k] += a
		while k > 0:
			k = (k - 1) // 2
			self.arr[k] = func(self.arr[2 * k + 1], self.arr[2 * k + 2])

	def query(self, l, r):
		(L, R) = (l + self.n, r + self.n)
		res = 0
		while L < R:
			if R & 1:
				R -= 1
				res = func(res, self.arr[R - 1])
			if L & 1:
				res = func(res, self.arr[L - 1])
				L += 1
			L >>= 1
			R >>= 1
		return res
(n, q) = map(int, input().split())
sg = SegmentTree(n)
for _ in range(q):
	(c, x, y) = map(int, input().split())
	if c == 0:
		sg.update(x - 1, y)
	else:
		print(sg.query(x - 1, y))


class FenwickTree(object):

	def __init__(self, num_elems):
		self.num_elems = num_elems
		self.data = [0 for _ in range(num_elems)]

	def sum_to(self, end):
		s = 0
		i = end - 1
		while i >= 0:
			s += self.data[i]
			i = (i & i + 1) - 1
		return s

	def sum_range(self, start, end):
		return self.sum_to(end) - self.sum_to(start)

	def add(self, idx, x):
		while idx < self.num_elems:
			self.data[idx] += x
			idx |= idx + 1

def main():
	(n, q) = map(int, input().split())
	ft = FenwickTree(n)
	for _ in range(q):
		(c, x, y) = map(int, input().split())
		if c == 0:
			ft.add(x - 1, y)
		elif c == 1:
			print(ft.sum_range(x - 1, y))
main()


import math

class SegmentTree:
	__slots__ = ['elem_size', 'tree_size', 'tree']

	def __init__(self, a: list, default: int):
		real_size = len(a)
		self.elem_size = 1 << math.ceil(math.log2(real_size))
		self.tree_size = 2 * self.elem_size + 1
		self.tree = [default] * (self.elem_size - 1) + a + [default] * (self.elem_size - real_size)

	def get_range_index(self, x, y, k=0, l_end=0, r_end=None):
		if r_end is None:
			r_end = self.elem_size
		if l_end == x and y == r_end - 1:
			return [k]
		mid = (l_end + r_end) // 2
		left_y = y if y < mid - 1 else mid - 1
		right_x = x if x > mid else mid
		left = self.get_range_index(x, left_y, 2 * k + 1, l_end, mid) if x <= left_y else []
		right = self.get_range_index(right_x, y, 2 * k + 2, mid, r_end) if right_x <= y else []
		return left + right

	def get_value(self, x, y):
		tree = self.tree
		index_list = self.get_range_index(x, y)
		return sum((tree[n] for n in index_list))

	def update_tree(self, k: int):
		tree = self.tree
		while k > 0:
			k = (k - 1) // 2
			(left, right) = (tree[2 * k + 1], tree[2 * k + 2])
			tree[k] = left + right

	def set_value(self, i: int, value: int, op: str):
		k = self.elem_size - 1 + i
		if op == '=':
			self.tree[k] = value
		elif op == '+':
			self.tree[k] += value
		self.update_tree(k)
(n, q) = map(int, input().split())
rsq = SegmentTree([0] * n, 0)
ans = []
for _ in [0] * q:
	(c, x, y) = map(int, input().split())
	if c == 0:
		rsq.set_value(x - 1, y, '+')
	else:
		ans.append(rsq.get_value(x - 1, y - 1))
print('\n'.join([str(n) for n in ans]))


import sys

def initialize(N):
	i = 1
	while i < N:
		i *= 2
	return ([0] * (2 * i - 1), i)

def add(i, x, L, d):
	K = i + d - 1
	L[K] += x
	while K > 0:
		K = (K - 1) // 2
		L[K] += x

def getSum(s, t, index, l, r, L):
	if r <= s or t <= l:
		return 0
	elif s <= l and r <= t:
		return L[index]
	else:
		sumL = getSum(s, t, 2 * index + 1, l, (l + r) // 2, L)
		sumR = getSum(s, t, 2 * index + 2, (l + r) // 2, r, L)
		return sumL + sumR
F = sys.stdin
(N, Q) = map(int, F.readline().strip('\n').split(' '))
(SegTree, d) = initialize(N)
for _ in range(Q):
	(com, x, y) = map(int, F.readline().strip('\n').split(' '))
	if com == 0:
		add(x - 1, y, SegTree, d)
	elif com == 1:
		print(getSum(x - 1, y, 0, 0, d, SegTree))


import math

class BinaryIndexedTree:

	def __init__(self, size):
		self.N = size
		self.tree = [0] * (self.N + 1)

	def add(self, idx, val):
		while idx <= self.N:
			self.tree[idx] += val
			idx += idx & -idx

	def sum_to(self, idx):
		result = 0
		while idx > 0:
			result += self.tree[idx]
			idx -= idx & -idx
		return result
(n, q) = map(int, input().split())
bit = BinaryIndexedTree(n)
for _ in range(q):
	(com, n1, n2) = map(int, input().split())
	if com == 0:
		bit.add(n1, n2)
	else:
		print(bit.sum_to(n2) - bit.sum_to(n1 - 1))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

class BIT:

	def __init__(self, n):
		i = 1
		while 2 ** i <= n:
			i += 1
		self.H = i
		self.N = 2 ** i
		self.A = [0] * self.N

	def find(self, i):
		r = 0
		while i:
			r += self.A[i]
			i -= i & i - 1 ^ i
		return r

	def update(self, i, x):
		while i < self.N:
			self.A[i] += x
			i += i & i - 1 ^ i

	def query(self, a, b):
		return self.find(b - 1) - self.find(a - 1)

def main():
	(n, q) = LI()
	a = [LI() for _ in range(q)]
	b = BIT(n + 3)
	r = []
	for (c, x, y) in a:
		if c == 0:
			b.update(x, y)
		else:
			r.append(b.query(x, y + 1))
	return '\n'.join(map(str, r))
print(main())


import math

def update(index, y):
	targ[index] += y
	index = (index - 1) // 2
	while True:
		targ[index] = targ[index * 2 + 1] + targ[index * 2 + 2]
		if index <= 0:
			break
		index = (index - 1) // 2

def find(ini, end, node, inode, enode):
	if ini > enode or inode > end:
		return 0
	elif inode >= ini and end >= enode or inode == enode:
		return targ[node]
	else:
		ininum = find(ini, end, node * 2 + 1, inode, (inode + enode) // 2)
		endnum = find(ini, end, node * 2 + 2, (inode + enode) // 2 + 1, enode)
		return ininum + endnum
(num, query) = (int(n) for n in input().split(' '))
ln = 2 ** math.ceil(math.log2(num)) - 1
if num == 1:
	tail = 2
else:
	tail = 2 ** math.ceil(math.log2(num)) - num
targ = [0] * (ln + num + tail)
for q in range(query):
	(qtype, temp1, temp2) = (int(n) for n in input().split(' '))
	if qtype == 0:
		update(temp1 + ln - 1, temp2)
	else:
		print(find(temp1 - 1, temp2 - 1, 0, 0, ln))


(N, Q) = map(int, input().split())
pn = 1
while pn < N:
	pn *= 2
N = pn
A = [0] * (2 * N - 1)

def add(x, y):
	n = N + x - 1
	A[n] += y
	while n > 0:
		n = (n - 1) // 2
		A[n] += y

def getSum(k, x, y, s, t):
	if x >= t or y <= s:
		return 0
	if x <= s and t <= y:
		return A[k]
	lv = getSum(2 * k + 1, x, y, s, (s + t) // 2)
	rv = getSum(2 * k + 2, x, y, (s + t) // 2, t)
	return lv + rv
for i in range(Q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		add(x - 1, y)
	else:
		print(getSum(0, x - 1, y, 0, N))


class BIT:

	def __init__(self, n):
		self.n = n
		self.data = [0] * (n + 1)
		self.el = [0] * (n + 1)

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.data[i]
			i -= i & -i
		return s

	def add(self, i, x):
		self.el[i] += x
		while i <= self.n:
			self.data[i] += x
			i += i & -i

	def get(self, i, j=None):
		if j is None:
			return self.el[i]
		return self.sum(j) - self.sum(i)

def solve():
	(N, Q) = map(int, input().split())
	ans = []
	bit = BIT(N)
	for i in range(Q):
		(com, x, y) = map(int, input().split())
		if com == 0:
			bit.add(x, y)
		else:
			ans.append(bit.get(x - 1, y))
	return ans
print(*solve(), sep='\n')


SEG_LEN = 1 << 18
seg = [0 for i in range(2 * SEG_LEN)]

def add(ind, v):
	ind += SEG_LEN
	seg[ind] += v
	while True:
		ind //= 2
		if ind == 0:
			break
		seg[ind] = seg[ind * 2] + seg[ind * 2 + 1]

def sum(l, r):
	l += SEG_LEN
	r += SEG_LEN
	ans = 0
	while l < r:
		if l % 2 == 1:
			ans += seg[l]
			l += 1
		l //= 2
		if r % 2 == 1:
			ans += seg[r - 1]
			r -= 1
		r //= 2
	return ans

def main():
	(n, q) = map(int, input().split())
	ans = []
	for i in range(q):
		(com, x, y) = map(int, input().split())
		if com == 0:
			add(x, y)
		elif com == 1:
			ans.append(sum(x, y + 1))
	for i in range(len(ans)):
		print(ans[i])
main()


class SegmentTree:

	def __init__(self, arr, e):
		self.e = e
		self.len = len(arr)
		n = 2 ** (len(bin(self.len + 1)) - 2)
		self.n = n
		node = [e] * (2 * n)
		node[n:n + self.len] = arr
		for i in range(n - 1, 0, -1):
			node[i] = node[2 * i] + node[2 * i + 1]
		self.node = node

	def __setitem__(self, i, val):
		i += self.n
		self.node[i] = val
		while i > 1:
			i //= 2
			self.node[i] = self.node[2 * i] + self.node[2 * i + 1]

	def __getitem__(self, i):
		return self.node[self.n + i]

	def query(self, a, b):
		a = self.trim(a, self.len)
		b = self.trim(b, self.len)

		def get(k, l, r):
			if r <= a or b <= l:
				return self.e
			if a <= l and r <= b:
				return self.node[k]
			m = (l + r) // 2
			return get(2 * k, l, m) + get(2 * k + 1, m, r)
		return get(1, 0, self.n)

	def getlist(self):
		return self.node[self.n:]

	def trim(self, i, n):
		i = max(i, -n)
		i = min(i, n)
		if i < 0:
			i += n
		return i
(n, q) = map(int, input().split())
A = [0] * n
st = SegmentTree(A, 0)
for i in range(q):
	(com, x, y) = map(int, input().split())
	x -= 1
	if com == 0:
		st[x] += y
	else:
		y -= 1
		print(st.query(x, y + 1))


(n, q) = map(int, input().split())
answer = []
size = 1
while size < n:
	size *= 2
size = size * 2 - 1
segtree = [0 for x in range(size)]

def update(i, x):
	ind = size // 2 + i
	segtree[ind] += x
	while ind:
		ind = (ind - 1) // 2
		ch1 = segtree[ind * 2 + 1]
		ch2 = segtree[ind * 2 + 2]
		segtree[ind] = ch1 + ch2

def query(s, t, l, r, p):
	if s > r or t < l:
		return 0
	if s <= l and t >= r:
		return segtree[p]
	else:
		vl = query(s, t, l, (l + r) // 2, p * 2 + 1)
		vr = query(s, t, (l + r) // 2 + 1, r, p * 2 + 2)
		return vl + vr
for i in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		update(x - 1, y)
	else:
		answer.append(query(x - 1, y - 1, 0, size // 2, 0))
for a in answer:
	print(a)


import math

class SegmentTree:

	def __init__(self, n):
		self.n = n
		self.height = math.ceil(math.log2(n))
		self.nodes = [0 for i in range(pow(2, self.height + 1) - 1)]
		self.leaf_start = pow(2, self.height) - 1

	def update(self, i, x):
		pntr = self.leaf_start + i
		self.nodes[pntr] += x
		while True:
			pntr = (pntr - 1) // 2
			if pntr == -1:
				break
			self.nodes[pntr] += x

	def __query(self, s, t, k, l, r):
		if t - s <= 0:
			return 0
		if r <= s or t <= l:
			return 0
		if l == s and t == r:
			return self.nodes[k]
		else:
			m = (l + r) // 2
			if t <= m:
				return self.__query(s, t, k * 2 + 1, l, m)
			elif m <= s:
				return self.__query(s, t, k * 2 + 2, m, r)
			else:
				vl = self.__query(s, m, k * 2 + 1, l, m)
				vr = self.__query(m, t, k * 2 + 2, m, r)
				return vl + vr

	def find(self, s, t):
		return self.__query(s, t + 1, 0, 0, pow(2, self.height))
(n, q) = list(map(int, input().split(' ')))
st = SegmentTree(n)
for i in range(q):
	(com, x, y) = list(map(int, input().split(' ')))
	if com == 0:
		st.update(x - 1, y)
	elif com == 1:
		print(st.find(x - 1, y - 1))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

class Seg:

	def __init__(self, na, default, func):
		if isinstance(na, list):
			n = len(na)
		else:
			n = na
		i = 1
		while 2 ** i <= n:
			i += 1
		self.D = default
		self.H = i
		self.N = 2 ** i
		if isinstance(na, list):
			self.A = [default] * self.N + na + [default] * (self.N - n)
			for i in range(self.N - 1, 0, -1):
				self.A[i] = func(self.A[i * 2], self.A[i * 2 + 1])
		else:
			self.A = [default] * (self.N * 2)
		self.F = func

	def find(self, i):
		return self.A[i + self.N]

	def update(self, i, x):
		i += self.N
		self.A[i] = x
		while i > 1:
			i = i // 2
			self.A[i] = self.merge(self.A[i * 2], self.A[i * 2 + 1])

	def merge(self, a, b):
		return self.F(a, b)

	def total(self):
		return self.A[1]

	def query(self, a, b):
		A = self.A
		l = a + self.N
		r = b + self.N
		res = self.D
		while l < r:
			if l % 2 == 1:
				res = self.merge(res, A[l])
				l += 1
			if r % 2 == 1:
				r -= 1
				res = self.merge(res, A[r])
			l >>= 1
			r >>= 1
		return res

def main():
	(n, q) = LI()
	a = [LI() for _ in range(q)]

	def f(a, b):
		return a + b
	seg = Seg(n + 1, 0, f)
	r = []
	for (c, x, y) in a:
		if c == 0:
			seg.update(x, seg.find(x) + y)
		else:
			r.append(seg.query(x, y + 1))
	return '\n'.join(map(str, r))
print(main())


class BIT:

	def __init__(self, size):
		self.tree = [0] * (size + 1)
		self.size = size

	def sum(self, a):
		res = 0
		a += 1
		while a:
			res += self.tree[a]
			a -= a & -a
		return res

	def add(self, a, x):
		a += 1
		while a < len(self.tree):
			self.tree[a] += x
			a += a & -a
import sys
stdin = sys.stdin
na = lambda : map(int, stdin.readline().split())
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())

def main():
	(n, q) = na()
	bit = BIT(n)
	for _ in range(q):
		(t, x, y) = na()
		if t == 0:
			bit.add(x - 1, y)
		else:
			print(bit.sum(y - 1) - bit.sum(x - 2))
main()


class SegT:

	def __init__(self, size, origin=None):
		self.size = 1
		while self.size < size:
			self.size *= 2
		self._data_init()
		if origin:
			for i in range(size):
				self.data[i + self.size - 1] = origin[i]
			for i in range(self.size - 2, -1, -1):
				self.data[i] = self._calc(self.data[i * 2 + 1], self.data[i * 2 + 2])

	def _data_init(self):
		self.e = 0
		self.data = [self.e for _ in range(self.size * 2 - 1)]

	def _calc(self, a, b):
		return a + b

	def update(self, i, x):
		i += self.size - 1
		self.data[i] += x
		while i > 0:
			i = (i - 1) // 2
			self.data[i] = self._calc(self.data[i * 2 + 1], self.data[i * 2 + 2])

	def get(self, a, b, node=0, l=0, r=-1):
		if r < 0:
			r = self.size
		if r <= a or b <= l:
			return self.e
		if a <= l and r <= b:
			return self.data[node]
		vl = self.get(a, b, node * 2 + 1, l, (l + r) // 2)
		vr = self.get(a, b, node * 2 + 2, (l + r) // 2, r)
		return self._calc(vl, vr)
(N, Q) = map(int, input().split())
origin = [pow(2, 31) - 1 for i in range(N)]
segt = SegT(N)
for i in range(Q):
	(t, l, r) = input().split()
	if t == '0':
		segt.update(int(l) - 1, int(r))
	else:
		x = segt.get(int(l) - 1, int(r))
		print(x)


import sys
from operator import add
sys.setrecursionlimit(10 ** 9)

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))
INF = float('inf')

class SegTree:

	def __init__(self, n, func, init):
		self.n = n
		self.func = func
		self.init = init
		n2 = 1
		while n2 < n:
			n2 <<= 1
		self.n2 = n2
		self.tree = [self.init] * (n2 << 1)

	def update(self, i, x):
		i += self.n2
		self.tree[i] = x
		while i > 1:
			self.tree[i >> 1] = x = self.func(x, self.tree[i ^ 1])
			i >>= 1

	def get_val(self, a, b):
		return self._get_val(a, b, 1, 0, self.n2)

	def _get_val(self, a, b, k, l, r):
		if r <= a or b <= l:
			return self.init
		if a <= l and r <= b:
			return self.tree[k]
		m = (l + r) // 2
		return self.func(self._get_val(a, b, k << 1, l, m), self._get_val(a, b, (k << 1) + 1, m, r))
(N, Q) = MAP()
st = SegTree(N + 1, add, 0)
for _ in range(Q):
	(com, x, y) = MAP()
	if com == 0:
		st.update(x, y + st.get_val(x, x + 1))
	else:
		print(st.get_val(x, y + 1))


class SegmentTree:

	def __init__(self, n):
		size = 1
		while size < n:
			size *= 2
		self.size = 2 * size - 1
		self.data = [0] * self.size

	def add(self, i, v):
		index = self.size // 2 + i
		self.data[index] += v
		while index > 0:
			index = (index - 1) // 2
			self.data[index] = self.data[index * 2 + 1] + self.data[index * 2 + 2]

	def sum(self, lo, hi):

		def _sum(r, i, j):
			if j < lo or i > hi:
				return 0
			elif lo <= i and j <= hi:
				return self.data[r]
			else:
				mid = i + (j - i) // 2
				return _sum(r * 2 + 1, i, mid) + _sum(r * 2 + 2, mid + 1, j)
		return _sum(0, 0, self.size // 2)

def run():
	(n, q) = [int(i) for i in input().split()]
	t = SegmentTree(n)
	for _ in range(q):
		(com, x, y) = [int(i) for i in input().split()]
		if com == 0:
			t.add(x - 1, y)
		else:
			print(t.sum(x - 1, y - 1))
run()


class SEGTree:

	def __init__(self, n, fanction, unit):
		self.Unit = unit
		i = 1 << n.bit_length() - 1
		if i != n:
			i *= 2
		self.Fanction = fanction
		self.SEG = [self.Unit] * (2 * i - 1)
		self.d = i

	def update(self, i, x):
		i += self.d - 1
		self.SEG[i] += x
		while i > 0:
			i = (i - 1) // 2
			self.SEG[i] = self.Fanction(self.SEG[i * 2 + 1], self.SEG[i * 2 + 2])

	def find(self, a, b, k, l, r):
		if r <= a or b <= l:
			return self.Unit
		if a <= l and r <= b:
			return self.SEG[k]
		else:
			c1 = self.find(a, b, 2 * k + 1, l, (l + r) // 2)
			c2 = self.find(a, b, 2 * k + 2, (l + r) // 2, r)
			return self.Fanction(c1, c2)

	def get(self, a, b):
		return self.find(a, b, 0, 0, self.d)

def sumint(a, b):
	return a + b
(n, q) = map(int, input().split())
SEG = SEGTree(n, sumint, 0)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	x -= 1
	if com == 0:
		SEG.update(x, y)
	else:
		print(SEG.get(x, y))


def add(bit, a, w, n):
	x = a
	while x <= n:
		bit[x] += w
		x += x & -x

def sum_from_zero(bit, a):
	ret = 0
	x = a
	while x > 0:
		ret += bit[x]
		x -= x & -x
	return ret

def main():
	[n, q] = [int(num) for num in input().split()]
	bit = [0 for _ in range(n + 1)]
	for i in range(q):
		[com, x, y] = [int(num) for num in input().split()]
		if com == 0:
			add(bit, x, y, n)
		else:
			print(sum_from_zero(bit, y) - sum_from_zero(bit, x - 1))
main()


import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 5)

def li():
	return map(int, stdin.readline().split())

def li_():
	return map(lambda x: int(x) - 1, stdin.readline().split())

def lf():
	return map(float, stdin.readline().split())

def ls():
	return stdin.readline().split()

def ns():
	return stdin.readline().rstrip()

def lc():
	return list(ns())

def ni():
	return int(stdin.readline())

def nf():
	return float(stdin.readline())

class BIT(object):

	def __init__(self, size: int):
		self.bitree = [0] * (size + 1)

	def setval(self, idx: int, val: int):
		tree = self.bitree
		nex_idx = idx + 1
		while nex_idx < len(tree):
			tree[nex_idx] += val
			nex_idx += nex_idx & -nex_idx

	def getsum(self, idx: int):
		(tree, result) = (self.bitree, 0)
		nex_idx = idx + 1
		while nex_idx:
			result += tree[nex_idx]
			nex_idx -= nex_idx & -nex_idx
		return result
(n, q) = li()
bitree = BIT(n)
for _ in range(q):
	(com, x, y) = li()
	if com == 0:
		bitree.setval(x - 1, y)
	else:
		print(bitree.getsum(y - 1) - bitree.getsum(x - 2))


import time

class segTree:
	size = 0
	data = []
	__unitElement = 0
	__tree = []
	__totalSize = 0

	def __init__(self, inputData):
		self.data = inputData
		tmp = 1
		while tmp < len(inputData):
			tmp *= 2
		self.size = tmp
		self.__totalSize = 2 * self.size - 1
		self.__tree = [self.__unitElement] * self.__totalSize
		for i in range(len(inputData)):
			self.change(i, inputData[i])

	def change(self, i, x):
		self.data[i] = x
		cur = self.size - 1 + i
		self.__tree[cur] = x
		while True:
			cur = cur - 1
			if cur < 0:
				break
			cur = cur // 2
			self.__tree[cur] = self.__tree[2 * cur + 1] + self.__tree[2 * cur + 2]

	def __queryBody(self, i, a, b, left, right):
		if right <= a or b <= left:
			return self.__unitElement
		elif a <= left and right <= b:
			return self.__tree[i]
		else:
			mid = (left + right) // 2
			child1 = self.__queryBody(2 * i + 1, a, b, left, mid)
			child2 = self.__queryBody(2 * i + 2, a, b, mid, right)
			return child1 + child2

	def query(self, a, b):
		return self.__queryBody(0, a, b, 0, self.size)
(n, q) = map(int, input().split())
s = segTree([0] * n)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		cur = s.data[x - 1]
		s.change(x - 1, cur + y)
	else:
		print(s.query(x - 1, y))


class BIT:

	def __init__(self, n: int):
		self.n = n
		self.bit = [0] * (n + 1)

	def add(self, i: int, x: int):
		while i <= self.n:
			self.bit[i] += x
			i += i & -i

	def sum_1_to_i(self, i: int) -> int:
		s = 0
		while i > 0:
			s += self.bit[i]
			i -= i & -i
		return s

	def sum_i_to_j(self, i: int, j: int):
		return self.sum_1_to_i(j) - self.sum_1_to_i(i - 1)
(n, q) = map(int, input().split())
bit = BIT(n)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		bit.add(x, y)
	else:
		print(bit.sum_i_to_j(x, y))


import sys
from sys import stdin
input = stdin.readline

class RSQ(object):
	INT_MAX = 2 ** 31 - 1

	def __init__(self, nn, init_val=0):
		self.val = [init_val] * (nn + 1)
		self.n = 1
		while self.n < nn:
			self.n *= 2
		self.dat = [init_val] * (2 * self.n - 1)

	def update(self, k, a):
		self.val[k] = a
		k += self.n - 1
		self.dat[k] = a
		while k > 0:
			k = (k - 1) // 2
			self.dat[k] = self.dat[k * 2 + 1] + self.dat[k * 2 + 2]

	def add(self, k, a):
		self.val[k] += a
		self.update(k, self.val[k])

	def query(self, a, b, k, l, r):
		if r <= a or b <= l:
			return RSQ.INT_MAX
		if a == l and r == b:
			return self.dat[k]
		else:
			mid = (l + r) // 2
			if b <= mid:
				return self.query(a, b, k * 2 + 1, l, (l + r) // 2)
			elif a >= mid:
				return self.query(a, b, k * 2 + 2, (l + r) // 2, r)
			else:
				vl = self.query(a, mid, k * 2 + 1, l, mid)
				vr = self.query(mid, b, k * 2 + 2, mid, r)
				return vl + vr

	def find(self, s, t):
		return self.query(s, t + 1, 0, 0, self.n)

def main(args):
	(n, q) = map(int, input().split(' '))
	rq = RSQ(n + 1)
	for _ in range(q):
		(com, x, y) = map(int, input().split(' '))
		if com == 0:
			rq.add(x, y)
		elif com == 1:
			res = rq.find(x, y)
			print(res)
main(sys.argv[1:])


class SegTreeSum:

	def __init__(self, V):
		self.sz = len(V)
		N = 1
		while N < self.sz:
			N *= 2
		self.N = N
		self.node = [0] * (2 * self.N - 1)
		for i in range(self.sz):
			self.node[i + self.N - 1] = V[i]
		for i in range(self.N - 2, 0, -1):
			self.node[i] = self.node[2 * i + 1] + self.node[2 * i + 2]

	def add(self, i, x):
		i += self.N - 1
		self.node[i] += x
		while i > 0:
			i = (i - 1) // 2
			self.node[i] = self.node[2 * i + 1] + self.node[2 * i + 2]

	def getsum(self, a, b, k=0, l=0, r=-1):
		if r < 0:
			r = self.N
		if b <= l or a >= r:
			return 0
		if a <= l and b >= r:
			return self.node[k]
		vl = self.getsum(a, b, 2 * k + 1, l, (l + r) // 2)
		vr = self.getsum(a, b, 2 * k + 2, (l + r) // 2, r)
		return vl + vr

def main():
	(n, q) = map(int, input().split())
	V = [0] * n
	seg = SegTreeSum(V)
	for _ in range(q):
		(com, x, y) = map(int, input().split())
		x -= 1
		if com:
			print(seg.getsum(x, y))
		else:
			seg.add(x, y)
main()


import sys
BIT = []
n = 0

def init():
	global BIT, n
	BIT = [0] * (n + 1)

def add(i, x):
	global BIT, n
	while i < n + 1:
		BIT[i] += x
		i += i & -i

def sum(i):
	global BIT, n
	_sum = 0
	while i > 0:
		_sum += BIT[i]
		i -= i & -i
	return _sum

def main():
	global BIT, n
	(n, q) = map(int, sys.stdin.readline().rstrip().split())
	init()
	for _ in range(q):
		(com, x, y) = map(int, sys.stdin.readline().rstrip().split())
		if com == 0:
			add(x, y)
		else:
			print(sum(y) - sum(x - 1))
main()


def segfunc(x, y):
	return x + y
ide_ele = 0

class SegTree:

	def __init__(self, init_val, segfunc, ide_ele):
		n = len(init_val)
		self.segfunc = segfunc
		self.ide_ele = ide_ele
		self.num = 1 << (n - 1).bit_length()
		self.tree = [ide_ele] * 2 * self.num
		for i in range(n):
			self.tree[self.num + i] = init_val[i]
		for i in range(self.num - 1, 0, -1):
			self.tree[i] = segfunc(self.tree[2 * i], self.tree[2 * i + 1])

	def update(self, k, x):
		k += self.num
		self.tree[k] = x
		while k > 1:
			self.tree[k >> 1] = segfunc(self.tree[k], self.tree[k ^ 1])
			k >>= 1

	def query(self, l, r):
		res = self.ide_ele
		l += self.num
		r += self.num
		while l < r:
			if l & 1:
				res = segfunc(res, self.tree[l])
				l += 1
			if r & 1:
				res = segfunc(res, self.tree[r - 1])
			l >>= 1
			r >>= 1
		return res
(n, q) = [int(x) for x in input().split()]
seg = SegTree([0] * n, segfunc, ide_ele)
for _ in range(q):
	(com, x, y) = [int(x) for x in input().split()]
	if com:
		print(seg.query(x - 1, y))
	else:
		x -= 1
		y += seg.tree[seg.num + x]
		seg.update(x, y)


class Binary_Indexed_Tree:

	def __init__(self, n):
		self.size = n
		self.graph = [0] * (n + 1)

	def partially_sum(self, i):
		res = 0
		while i > 0:
			res += self.graph[i]
			i -= i & -i
		return res

	def add_element(self, i, x):
		while self.size >= i:
			self.graph[i] += x
			i += i & -i
(n, q) = map(int, input().split())
tree = Binary_Indexed_Tree(n)
for _ in range(q):
	(c, x, y) = map(int, input().split())
	if c == 0:
		tree.add_element(x, y)
	else:
		print(tree.partially_sum(y) - tree.partially_sum(x - 1))


import sys

class BIT:

	def __init__(self, node_size):
		self._node = node_size + 1
		self.bit = [0] * self._node

	def add(self, index, add_val):
		index += 1
		while index < self._node:
			self.bit[index] += add_val
			index += index & -index

	def sum(self, index):
		index += 1
		res = 0
		while index > 0:
			res += self.bit[index]
			index -= index & -index
		return res
(n, q) = map(int, sys.stdin.readline().split())
bt = BIT(n)
for i in range(q):
	(a, b, c) = map(int, sys.stdin.readline().split())
	if a == 0:
		bt.add(b - 1, c)
	else:
		print(bt.sum(c - 1) - bt.sum(b - 2))


(n, q) = map(int, input().split())

class BIT:

	def __init__(self, n):
		self.n = n
		self.data = [0] * (n + 1)
		self.el = [0] * (n + 1)

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.data[i]
			i -= i & -i
		return s

	def add(self, i, x):
		self.el[i] += x
		while i <= self.n:
			self.data[i] += x
			i += i & -i

	def get(self, i, j=None):
		if j is None:
			return self.el[i]
		return self.sum(j) - self.sum(i)
bit = BIT(n + 1)
for i in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		bit.add(x, y)
	else:
		s = bit.get(x - 1, y)
		print(s)


from operator import add
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

class SegmentTree:

	def __init__(self, N, arr=None, op=None, unit=None):
		self.N = N
		self.unit = unit
		self.op = op
		self.tree = [unit] * (2 * N + 1)
		if arr is not None:
			self._build(arr)

	def _build(self, arr):
		op = self.op
		N = self.N
		for (i, a) in enumerate(arr, N):
			self.tree[i] = a
		for i in reversed(range(1, N)):
			self.tree[i] = op(self.tree[i << 1], self.tree[i << 1 | 1])

	def update(self, i, x):
		i += self.N
		op = self.op
		self.tree[i] += x
		while i > 1:
			i >>= 1
			self.tree[i] = op(self.tree[i << 1], self.tree[i << 1 | 1])

	def query(self, L, R):
		op = self.op
		res = self.unit
		L += self.N
		R += self.N
		while L < R:
			if L & 1:
				res = op(res, self.tree[L])
				L += 1
			if R & 1:
				R -= 1
				res = op(res, self.tree[R])
			L >>= 1
			R >>= 1
		return res
(N, Q) = map(int, input().split())
query = tuple((tuple(map(int, input().split())) for _ in range(Q)))
seg = SegmentTree(N, [0] * N, add, 0)
ans = []
for (f, x, y) in query:
	if f:
		ans.append(seg.query(x - 1, y))
	else:
		seg.update(x - 1, y)
print(*ans, sep='\n')


class SegTree:

	def __init__(self, n, init_num, func):
		self.func = func
		self.init_num = init_num
		self.size = 2 ** (len(bin(n - 1)) - 2) * 2 - 1
		self.tree = [init_num for i in range(self.size)]

	def data(self):
		return self.tree[self.size // 2:]

	def update(self, i, x, update_func):
		i = self.size // 2 + i
		self.tree[i] = update_func(self.tree[i], x)
		while 1:
			i = (i - 1) // 2
			self.tree[i] = self.func(self.tree[i * 2 + 1], self.tree[i * 2 + 2])
			if i <= 0:
				break

	def _check(self, s, t, l, r, _p=0):
		if s <= l and r <= t:
			return self.tree[_p]
		elif r < s or t < l:
			return self.init_num
		else:
			return self.func(self._check(s, t, l, l + (r - l) // 2, _p * 2 + 1), self._check(s, t, l + (r - l) // 2 + 1, r, _p * 2 + 2))

	def find(self, s, t):
		return self._check(s, t, 0, self.size // 2)
(n, q) = map(int, input().split())
st = SegTree(n, 0, lambda x, y: x + y)
for i in range(q):
	(c, x, y) = map(int, input().split())
	if c:
		print(st.find(x - 1, y - 1))
	else:
		st.update(x - 1, y, lambda x, y: x + y)


import sys

class BinaryIndexedTree(object):
	__slots__ = ('length', 'dat')

	def __init__(self, n):
		self.length = int(n)
		self.dat = [0] * (self.length + 1)

	def __init_sum(self, i):
		_sum = 0
		while i > 0:
			_sum += self.dat[i]
			i -= i & -i
		return _sum

	def get_sum(self, s, t):
		return self.__init_sum(t) - self.__init_sum(s - 1)

	def get_add(self, i, x):
		while i <= self.length:
			self.dat[i] += x
			i += i & -i
		return self.dat

def action(cmd_list):
	for query in cmd_list:
		(cmd, ele_1, ele_2) = map(int, query)
		if cmd == 0:
			case.get_add(ele_1, ele_2)
		elif cmd == 1:
			res = case.get_sum(ele_1, ele_2)
			print(res)
	return case
_input = sys.stdin.readlines()
(n_num, q_num) = map(int, _input[0].split())
q_list = map(lambda x: x.split(), _input[1:])
case = BinaryIndexedTree(n_num)
ans = action(q_list)


class FenwickTree:

	def __init__(self, a_list):
		self.N = len(a_list)
		self.bit = a_list[:]
		for _ in range(self.N, 1 << (self.N - 1).bit_length()):
			self.bit.append(0)
		for i in range(self.N - 1):
			self.bit[i | i + 1] += self.bit[i]

	def add(self, i, val):
		while i < self.N:
			self.bit[i] += val
			i |= i + 1

	def sum(self, n):
		ret = 0
		while n >= 0:
			ret += self.bit[n]
			n = (n & n + 1) - 1
		return ret

	def query(self, low, high):
		return self.sum(high) - self.sum(low)

def yosupo():
	(N, Q) = map(int, input().split())
	fwt = FenwickTree([int(x) for x in input().split()])
	for _ in range(Q):
		(type_, l, r) = map(int, input().split())
		print([fwt.sum(i) for i in range(N + 1)])
		if type_ == 0:
			fwt.add(l, r)
		else:
			print(fwt.query(l, r))

def aoj():
	(N, Q) = map(int, input().split())
	fwt = FenwickTree([0] * N)
	for _ in range(Q):
		(type_, l, r) = map(int, input().split())
		if type_ == 0:
			fwt.add(l - 1, r)
		else:
			print(fwt.query(l - 2, r - 1))
aoj()


class SegmentTree:

	def __init__(self, n):
		self.n = n
		self.T = [0 for _ in range(2 * n - 1)]

	def add(self, i, x):
		i += self.n - 1
		self.T[i] += x
		while i > 0:
			i = (i - 1) // 2
			self.T[i] += x

	def get_sum(self, a, b, k, l, r):
		if r <= a or b <= l:
			return 0
		if a <= l and r <= b:
			return self.T[k]
		vl = self.get_sum(a, b, k * 2 + 1, l, (l + r) // 2)
		vr = self.get_sum(a, b, k * 2 + 2, (l + r) // 2, r)
		return vl + vr
(n_, q) = [int(i) for i in input().split()]
n = 1
while n < n_:
	n *= 2
T = SegmentTree(n)
for _ in range(q):
	(c, x, y) = [int(i) for i in input().split()]
	if c == 0:
		T.add(x - 1, y)
	else:
		print(T.get_sum(x - 1, y, 0, 0, n))


(n, q) = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(q)]
for i in range(30):
	if n < 1 << i:
		seg_el = 1 << i
		break
SEG = [0] * (2 * seg_el - 1)

def update(n, x, seg_el):
	i = n + seg_el - 1
	SEG[i] += x
	i = (i - 1) // 2
	while i >= 0:
		SEG[i] += x
		i = (i - 1) // 2

def getvalues(a, b, k, l, r):
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return SEG[k]
	vl = getvalues(a, b, k * 2 + 1, l, (l + r) // 2)
	vr = getvalues(a, b, k * 2 + 2, (l + r) // 2, r)
	return vl + vr
for (com, x, y) in Q:
	if com == 0:
		update(x, y, seg_el)
	else:
		print(getvalues(x, y + 1, 0, 0, seg_el))


import math

class FenwickTree:

	def __init__(self, a_list):
		self.N = len(a_list)
		self.bit = a_list[:]
		for _ in range(N, 1 << math.ceil(math.log(N, 2))):
			self.bit.append(0)
		for i in range(self.N - 1):
			self.bit[i | i + 1] += self.bit[i]

	def add(self, i, val):
		while i < self.N:
			self.bit[i] += val
			i |= i + 1

	def sum(self, n):
		ret = 0
		while n >= 0:
			ret += self.bit[n]
			n = (n & n + 1) - 1
		return ret
(N, Q) = map(int, input().split())
bit = FenwickTree([0] * N)
for _ in range(Q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		bit.add(x - 1, y)
	elif com == 1:
		print(bit.sum(y - 1) - bit.sum(x - 2))


from math import sqrt, ceil
(n, q) = map(int, input().split())
unit = ceil(sqrt(n))
l = [(0, [0] * unit) for _ in range(unit)]
while q:
	(op, s, t) = map(int, input().split())
	s -= 1
	(sd, sm) = (s // unit, s % unit)
	if op:
		t -= 1
		(td, tm) = (t // unit, t % unit)
		if sd == td:
			print(sum(l[sd][1][sm:tm + 1]))
		else:
			unit_sum = sum((tup[0] for tup in l[sd + 1:td]))
			s_sum = sum(l[sd][1][sm:])
			t_sum = sum(l[td][1][:tm + 1])
			print(unit_sum + s_sum + t_sum)
	else:
		tup = l[sd]
		tup[1][sm] += t
		l[sd] = (tup[0] + t, tup[1])
	q -= 1


import sys, queue, math, copy, itertools, bisect, collections, heapq

def main():
	sys.setrecursionlimit(10 ** 7)
	INF = 10 ** 18
	MOD = 10 ** 9 + 7
	LI = lambda : [int(x) for x in sys.stdin.readline().split()]
	_LI = lambda : [int(x) - 1 for x in sys.stdin.readline().split()]
	NI = lambda : int(sys.stdin.readline())
	SI = lambda : sys.stdin.readline().rstrip()
	(n, q) = LI()
	bit = [0] * (n + 1)

	def bit_add(i, x):
		while i <= n:
			bit[i] += x
			i += i & -i

	def sum_bit(i):
		ret = 0
		while i > 0:
			ret += bit[i]
			i -= i & -i
		return ret
	for _ in range(q):
		(c, x, y) = LI()
		if c == 0:
			bit_add(x, y)
		else:
			ans = sum_bit(y) - sum_bit(x - 1)
			print(ans)
main()


def _max(a, b):
	return max(a, b)

def _min(a, b):
	return min(a, b)

def _sum(a, b):
	return a + b

class SegmentTree:

	def __init__(self, a):
		sz = len(a)
		self.n = int(1)
		while self.n < sz:
			self.n = int(self.n * 2)
		self.func = _sum
		self.init = 0
		self.val = [0] * (self.n * 2 - 1)
		self.val[self.n - 1:self.n - 1 + sz] = a
		for i in range(self.n - 2, -1, -1):
			self.val[i] = self.func(self.val[2 * i + 1], self.val[2 * i + 2])

	def update(self, pos, x):
		k = int(pos + self.n - 1)
		self.val[k] += x
		while k > 0:
			k = int(k - 1) // 2
			self.val[k] = self.func(self.val[2 * k + 1], self.val[2 * k + 2])

	def query(self, a, b, k=0, l=0, r=-1):
		if r < 0:
			r = self.n
		if r <= a or b <= l:
			return self.init
		if a <= l and r <= b:
			return self.val[k]
		lv = self.query(a, b, 2 * k + 1, l, (l + r) // 2)
		rv = self.query(a, b, 2 * k + 2, (l + r) // 2, r)
		return self.func(lv, rv)

	def get(self, pos):
		return self.val[pos + self.n - 1]
(n, q) = map(int, input().split())
a = [0] * n
st = SegmentTree(a)
for _ in range(q):
	(t, x, y) = map(int, input().split())
	x -= 1
	if t == 0:
		st.update(x, y)
	else:
		ans = st.query(x, y)
		print(int(ans))


import sys
inf = (1 << 31) - 1

def solve():
	(n, q) = map(int, sys.stdin.readline().split())
	sg = SegTree([0] * n)
	for qi in range(q):
		(c, x, y) = map(int, sys.stdin.readline().split())
		if c == 0:
			x -= 1
			sg.add(x, y)
		else:
			(x, y) = (x - 1, y - 1)
			ans = sg.get_sum(x, y + 1, 0, 0, 2 ** sg.depth)
			print(ans)

class SegTree:

	def __init__(self, a):
		self.n = len(a)
		self.depth = 0
		while 2 ** self.depth < self.n:
			self.depth += 1
		self.data = [0] * (2 ** (self.depth + 1) - 1)
		self.data[2 ** self.depth - 1:2 ** self.depth - 1 + self.n] = a[:]
		for i in range(2 ** self.depth - 2, -1, -1):
			self.data[i] = self.data[2 * i + 1] + self.data[2 * i + 2]

	def add(self, i, x):
		i += 2 ** self.depth - 1
		self.data[i] += x
		while i > 0:
			i = (i - 1) // 2
			self.data[i] += x

	def get_sum(self, s, t, k, left, right):
		if t <= left or right <= s:
			return 0
		if s <= left and right <= t:
			return self.data[k]
		vl = self.get_sum(s, t, 2 * k + 1, left, (left + right) // 2)
		vr = self.get_sum(s, t, 2 * k + 2, (left + right) // 2, right)
		return vl + vr
solve()


import sys
from sys import stdin
input = stdin.readline

class BIT(object):

	def __init__(self, n):
		self.n = n
		self.bit = [0] * (n + 1)

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.bit[i]
			i -= i & -i
		return s

	def add(self, i, x):
		while i <= self.n:
			self.bit[i] += x
			i += i & -i

	def find(self, s, t):
		t_sum = self.sum(t)
		s_sum = self.sum(s - 1)
		return t_sum - s_sum

def main(args):
	(n, q) = map(int, input().split(' '))
	rq = BIT(n + 1)
	for _ in range(q):
		(com, x, y) = map(int, input().split(' '))
		if com == 0:
			rq.add(x, y)
		elif com == 1:
			res = rq.find(x, y)
			print(res)
main(sys.argv[1:])


class RSQ:

	def __init__(self, n_):
		self.n_ = n_
		self.n = 1
		while self.n < n_:
			self.n *= 2
		self.st = [0] * (2 * self.n - 1)

	def update(self, k, x):
		k += self.n - 1
		self.st[k] += x
		while k > 0:
			k = (k - 1) // 2
			self.st[k] = self.st[2 * k + 1] + self.st[2 * k + 2]

	def search(self, a, b, k, l, r):
		if r <= a or b <= l:
			return 0
		if a <= l and r <= b:
			return self.st[k]
		L = self.search(a, b, k * 2 + 1, l, (l + r) // 2)
		R = self.search(a, b, k * 2 + 2, (l + r) // 2, r)
		return L + R

	def query(self, a, b):
		return self.search(a, b, 0, 0, self.n)

def main():
	(n, q) = map(int, input().split())
	ST = RSQ(n)
	for _ in range(q):
		(a, b, c) = map(int, input().split())
		if a == 0:
			ST.update(b - 1, c)
		else:
			print(ST.query(b - 1, c))
main()


D = [0]
[n, q] = list(map(int, input().split()))

def initRMQ(n_):
	global D, n
	size = 1
	while size < n_:
		size *= 2
	i = 1
	while i <= 2 * size - 1 - 1:
		D.append(0)
		i += 1
	n = size

def add(k, a):
	global D
	k += n - 1
	D[k] += a
	while k > 0:
		k = int((k - 1) / 2)
		D[k] = D[k * 2 + 1] + D[k * 2 + 2]

def query(a, b, k, l, r):
	global D
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return D[k]
	vl = query(a, b, k * 2 + 1, l, int((l + r) / 2))
	vr = query(a, b, k * 2 + 2, int((l + r) / 2), r)
	return vl + vr

def getSum(a, b):
	global n
	return query(a, b + 1, 0, 0, n)
initRMQ(n)
for i in range(q):
	data = list(map(int, input().split()))
	if data[0] == 0:
		add(data[1] - 1, data[2])
	if data[0] == 1:
		print(getSum(data[1] - 1, data[2] - 1))


class BIT(object):

	def __init__(self, size, init_data=None):
		self.size = size
		if init_data is None:
			init_data = [0] * (size + 1)
		self.data = init_data

	def sum(self, idx):
		ret = 0
		while idx > 0:
			ret += self.data[idx]
			idx -= idx & -idx
		return ret

	def add(self, idx, value):
		while idx <= self.size:
			self.data[idx] += value
			idx += idx & -idx
(n, q) = list(map(int, input().split()))
bit = BIT(n)
for _ in range(q):
	(com, x, y) = list(map(int, input().split()))
	if com == 0:
		bit.add(x, y)
	else:
		print(bit.sum(y) - bit.sum(x - 1))


import sys
inf = (1 << 31) - 1

def solve():
	(n, q) = map(int, sys.stdin.readline().split())
	bit = BinaryIndexedTree([0] * n)
	for qi in range(q):
		(c, x, y) = map(int, sys.stdin.readline().split())
		if c == 0:
			x -= 1
			bit.add(x, y)
		else:
			ans = bit.get_sum(y) - bit.get_sum(x - 1)
			print(ans)

class BinaryIndexedTree:

	def __init__(self, a):
		self.n = len(a)
		self.bit = [0] * (self.n + 1)
		for i in range(1, self.n + 1):
			self.bit[i] += a[i - 1]
			if i + (i & -i) <= self.n:
				self.bit[i + (i & -i)] += self.bit[i]

	def add(self, i, x):
		i += 1
		while i <= self.n:
			self.bit[i] += x
			i += i & -i

	def get_sum(self, r):
		res = 0
		while r > 0:
			res += self.bit[r]
			r -= r & -r
		return res

class SegTree:

	def __init__(self, a):
		self.n = len(a)
		self.depth = 0
		while 2 ** self.depth < self.n:
			self.depth += 1
		self.data = [0] * (2 ** (self.depth + 1) - 1)
		self.data[2 ** self.depth - 1:2 ** self.depth - 1 + self.n] = a[:]
		for i in range(2 ** self.depth - 2, -1, -1):
			self.data[i] = self.data[2 * i + 1] + self.data[2 * i + 2]

	def add(self, i, x):
		i += 2 ** self.depth - 1
		self.data[i] += x
		while i > 0:
			i = (i - 1) // 2
			self.data[i] += x

	def get_sum(self, s, t, k, left, right):
		if t <= left or right <= s:
			return 0
		if s <= left and right <= t:
			return self.data[k]
		vl = self.get_sum(s, t, 2 * k + 1, left, (left + right) // 2)
		vr = self.get_sum(s, t, 2 * k + 2, (left + right) // 2, right)
		return vl + vr
solve()


class TemplateTree:

	def __init__(self, iterable):
		self.iter_size = self.get_size(iterable)
		self.size = self.iter_size * 2 - 1
		self.value = [None] * self.size
		for (i, v) in enumerate(iterable):
			self.value[self.iter_size + i - 1] = v
		self.set_value(0)
		self.range = [None] * self.size
		self.set_range(0, 0, self.iter_size - 1)

	def get_size(self, iterable):
		ret = 1
		x = len(iterable)
		while ret < x:
			ret *= 2
		return ret

	def set_range(self, x, left, right):
		self.range[x] = (left, right)
		if left != right:
			self.set_range(x * 2 + 1, left, (right + left) // 2)
			self.set_range(x * 2 + 2, (right + left) // 2 + 1, right)

	def set_value(self, x):
		if x >= self.iter_size - 1:
			return self.value[x]
		a = self.set_value(x * 2 + 1)
		b = self.set_value(x * 2 + 2)
		if a == None and b == None:
			self.value[x] = None
		elif a == None:
			self.value[x] = b
		elif b == None:
			self.value[x] = a
		else:
			self.value[x] = a + b
		return self.value[x]

	def update(self, i, x):
		target = self.iter_size + i - 1
		while target >= 0:
			self.value[target] += x
			target = (target - 1) // 2

	def query(self, x, left, right):
		(x_left, x_right) = self.range[x]
		if right < x_left or x_right < left:
			return 0
		if left <= x_left and x_right <= right:
			return self.value[x]
		return self.query(x * 2 + 1, left, right) + self.query(x * 2 + 2, left, right)

	def print_tree(self):
		print(self.value)
		print(self.range)
(n, q) = map(int, input().split())
tree = TemplateTree([0] * n)
for _ in range(q):
	(c, x, y) = map(int, input().split())
	if c == 0:
		tree.update(x - 1, y)
	else:
		print(tree.query(0, x - 1, y - 1))


class segmentTreeSum:
	initValue = 0
	dat = []
	lenData = -1

	def __init__(self):
		pass

	def load(self, l):
		self.lenData = 2 ** (len(l) - 1).bit_length()
		self.dat = [self.initValue] * (self.lenData * 2)
		for i in range(len(l)):
			self.dat[self.lenData - 1 + i] = l[i]
		self.build()

	def build(self):
		for i in range(self.lenData - 2, -1, -1):
			self.dat[i] = self.dat[2 * i + 1] + self.dat[2 * i + 2]

	def addValue(self, i, a):
		nodeId = self.lenData - 1 + i
		self.dat[nodeId] += a
		self.setValue(i, self.dat[nodeId])

	def setValue(self, i, a):
		nodeId = self.lenData - 1 + i
		self.dat[nodeId] = a
		while nodeId != 0:
			nodeId = (nodeId - 1) // 2
			self.dat[nodeId] = self.dat[nodeId * 2 + 1] + self.dat[nodeId * 2 + 2]

	def querySub(self, a, b, nodeId, l, r):
		if r <= a or b <= l:
			return self.initValue
		if a <= l and r <= b:
			return self.dat[nodeId]
		resLeft = self.querySub(a, b, 2 * nodeId + 1, l, (l + r) // 2)
		resRight = self.querySub(a, b, 2 * nodeId + 2, (l + r) // 2, r)
		return resLeft + resRight

	def query(self, a, b):
		return self.querySub(a, b, 0, 0, self.lenData)
initVal = 0
(n, q) = map(int, input().split())
dat = [initVal] * n
st = segmentTreeSum()
st.load(dat)
st.build()
for _ in range(q):
	(cmd, a, b) = map(int, input().split())
	if cmd == 0:
		st.addValue(a - 1, b)
	else:
		print(st.query(a - 1, b + 1 - 1))


import math
import functools

class SegmentTree:

	def __init__(self, a: list, default: int, op):
		real_size = len(a)
		self.elem_size = 1 << int(math.ceil(math.log2(real_size)))
		self.tree_size = 2 * self.elem_size + 1
		self.tree = [default] * (self.elem_size - 1) + a + [default] * (self.elem_size - real_size)
		self.operation = op

	def get_range_index(self, x, y, k=0, l_end=0, r_end=None):
		if r_end is None:
			r_end = self.elem_size
		if l_end == x and y == r_end - 1:
			return [k]
		elif not l_end <= x <= y < r_end:
			return []
		mid = (l_end + r_end) // 2
		left_y = y if y < mid - 1 else mid - 1
		right_x = x if x > mid else mid
		left = self.get_range_index(x, left_y, 2 * k + 1, l_end, mid)
		right = self.get_range_index(right_x, y, 2 * k + 2, mid, r_end)
		return left + right

	def get_value(self, x, y):
		tree = self.tree
		index_list = self.get_range_index(x, y)
		op = self.operation
		return functools.reduce(op, (tree[n] for n in index_list))

	def update_tree(self, k: int):
		op = self.operation
		tree = self.tree
		while k > 0:
			k = (k - 1) // 2
			(left, right) = (tree[2 * k + 1], tree[2 * k + 2])
			tree[k] = op(left, right)

	def set_value(self, i: int, value: int, op: str):
		k = self.elem_size - 1 + i
		if op == '=':
			self.tree[k] = value
		elif op == '+':
			self.tree[k] += value
		self.update_tree(k)
(n, q) = map(int, input().split())
rsq = SegmentTree([0] * n, 0, lambda x, y: x + y)
ans = []
for _ in [0] * q:
	(c, x, y) = map(int, input().split())
	if c == 0:
		rsq.set_value(x - 1, y, '+')
	else:
		ans.append(rsq.get_value(x - 1, y - 1))
print('\n'.join([str(n) for n in ans]))


import math, sys

class SegmentTree:

	def __init__(self, n):
		self.TreeRange = pow(2, math.ceil(math.log2(n)))
		self.List = [0] * (2 * self.TreeRange - 1)

	def add(self, i, x):
		i += self.TreeRange - 1
		self.List[i] += x
		while i > 0:
			i = (i - 1) // 2
			self.List[i] += x

	def getsum(self, s, t, i=0, left=0, right=float('inf')):
		if right <= s or t <= left:
			return 0
		elif s <= left <= right <= t:
			return self.List[i]
		else:
			l = self.getsum(s, t, i * 2 + 1, left, (left + right) // 2)
			r = self.getsum(s, t, i * 2 + 2, (left + right) // 2, right)
			return l + r
_input = sys.stdin.readlines()
(n, q) = map(int, _input[0].split())
qlist = map(lambda x: x.split(), _input[1:])
ST = SegmentTree(n)
for q in qlist:
	(cmd, x, y) = map(int, q)
	if cmd == 0:
		ST.add(x - 1, y)
	elif cmd == 1:
		print(ST.getsum(x - 1, y, right=ST.TreeRange))


from typing import Optional, Sequence

class BinaryIndexedTree:
	__slots__ = ['_size', '_tree', '_is_zero_indexed']

	def __init__(self, size: int, initial_values: Optional[Sequence[int]]=None, is_zero_indexed: bool=True):
		self._size = size
		self._tree = [0] * (self._size + 1)
		self._is_zero_indexed = is_zero_indexed
		if initial_values:
			self._build(initial_values)

	def _build(self, initial_values: Sequence[int]):
		for (i, a) in enumerate(initial_values):
			self.add(i, a)

	def add(self, index: int, value: int) -> None:
		if self._is_zero_indexed:
			index += 1
		while index <= self._size:
			self._tree[index] += value
			index += index & -index

	def sum(self, index: int) -> int:
		ret = 0
		while index > 0:
			ret += self._tree[index]
			index -= index & -index
		return ret

	def range_sum(self, left: int, right: int) -> int:
		if not self._is_zero_indexed:
			left -= 1
		return self.sum(right) - self.sum(left)

def main():
	(N, Q, *queries) = map(int, open(0).read().split())
	tree = BinaryIndexedTree(N, is_zero_indexed=False)
	result = []
	for (com, x, y) in zip(*[iter(queries)] * 3):
		if com:
			result.append(tree.range_sum(x, y))
		else:
			tree.add(x, y)
	print(*result, sep='\n')
main()


class Segment_Tree:

	def __init__(self, n, func, init):
		self.n = n
		self.tree = [init] * (2 * self.n - 1)
		self.func = func
		self.init = init

	def update(self, i, x):
		i += self.n - 1
		self.tree[i] = x
		while i > 0:
			i = int((i - 1) / 2)
			self.tree[i] = self.func((self.tree[2 * i + 1], self.tree[2 * i + 2]))

	def find(self, a, b, k, l, r):
		if r <= a or b <= l:
			return self.init
		if a <= l and r <= b:
			return self.tree[k]
		vl = self.find(a, b, k * 2 + 1, l, int((l + r) / 2))
		vr = self.find(a, b, k * 2 + 2, int((l + r) / 2), r)
		return self.func((vl, vr))
(n, q) = map(int, input().split())
N = 1
while N < n:
	N *= 2
func = lambda a: a[0] + a[1]
segtre = Segment_Tree(N, func, 0)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		segtre.update(x - 1, segtre.tree[x + segtre.n - 2] + y)
	else:
		print(segtre.find(x - 1, y, 0, 0, N))


from array import array

class BIT(object):

	def __init__(self, size, init_data=None):
		self.size = size
		if init_data is None:
			init_data = [0] * (size + 1)
		self.data = array('q', init_data)

	def sum(self, idx):
		ret = 0
		while idx > 0:
			ret += self.data[idx]
			idx -= idx & -idx
		return ret

	def add(self, idx, value):
		while idx <= self.size:
			self.data[idx] += value
			idx += idx & -idx
(n, q) = list(map(int, input().split()))
bit = BIT(n)
for _ in range(q):
	(com, x, y) = list(map(int, input().split()))
	if com == 0:
		bit.add(x, y)
	else:
		print(bit.sum(y) - bit.sum(x - 1))


class RSQ(object):
	INIT = 0

	def __init__(self, num) -> None:
		n = 1
		while n <= num:
			n = n * 2
		self.n = n
		self.val = [self.INIT] * (2 * n - 1)

	@staticmethod
	def merge(a: int, b: int) -> int:
		return a + b

	def update(self, k: int, x: int) -> None:
		k = k + self.n - 1
		self.val[k] += x
		while k:
			k = (k - 1) // 2
			self.val[k] = self.merge(self.val[k * 2 + 1], self.val[k * 2 + 2])

	def dfs(self, beg: int, end: int, k: int, l: int, r: int) -> int:
		if end <= l or r <= beg:
			return self.INIT
		if beg <= l and r <= end:
			return self.val[k]
		vl = self.dfs(beg, end, k * 2 + 1, l, (l + r) // 2)
		vr = self.dfs(beg, end, k * 2 + 2, (l + r) // 2, r)
		return self.merge(vl, vr)

	def query(self, beg: int, end: int) -> int:
		return self.dfs(beg, end, 0, 0, self.n)
(n, q) = map(lambda x: int(x), input().split())
rmq = RSQ(n)
for _ in range(q):
	(com, x, y) = map(lambda x: int(x), input().split())
	if 0 == com:
		rmq.update(x, y)
	else:
		print(rmq.query(x, y + 1))


class BIT:

	def __init__(self, n):
		self.n = n
		self.bit = [0] * (n + 1)

	def getsum(self, k):
		ret = 0
		while k:
			ret += self.bit[k]
			k -= k & -k
		return ret

	def p_sum(self, i, j):
		return self.getsum(j) - self.getsum(i - 1)

	def add(self, k, x):
		while k <= n:
			self.bit[k] += x
			k += k & -k
(n, q) = map(int, input().split())
BIT = BIT(n)
for _ in range(q):
	(c, x, y) = map(int, input().split())
	if c == 0:
		BIT.add(x, y)
	else:
		print(BIT.p_sum(x, y))


import sys
input = sys.stdin.readline

class SegmentTree:

	def __init__(self, arr, func=min, ie=2 ** 63):
		self.n = 2 ** (len(arr) - 1).bit_length()
		self.ie = ie
		self.func = func
		self.tree = [ie for _ in range(2 * self.n)]
		for i in range(len(arr)):
			self.tree[self.n + i - 1] = arr[i]
		for i in range(self.n - 1)[::-1]:
			self.tree[i] = func(self.tree[2 * i + 1], self.tree[2 * i + 2])

	def update(self, index, x):
		index += self.n - 1
		self.tree[index] = x
		while index > 0:
			index = (index - 1) // 2
			self.tree[index] = self.func(self.tree[2 * index + 1], self.tree[2 * index + 2])

	def query(self, left, right):
		if right <= left:
			return self.ie
		left += self.n - 1
		right += self.n - 2
		res = self.ie
		while right - left > 1:
			if left & 1 == 0:
				res = self.func(res, self.tree[left])
			if right & 1 == 1:
				res = self.func(res, self.tree[right])
				right -= 1
			left = left // 2
			right = (right - 1) // 2
		if left == right:
			res = self.func(res, self.tree[left])
		else:
			res = self.func(self.func(res, self.tree[left]), self.tree[right])
		return res
(N, Q) = map(int, input().split())
A = [0 for _ in range(N)]
st = SegmentTree(A, lambda x, y: x + y, 0)
ans = []
for _ in range(Q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		st.update(x - 1, st.query(x - 1, x) + y)
	else:
		ans.append(st.query(x - 1, y))
print(*ans, sep='\n')


class RSQ:

	def __init__(self, length, ini_num=float('inf')):
		self.length = 1
		self.ini_num = ini_num
		if length == 1:
			length = 2
		while self.length < length:
			self.length <<= 1
		self.segtree = [ini_num] * (2 * self.length - 1)

	def update(self, index, num):
		leaf_index = index + self.length - 1
		self.segtree[leaf_index] = num
		while leaf_index > 0:
			leaf_index = (leaf_index - 1) // 2
			self.segtree[leaf_index] = self.segtree[2 * leaf_index + 1] + self.segtree[2 * leaf_index + 2]

	def add(self, index, num):
		leaf_index = index + self.length - 1
		self.segtree[leaf_index] += num
		while leaf_index > 0:
			leaf_index = (leaf_index - 1) // 2
			self.segtree[leaf_index] = self.segtree[2 * leaf_index + 1] + self.segtree[2 * leaf_index + 2]

	def call_search(self, a, b):
		return self.search(a, b, index=0, l=0, r=self.length - 1)

	def search(self, a, b, index, l, r):
		if r < a or b < l:
			return self.ini_num
		elif a <= l <= r <= b:
			return self.segtree[index]
		else:
			return self.search(a, b, index * 2 + 1, l, (l + r) // 2) + self.search(a, b, index * 2 + 2, (l + r) // 2 + 1, r)
(v_num, query) = map(int, input().split(' '))
rsq = RSQ(v_num, 0)
for _ in range(query):
	(comm, index, num) = map(int, input().split(' '))
	if comm == 0:
		rsq.add(index - 1, num)
	else:
		print(rsq.call_search(index - 1, num - 1))


(N, Q) = map(int, input().split())
bit = [0] * (N + 1)

def add(a, w):
	x = a
	while x <= N:
		bit[x] += w
		x += x & -x

def bsum(a):
	ret = 0
	x = a
	while x > 0:
		ret += bit[x]
		x -= x & -x
	return ret
for i in range(Q):
	l = list(map(int, input().split()))
	if l[0] == 0:
		add(l[1], l[2])
	else:
		print(bsum(l[2]) - bsum(l[1] - 1))


import math

class SegmentTree:
	__slots__ = ['elem_size', 'tree_size', 'tree']

	def __init__(self, a: list, default: int):
		real_size = len(a)
		self.elem_size = 1 << math.ceil(math.log2(real_size))
		self.tree_size = 2 * self.elem_size + 1
		self.tree = [default] * (self.elem_size - 1) + a + [default] * (self.elem_size - real_size)

	def get_range_index(self, x, y, k=0, l_end=0, r_end=None):
		if r_end is None:
			r_end = self.elem_size
		if l_end == x and y == r_end - 1:
			return [k]
		elif not l_end <= x <= y < r_end:
			return []
		mid = (l_end + r_end) // 2
		left_y = y if y < mid - 1 else mid - 1
		right_x = x if x > mid else mid
		left = self.get_range_index(x, left_y, 2 * k + 1, l_end, mid)
		right = self.get_range_index(right_x, y, 2 * k + 2, mid, r_end)
		return left + right

	def get_value(self, x, y):
		tree = self.tree
		index_list = self.get_range_index(x, y)
		return sum((tree[n] for n in index_list))

	def update_tree(self, k: int):
		tree = self.tree
		while k > 0:
			k = (k - 1) // 2
			(left, right) = (tree[2 * k + 1], tree[2 * k + 2])
			tree[k] = left + right

	def set_value(self, i: int, value: int, op: str):
		k = self.elem_size - 1 + i
		if op == '=':
			self.tree[k] = value
		elif op == '+':
			self.tree[k] += value
		self.update_tree(k)
(n, q) = map(int, input().split())
rsq = SegmentTree([0] * n, 0)
ans = []
for _ in [0] * q:
	(c, x, y) = map(int, input().split())
	if c == 0:
		rsq.set_value(x - 1, y, '+')
	else:
		ans.append(rsq.get_value(x - 1, y - 1))
print('\n'.join([str(n) for n in ans]))


def main():
	(n, q) = map(int, input().split())
	nums = [0] * (n + 1)
	for i in range(q):
		(com, x, y) = map(int, input().split())
		if not com:
			while x <= n:
				nums[x] += y
				x += x & -x
		else:
			x -= 1
			s_sum = 0
			while x:
				s_sum += nums[x]
				x -= x & -x
			t_sum = 0
			while y:
				t_sum += nums[y]
				y -= y & -y
			print(t_sum - s_sum)
main()


class SegmentTree:

	def __init__(self, n):
		self.offset = self.setOffset(n)
		self.segTree = [0] * (2 * self.offset + 1)

	def init_array(self, array):
		for i in range(len(array)):
			self.segTree[i + self.offset] = array[i]
		for i in range(offset - 1, -1, -1):
			self.segTree[i] = self.sumChild(i)

	def setOffset(self, n):
		if n == 1:
			return 1
		else:
			return 2 ** (n - 1).bit_length() - 1

	def update(self, k, x):
		k += self.offset
		self.segTree[k] += x
		while k:
			k = (k - 1) // 2
			self.segTree[k] += x

	def sum_query(self, p, q):
		if p >= q:
			return
		p += self.offset
		q += self.offset - 1
		segsum = 0
		while q - p > 1:
			if not p & 1:
				segsum += self.segTree[p]
			if q & 1:
				segsum += self.segTree[q]
				q -= 1
			p = p // 2
			q = (q - 1) // 2
		if p == q:
			return segsum + self.segTree[p]
		else:
			return segsum + self.segTree[p] + self.segTree[q]

	def sumChild(self, n):
		return self.segTree[2 * n + 1] + self.segTree[2 * n + 2]

	def show(self):
		print(self.segTree)
(n, q) = map(int, input().split())
ST = SegmentTree(n)
for i in range(q):
	qry = list(map(int, input().split()))
	if qry[0] == 0:
		ST.update(qry[1] - 1, qry[2])
	else:
		print(ST.sum_query(qry[1] - 1, qry[2]))


line = input()
(n, q) = list(map(int, line.split()))
N = 1
while N < n + 1:
	N *= 2
a = [0 for _ in range(0, 2 * N - 1)]

def update(k, v):
	k += N - 1
	a[k] += v
	while k > 0:
		k = (k - 1) // 2
		a[k] = a[k * 2 + 1] + a[k * 2 + 2]

def query(x, y, k, l, r):
	if r <= x or y <= l:
		return 0
	elif x <= l and r <= y:
		return a[k]
	m = (l + r) // 2
	return query(x, y, k * 2 + 1, l, m) + query(x, y, k * 2 + 2, m, r)
for _ in range(0, q):
	line = input()
	(c, x, y) = list(map(int, line.split()))
	if c == 0:
		update(x, y)
	elif c == 1:
		ans = query(x, y + 1, 0, 0, N)
		print(ans)


import math

class SegmentTree:
	__slots__ = ['elem_size', 'tree_size', 'tree']

	def __init__(self, a: list, default: int):
		real_size = len(a)
		self.elem_size = 1 << math.ceil(math.log2(real_size))
		self.tree_size = 2 * self.elem_size + 1
		self.tree = [default] * (self.elem_size - 1) + a + [default] * (self.elem_size - real_size)

	def get_range_index(self, x, y, k=0, l_end=0, r_end=None):
		(default, tree) = (0, self.tree)
		if r_end is None:
			r_end = self.elem_size
		if l_end == x and y == r_end - 1:
			return tree[k]
		mid = (l_end + r_end) // 2
		left_y = y if y < mid - 1 else mid - 1
		right_x = x if x > mid else mid
		left = self.get_range_index(x, left_y, 2 * k + 1, l_end, mid) if x <= left_y else default
		right = self.get_range_index(right_x, y, 2 * k + 2, mid, r_end) if right_x <= y else default
		return left + right

	def get_value(self, x, y):
		tree = self.tree
		return self.get_range_index(x, y)

	def update_tree(self, k: int):
		tree = self.tree
		while k > 0:
			k = (k - 1) // 2
			(left, right) = (tree[2 * k + 1], tree[2 * k + 2])
			tree[k] = left + right

	def set_value(self, i: int, value: int, op: str):
		k = self.elem_size - 1 + i
		if op == '=':
			self.tree[k] = value
		elif op == '+':
			self.tree[k] += value
		self.update_tree(k)
(n, q) = map(int, input().split())
rsq = SegmentTree([0] * n, 0)
ans = []
for _ in [0] * q:
	(c, x, y) = map(int, input().split())
	if c == 0:
		rsq.set_value(x - 1, y, '+')
	else:
		ans.append(rsq.get_value(x - 1, y - 1))
print('\n'.join([str(n) for n in ans]))


(n, q) = map(int, input().split())
DEF = 0
seg_size = 2
while seg_size < n:
	seg_size *= 2
seg_size = seg_size * 2 - 1
seg_tree = [DEF for x in range(seg_size)]
answer_stk = []

def update(i, x):
	idx = seg_size // 2 + i
	seg_tree[idx] += x
	while idx:
		idx = (idx - 1) // 2
		l_child = seg_tree[idx * 2 + 1]
		r_child = seg_tree[idx * 2 + 2]
		seg_tree[idx] = l_child + r_child

def query(s, t, l, r, curnode):
	if s > r or t < l:
		return DEF
	if s <= l and t >= r:
		return seg_tree[curnode]
	else:
		l_child = curnode * 2 + 1
		r_child = curnode * 2 + 2
		l_value = query(s, t, l, (l + r) // 2, l_child)
		r_value = query(s, t, (l + r) // 2 + 1, r, r_child)
		return l_value + r_value
for i in range(q):
	(q, x, y) = map(int, input().split())
	if q == 0:
		update(x - 1, y)
	else:
		answer_stk.append(query(x - 1, y - 1, 0, seg_size // 2, 0))
for a in answer_stk:
	print(a)


import sys
from sys import stdin
input = stdin.readline

class BIT(object):

	def __init__(self, n):
		self.n = n
		self.bit = [0] * (n + 1)

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.bit[i]
			i &= i - 1
		return s

	def add(self, i, x):
		while i <= self.n:
			self.bit[i] += x
			i += i & -i

	def find(self, s, t):
		t_sum = self.sum(t)
		s_sum = self.sum(s - 1)
		return t_sum - s_sum

def main(args):
	(n, q) = map(int, input().split(' '))
	rq = BIT(n + 1)
	for _ in range(q):
		(com, x, y) = map(int, input().split(' '))
		if com == 0:
			rq.add(x, y)
		elif com == 1:
			res = rq.find(x, y)
			print(res)
main(sys.argv[1:])


class SegmentTree:

	def __init__(self, size, f=lambda x, y: x + y, default=0):
		self.size = 2 ** (size - 1).bit_length()
		self.default = default
		self.dat = [default] * (self.size * 2)
		self.f = f

	def update(self, i, x):
		i += self.size
		self.dat[i] = x
		while i > 0:
			i >>= 1
			self.dat[i] = self.f(self.dat[i * 2], self.dat[i * 2 + 1])

	def query(self, l, r):
		l += self.size
		r += self.size
		(lres, rres) = (self.default, self.default)
		while l < r:
			if l & 1:
				lres = self.f(lres, self.dat[l])
				l += 1
			if r & 1:
				r -= 1
				rres = self.f(self.dat[r], rres)
			l >>= 1
			r >>= 1
		res = self.f(lres, rres)
		return res
(n, q) = map(int, input().split())
s = SegmentTree(n)
for i in range(q):
	(com, x, y) = map(int, input().split())
	x -= 1
	if com == 0:
		s.update(x, s.query(x, x + 1) + y)
	else:
		print(s.query(x, y))


(n, q) = map(int, input().split(' '))
tree = [0] * (n + 1)
querys = [tuple(map(int, input().split(' '))) for _ in range(q)]

def b_sum(i):
	ans = 0
	while i > 0:
		ans += tree[i]
		i -= i & -i
	return ans
for query in querys:
	(com, x, y) = query
	if com == 0:
		i = x
		x = y
		while i <= n:
			tree[i] += x
			i += i & -i
	if com == 1:
		s = x - 1
		t = y
		print(b_sum(t) - b_sum(s))


class SegmentTree:

	def __init__(self, n):
		self.n = n
		self.size = 1
		while self.size < n:
			self.size *= 2
		self.node = [0] * (2 * self.size - 1)

	def add(self, i, val):
		i += self.size - 1
		self.node[i] += val
		while i > 0:
			i = (i - 1) // 2
			self.node[i] = self.node[2 * i + 1] + self.node[2 * i + 2]

	def get_sum(self, begin, end):
		begin += self.size - 1
		end += self.size - 1
		s = 0
		while begin < end:
			if end - 1 & 1:
				end -= 1
				s += self.node[end]
			if begin - 1 & 1:
				s += self.node[begin]
				begin += 1
			begin = (begin - 1) // 2
			end = (end - 1) // 2
		return s

	def debug(self):
		return self.node[self.size - 1:self.size - 1 + self.n]
(n, q) = map(int, input().split())
info = [list(map(int, input().split())) for i in range(q)]
st = SegmentTree(n)
for i in range(q):
	(com, x, y) = info[i]
	if com == 0:
		st.add(x - 1, y)
	else:
		print(st.get_sum(x - 1, y))


class SegTree:
	from operator import add
	X_unit = 0
	X_f = add

	def __init__(self, N):
		self.N = N
		self.X = [self.X_unit] * (N + N)

	def build(self, seq):
		for (i, x) in enumerate(seq, self.N):
			self.X[i] = x
		for i in range(self.N - 1, 0, -1):
			self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

	def set_val(self, i, x):
		i += self.N
		self.X[i] += x
		while i > 1:
			i >>= 1
			self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])

	def fold(self, L, R):
		L += self.N
		R += self.N
		vL = self.X_unit
		vR = self.X_unit
		while L < R:
			if L & 1:
				vL = self.X_f(vL, self.X[L])
				L += 1
			if R & 1:
				R -= 1
				vR = self.X_f(self.X[R], vR)
			L >>= 1
			R >>= 1
		return self.X_f(vL, vR)

def main():
	(N, Q) = (int(i) for i in input().split())
	seg = SegTree(N)
	for _ in range(Q):
		(com, x, y) = (int(i) for i in input().split())
		if com == 0:
			seg.set_val(x - 1, y)
		else:
			print(seg.fold(x - 1, y))
main()


import sys
sys.setrecursionlimit(10000)

def initRMQ(n):
	n_ = 1
	while n_ < n:
		n_ *= 2
	D = []
	for _ in range(2 * n_ - 1):
		D.append(0)
	return (n_, D)

def update(k, a):
	k += n_ - 1
	D[k] += a
	while k > 0:
		k = int((k - 1) / 2)
		D[k] = D[k * 2 + 1] + D[k * 2 + 2]

def findSum(a, b):
	return query(a, b + 1, 0, 0, n_)

def query(a, b, k, l, r):
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return D[k]
	vl = query(a, b, k * 2 + 1, l, int((l + r) / 2))
	vr = query(a, b, k * 2 + 2, int((l + r) / 2), r)
	return vl + vr
(n, q) = map(int, input().split())
(n_, D) = initRMQ(n)
for _ in range(q):
	(c, x, y) = map(int, input().split())
	if c == 0:
		update(x - 1, y)
	else:
		print(findSum(x - 1, y - 1))


class SegmentTree:

	def __init__(self, size, f=lambda x, y: x + y, default=0):
		self.size = 2 ** (size - 1).bit_length()
		self.default = default
		self.dat = [default] * (self.size * 2 - 1)
		self.f = f

	def update(self, i, x):
		i += self.size - 1
		self.dat[i] = x
		while i > 0:
			i = i - 1 >> 1
			self.dat[i] = self.f(self.dat[i * 2 + 1], self.dat[i * 2 + 2])

	def query(self, l, r, k=0, L=0, R=None):
		if R is None:
			R = self.size
		if R <= l or r <= L:
			return self.default
		if l <= L and R <= r:
			return self.dat[k]
		else:
			lres = self.query(l, r, k * 2 + 1, L, L + R >> 1)
			rres = self.query(l, r, k * 2 + 2, L + R >> 1, R)
			return self.f(lres, rres)
(n, q) = map(int, input().split())
s = SegmentTree(n)
for i in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		i = x - 1
		s.update(i, s.query(i, i + 1) + y)
	else:
		print(s.query(x - 1, y))


import sys

class BinaryIndexedTree(object):
	__slots__ = ['tree']

	def __init__(self, size: int):
		self.tree = [0] * (size + 1)

	def add(self, index: int, value: int) -> None:
		tree = self.tree
		next_index = index + 1
		while next_index < len(tree):
			tree[next_index] += value
			next_index += next_index & -next_index

	def sum(self, index: int):
		(tree, result) = (self.tree, 0)
		next_index = index + 1
		while next_index:
			result += tree[next_index]
			next_index -= next_index & -next_index
		return result
(n, q) = map(int, input().split())
bit = BinaryIndexedTree(n)
result = []
for (com, x, y) in (map(int, l.split()) for l in sys.stdin):
	if not com:
		bit.add(x - 1, y)
	else:
		result.append(bit.sum(y - 1) - bit.sum(x - 2))
print(*result, sep='\n')


dat = [0] * 400000
m = 0

def init():
	global dat, m
	for i in range(2 * m - 1):
		dat[i] = 0

def add(i, x):
	global dat, m
	i += m - 1
	dat[i] += x
	while i > 0:
		i = (i - 1) // 2
		dat[i] = dat[2 * i + 1] + dat[2 * i + 2]

def getSum(a, b, k, l, r):
	global dat, m
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return dat[k]
	else:
		vl = getSum(a, b, 2 * k + 1, l, (l + r) // 2)
		vr = getSum(a, b, 2 * k + 2, (l + r) // 2, r)
		return vl + vr
(n, q) = map(int, input().split())
m = 1
while m < n:
	m *= 2
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		add(x - 1, y)
	else:
		print(getSum(x - 1, y, 0, 0, m))


import sys
import math
f_i = sys.stdin
(n, q) = map(int, f_i.readline().split())
n = 2 ** math.ceil(math.log(n, 2))
A = [0 for i in range(2 * n - 1)]

def add(i, x):
	i += n - 2
	A[i] += x
	while i > 0:
		i = (i - 1) // 2
		A[i] += x

def getSum(s, t, k, l, r):
	if r < s or t < l:
		return 0
	elif s <= l and r <= t:
		return A[k]
	else:
		mid = (l + r) // 2
		lsum = getSum(s, t, k * 2 + 1, l, mid)
		rsum = getSum(s, t, k * 2 + 2, mid + 1, r)
		return lsum + rsum
for s_i in f_i:
	(com, x, y) = map(int, s_i.split())
	if com == 0:
		add(x, y)
	else:
		ans = getSum(x, y, 0, 1, n)
		print(ans)


def main():
	import sys
	input = sys.stdin.readline
	(n, q) = map(int, input().split())
	seg = []
	cnt = -1
	inf = 2 ** 31 - 1
	while 2 ** cnt <= n:
		cnt += 1
		seg.append([0 for _ in range(2 ** cnt)])

	def f(i, j):
		Range = (2 ** (cnt - i) * j, 2 ** (cnt - i) * (j + 1) - 1)
		if Range[0] > y or Range[1] < x:
			return 0
		elif Range[0] >= x and Range[1] <= y:
			return seg[i][j]
		else:
			return f(i + 1, 2 * j) + f(i + 1, 2 * j + 1)
	for _ in range(q):
		(c, x, y) = map(int, input().split())
		if c == 0:
			seg[-1][x] += y
			x //= 2
			for j in range(1, cnt + 1):
				seg[-j - 1][x] = seg[-j][x * 2] + seg[-j][x * 2 + 1]
				x //= 2
		else:
			print(f(0, 0))
main()


class Bit(object):

	def __init__(self, N):
		self.N = N
		self.bit = [0] * (N + 1)

	def add(self, a: int, w: int):
		x: int = a
		while x <= self.N:
			self.bit[x] += w
			x += x & -x

	def sum(self, a: int):
		ret: int = 0
		x: int = a
		while x > 0:
			ret += self.bit[x]
			x -= x & -x
		return ret

	def range_sum(self, x, y):
		ret1 = self.sum(y)
		ret2 = self.sum(x - 1)
		return ret1 - ret2
(N, q) = input().split()
N = int(N)
q = int(q)
bit = Bit(N)
for _ in range(q):
	(mode, x, y) = input().rstrip().split()
	if mode == '0':
		bit.add(int(x), int(y))
	else:
		ret = bit.range_sum(int(x), int(y))
		print(ret)


import math
(n, q) = map(int, input().split())
b_size = math.ceil(math.sqrt(n))
b_len = math.ceil(n / b_size)
a = [0 for i in range(n)]
b = [min(a[b_size * i:b_size * (i + 1)]) for i in range(b_len)]
for i in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		x -= 1
		a[x] += y
		index = x // b_size
		b[index] += y
	else:
		x -= 1
		y -= 1
		target = []
		x_index = x // b_size
		y_index = y // b_size
		x_mod = x % b_size
		y_mod = y % b_size
		if x_index == y_index:
			target.extend(a[x:y + 1])
		else:
			if x_mod == 0:
				target.append(b[x_index])
			else:
				target.extend(a[x:(x_index + 1) * b_size])
			if y_mod == b_size - 1:
				target.append(b[y_index])
			else:
				target.extend(a[y_index * b_size:y + 1])
			if x_index + 1 <= y_index - 1:
				target.append(sum(b[x_index + 1:y_index]))
		print(sum(target))


class BinaryIndexedTree(object):

	def __init__(self, N):
		self.N = N
		self.tree = [0] * (N + 1)

	def add(self, a, w):
		x = a
		while x <= self.N:
			self.tree[x] += w
			x += x & -x

	def sum(self, a):
		if a == 0:
			return 0
		s = 0
		x = a
		while x > 0:
			s += self.tree[x]
			x -= x & -x
		return s

def main():
	(N, Q) = map(int, input().split(' '))
	bit = BinaryIndexedTree(N)
	for i in range(Q):
		(c, x, y) = map(int, input().split(' '))
		if c == 0:
			bit.add(x, y)
		elif c == 1:
			print(bit.sum(y) - bit.sum(x - 1))
main()


import sys

class BIT:

	def __init__(self, node_size):
		self._node = node_size + 1
		self.bit = [0] * self._node

	def add(self, index, add_val):
		while index < self._node:
			self.bit[index] += add_val
			index += index & -index

	def sum(self, index):
		res = 0
		while index > 0:
			res += self.bit[index]
			index -= index & -index
		return res
(n, q) = map(int, sys.stdin.readline().split())
bt = BIT(n)
for i in range(q):
	(a, b, c) = map(int, sys.stdin.readline().split())
	if a == 0:
		bt.add(b, c)
	else:
		print(bt.sum(c) - bt.sum(b - 1))


import sys
input = sys.stdin.readline

class SegmentTree0:

	def __init__(self, n_, ele_id, op_func):
		self.n = 1 << (n_ - 1).bit_length()
		self.data = [ele_id] * (2 * self.n - 1)
		self.ele_id = ele_id
		self.op_func = op_func

	def __getitem__(self, i):
		return self.data[i + self.n - 1]

	def build(self, data_init):
		for i in range(len(data_init)):
			self.data[i + self.n - 1] = data_init[i]
		for i in range(self.n - 2, -1, -1):
			self.data[i] = self.op_func(self.data[2 * i + 1], self.data[2 * i + 2])

	def update(self, i, x):
		i += self.n - 1
		self.data[i] = x
		while i > 0:
			i = (i - 1) // 2
			self.data[i] = self.op_func(self.data[2 * i + 1], self.data[2 * i + 2])

	def query(self, a, b):
		return self.query_(a, b, 0, 0, self.n)

	def query_(self, a, b, k, l, r):
		if r <= a or b <= l:
			return self.ele_id
		if a <= l and r <= b:
			return self.data[k]
		else:
			child_l = self.query_(a, b, 2 * k + 1, l, (l + r) // 2)
			child_r = self.query_(a, b, 2 * k + 2, (l + r) // 2, r)
			return self.op_func(child_l, child_r)
(n, q) = map(int, input().split())
ele_id = 0
op_func = lambda a, b: a + b
st_rsq = SegmentTree0(n, ele_id, op_func)
for _ in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		x -= 1
		st_rsq.update(x, st_rsq[x] + y)
	elif com == 1:
		x -= 1
		y -= 1
		ans = st_rsq.query(x, y + 1)
		print(ans)


import sys

def init(n_):
	length = 1
	while length < n_:
		length *= 2
	element = [0] * (2 * length - 1)
	for i in range(2 * length - 1):
		element[i] = 0
	return (element, length)

def update(k, a, element):
	k += n - 1
	element[k] += a
	while k > 0:
		k = int((k - 1) / 2)
		element[k] = element[k * 2 + 1] + element[k * 2 + 2]

def findmin(a, b):
	return findquery(a, b + 1, 0, 0, n)

def findquery(a, b, k, l, r):
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return element[k]
	vl = findquery(a, b, k * 2 + 1, l, int((l + r) / 2 + 0.5))
	vr = findquery(a, b, k * 2 + 2, int((l + r) / 2), r)
	return vl + vr
(n, q) = map(int, input().split())
(element, n) = init(n)
for i in range(q):
	(query, key, value) = map(int, input().split())
	if query == 0:
		update(key - 1, value, element)
	else:
		print(findmin(key - 1, value - 1))


import operator

class SegmentTree:

	def __init__(self, size, fn=operator.add, default=0):
		n = 1
		while n < size:
			n *= 2
		self._size = n
		self._tree = [default for _ in range(self._size * 2 - 1)]
		self._fn = fn

	def set(self, i, value):
		x = self._size - 1 + i
		self._tree[x] = value
		while x > 0:
			x = (x - 1) // 2
			self._tree[x] = self._fn(self._tree[x * 2 + 1], self._tree[x * 2 + 2])

	def add(self, i, value):
		x = self._size - 1 + i
		self.set(i, self._fn(self._tree[x], value))

	def get(self, from_i, to_i, k=0, L=None, r=None):
		L = 0 if L is None else L
		r = self._size if r is None else r
		if from_i <= L and r <= to_i:
			return self._tree[k]
		if to_i <= L or r <= from_i:
			return None
		ret_L = self.get(from_i, to_i, k * 2 + 1, L, (L + r) // 2)
		ret_r = self.get(from_i, to_i, k * 2 + 2, (L + r) // 2, r)
		if ret_L is None:
			return ret_r
		if ret_r is None:
			return ret_L
		return self._fn(ret_L, ret_r)

	def __len__(self):
		return self._size
(N, Q) = list(map(int, input().split()))
(com, X, Y) = zip(*[input().split() for _ in range(Q)])
X = list(map(int, X))
Y = list(map(int, Y))
st = SegmentTree(size=N + 1, fn=operator.add, default=0)
for (c, x, y) in zip(com, X, Y):
	if c == '0':
		st.add(x, y)
	if c == '1':
		print(st.get(x, y + 1))


(n, q) = map(int, input().split())
bit = [0] * (n + 1)

def add(a, w):
	x = a
	while x <= n:
		bit[x] += w
		x += x & -x

def sum(a):
	ret = 0
	x = a
	while x > 0:
		ret += bit[x]
		x -= x & -x
	return ret
for j in range(q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		add(x, y)
	else:
		print(sum(y) - sum(x - 1))


(n, q) = map(int, input().split())
n_ = 1
while n_ < n:
	n_ *= 2
seg_tree = [0 for i in range(2 * n_ - 1)]

def add(i, x):
	i += n_ - 1
	seg_tree[i] += x
	while i > 0:
		i = int((i - 1) / 2)
		seg_tree[i] += x

def getSum(s, t):
	return query(s, t + 1, 0, 0, n_)

def query(a, b, k, l, r):
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return seg_tree[k]
	vl = query(a, b, k * 2 + 1, l, int((l + r) / 2))
	vr = query(a, b, k * 2 + 2, int((l + r) / 2), r)
	return vl + vr
output = []
for i in range(q):
	line = list(map(int, input().split()))
	if line[0] == 0:
		add(line[1] - 1, line[2])
	else:
		output.append(getSum(line[1] - 1, line[2] - 1))
for ans in output:
	print(ans)


import sys, math, itertools, collections, bisect
input = lambda : sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10 ** 9 + 7
mans = inf
ans = 0
count = 0
pro = 1

class BIT:

	def __init__(self, size):
		self.data = [0] * (size + 1)
		self.size = size

	def sum(self, n):
		res = 0
		while n > 0:
			res += self.data[n]
			n -= n & -n
		return res

	def add(self, k, x):
		while k < self.size + 1:
			self.data[k] += x
			k += k & -k
(n, q) = map(int, input().split())
bit = BIT(n)
for _ in range(q):
	(typo, x, y) = map(int, input().split())
	if typo == 0:
		bit.add(x, y)
	else:
		print(bit.sum(y) - bit.sum(x - 1))


def update(idx, x):
	idx += size - 1
	seg[idx] += x
	while idx > 0:
		idx = (idx - 1) // 2
		seg[idx] = seg[2 * idx + 1] + seg[2 * idx + 2]
	return

def query(a, b, k, l, r):
	if r <= a or b <= l:
		return INF
	if a <= l and r <= b:
		return seg[k]
	else:
		c1 = query(a, b, 2 * k + 1, l, (l + r) // 2)
		c2 = query(a, b, 2 * k + 2, (l + r) // 2, r)
		return c1 + c2
(N, Q) = map(int, input().split())
size = 1
while N > size:
	size *= 2
INF = 0
seg = [INF] * (2 * size - 1)
for _ in range(Q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		x -= 1
		update(x, y)
	else:
		x -= 1
		y -= 1
		print(query(x, y + 1, 0, 0, size))


(n, q) = [int(s) for s in input().split()]
bit = [0] * (n + 1)

def add(a, w):
	x = a
	while x <= n:
		bit[x] += w
		x += x & -x

def sum(a):
	ret = 0
	x = a
	while x > 0:
		ret += bit[x]
		x -= x & -x
	return ret
for _ in range(q):
	(com, x_i, y_i) = [int(s) for s in input().split()]
	if com == 0:
		add(x_i, y_i)
	else:
		ans = sum(y_i) - sum(x_i - 1)
		print(ans)


class BinaryIndexedTree:

	def __init__(self, n):
		self.n = n
		self.bit = [0] * (n + 1)

	def sum(self, i):
		s = 0
		while i > 0:
			s += self.bit[i]
			i -= i & -i
		return s

	def add(self, i, x):
		while i <= self.n:
			self.bit[i] += x
			i += i & -i

	def reset(self):
		self.bit = [0] * (self.n + 1)
(N, Q) = map(int, input().split())
BIT = BinaryIndexedTree(N)
for q in range(Q):
	(com, x, y) = map(int, input().split())
	if com == 0:
		BIT.add(x, y)
	if com == 1:
		print(BIT.sum(y) - BIT.sum(x - 1))


import sys
sys.setrecursionlimit(10 ** 9)

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))
INF = float('inf')

class BIT:

	def __init__(self, n):
		nv = 1
		while nv < n:
			nv *= 2
		self.size = nv
		self.tree = [0] * nv

	def sum(self, i):
		s = 0
		i += 1
		while i > 0:
			s += self.tree[i - 1]
			i -= i & -i
		return s

	def add(self, i, x):
		i += 1
		while i <= self.size:
			self.tree[i - 1] += x
			i += i & -i

	def get(self, l, r=None):
		if r is None:
			r = l + 1
		res = 0
		if r:
			res += self.sum(r - 1)
		if l:
			res -= self.sum(l - 1)
		return res
(N, Q) = MAP()
bit = BIT(N + 1)
for _ in range(Q):
	(com, x, y) = MAP()
	if com == 0:
		bit.add(x, y)
	else:
		print(bit.get(x, y + 1))