package contest190208; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class F { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(); DynamicSegmentTreeRSQSimple dst = new DynamicSegmentTreeRSQSimple(n, 30); long ans = 0; for(int i = 0;i < n;i++) { int t = ni(); if(t == 0) { dst.add(ni(), ni()); }else { ans += dst.sum(ni(), ni()+1); } } out.println(ans); } public static class DynamicSegmentTreeRSQSimple { public long[] vals; public int[] ls; public int[] rs; public int gen; public int height; public DynamicSegmentTreeRSQSimple(int q, int height) { int bufsize = q * (height+1) + 1; this.vals = new long[bufsize]; this.ls = new int[bufsize]; this.rs = new int[bufsize]; Arrays.fill(this.ls, -1); Arrays.fill(this.rs, -1); this.height = height; gen = 0; vals[gen++] = 0; } public void add(long x, long v) { addDfs(0, x, v, height-1); } private int addDfs(int id, long x, long v, int d) { if(id == -1)id = gen++; if(d == -1){ vals[id] += v; }else{ if(x<<~d<0){ rs[id] = addDfs(rs[id], x, v, d-1); }else{ ls[id] = addDfs(ls[id], x, v, d-1); } propagate(id); } return id; } private long val(int id){ return id == -1 ? 0 : vals[id]; } private int L(int id){ return id == -1 ? -1 : ls[id]; } private int R(int id){ return id == -1 ? -1 : rs[id]; } private void propagate(int id) { if(id == -1)return; vals[id] = val(ls[id]) + val(rs[id]); } // sum of a[pos] which (t xor pos) >= v public long sumge(long t, long v) { if(v >= 1L<= 1L<= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private double nd() { return Double.parseDouble(ns()); } private char nc() { return (char)skip(); } private String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ') sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private long[] nal(int n) { long[] a = new long[n]; for(int i = 0;i < n;i++)a[i] = nl(); return a; } private char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private int[][] nmi(int n, int m) { int[][] map = new int[n][]; for(int i = 0;i < n;i++)map[i] = na(m); return map; } private int ni() { return (int)nl(); } private long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } }