jiahuimbzuai/CoQuIR huggingface dataset:
//  [ruby]
# https://atcoder.jp/contests/abc113/tasks/abc113_c

n, m = gets.split.map(&:to_i)

prefs = Array.new(10**6).map { Array.new }
City = Struct.new("City", :pref, :year, :index)
cities = []
m.times do
  pref, year = gets.split.map(&:to_i)
  city = City.new(pref, year, nil)
  prefs[pref] << city
  cities << city
end

prefs.reject(&:nil?).each do |pref|
  sorted_pref_cities = pref.sort_by { |c| c.year }
  sorted_pref_cities.each_with_index { |c, idx| c.index = idx + 1 }
end
cities.each { |i| printf "%06d%06d\n", i.pref, i.index }
//  [ruby]
class Heap
  attr_reader :size

  def initialize
    @heap = []
    @data = {}
    @size = 0
  end

  def add(n, data)
    i = @size
    while i > 0 do
      parent_index = (i - 1) / 2
      break if n >= @heap[parent_index]

      @heap[i] = @heap[parent_index]
      i = parent_index
    end

    @heap[i] = n
    @data[n] = data.merge(key: n)
    @size += 1
  end

  def pop
    min_n = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size do
      child_index1 = i * 2 + 1
      child_index2 = i * 2 + 2
      if child_index2 < @size && @heap[child_index2] < @heap[child_index1]
        child_index1 = child_index2
      end
      break if @heap[child_index1] >= n

      @heap[i] = @heap[child_index1]
      i = child_index1
    end
    @heap[i] = n
    @data.delete(min_n)
  end

  def min; @heap[0] end
  def values; @heap.first(@size) end
  def inspect; "Heap: #{values}" end
end

N, M = gets.split.map(&:to_i)
heaps = {}
cities = []
M.times do |i|
  pref, year = gets.split.map(&:to_i)
  heaps[pref] ||= Heap.new
  heaps[pref].add(year, {n: i})
  cities[i] = {p: pref}
end

# p heaps
heaps.each do |pref, heap|
  o = 1
  while c = heap.pop
    cities[c[:n]][:o] = o
    o += 1
  end
end

cities.each do |city|
  puts "%06d%06d" % [city[:p], city[:o]]
end
//  [rust]
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (_n, m) = i.read2::<usize, usize>();
    let mut py = Vec::new();
    for c in 0..m {
        py.push((i.read2::<usize, usize>(), c));
    }
    py.sort();

    let mut p_last = None;
    let mut idx = 0;

    let mut rs = vec![(0, 0); m];
    for ((p, _y), c) in py {
        if Some(p) != p_last {
            idx = 0;
            p_last = Some(p);
        }
        idx += 1;
        rs[c] = (p, idx);
    }

    for r in rs {
        writeln!(o, "{:>06}{:>06}", r.0, r.1).unwrap();
    }
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}
//  [rust]
use std::io::{stdout, Write, BufWriter};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        p: [(usize, usize); m],
    }
    let mut py: Vec<((usize, usize), usize)> = p.into_iter().zip(1..).collect();
    py.sort_by_key(|t| (t.0).1);

    let mut kens = vec![1; n];
    for i in 0..m {
        (py[i].0).1 = kens[(py[i].0).0 - 1];
        kens[(py[i].0).0 - 1] += 1;
    }
    py.sort_by_key(|t| t.1);

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    for i in 0..m {
        writeln!(out, "{0: >06}{1: >06}", (py[i].0).0, (py[i].0).1).unwrap();
    }
}
//  [rust]
use proconio::{input, fastout, marker::Usize1};

#[fastout]
fn main() {
    input! {
        n: usize, m: usize,
        arr: [(Usize1, usize); m],
    }

    let mut mm: Vec<Vec<usize>> = vec![vec![]; n];
    for &(p, y) in &arr {
        mm[p].push(y);
    }

    for v in mm.iter_mut() {
        v.sort();
    }

    for &(p, y) in &arr {
        println!("{:06}{:06}", p+1, mm[p].binary_search(&y).unwrap()+1)
    }
}
//  [rust]
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        m:usize,
        py: [(usize, u64);m],
    }
    let mut v:Vec<Vec<(u64, usize)>> = vec![vec![];n];
    for i in 0..m {
        v[py[i].0 - 1].push((py[i].1, i));
    }
    for i in 0..n {
        v[i].sort_by_key(|k| k.0);
    }
    let mut ans:Vec<(String, usize)> = Vec::new();
    for i in 0..n {
        let mut ind = 0;
        for &(_j, org) in &v[i] {
            ind+=1;
            ans.push((format!("{0:>06}{1:>06}", i+1, ind), org));
        }
    }
    ans.sort_by_key(|k| k.1);
    for a in ans {
        println!("{}", a.0);
    }
}
//  [rust]
use std::collections::{BinaryHeap, HashMap};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve(v: Vec<(usize, usize)>) {
    let mut map = {
        let mut m = HashMap::new();
        for &(k, v) in v.iter() {
            if !m.contains_key(&k) {
                let mut b = BinaryHeap::new();
                b.push(v);
                m.insert(k, b);
            } else {
                m.get_mut(&k).unwrap().push(v);
            }
        }
        m
    };
    let n = map.clone();
    let townpage = {
        let mut ret = HashMap::new(); // <(usize, usize), String>
        for (k,_) in n.iter() {
            let v = map.get_mut(k).unwrap();
            let mut c = v.len();
            loop {
                if let Some(n) = v.pop() {
                    ret.insert((k, n), format!("{:06}{:06}", k, c));
                    c -= 1;
                } else {
                    break;
                }
            }
        }
        ret
    };
    for &(x, y) in v.iter() {
        println!("{}", townpage.get(&(&x, y)).unwrap());
    }
}

fn main() {
    input! {
        _n: usize,
        m: usize,
        pys: [(usize, usize); m]
    };
    solve(pys);
}
//  [typescript]
const pad = (s) => `000000${s}`.slice(-6)

const solve = (input) => {
  const [head, ...l] = input.split("\n")
  const mm = l.map((v, l) => {
    const [pref, year] = v.split(" ").map(Number)
    return {
      idx: l,
      pref,
      year
    }
  })
  let r = []
  let mm2 = mm.sort((a, b) => a.year - b.year)
  let prefIdx = []
  mm2.map(({ idx, pref, year }) => {
    if (prefIdx[pref] === undefined) {
      prefIdx[pref] = 1
    }
    r[idx] = `${pad(pref)}${pad(prefIdx[pref])}`
    prefIdx[pref]++
  })
  return r.join("\n")
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}
//  [typescript]
const inlt = new Intl.NumberFormat("ja-JP", {
  minimumIntegerDigits: 6,
  useGrouping: false
})
const pad = (s) => inlt.format(s)

const solve = (input) => {
  const [head, ...l] = input.split("\n")
  const mm = l.map((v, l) => {
    const [pref, year] = v.split(" ").map(Number)
    return {
      idx: l,
      pref,
      year
    }
  })
  let r = []
  let mm2 = mm.sort((a, b) => a.year - b.year)
  let prefIdx = []
  mm2.map(({ idx, pref, year }) => {
    if (prefIdx[pref] === undefined) {
      prefIdx[pref] = 1
    }
    r[idx] = `${pad(pref)}${pad(prefIdx[pref])}`
    prefIdx[pref]++
  })
  return r.join("\n")
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [n, m] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)
const [_, ..._py] = stdin.split('\n')
const py = _py.map((v, i) => [...v.split(' ').map(Number), i])

const ans = () => {
  const pys = py.sort((a, b) => a[1] - b[1])

  let prefs = []

  let codeList = []

  for (let i = 0; i < m; i++) {
    const [p, y, idx] = pys[i]

    if (prefs[p] === undefined) {
      prefs[p] = 1
    } else {
      prefs[p]++
    }

    const x = prefs[p]
    const codeP = `000000${p}`.slice(-6)
    const codeX = `000000${x}`.slice(-6)

    const code = `${codeP}${codeX}`

    codeList[idx] = code
  }

  for (let i = 0; i < m; i++) {
    console.log(codeList[i])
  }
}

ans()
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const [n, m] = input[0].split(" ").map(a => Number(a));
  const pys = input.slice(1).map(a => a.split(" ").map(b => Number(b)));
  const originalPys = pys.slice();
  pys.sort((a, b) => {
    const [ap, ay] = a;
    const [bp, by] = b;
    if (ap === bp) return ay-by;
    return ap-bp;
  });
  const map = {};
  let prevNo;
  for(let i = 0; i < m; i++) {
    const [p, y] = pys[i];
    const pDigit = ("" + p).length;
    const pStr = Array(6-pDigit).fill(0).join("") + p;
    const no = (() => {
      if (i === 0) return 1;
      if (pys[i-1][0] === p) return prevNo + 1;
      return 1;
    })();
    const noDigit = ("" + no).length;
    const noStr = Array(6-noDigit).fill(0).join("") + no;
    map[p + "-" + y] = pStr + noStr;
    prevNo = no;
  }
  for(const py of originalPys) {
    const [p, y] = py;
    console.log(map[p + "-" + y]);
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [python]
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rgL2kk@5WGjqANJCc6oZ1)N>v0s^nlb;A3#x+#7<(>*x)#U{=VzlC8n?^XJ#@xyLPSB4ytd{DmmX5x)6d1sQ7NLw1K@YWW(a9wj#mHYTg;j)tPUYsoFvl6mn^50v$6$+2i5!?S1{aM!-<jn>eZ{t3fE)Y@RZ##TKXst-)rI`Pu^h9!K6MalaF|@H~rCZ-Korl1x&Ns^KD!BfvUSC4mZ7kU99+a=~EXMYc*L{Uk{`!n{Ui36IY?l$sS^BV*kvc)%bqMa>K~j?~QbT0-S>4T@7JC{1h%PJY9jE<?IB9F{APK_t52TbQok6vVOL9PVMpgLOjJ@0|UO;ho_B=p0@k3wm|d*ftD%&Bk8AU|q0qX_sJ^PT(*eaZ0?dp1=@CM{e4SP_@$N%B6o-iA;019$e#sIE(bQ^pFOL&0oI}>aU^U8p10zxqqz5<WA5JIU&C*98$bSd+5_Z&qT*u#NI_5ko*DG!`1i")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve
//  [python]
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode('c${rg!EWj>5WFMt4=bvtLJ2Wdd#F&;Uw9X8eF!=B1}q%gwH=^;|JF%>RK=GhGvnFa**t($AvRIzuma7^uHic@#C$#;J%IR*duwj^R^t(M@iOG_96jF(TRWw3%l$4Ci@y~QF^LA=$_U*^+)Cv`@yYhKMkcI@7$P^3<=P6anN}rpt@BI%#)68ta9kXyc3`Hd-8bFw$a=F3n01lyD6B-k2vKjwBO$R$U7<Hnd0WHey%(?w%}I$v^oSo5FucY<?g*1!Fj<X9K&Q13&I!#!fd1AtUHe>bdQCb*W~xjCGrN&Tt0ZtKTf$|qhVy`3Lul%j(ix<OCvrS$8>SFM9->qhgsPqO5q22Gp8E`(Cvi0pI+q_&MC-5G?z0a<8LbR<6_Cs6Y&c><%M1h*u<YQ|p0)_jgBeRA`|8sfEa3I+#;J<vcUZ2VB=f_KNR9%Y;CTsiC_CI^Y-lCo+8D(}vaYKPz6S3qOM#uUl+9(3A6wAY>^AUJsz|pCp6;;Iw2O*jQB(>%{lQ2Ob*f_CZYAr>{g!=QLZbP8gqDuJ_Ibnn9jsf_^zo0D|IB07)=eu<Bh7jp>VN}lcgN;@2fK`rG9vgt%e@>0')))
    os.system('cythonize -i -3 -b solve.pyx')
