criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<vector>
#include<iostream>
#include<algorithm>
#include <stdint.h>
using namespace std;
 int const INF = INT_MAX;
class segment_tree {
private:
	int n;
	vector<int> node;
public:
	//元配列をセグメント木で表現する
	segment_tree(vector<int>v) {
		
		int sz = v.size();
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく
		n = 1;
		while (n < sz) {
			n *= 2;
		}
		node.resize(2 * n - 1, INF);
		//最下段を初期化
		for (int i = 0; i < sz; i++) {
			node[i + n - 1] = v[i];
		}
		//親の値を決めていく
		for (int i = n - 2; i >= 0; i++) {
			node[i] = min(node[2 * i + 1], node[2 * i + 2]);
		}
	}

	void update(int x, int val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = min(node[2 * x + 1], node[2 * x + 2]);
		}
	}
	//[a,b)の最小値を求める
	//k番目のノード　範囲は[l,r)
	int query(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) {
			r = n;
		}
		if (r <= a || b <= l)
		{
			return INF;
		}
		if (a <= l && r <= b)
		{
			return node[k];
		}
		else
		{
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}

};

int main() {
	int N;
	int Q;
	cin >> N >> Q;
	segment_tree seg(vector<int>(N, INF));
	for (int i = 0; i < Q; i++) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c == 0) {
			seg.update(x, y);
		}
		else {
			cout << seg.query(x, y + 1) << endl;
		}
	}
}








Compiler output:
a.cc:6:18: error: 'INT_MAX' was not declared in this scope
    6 |  int const INF = INT_MAX;
      |                  ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <stdint.h>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

import bisect
import collections
import heapq
import itertools
import operator
import sys


