{-# LANGUAGE FlexibleContexts #-}

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Bits
import Data.Int
import Debug.Trace

main = do
  [n,q] <- map read . words <$> getLine :: IO [Int]
  queries <- replicateM q $ map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine :: IO [[Int]]



  seg <- stToIO $ newSegmentTree n 0 :: IO (IOSegmentTree Int)

  forM_ queries $ \[com,x,y] -> do
    when (com == 0) $ do
      stToIO $ updateSegmentTree seg x y (+)
    when (com == 1) $ do
      a <- stToIO $ findSegmentTree seg x (y+1) 0 (+)
      print a



type STSegmentTree s a = VM.MVector s a
type IOSegmentTree a = STSegmentTree RealWorld a

newSegmentTree :: Num a => Int -> a ->  ST s (STSegmentTree s a)
newSegmentTree n x = V.thaw $ V.replicate m x
  where m = 2 * (2 ^ (ceiling $ logBase 2 (fromIntegral n))) - 1


updateSegmentTree :: Num a => STSegmentTree s a -> Int -> a -> (a -> a -> a) -> ST s ()
updateSegmentTree tree i x f = do
  let
    n = (VM.length tree + 1) `div` 2
    j = i + n - 1
  VM.write tree j x
  aux ((j-1)`div`2) x
  where
    aux i x = do
      when (i >= 0) $ do
        VM.write tree i =<< f <$> VM.read tree (i*2+1) <*> VM.read tree (i*2+2)
        aux ((i-1)`div`2) x
      

findSegmentTree :: Num a => STSegmentTree s a -> Int -> Int -> a -> (a -> a -> a) -> ST s a
findSegmentTree tree x y e f = do
  let n = (VM.length tree) `div` 2 + 1
  aux 0 0 n
  where
    aux i l r
      | r <= x || y <= l = return e
      | x <= l && r <= y = VM.read tree i
      | otherwise = f <$> aux (i*2+1) l ((l+r)`div`2) <*> aux (i*2+2) ((l+r)`div`2) r