import solve
//  [python]
class Fenwick_Tree:
    def __init__(self, n):
        self._n = n
        self.data = [0] * n
    
    def add(self, p, x):
        assert 0 <= p < self._n
        p += 1
        while p <= self._n:
            self.data[p - 1] += x
            p += p & -p
    
    def sum(self, l, r):
        assert 0 <= l <= r <= self._n
        return self._sum(r) - self._sum(l)
    
    def _sum(self, r):
        s = 0
        while r > 0:
            s += self.data[r - 1]
            r -= r & -r
        return s


def main():
    n, q = map(int, input().split())
    fw = Fenwick_Tree(n)
    for i, a in enumerate(map(int, input().split())): fw.add(i, a)
    for _ in range(q):
        t, a, b = map(int, input().split())
        if t == 0:
            fw.add(a, b)
        else:
            print(fw.sum(a, b))

if __name__ == "__main__":
    main()
//  [python]
class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(self.n+1) # 1-indexed
 
    def init(self, init_val):
        for i, v in enumerate(init_val):
            self.add(i, v)
 
    def add(self, i, x):
        # i: 0-indexed
        i += 1 # to 1-indexed
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)
 
    def sum(self, i, j):
        # return sum of [i, j)
        # i, j: 0-indexed
        return self._sum(j) - self._sum(i)
 
    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & (-i)
        return res
 
    def lower_bound(self, x):
        s = 0
        pos = 0
        depth = self.n.bit_length()
        v = 1 << depth
        for i in range(depth, -1, -1):
            k = pos + v
            if k <= self.n and s + self.bit[k] < x:
                    s += self.bit[k]
                    pos += v
            v >>= 1
        return pos

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

bit = BIT(n)
bit.init(A)

for _ in range(q):
  i, j, k = map(int, input().split())
  if i == 0:
    bit.add(j, k)
  else:
    print(bit.sum(j, k))
//  [python]
# test
class fenwick_tree:
  def __init__(s, n):
    s._n = n
    s.data = [0] * n

  def add(s, p, x):
    p += 1
    while p <= s._n:
      s.data[p - 1] += x
      p += p & -p

  def sumlr(s, l, r):
    return s.sum(r) - s.sum(l)

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


N, Q = list(map(int, input().split()))
a = list(map(int, input().split()))
Query = [list(map(int, input().split())) for _ in range(Q)]
  
bit = fenwick_tree(N)
for i in range(N):
  bit.add(i, a[i])

for q in Query:
  if q[0] == 0:
    _, p, x = q
    bit.add(p, x)
  else:
    _, l, r = q
    print(bit.sumlr(l, r))
//  [java]
import java.util.*;

class FenwickTree{
    private int _n;
    private long[] data;

    public FenwickTree(int n){
        this._n = n;
        data = new long[n];
    }

    public void add(int p, long x){
        assert(0<=p && p<_n);
        p++;
        while(p<=_n){
            data[p-1] += x;
            p += p&-p;
        }
    }
    public long sum(int l, int r){
        assert(0<=l && l<=r && r<=_n);
        return sum(r)-sum(l);
    }