def main():
    int_max = 2 ** 31 - 1
    n, q = map(int, sys.stdin.readline().split())
    dat = [int_max] * (131072 * 2 - 1)

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

    def query(a, b, k, l, r):
        if r <= a or b <= l:
            return int_max
        if a <= l and r <= b:
            return dat[k]
        else:
            vl = query(a, b, k * 2 + 1, l, (l + r) // 2)
            vr = query(a, b, k * 2 + 2, (l + r) // 2, r)
            return min(vl, vr)

    for _ in range(q):
        com, x, y = map(int, sys.stdin.readline().split())
        if com == 0:
            update(x, y)
        elif com == 1:
            print(query(x, y + 1, 0, 0, n))


if __name__ == "__main__":
    main()



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import bisect
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
const int INF = INT_MAX;

using namespace std;

struct RMQ {
    vector<int> data;
    int n;

    RMQ(int size) {
        n = 1;
        while(n < size) n *= 2;
        data = vector<int>(2*n-1, INF);
    }

    // 0??????????????則k?????????????卒????a????????卒??????
    void update(int k, int a) {
        k += n-1;
        data[k] = a;
        while(k > 0) {
            k = (k-1)/2;
            data[k] = min(data[2*k+1], data[2*k+2]);
        }
    }

    // minimum [a, b)
    int q(int a, int b) {
        return subq(a, b, 0, 0, n);
    }

    int subq(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return INF;

        if(a <= l && r <= b) return data[k];
        else return min(subq(a, b, 2*k+1, l, (l+r)/2), subq(a, b, 2*k+2, (l+r)/2, r));
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    RMQ rmq(N);
    for(int i = 0; i < Q; i++) {
        int comm, x, y;
        cin >> comm >> x >> y;
        if(comm == 0) rmq.update(x, y);
        else cout << rmq.q(x, y + 1) << endl;
    }
}

Compiler output:
a.cc:4:17: error: 'INT_MAX' was not declared in this scope
    4 | const int INF = INT_MAX;
      |                 ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 | const int INF = INT_MAX;
Language: C++

#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int *buildRMQ(int *a, int n) {
  int logn = 1;
  for (int k = 1; k < n; k *= 2) ++logn;
  int *r = new int[n * logn];
  int *b = r; copy(a, a+n, b);
  for (int k = 1; k < n; k *= 2) {
    copy(b, b+n, b+n); b += n;
    REP(i, n-k) b[i] = min(b[i], b[i+k]);
  }
  return r;
}
int minimum(int x, int y, int *rmq, int n) {
  int z = y - x, k = 0, e = 1, s; // y - x >= e = 2^k ???????????則 k
  s = ( (z & 0xffff0000) != 0 ) << 4; z >>= s; e <<= s; k |= s;
  s = ( (z & 0x0000ff00) != 0 ) << 3; z >>= s; e <<= s; k |= s;
  s = ( (z & 0x000000f0) != 0 ) << 2; z >>= s; e <<= s; k |= s;
  s = ( (z & 0x0000000c) != 0 ) << 1; z >>= s; e <<= s; k |= s;
  s = ( (z & 0x00000002) != 0 ) << 0; z >>= s; e <<= s; k |= s;
  return min( rmq[x+n*k], rmq[y+n*k-e+1] );
}

int a[100000],*p;
int main(){
	int n,q,c,x,y,f=0;
	scanf("%d%d",&n,&q);
	for(y=0;y<n;y++)a[y]=0x7fffffff;
	for(;q--;){
		scanf("%d%d%d",&c,&x,&y);
		if(c){
			if(!f)p=buildRMQ(a,n),f=1;
			printf("%d\n",minimum(x,y,p,n));
		}else{
			if(f)delete []p,f=0;
			a[x]=y;
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'scanf' was not declared in this scope
   32 |         scanf("%d%d",&n,&q);
      |         ^~~~~
a.cc:38:25: error: 'printf' was not declared in this scope
   38 |                         printf("%d\n",minimum(x,y,p,n));
      |                         ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    1 | #include <algorithm>
  +++ |+#include <cstdio>
    2 | using namespace std;
Language: C++

#include<cstdio>
#include<vector>
#include<map>
#include<cctype>
#include<algorithm>
using namespace std;
typedef pair<int,int> Pt;
#define MAX 1000001
#define fr first
#define sc second
int n,dat[MAX * 2 - 1];
void update(int i,int x){
  i += n - 1;
  dat[i] = x;
  while(i > 0){
    i = (i - 1)/2;
    dat[i] = min(dat[i*2+1],dat[i*2+2]);
  }
}
int query(int a,int b,int k,int l,int r){
  if( r<=a || b <= l ) return INT_MAX;
  if( a<=l && r <= b ) return dat[k];
  return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}
int main(){
  int q,a,b,c,N;
  for(int i=0;i<MAX*2-1;i++) dat[i] = INT_MAX;
  scanf("%d %d",&N,&q);
  n=1;
  while(n < N) n *= 2;
  while(q--){
    scanf("%d %d %d",&a,&b,&c);
    if(!a) update(b,c);
    else printf("%d\n",query(b,c+1,0,0,n));
  }
}

Compiler output:
a.cc: In function 'int query(int, int, int, int, int)':
a.cc:21:31: error: 'INT_MAX' was not declared in this scope
   21 |   if( r<=a || b <= l ) return INT_MAX;
      |                               ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<algorithm>
  +++ |+#include <climits>
    6 | using namespace std;
a.cc: In function 'int main()':
a.cc:27:39: error: 'INT_MAX' was not declared in this scope
   27 |   for(int i=0;i<MAX*2-1;i++) dat[i] = INT_MAX;
      |                                       ^~~~~~~
a.cc:27:39: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>

#define MAX_V 1<<17
#define INF INT_MAX

using namespace std;

int dat[MAX_V*2],sz;

void update(int k,int x){
  k+=sz-1;
  dat[k]=x;
  while(k>0){
    k=(k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}

int query(int a,int b,int k,int l,int r){
  if(r<=a || b<=l)return INF;
  if(a<=l && r<=b)return dat[k];

  int vl=query(a,b,k*2+1,l,(l+r)/2);
  int vr=query(a,b,k*2+2,(l+r)/2,r);
  return min(vl,vr);
}

int main(void){

  fill(dat,dat+MAX_V*2,INF);

  int n,q;
  cin >> n >> q;
  sz=1;
  while(sz<n)sz*=2;

  while(q--){
    int com,x,y;
    cin >> com >> x >> y;
    if(com)cout << query(x,y+1,0,0,sz) << endl;
    else update(x,y);
  }

  return 0;
}

Compiler output:
a.cc:6:16: warning: left shift count >= width of type [-Wshift-count-overflow]
    6 | #define MAX_V 1<<17
      |                ^
a.cc:11:9: note: in expansion of macro 'MAX_V'
   11 | int dat[MAX_V*2],sz;
      |         ^~~~~
a.cc: In function 'int main()':
a.cc:6:16: error: invalid operands of types 'int*' and 'int' to binary 'operator<<'
    6 | #define MAX_V 1<<17
      |                ^~
a.cc:33:16: note: in expansion of macro 'MAX_V'
   33 |   fill(dat,dat+MAX_V*2,INF);
      |                ^~~~~
Language: C++

#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N =1<<31-1;

//segment-tree
int n;//nは2のべき乗
int dat[100001*2-1];

//初期化
void init(){
  //すべての値をINT_MAXに
  for(int i =0;i <2*n-1;i++){
    dat[i]=INT_MAX;
  }
}

//i番目の値(0-indexed)をxに変更
void update(int i,int x){
  //葉のノード番号
  i +=n-1;
  dat[i] = x;
  while(i >0){
    i =(i-1)/2;
    dat[i] =min(dat[i*2+1],dat[i*2+2]);
  }
}

//[a,b)の最小値,l,rにはノードkに対応づく区画を与える
//外からはquery(a,b,0,0,n)のように呼ぶ
int query(int a,int b,int k,int l,int r){
  if(r <=a||b <=l)//交差しない
    return INT_MAX;
  if(a <=l&&r<=b)//完全に含む
    return dat[k];
  else{
    int vl =query(a, b, k*2+1, l, (l+r)/2);
    int vr =query(a, b, k*2+2, (l+r)/2, r);
    return min(vl,vr);
  }
}
int q;
int main(){
	cin>>n>>q;
	init();
	for(int i =0;i <q;i++){
		int c,x,y;
		cin>>c>>x>>y;
		if(c==0){
			update(x,y);
		}else{
			cout<<query(x,y+1,0,0,n)<<endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'void init()':
a.cc:48:12: error: 'INT_MAX' was not declared in this scope
   48 |     dat[i]=INT_MAX;
      |            ^~~~~~~
a.cc:18:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   17 | #include<functional>
  +++ |+#include <climits>
   18 | 
a.cc: In function 'int query(int, int, int, int, int)':
a.cc:67:12: error: 'INT_MAX' was not declared in this scope
   67 |     return INT_MAX;
      |            ^~~~~~~
a.cc:67:12: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define MAX 1000001

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N =1<<31-1;

//segment-tree
int n;//nは2のべき乗
int dat[1000001*2-1];
int na;
//初期化
void init(){
	//すべての値をINT_MAXに
	for(int i =0;i <2*n-1;i++){
		dat[i]=INT_MAX;
	}
}

//i番目の値(0-indexed)をxに変更
void update(int i,int x){
	//葉のノード番号
	i += na - 1;
	dat[i] = x;
	while(i >0){
		i =(i-1)/2;
		dat[i] =min(dat[i*2+1],dat[i*2+2]);
	}
}

//[a,b)の最小値,l,rにはノードkに対応づく区画を与える
//外からはquery(a,b,0,0,n)のように呼ぶ
int query(int a,int b,int k,int l,int r){
	if(r <=a||b <=l)//交差しない
		return INT_MAX;
	if(a <=l&&r<=b)//完全に含む
		return dat[k];
	else{
		int vl =query(a, b, k*2+1, l, (l+r)/2);
		int vr =query(a, b, k*2+2, (l+r)/2, r);
		return min(vl,vr);
	}
}
int q;
int main(){
	cin>>n>>q;
	na = 1;
	na =na<<n;
	for(int i=0;i<MAX*2-1;i++) dat[i] = INT_MAX;
	int c,x,y;
	while(q--){
		cin>>c>>x>>y;
		if(!c)
			update(x,y);
		else
			cout<<query(x,y+1,0,0,na)<<endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'void init()':
a.cc:49:24: error: 'INT_MAX' was not declared in this scope
   49 |                 dat[i]=INT_MAX;
      |                        ^~~~~~~
a.cc:18:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   17 | #include<functional>
  +++ |+#include <climits>
   18 | 
a.cc: In function 'int query(int, int, int, int, int)':
a.cc:68:24: error: 'INT_MAX' was not declared in this scope
   68 |                 return INT_MAX;
      |                        ^~~~~~~
a.cc:68:24: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc: In function 'int main()':
a.cc:82:45: error: 'INT_MAX' was not declared in this scope
   82 |         for(int i=0;i<MAX*2-1;i++) dat[i] = INT_MAX;
      |                                             ^~~~~~~
a.cc:82:45: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: Java

import java.util.Scanner;

import static java.lang.Long.max;
import static java.lang.Math.min;

/**
 * Created by shoya on 2017/04/14.
 */
public class Main {
    final int INF = 100_000_000;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        RSQ.PriRSQ rsq = new RSQ.PriRSQ(n);
        for (int i = 0; i < q; i++){
            int com = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (com == 0)
                rsq.add(x, y);
            else
                System.out.println(rsq.getSum(x, y + 1));

            //System.out.printf("%d %d %d\n", com, x, y);
            //rsq.print();
            //System.out.println("\n");
        }
    }


    public static class PriRSQ {
        long nodes[];
        int size;

        PriRSQ(int n){
            int c = 1;
            while (n >= c) c *= 2;
            nodes = new long[2 * c - 1];
            size = c;
            for (int i = 0; i < 2 * c - 1; i++)
                nodes[i] = 0;
        }

        public void add(int node, int val){
            int child = node + size - 1;
            nodes[child] = val;
            while (child != 0){
                child = (child - 1) / 2;
                nodes[child] = nodes[child * 2 + 1] + nodes[child * 2 + 2];
            }
        }

        public long getSum(int queryl, int queryr){
            return getSum(queryl, queryr, 0, 0, size);
        }


        private long getSum(int queryl, int queryr, int root, int left, int right){
            //System.out.printf("%d <--> %d - %d <--> %d - Val %d\n", queryl, queryr, left, right, root);
            if (right <= queryl || queryr <= left)
                return 0;
            if (queryl <= left && right <= queryr)
                return nodes[root];

            long vl = getSum(queryl, queryr, root * 2 + 1, left, (left + right) / 2);
            long vr = getSum(queryl, queryr, root * 2 + 2, (left + right) / 2, right);
            return vl + vr;
        }

        void print(){
            int tmp = 1;
            for (int i = 0; i < 2 * size - 1; i++){
                if (i == tmp) {
                    System.out.println();
                    tmp += ((tmp + 1) / 2) * 2;
                }
                System.out.printf("%d ", nodes[i]);
            }
        }

    }
}

Compiler output:
Main.java:17: error: package RSQ does not exist
        RSQ.PriRSQ rsq = new RSQ.PriRSQ(n);
           ^
Main.java:17: error: package RSQ does not exist
        RSQ.PriRSQ rsq = new RSQ.PriRSQ(n);
                                ^
2 errors
Language: C

#include<stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int bit[100001], n;
int sum(int i) {
	int s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i&-i;
	}
	return s;
}
void add(int i, int x) {
	while (i <= n) {
		bit[i] += x;
		i += i&-i;
	}
}
int main() {
	int q; scanf("%d%d", &n, &q);
	rep(i, q) {
		int com, x, y; scanf("%d%d%d", &com, &x, &y);
		if (com) printf("%d\n", sum(y) - sum(x - 1));
		else add(x, y);
	}
}

Compiler output:
main.c:3:1: error: unknown type name 'using'
    3 | using namespace std;
      | ^~~~~
main.c:3:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    3 | using namespace std;
      |                 ^~~
Language: C

#include<stdio.h>

int main(void){

  int a[10000]={};
  int getSum[10000]={};
  int i=0;  
  int time=0;
  int b,x,s,t,n,q,d;

  scanf("%d %d",&n,&q);
  if(1>n||n<100000||1>q||q<100000){
  printf("Too Large\n");
  break;
  }


  while(i<q){
    i++;
       scanf("%d",&b);
   if(b==0){
   scanf("%d",&d);
   scanf("%d",&x);
   a[d] += x;
   }
 
   else if(b==1){
     time++;
   scanf("%d",&s);
   scanf("%d",&t);
   
   for(s;s<=t;s++){
     getSum[time] += a[s];
   }

   }


  }

  i=0;

  while(i<time){
    ++i;
    printf("%d\n",getSum[i]);

  }
  


}

Compiler output:
main.c: In function 'main':
main.c:14:3: error: break statement not within loop or switch
   14 |   break;
      |   ^~~~~
Language: C++

#include <cassert>

template <class CommutativeMonoid, template <class> class Container>
class fenwick_tree {

public:
	using value_structure = CommutativeMonoid;
	using value_type = typename value_structure::value_type;
	using container_type = Container<value_type>;
	using const_reference = typename container_type::const_reference;
	using size_type = typename container_type::size_type;

private:
	size_type base_size;
	container_type c;
	static size_type getsize(const size_type size) {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}

public:
	fenwick_tree() : base_size(0), c() {}
	explicit fenwick_tree(const size_type size)
		: base_size(getsize(size)), c(size + 1, value_structure::identity()) {}

	bool empty() const { return size() == 0; }
	size_type size() const { return c.size() - 1; }

	value_type fold(size_type last) const {
		assert(last <= size());
		value_type ret = value_structure::identity();
		for (; last; last &= last - 1)
			ret = value_structure::operation(c[last], ret);
		return ret;
	}
	template <class F> size_type search(const F &f) const {
		if (f(value_structure::identity()))
			return 0;
		size_type i = 0, k = base_size;
		value_type acc = value_structure::identity();
		while (k >>= 1)
			if ((i | k) < c.size() && !f(value_structure::operation(acc, c[i | k])))
				acc = value_structure::operation(acc, c[i |= k]);
		return i + 1;
	}

	void update(size_type index, const value_type &diff) {
		assert(index < size());
		for (++index; index < c.size(); index += index & ~index + 1)
			c[index] = value_structure::operation(c[index], diff);
	}
};

template <class T> class plus_monoid {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return x + y;
	}
	static value_type identity() { return value_type(0); }
	static value_type reverse(const value_type &x) { return x; }
};

#include <iostream>
#include <vector>

template<class T> using vec_alias = ::std::vector<T>;

int main() {
	int n, q;
	::std::cin >> n >> q;

	fenwick_tree<plus_monoid<int>, vec_alias> fenwick(n);

	while (q--) {
		int c, x, y;
		::std::cin >> c >> x >> y;

		if (c) {
			::std::cout << fenwick.fold(x - 1, y) << ::std::endl;
		}
		else {
			fenwick.update(x - 1, y);
		}

	}

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:82:52: error: no matching function for call to 'fenwick_tree<plus_monoid<int>, vec_alias>::fold(int, int&)'
   82 |                         ::std::cout << fenwick.fold(x - 1, y) << ::std::endl;
      |                                        ~~~~~~~~~~~~^~~~~~~~~~
a.cc:31:20: note: candidate: 'fenwick_tree<CommutativeMonoid, Container>::value_type fenwick_tree<CommutativeMonoid, Container>::fold(size_type) const [with CommutativeMonoid = plus_monoid<int>; Container = vec_alias; value_type = int; size_type = long unsigned int]'
   31 |         value_type fold(size_type last) const {
      |                    ^~~~
a.cc:31:20: note:   candidate expects 1 argument, 2 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100005;

int bit[MAXN];

void update(int a, int b) {
    for (; a < MAXN; a += (a & -a))
        bit[a] += b;
}

int sum(int a, int b) {
    int r = 0;
    for (; a; a -= (a & -a))
        r += bit[a];
    return r;
}

int main() {
    int n, q; cin >> n >> q;
    for (int i = 0; i < q; i++) {
        int o, a, b; cin >> o >> a >> b;
        if (o == 0) {
            update(a, b);
        } else {
            cout << sum(b) - sum(a - 1) << endl;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:24: error: too few arguments to function 'int sum(int, int)'
   27 |             cout << sum(b) - sum(a - 1) << endl;
      |                     ~~~^~~
a.cc:13:5: note: declared here
   13 | int sum(int a, int b) {
      |     ^~~
a.cc:27:33: error: too few arguments to function 'int sum(int, int)'
   27 |             cout << sum(b) - sum(a - 1) << endl;
      |                              ~~~^~~~~~~
a.cc:13:5: note: declared here
   13 | int sum(int a, int b) {
      |     ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct SegTree {
    vector<int> node;
    int n;
    SegTree(int sz) {
        n = 1;
        while (sz > n) n *= 2;
        node.resize(2 * n - 1, 0);
    }
    void add(int p, int x) {
        p += n-1;
        do {
            node[p] += x;
        } while (p);
    }
    int get(int a, int b, int k = 0, int l = 0; r = -1) {
        if (r < 0) r = n;
        if (b < l || r < a) return 0;
        if (l <= a && b <= r) {
            return node[k];
        }
        return get(a, b, k * 2 + 1, l, (l + r) / 2) + get(a, b, k * 2 + 2, (r + l) / 2, r);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    SegTree s(n);
    while (q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            s.add(x-1, y);
        } else {
            cout << s.get(x-1, y-1) << endl;
        }
    }
}


Compiler output:
a.cc:19:47: error: expected ')' before ';' token
   19 |     int get(int a, int b, int k = 0, int l = 0; r = -1) {
      |            ~                                  ^
      |                                               )
a.cc:19:49: error: 'r' does not name a type
   19 |     int get(int a, int b, int k = 0, int l = 0; r = -1) {
      |                                                 ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct SegTree {
    vector<int> node;
    int n;
    SegTree(int sz) {
        n = 1;
        while (sz > n) n *= 2;
        node.resize(2 * n - 1, 0);
    }
    void add(int p, int x) {
        p += n-1;
        do {
            node[p] += x;
        } while (p);
    }
    int get(int a, int b, int k = 0, int l = 0, r = -1) {
        if (r < 0) r = n;
        if (b < l || r < a) return 0;
        if (l <= a && b <= r) {
            return node[k];
        }
        return get(a, b, k * 2 + 1, l, (l + r) / 2) + get(a, b, k * 2 + 2, (r + l) / 2, r);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    SegTree s(n);
    while (q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            s.add(x-1, y);
        } else {
            cout << s.get(x-1, y-1) << endl;
        }
    }
}


Compiler output:
a.cc:19:49: error: 'r' has not been declared
   19 |     int get(int a, int b, int k = 0, int l = 0, r = -1) {
      |                                                 ^
a.cc: In member function 'int SegTree::get(int, int, int, int, int)':
a.cc:20:13: error: 'r' was not declared in this scope
   20 |         if (r < 0) r = n;
      |             ^
a.cc:21:22: error: 'r' was not declared in this scope
   21 |         if (b < l || r < a) return 0;
      |                      ^
a.cc:22:28: error: 'r' was not declared in this scope
   22 |         if (l <= a && b <= r) {
      |                            ^
a.cc:25:45: error: 'r' was not declared in this scope
   25 |         return get(a, b, k * 2 + 1, l, (l + r) / 2) + get(a, b, k * 2 + 2, (r + l) / 2, r);
      |                                             ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct SegTree {
    vector<int> node;
    int n;
    SegTree(int sz) {
        n = 1;
        while (sz > n) n *= 2;
        node.resize(2 * n - 1, 0);
    }
    void add(int p, int x) {
        p += n-1;
        node[p] += x;
        do {
            p = (p-1) / 2;
            node[p] += x;
            node[p] = node[p*2+1] + p[p*2+2];
        } while (p);
    }
    void add(int k, int val) {
        k += (n - 1);
        node[k] += val;
 
        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }
    int get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) {
            return node[k];
        }
        return get(a, b, k * 2 + 1, l, (l + r) / 2) + get(a, b, k * 2 + 2, (r + l) / 2, r);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    SegTree s(n);
    while (q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            s.add(x-1, y);
        } else {
            cout << s.get(x-1, y) << endl;
        }
    }
}


Compiler output:
a.cc:22:10: error: 'void SegTree::add(int, int)' cannot be overloaded with 'void SegTree::add(int, int)'
   22 |     void add(int k, int val) {
      |          ^~~
a.cc:13:10: note: previous declaration 'void SegTree::add(int, int)'
   13 |     void add(int p, int x) {
      |          ^~~
a.cc: In member function 'void SegTree::add(int, int)':
a.cc:19:38: error: invalid types 'int[int]' for array subscript
   19 |             node[p] = node[p*2+1] + p[p*2+2];
      |                                      ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct SegTree {
    vector<int> node;
    int n;
    SegTree(int sz) {
        n = 1;
        while (sz > n) n *= 2;
        node.resize(2 * n - 1, 0);
    }
    void add(int p, int x) {
        p += n-1;
        node[p] += x;
        do {
            p = (p-1) / 2;
            node[p] += x;
            node[p] = node[p*2+1] + p[p*2+2];
        } while (p);
    }

    int get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) {
            return node[k];
        }
        return get(a, b, k * 2 + 1, l, (l + r) / 2) + get(a, b, k * 2 + 2, (r + l) / 2, r);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    SegTree s(n);
    while (q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            s.add(x-1, y);
        } else {
            cout << s.get(x-1, y) << endl;
        }
    }
}


Compiler output:
a.cc: In member function 'void SegTree::add(int, int)':
a.cc:19:38: error: invalid types 'int[int]' for array subscript
   19 |             node[p] = node[p*2+1] + p[p*2+2];
      |                                      ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct SegTree {
    vector<int> node;
    int n;
    SegTree(int sz) {
        n = 1;
        while (sz > n) n *= 2;
        node.resize(2 * n - 1, 0);
    }
    void add(int p, int x) {
        p += n-1;
        node[p] += x;
        while (p) {
            p = (p-1) / 2;
            node[p] += x;
        }
    }
    void add(int k, int val) {
        k += (n - 1);
        node[k] += val;
 
        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }
    int get(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return 0;
        if (a <= l && r <= b) {
            return node[k];
        }
        return get(a, b, k * 2 + 1, l, (l + r) / 2) + get(a, b, k * 2 + 2, (r + l) / 2, r);
    }
};

int main()
{
    int n, q;
    cin >> n >> q;
    SegTree s(n);
    while (q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            s.add(x-1, y);
        } else {
            cout << s.get(x-1, y) << endl;
        }
    }
}


Compiler output:
a.cc:21:10: error: 'void SegTree::add(int, int)' cannot be overloaded with 'void SegTree::add(int, int)'
   21 |     void add(int k, int val) {
      |          ^~~
a.cc:13:10: note: previous declaration 'void SegTree::add(int, int)'
   13 |     void add(int p, int x) {
      |          ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

class BIT {
private:
  
  vector<int> bit;
  int size;
  
public:
  
  BIT(int n) : size(n)
  {
    bit.resize(n);
  }
  
  int sum(int i) {
    int s = 0;
    while(i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  
  void add(int i, int x) {
    while(i <= size) {
      bit[i] += x;
      i += i & -i;
    }
  }
  
};

int main() {
  int n, q;
  int com, x, y;
  cin >> n >> q;
  BIT b(n);
  while(q--) {
    cin >> com >> x >> y;
    if(com == 0) {
      b.add(x, y);
    }
    else {
      cout << b.sum(y) - b.sum(x-1) << endl;
    }
  }
  return 0;
}javascript:void(0)

Compiler output:
a.cc:51:2: error: 'javascript' does not name a type
   51 | }javascript:void(0)
      |  ^~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int n,q,a[100000]={},i,j,com,x,y;
    
    cin>>n>>q;
     
    for(i=q;i--;){
        cin>>com>>x>>y;
         
        if(com){
            cout<<accumulate(a+x-1,a+y,0)<<endl;
            continue;
        }
        a[x-1] += y;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: 'accumulate' was not declared in this scope
   14 |             cout<<accumulate(a+x-1,a+y,0)<<endl;
      |                   ^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int n, q, N;
int dat[4*100000];

void init(){
	N = 1;
	while(N < n) N *= 2;
	rep(i,N*2) dat[i] = 0;
}

void add(int x, int y){
	x += N-1;
	dat[x] += y;
	while(x > 0){
		x = (x-1)/2;
		dat[x] += y;
	}
}

int getSum(int a, int b, int t, int r, int l){
	if(a >= l || b <= r) return 0;
	if(a <= r && l <= b) return dat[t];
	return getSum(a,b,t*2+1,r,(r+l)/2)+getSum(a,b,t*2+2,(r+l)/2,l);
}

int main(){
	scanf("%d%d",&n,&q);
	init();
	rep(i,q){
		int com, x, y;
		scanf("%d%d%d",&com,&x,&y); x--; y--:
		if(com == 0) add(x,y);
		else printf("%d\n",getSum(x,y+1,0,0,N));
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:53: error: expected ';' before ':' token
   34 |                 scanf("%d%d%d",&com,&x,&y); x--; y--:
      |                                                     ^
      |                                                     ;
a.cc:36:17: error: 'else' without a previous 'if'
   36 |                 else printf("%d\n",getSum(x,y+1,0,0,N));
      |                 ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

/*
Range Sum Query by FenwickTree(Binary Indexed Tree)

total number: n
queries:
    1. add(i, val): bit[i] += val 
    2. sum(n): sum(bit[0] + ... + bit[n-1])
time complexity: O(log n)
space complexity: O(N)

Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program and complexity also increases.

Thanks: http://hos.ac/slides/20140319_bit.pdf
    
used in ARC031 C, indeednow finalB E, DSL2B(AOJ), ARC033 C, yukicoder No.59
*/

template<typename T> struct RangeSumQuery {
  int N;
  vector<T> dat;

  RangeSumQuery(int N) : N(N) { dat.resize(N, 0); }

  void add(int k, T val) {
    for (int x = k; x < N; x |= x + 1) {
      dat[x] += val;
    }
  }

  // [0, k)
  T sum(int k) {
    T ret = 0;
    for (int x = k - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += dat[x];
    }
    return ret;
  }
  // [l, r)
  T sum(int l, int r) { return sum(r) - sum(l); }

  T index(int k) { return sum(k+1) - sum(k); }
};


int main() {
  ios_base::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;

  RangeSumQuery<int> bit(n);

  REP(i, q) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      bit.update(x-1, y);
    } else if (com == 1) {
      cout << bit.query(y-1) - bit.query(x-2) << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:73:11: error: 'struct RangeSumQuery<int>' has no member named 'update'
   73 |       bit.update(x-1, y);
      |           ^~~~~~
a.cc:75:19: error: 'struct RangeSumQuery<int>' has no member named 'query'
   75 |       cout << bit.query(y-1) - bit.query(x-2) << endl;
      |                   ^~~~~
a.cc:75:36: error: 'struct RangeSumQuery<int>' has no member named 'query'
   75 |       cout << bit.query(y-1) - bit.query(x-2) << endl;
      |                                    ^~~~~
Language: C++

#include<iostream>
using namespace std;

int bit[MAX_N],n,m,a,b,c;

int sum(int i){
	int s=0;
	while(i>0)
	{
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}

int add(int i,int x){
	while(i<=n){
		s+=bit[i];
		i+=i&-i;
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		if(a==0){add(b,c);}
		if(a==1){cout<<sum(c)-sum(b-1)<<endl;}
	}
	return 0;
}

Compiler output:
a.cc:4:9: error: 'MAX_N' was not declared in this scope
    4 | int bit[MAX_N],n,m,a,b,c;
      |         ^~~~~
a.cc: In function 'int sum(int)':
a.cc:10:20: error: 'bit' was not declared in this scope
   10 |                 s+=bit[i];
      |                    ^~~
a.cc: In function 'int add(int, int)':
a.cc:18:17: error: 's' was not declared in this scope
   18 |                 s+=bit[i];
      |                 ^
a.cc:18:20: error: 'bit' was not declared in this scope
   18 |                 s+=bit[i];
      |                    ^~~
a.cc:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
Language: C++

#include<iostream>
using namespace std;

#define MAX_N 1000000

int bit[MAX_N],n,m,a,b,c;

int sum(int i){
	int s=0;
	while(i>0)
	{
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}

int add(int i,int x){
	while(i<=n){
		s+=bit[i];
		i+=i&-i;
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		if(a==0){add(b,c);}
		if(a==1){cout<<sum(c)-sum(b-1)<<endl;}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int add(int, int)':
a.cc:20:17: error: 's' was not declared in this scope
   20 |                 s+=bit[i];
      |                 ^
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
Language: C++

#include <cstdio>
template <class Type>
class BIT {
private:
	int size_; Type *v;
	Type sum(int r) { Type ret = 0; while (r > 0) ret += v[r], r -= r & -r; return ret; }
public:
	BIT() {};
	BIT(int size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v = (Type *)malloc(sizeof(Type) * (size_ + 1));
		memset(v, 0, sizeof(v));
		for (int i = 0; i <= size_; i++) v[i] = 0;
	}
	void add(int i, Type x) { i++; while (i <= size_) v[i] += x, i += i & -i; }
	Type sum(int l, int r) { return sum(r) - sum(l); }
};
int n, q, c, x, y;
int main() {
	cin >> n >> q;
	BIT<int> b(n);
	for (int i = 0; i < q; i++) {
		cin >> c >> x >> y;
		if (!c) b.add(x - 1, y);
		else cout << b.sum(x - 1, y) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In constructor 'BIT<Type>::BIT(int)':
a.cc:11:29: error: there are no arguments to 'malloc' that depend on a template parameter, so a declaration of 'malloc' must be available [-fpermissive]
   11 |                 v = (Type *)malloc(sizeof(Type) * (size_ + 1));
      |                             ^~~~~~
a.cc:11:29: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc: In function 'int main()':
a.cc:20:9: error: 'cin' was not declared in this scope
   20 |         cin >> n >> q;
      |         ^~~
a.cc:25:22: error: 'cout' was not declared in this scope
   25 |                 else cout << b.sum(x - 1, y) << endl;
      |                      ^~~~
a.cc:25:49: error: 'endl' was not declared in this scope
   25 |                 else cout << b.sum(x - 1, y) << endl;
      |                                                 ^~~~
a.cc: In instantiation of 'BIT<Type>::BIT(int) [with Type = int]':
a.cc:21:14:   required from here
   21 |         BIT<int> b(n);
      |                     ^
a.cc:11:35: error: 'malloc' was not declared in this scope
   11 |                 v = (Type *)malloc(sizeof(Type) * (size_ + 1));
      |                             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:2:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    1 | #include <cstdio>
  +++ |+#include <cstdlib>
    2 | template <class Type>
a.cc:12:23: error: 'memset' was not declared in this scope
   12 |                 memset(v, 0, sizeof(v));
      |                 ~~~~~~^~~~~~~~~~~~~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <cstdio>
  +++ |+#include <cstring>
    2 | template <class Type>
Language: C++

#include <iostream>
using namespace std;
template <class Type>
class BIT {
private:
	int size_; Type *v;
	Type sum(int r) { Type ret = 0; while (r > 0) ret += v[r], r -= r & -r; return ret; }
public:
	BIT() {};
	BIT(int size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v = (Type *)malloc(sizeof(Type) * (size_ + 1));
		memset(v, 0, sizeof(v));
		for (int i = 0; i <= size_; i++) v[i] = 0;
	}
	void add(int i, Type x) { i++; while (i <= size_) v[i] += x, i += i & -i; }
	Type sum(int l, int r) { return sum(r) - sum(l); }
};
int n, q, c, x, y;
int main() {
	cin >> n >> q;
	BIT<int> b(n);
	for (int i = 0; i < q; i++) {
		cin >> c >> x >> y;
		if (!c) b.add(x - 1, y);
		else cout << b.sum(x - 1, y) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In instantiation of 'BIT<Type>::BIT(int) [with Type = int]':
a.cc:22:14:   required from here
   22 |         BIT<int> b(n);
      |                     ^
a.cc:13:23: error: 'memset' was not declared in this scope
   13 |                 memset(v, 0, sizeof(v));
      |                 ~~~~~~^~~~~~~~~~~~~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;


struct RSQ{
    int n;
    vector<int> dat;
    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        dat.resize(2 * n - 1, 0);
        // rep(i, 0, 2 * n - 1) dat[i] = MAX;
    }
    void update(int k, int a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = dat[2 * k + 1], dat[2 * k + 2];
        }
    }
    //min[a, b) query(a, b, 0, 0, r.n)
    int find(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return dat[k];
        int vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
        return vl + vr;
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    RMQ r;
    r.init(n);
    rep(i, 0, q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0){
            r.update(x, y);
        }else{
            cout << r.find(x, y + 1, 0, 0, r.n) << endl;
        }
    }
    // rep(i, 0, 15){
    //     cout << i << ' ' << r.dat[i] << endl;
    // }
}

Compiler output:
a.cc: In member function 'void RSQ::update(long long int, long long int)':
a.cc:25:51: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   25 |             dat[k] = dat[2 * k + 1], dat[2 * k + 2];
      |                                                   ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: declared here
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:41:5: error: 'RMQ' was not declared in this scope; did you mean 'RSQ'?
   41 |     RMQ r;
      |     ^~~
      |     RSQ
a.cc:42:5: error: 'r' was not declared in this scope
   42 |     r.init(n);
      |     ^
Language: C++

#pragma once
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
template<class T, class Func = function<T(T, T)>>
class segtree {
	vector<T> obj;
	int offset;
	Func updater;
	T e;
	int bufsize(int num) {
		int i = 1;
		for (; num >i; i <<= 1);
		offset = i - 1;
		return (i << 1) - 1;
	}
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return e;
		if (a <= l && r <= b)return obj[k];
		else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
public:
	T query(int a, int b) {//[a,b)
		return query(a, b, 0, 0, offset + 1);
	}
	void updateall(int l = 0, int r = offset + 1) {
		l += offset, r += offset;
		do {
			l = l - 1 >> 1, r = r - 1 >> 1;
			for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
		} while (r)
	}
	void update(int k, T a) {
		k += offset;
		obj[k] = a;
		while (k) {
			k = k - 1 >> 1;
			obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
		}
	}
	segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
	segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
		copy(vec.begin(), vec.end(), obj.begin() + offset);
		updateall();
	}
	auto operator[](int n) {//reference?????????????????????T&
		return obj[n + offset];
	}
};
int main() {
	int n, q;
	cin >> n >> q;
	segtree<int, plus<int>> seg(n+1,0);
	rep(i, q) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c) {
			cout << seg.query(x, y + 1) << endl;;
		}
		else {
			seg.update(x, seg[x]+y);
		}
	}
}

Compiler output:
a.cc:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
a.cc:55:43: error: invalid use of non-static data member 'segtree<T, Func>::offset'
   55 |         void updateall(int l = 0, int r = offset + 1) {
      |                                           ^~~~~~
a.cc:37:13: note: declared here
   37 |         int offset;
      |             ^~~~~~
a.cc: In member function 'void segtree<T, Func>::updateall(int, int)':
a.cc:61:9: error: expected ';' before '}' token
   61 |         }
      |         ^
Language: C++

#pragma once
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
template<class T, class Func = function<T(T, T)>>
class segtree {
	vector<T> obj;
	int offset;
	Func updater;
	T e;
	int bufsize(int num) {
		int i = 1;
		for (; num >i; i <<= 1);
		offset = i - 1;
		return (i << 1) - 1;
	}
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return e;
		if (a <= l && r <= b)return obj[k];
		else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
public:
	T query(int a, int b) {//[a,b)
		return query(a, b, 0, 0, offset + 1);
	}
	void updateall(int l = 0, int r = -1) {
		if (r == -1)r = offset + 1;
		l += offset, r += offset;
		do {
			l = l - 1 >> 1, r = r - 1 >> 1;
			for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
		} while (r);
	}
	void update(int k, T a) {
		k += offset;
		obj[k] = a;
		while (k) {
			k = k - 1 >> 1;
			obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
		}
	}
	segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
	segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
		copy(vec.begin(), vec.end(), obj.begin() + offset);
		updateall();
	}
	vector<T>::reference operator[](int n) {//reference?????????????????????T&
		return obj[n + offset];
	}
};
int main() {
	int n, q;
	cin >> n >> q;
	segtree<int, plus<int>> seg(n+1,0);
	rep(i, q) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c) {
			cout << seg.query(x, y + 1) << endl;;
		}
		else {
			seg.update(x, seg[x]+y);
		}
	}
}

Compiler output:
a.cc:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
a.cc:76:9: error: need 'typename' before 'std::vector<_Tp>::reference' because 'std::vector<_Tp>' is a dependent scope
   76 |         vector<T>::reference operator[](int n) {//reference?????????????????????T&
      |         ^~~~~~~~~
      |         typename 
a.cc: In function 'int main()':
a.cc:91:42: error: no match for 'operator[]' (operand types are 'segtree<int, std::plus<int> >' and 'int')
   91 |                         seg.update(x, seg[x]+y);
      |                                          ^