    private long sum(int r){
        long s = 0;
        while(r>0){
            s += data[r-1];
            r -= r&-r;
        }
        return s;
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int Q = sc.nextInt();
        FenwickTree fw = new FenwickTree(N);
        for(int n=0; n<N; n++){
            long a = sc.nextLong();
            fw.add(n, a);
        }
        for(int q=0; q<Q; q++){
            int t = sc.nextInt();
            if(t==0){
                int p = sc.nextInt();
                long x = sc.nextLong();
                fw.add(p, x);
            }else{
                int l = sc.nextInt();
                int r = sc.nextInt();
                System.out.println(fw.sum(l, r));
            }
        }
        
        
    }
}
//  [java]
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int q = sc.nextInt();
        long[] a = new long[n];
        BIT bit = new BIT(n);
        for (int i=0; i<n; i++) a[i] = sc.nextLong();
        for (int i=0; i<n; i++) bit.add(i+1, a[i]);
        StringBuilder sb = new StringBuilder();
        for (int i=0; i<q; i++) {
            int t = sc.nextInt();
            if (t == 0) {
                int p = sc.nextInt();
                int x = sc.nextInt();
                bit.add(p+1, x);
            } else {
                int l = sc.nextInt();
                int r = sc.nextInt();
                long diff = bit.sum(r) - bit.sum(l);
                sb.append(diff + "\n");
            }
        }

        System.out.print(sb.toString());

    }

    class BIT {
        int n;
        long[] arr;

        public BIT(int n) {
            this.n = n;
            arr = new long[n + 1];
        }

        void add(int idx, long val) {
            for (int i = idx; i <= n; i += i & -i) {
//                System.out.print(i);
                arr[i] += val;
            }
        }

        long sum(int idx) {
            long sum = 0;
            for (int i = idx; i > 0; i -= i & -i) {
                sum += arr[i];
            }
            return sum;
        }
    }


}
//  [cpp]
#include <iostream>
#include <atcoder/fenwicktree>

using namespace std;
using namespace atcoder;

int main() {
    int N,Q;
    cin >> N >> Q;
    fenwick_tree<long long int> fw(N);
    for(int i=0;i<N;i++) {
        int a;
        cin >> a;
        fw.add(i, a);
    }

    for(int i=0;i<Q;i++) {
        int t,c,d;
        cin >> t >> c >> d;
        if(t==0){
            fw.add(c, d);
        }else{
            cout << fw.sum(c, d) << endl;
        }
    }
}
//  [cpp]
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
#include<atcoder/all>
ll op(ll a, ll b){
    return a + b;
}
ll e(){
    return 0;
}
int main(void){
    ll n, q;
    cin >> n >> q;
    
    atcoder::segtree<ll, op, e> sgt(n);

    rep(i, n){
        ll a;
        cin >> a;
        sgt.set(i, a);
    }

    rep(i, q){
        ll t, a, b;
        cin >> t >> a >> b;
        if(t == 0){
            sgt.set(a, sgt.get(a) + b);
        } else {
            cout << sgt.prod(a, b) << endl;
        }
    }
}
//  [cpp]
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rep2(i,s,t) for(int i = s; i <= t; ++i)
#define rev(i,n) for(int i = n-1; i >= 0; --i)
#define rev1(i,n) for(int i = n; i > 0; --i)
#define rev2(i,s,t) for(int i = s; i >= t; --i)
#define F first
#define S second
using namespace std;
using namespace atcoder;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
using vii = vector<vi>;
int main()
{
  int n,q; cin >> n >> q;

  fenwick_tree<ll> fw(n);
  rep(i,n) {
    ll a; cin >> a;
    fw.add(i, a);
  }

  rep(i,q) {
    int t; cin >> t;
    if(t == 0) {
      int p, x; cin >> p >> x;
      fw.add(p, x);
    }
    else {
      int l, r; cin >> l >> r;
      cout << fw.sum(l, r) << "\n";
    }
  }
  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0;
	if(idx == 0)read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<buf_sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<buf_sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=buf_sz)exit(1);
	return res;
}

long data[1<<19];
void fen_add(int p, long x, int N){
	p++;
	while(p<=N){
		data[p-1] += x;
		p += p & -p;
	}
}
long fen_sum(int r){
	long s = 0;
	while(r > 0){
		s += data[r-1];
		r -= r & -r;
	}
	return s;
}
long fen_range(int l, int r){
	return fen_sum(r) - fen_sum(l);
}

int main(){
	int N = nextint(), Q = nextint();
	for(int i=0; i<N; i++)fen_add(i, nextint(), N);
	while(Q--){
		if(nextint() == 1)printf("%ld\n", fen_range(nextint(), nextint()));
		else fen_add(nextint(), nextint(), N);
	}
	return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0;
	if(idx == 0)read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<buf_sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<buf_sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=buf_sz)exit(1);
	return res;
}

long data[1<<19];
void fen_add(int p, long x, int N){
	p++;
	while(p<=N){
		data[p-1] += x;
		p += p & -p;
	}
}
long fen_sum(int r){
	long s = 0;
	while(r > 0){
		s += data[r-1];
		r -= r & -r;
	}
	return s;
}
inline long fen_range(int l, int r){
	return fen_sum(r) - fen_sum(l);
}

int main(){
	int N = nextint(), Q = nextint();
	for(int i=0; i<N; i++)fen_add(i, nextint(), N);
	while(Q--){
		int t = nextint(), x = nextint(), y = nextint();
		if(t)printf("%ld\n", fen_range(x, y));
		else fen_add(x, y, N);
	}
	return 0;
}
//  [c]
#include<stdio.h>
int N;
long data[] = {[0 ... 1<<19] 0};
void fen_add(int p, long x){
	p++;
	while(p <= N){
		data[p-1] += x;
		p += p & -p;
	}
}
long fen_sum(int r){
	long s = 0;
	while(r > 0){
		s += data[r-1];
		r -= r & -r;
	}
	return s;
}
long fen_range(int l, int r){
	return fen_sum(r) - fen_sum(l);
}

int Q;
int main(){
	scanf("%d%d", &N, &Q);
	for(int i=0; i<N; i++){
		int a;
		scanf("%d", &a);
		fen_add(i, a);
	}
	while(Q--){
		int t, x, y;
		scanf("%d%d%d", &t, &x, &y);
		if(t) printf("%ld\n", fen_range(x, y));
		else fen_add(x, y);
	}
	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define ll long long

//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a;}atai;
atai xx(atai x,atai y){
	atai r;
	r.a=x.a+y.a;//sum
	return r;
}
atai aid={0};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/


int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	seguse(1<<19);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		seg[i].a=t;
	}
	seginit();
	
	while(q--){
		int t,x,y;
		scanf("%d%d%d",&t,&x,&y);
		if(t==0){
			atai aaa={seg[x].a+y};
			segupdate(x,aaa);
		}else{
			printf("%lld\n",segcalc(x,y).a);
		}
	}
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdbool.h>

int ceil_pow2(int n){
	int res = 0;
	while(1U<<res < (unsigned int)n)res++;
	return res;
}

typedef int64_t Int;
Int segtree_op(Int a, Int b){return a + b;}
const Int segtree_id = 0;

Int* segtree(int n){
	int lg = ceil_pow2(n);
	Int* res = (Int*)malloc(sizeof(Int) * (1<<lg) * 2);
	for(int i=0; i<=(1<<lg)*2; i++)res[i] = segtree_id;
	return res;
}
void update(Int arr[], int k){arr[k] = segtree_op(arr[k*2], arr[2*k+1]);}
void set(Int arr[], int n, int p, Int x){
	int lg = ceil_pow2(n);
	p += 1<<lg;
	arr[p] = x;
	for(int i=1; i<=lg; i++)update(arr, p>>i);
}
void _set(Int arr[], int n, int p, Int x){
	int lg = ceil_pow2(n);
	p += 1<<lg;
	arr[p] = segtree_op(arr[p], x);
	for(int i=1; i<=lg; i++)update(arr, p>>i);
}
Int get(Int arr[], int n, int p){
	return arr[p +(1<<ceil_pow2(n))];
}
Int prod(Int arr[], int n, int l, int r){
	Int sml = segtree_id, smr = segtree_id;
	int lg = ceil_pow2(n);
	l += 1<<lg;
	r += 1<<lg;
	while(l < r){
		if(l & 1) sml = segtree_op(sml, arr[l++]);
		if(r & 1) smr = segtree_op(arr[--r], smr);
		l >>= 1;
		r >>= 1;
	}
	return segtree_op(sml, smr);
}
Int all_prod(Int arr[]){return arr[1];}
int max_right(Int arr[], int n, int l, bool (*f)(Int)){
	if(l == n) return n;
	int lg = ceil_pow2(n);
	int size = 1<<lg;
	l += size;
	Int sm = segtree_id;
	do{
		while(l % 2 == 0) l >>= 1;
		if(!f(segtree_op(sm, arr[l]))){
			while(l < size){
				l = 2*l;
				if(f(segtree_op(sm, arr[l]))){
					sm = segtree_op(sm, arr[l]);
					l++;
				}
			}
			return l - size;
		}
		sm = segtree_op(sm, arr[l]);
		l++;
	}while((l & -l) != l);
	return n;
}
int min_right(Int arr[], int n, int r, bool (*f)(Int)){
	if(r == 0) return 0;
	int lg = ceil_pow2(n);
	int size = 1<<lg;
	r += size;
	Int sm = segtree_id;
	do{
		r--;
		while(r>1 && r&1) r >>= 1;
		if(!f(segtree_op(arr[r], sm))){
			while(r < size){
				r = 2*r + 1;
				if(f(segtree_op(arr[r], sm))){
					sm = segtree_op(arr[r], sm);
					r--;
				}
			}
			return r + 1 - size;
		}
		sm = segtree_op(arr[r], sm);
	}while((r & -r) != r);
	return 0;
}

int main(){
	int N, Q;
	scanf("%d%d", &N, &Q);
	Int *d = segtree(N);
	for(int i=0; i<N; i++){
		int A;
		scanf("%d", &A);
		set(d, N, i, A);
	}
	while(Q--){
		int T, X, Y;
		scanf("%d%d%d", &T, &X, &Y);
		if(T == 1)printf("%ld\n", prod(d, N, X, Y));
		else _set(d, N, X, Y);
	}
	return 0;
}
//  [c]
#include<stdio.h>
long long int seg[2000006];
long long int ss;
void set(long long int i, long long int x)
{
	i += ss - 1;
	seg[i] += x;
	while (i > 0)
	{
		i = (i - 1) / 2;
		seg[i] = seg[2 * i + 1] + seg[2 * i + 2];
	}
	return;
}
long long int get(long long int l, long long int r)
{
	l += ss - 1;
	r += ss - 1;
	long long int res = 0;
	while (l < r)
	{
		if (l % 2 == 0)
			res += seg[l];
		l /= 2;
		if (r % 2 > 0)
			res += seg[r];
		r = r / 2 - 1;
	}
	if (l == r)
		res += seg[l];
	return res;
}
int main()
{
	long long int n, q;
	scanf("%lld %lld", &n, &q);
	long long int i;
	ss = 1;
	while (ss < n)
		ss *= 2;
	for (i = 0; i < n; i++)
		scanf("%lld", &seg[i + ss - 1]);
	for (i = ss - 2; i >= 0; i--)
		seg[i] = seg[2 * i + 1] + seg[2 * i + 2];
	long long int x, y, z;
	for (i = 0; i < q; i++)
	{
		scanf("%lld %lld %lld", &x, &y, &z);
		if (x == 0)
			set(y, z);
		else
			printf("%lld\n", get(y, z - 1));
	}
	return 0;
}
//  [javascript]
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

class BIT{
  constructor(n){
    this.a = Array(n+1).fill(0);
  }
  add(val,id){
    for(var x=val,i=id;i<this.a.length;i+=i&-i)this.a[i]+=x;
  }
  get(id){
    for(var r=0,i=id;i;i-=i&-i)r+=this.a[i];
    return r;
  }
  range(l,r){//[l,r]
    return this.get(r) - this.get(l-1);
  }
}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var [n,q] = nexts(2);
  var bi = new BIT(n);
  for(var i = 1; i <= n; i++){
    var a = next();
    bi.add(a,i);
  }
  for(var i = 0; i < q; i++){
    var [t,x,y] = nexts(3);
    if(t){
      print(bi.range(x+1,y));
    }else{
      bi.add(y,x+1);
    }
  }
}
//  [ruby]
# frozen_string_literal: true

# Fenwick Tree
class FenwickTree
  def initialize(arg)
    case arg
    when Array
      @size = arg.size
      @data = Array.new(@size + 1, 0)
      arg.each_with_index { |e, i| add(i + 1, e) }
    when Integer
      @size = arg
      @data = Array.new(@size + 1, 0)
    else
      raise ArgumentError
    end
  end

  def add(i, x)
    while i <= @size
      @data[i] += x
      i += (i & -i)
    end
  end

  def sum(l, r)
    _sum(r) - _sum(l)
  end

  def _sum(i)
    res = 0
    while i > 0
      res += @data[i]
      i &= i - 1
    end
    res
  end
end

FeTree            = FenwickTree
BinaryIndexedTree = FenwickTree

n, q = gets.split.map { |e| e.to_i }
a    = gets.split.map { |e| e.to_i }
 
ft = FeTree.new(a)
 
q.times do
  t, u, v = gets.split.map { |e| e.to_i }
 
  if t == 0
    ft.add(u + 1, v)
  else
    puts ft.sum(u, v)
  end
end
//  [ruby]
# frozen_string_literal: true
 
# Fenwick Tree
class FenwickTree
  def initialize(arg)
    case arg
    when Array
      @size = arg.size
      @data = Array.new(@size + 1, 0)
      arg.each.with_index(1) { |e, i| add(i, e) }
    when Integer
      @size = arg
      @data = Array.new(@size + 1, 0)
    else
      raise ArgumentError
    end
  end
 
  def add(i, x)
    while i <= @size
      @data[i] += x
      i += (i & -i)
    end
  end
 
  def sum(l, r)
    _sum(r) - _sum(l)
  end
 
  def _sum(i)
    res = 0
    while i > 0
      res += @data[i]
      i &= i - 1
    end
    res
  end
end
 
FeTree            = FenwickTree
BinaryIndexedTree = FenwickTree
 
n, q = gets.split.map { |e| e.to_i }
a    = gets.split.map { |e| e.to_i }
 
ft = FeTree.new(a)
 
q.times do
  t, u, v = gets.split.map { |e| e.to_i }
 
  if t == 0
    ft.add(u + 1, v)
  else
    puts ft.sum(u, v)
  end
end
//  [ruby]
class FeTree
    def initialize(n)
        @n = n
        @f = Array.new(@n+1,0)
    end

    def add(i, x)
        while i <= @n
            @f[i] += x
            i += i & -i
        end
    end

    def sum(i)
        s = 0
        while i > 0
            s += @f[i]
            i &= i-1
        end
        s
    end
end

n, q = gets.split.map &:to_i
a = gets.split.map &:to_i

ft = FeTree.new(n)
a.each_with_index {|e,i| ft.add(i+1, e)}

q.times do
    t, x, y = gets.split.map &:to_i
    if t == 0
        ft.add(x+1, y)
    else
        puts ft.sum(y) - ft.sum(x)
    end
end
//  [ruby]
(N,),A,*Q=$<.map{_1.split.map &:to_i}
B=[i=0]*-~N
f=->i,x{(B[i]+=x;i+=i&-i)until i>N}
g=->i{s=0;i&=i-1while i>0&&s+=B[i];s}
A.map{f[i+=1,_1]}
Q.map{_1<1?f[_2+1,_3]:p(g[_3]-g[_2])}
//  [ruby]
class FenwickTree
    def initialize(n)
        @data = Array.new(n){0}
    end
    def add(i, x)
        i += 1
        while i <= @data.size
            @data[i - 1] += x
            i += i & -i
        end
    end
    def sum(r)
        s = 0
        while r > 0
            s += @data[r - 1]
            r -= r & -r
        end
        s
    end
end 

N,Q=gets.split.map(&:to_i)
ft=FenwickTree.new(N)
A=gets.split.map(&:to_i)
N.times{|i|
	ft.add(i, A[i])
}
Q.times{
	q,a,b=gets.split.map(&:to_i)
	case q
	when 0
		ft.add(a, b)
	when 1
		puts ft.sum(b)-ft.sum(a)
	end
}
//  [ruby]
class BinaryIndexTree
  def initialize(size, init: 0)
    @values = Array.new(size, init)
    @size = size
  end

  # @param idx [Integer]
  # @param x [Numeric]
  def add(idx, x)
    raise 'Out of range reference' if @size <= idx

    idx += 1

    while idx <= @size
      @values[idx - 1] += x
      idx += idx & -idx
    end
  end

  def sum(l, r)
    _sum(r) - _sum(l)
  end

  private

  def _sum(idx)
    res = 0

    while idx > 0
      res += @values[idx - 1]
      idx -= idx & -idx
    end

    res
  end
end

N, Q = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

bit = BinaryIndexTree.new(N)

A.each_with_index do |a, idx|
  bit.add(idx, a)
end

Q.times do
  query = gets.split.map(&:to_i)

  if query[0] == 0
    _, idx, x = query
    bit.add(idx, x)
  else
    _, l, r = query
    puts bit.sum(l, r)
  end
end
//  [rust]
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, q) = (v[0], v[1]);
    let a = read_vec::<i64>();

    let mut bit = BinaryIndexTree::new(n);
    for i in 0..n {
        bit.add(i + 1, a[i]);
    }
    for i in 0..q {
        let query = read_vec::<i64>();
        if query[0] == 0 {
            let (p, x) = (query[1] as usize, query[2]);
            bit.add(p + 1, x);
        } else {
            let (l, r) = (query[1] as usize, query[2] as usize);
            let ans = bit.sum(r) - bit.sum(l);
            println!("{}", ans);
        }
    }
}
struct BinaryIndexTree {
    bit: Vec<i64>,
    n: usize,
}

impl BinaryIndexTree {
    fn new(n: usize) -> BinaryIndexTree {
        BinaryIndexTree {
            bit: vec![0; n + 1],
            n: n,
        }
    }

    fn sum(&self, i: usize) -> i64 {
        let mut i = i;
        let mut s = 0i64;
        while i > 0 {
            s += self.bit[i];
            i -= (i as i64 & -(i as i64)) as usize;
        }
        s
    }

    fn add(&mut self, i: usize, x: i64) {
        assert!(i > 0);
        let mut i = i;
        while i <= self.n {
            self.bit[i as usize] += x;
            i += (i as i64 & -(i as i64)) as usize;
        }
    }
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        a: [u64; n],
        query: [(usize, usize, usize); q],
    }
    let mut segtree = SegmentTree::new(&a, std::u64::MIN, |a, b| a + b);
    for (qq, x, y) in query {
        match qq {
            0 => segtree.update_with(x as usize, |v| v + y as u64),
            1 => println!("{}", segtree.query(x, y)),
            _ => unreachable!(),
        }
    }
}
struct SegmentTree<T: Copy> {
    n: usize,            // size of data
    f: fn(T, T) -> T,    // binary operation of the monoid
    e: T,                // identity element of the monoid
    binary_tree: Vec<T>, // 1-indexed binary tree (parent: x/2, left_child: x*2, right_child: x*2+1, sibling: x^1, is_x_left_child: x%2==0, is_x_right_child: x%2==1)
}
impl<T: Copy> SegmentTree<T> {
    /// O(n) # create segment tree (e is identity element for a function f in type T)
    fn new(data: &[T], e: T, f: fn(T, T) -> T) -> Self {
        let (n, binary_tree) = (data.len(), vec![e; 2 * data.len().next_power_of_two()]);
        let segment_tree = SegmentTree {
            n,
            f,
            e,
            binary_tree,
        };
        segment_tree.init(data)
    }

    /// O(n) # init segment tree by given data
    fn init(mut self, data: &[T]) -> Self {
        let leaf_offset = self.leaf_offset();
        for (i, &di) in data.iter().enumerate() {
            self.binary_tree[leaf_offset + i] = di;
        }
        for i in (1..leaf_offset).rev() {
            self.binary_tree[i] = (self.f)(self.binary_tree[i * 2], self.binary_tree[i * 2 + 1]);
        }
        self
    }

    /// O(1) # get beginning index of the segment tree leaf
    fn leaf_offset(&self) -> usize {
        self.n.next_power_of_two()
    }

    /// O(log(n)) # set leaf[k] = x, and update segment tree. (non-recursive)
    fn update_with<U>(&mut self, k: usize, f: U)
    where
        U: Fn(T) -> T,
    {
        let mut current = self.leaf_offset() + k;
        self.binary_tree[current] = f(self.binary_tree[current]);
        while current / 2 > 0 {
            current /= 2;
            self.binary_tree[current] = (self.f)(
                self.binary_tree[current * 2],
                self.binary_tree[current * 2 + 1],
            );
        }
    }

    /// O(log(n)) # calculate f(l, l+1, ..., r-1). note the half interval [l, r). (non-recursive)
    fn query(&self, l: usize, r: usize) -> T {
        let (mut l, mut r) = (self.leaf_offset() + l, self.leaf_offset() + r);
        let mut result = self.e;
        while l < r {
            if l % 2 == 1 {
                result = (self.f)(result, self.binary_tree[l]);
                l += 1; // l is right child, so move to next subtree.
            }
            if r % 2 == 1 {
                result = (self.f)(result, self.binary_tree[r ^ 1]);
            }
            l /= 2;
            r /= 2;
        }
        result
    }
}
//  [python]
H,W,K = map(int,input().split())
C = [0]*H
 
for i in range(H):
    C[i] = list(str(input()))
    
 
    
def gyotsubushi(n,E):
    if I[n] == 1:
        E[n] = ['R']*W
        #print('GYO')
        
def retsutsubushi(n,E):
    if J[n] == 1:
        for i in range(H):
            E[i][n] = 'R'
stock = []
counter = 0
import copy
for i0 in range(2):
    for i1 in range(2):
        for i2 in range(2):
            for i3 in range(2):
                for i4 in range(2):
                    for i5 in range(2):
                        for j0 in range(2):
                            for j1 in range(2):
                                for j2 in range(2):
                                    for j3 in range(2):
                                        for j4 in range(2):
                                            for j5 in range(2):
                                                preI = [i0,i1,i2,i3,i4,i5]
                                                preJ = [j0,j1,j2,j3,j4,j5]
                                                I = preI[0:H]
                                                J = preJ[0:W]
                                                if I+J in stock:
                                                    break
                                                stock.append(I+J)
                                                D = copy.deepcopy(C)
                                                #print(D,I,J)
                                                for i in range(H):
                                                    gyotsubushi(i,D)
                                                for j in range(W):
                                                    retsutsubushi(j,D)
                                                #print(D)
                                                count = 0
                                                for i in range(H):
                                                    for j in range(W):
                                                        if D[i][j] == '#':
                                                            count += 1
                                                if count == K:
                                                    counter += 1
 
    
print(counter)
//  [python]
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, K, C):
    ans = 0

    for h in range(H+1):
        for w in range(W+1):
            for i in combinations(range(H), r=h):
                i = set(i)
                for j in combinations(range(W), r=w):
                    j = set(j)
                    t = 0
                    for x in range(H):
                        for y in range(W):
                            if x in i or y in j:
                                continue
                            if C[x][y] == '#':
                                t += 1
                    if t == K:
                        ans += 1

    return ans


def main():
    H, W, K = read_int_n()
    C = [read_str() for _ in range(H)]
    print(slv(H, W, K, C))


if __name__ == '__main__':
    main()
//  [java]
import java.util.*;



public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int h = scanner.nextInt();
    int w = scanner.nextInt();
    int k = scanner.nextInt();
    scanner.nextLine();
    int[][] c = new int[h][w];
    for(int i=0; i<h; i++){
      String str = scanner.nextLine();
      for(int j=0; j<w; j++){
        if(str.charAt(j)=='#'){
          c[i][j] = 1;
        }
      }
    }
  

    int ans = 0;
    for (int i=0; i<Math.pow(2,h); i++){
      for (int j=0; j<Math.pow(2,w); j++){
        String i_bin = String.format("%"+h+"s",Integer.toBinaryString(i)).replace(" ", "0");
        String j_bin = String.format("%"+w+"s",Integer.toBinaryString(j)).replace(" ", "0");
        // System.out.println(i_bin + ","+j_bin);
        int[][] tmp = new int[c.length][c[0].length];
        for (int l=0; l < c.length; l++) {
          tmp[l] = new int[c[l].length];
          System.arraycopy(c[l], 0, tmp[l], 0, c[l].length);
      }
        // System.out.println(Arrays.deepToString(tmp));

        for(int l=0; l<i_bin.length(); l++){
          if(i_bin.charAt(l) == '1'){
            for(int m=0; m<w; m++){
              tmp[l][m] = 0;
            }
          }
        }
        for(int l=0; l<j_bin.length(); l++){
          if(j_bin.charAt(l) == '1'){
            for(int m=0; m<h; m++){
              tmp[m][l] = 0;
            }
          }
        }
        // System.out.println(Arrays.deepToString(tmp));
        int sum = 0;
        for(int l=0; l<h;l++){
          sum += Arrays.stream(tmp[l]).sum();
        }
        if(sum == k){
          ans ++;
        }

      }

    }


    System.out.println(ans);
    
    scanner.close();
    return;
  }
  
}