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

#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#define REP(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;

template <class T> struct StarrySkyTreeMin {

    int N;
    vector<T> node_acc, node_min;
    const T INF = numeric_limits<T>::max() / 2;
  
    StarrySkyTreeMin (int n) {
        N = 4 * (int)log2(n);
        node_acc.resize(N*2,0);
        node_min.resize(N*2,0); 
    }

    void add(int l, int r, T val) {
        _add(l,r,val,0,0,N);
    }
    
    T get_min(int l, int r) {
        return _get_min(l,r,0,0,N);
    }

    void _add(int a, int b, T x, int k, int l, int r) {
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            node_acc[k] += x;
            return;
        }
        _add(a,b,x,k*2+1,l,(l+r)/2);
        _add(a,b,x,k*2+2,(l+r)/2,r);
        T l_val = node_min[k*2+1] + node_acc[k*2+1];
        T r_val = node_min[k*2+2] + node_acc[k*2+2];
        node_min[k] = min(l_val,r_val);
    }

    T _get_min(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return (node_min[k] + node_acc[k]);
        T l_val = _get_min(a,b,k*2+1,l,(l+r)/2);
        T r_val = _get_min(a,b,k*2+2,(l+r)/2,r);
        return (min(l_val,r_val) + node_acc[k]);
    }

};

int main() {
    
    StarrySkyTreeMin<ll> inst(100010);

    int n,q; cin >> n >> q;
    REP(i,q) {
        int com; cin >> com;
        if(com == 0) {
            int s,t,x; cin >> s >> t >> x;
            inst.add(s,t+1,x);
        } else {   
            int a; cin >> a;
            cout << inst.get_min(a,a+1) << endl;
        }
    }    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:22: error: 'll' was not declared in this scope
   53 |     StarrySkyTreeMin<ll> inst(100010);
      |                      ^~
a.cc:53:24: error: template argument 1 is invalid
   53 |     StarrySkyTreeMin<ll> inst(100010);
      |                        ^
a.cc:60:18: error: request for member 'add' in 'inst', which is of non-class type 'int'
   60 |             inst.add(s,t+1,x);
      |                  ^~~
a.cc:63:26: error: request for member 'get_min' in 'inst', which is of non-class type 'int'
   63 |             cout << inst.get_min(a,a+1) << endl;
      |                          ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#define REP(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;

template <class T> struct StarrySkyTreeMin {

    int N;
    vector<T> node_acc, node_min;
    const T INF = numeric_limits<T>::max() / 2;
  
    StarrySkyTreeMin (int n) {
        N = 4 * (int)log2(n);
        node_acc.resize(N*2,0);
        node_min.resize(N*2,0); 
    }

    void add(int l, int r, T val) {
        _add(l,r,val,0,0,N);
    }
    
    T get_min(int l, int r) {
        return _get_min(l,r,0,0,N);
    }

    void _add(int a, int b, T x, int k, int l, int r) {
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            node_acc[k] += x;
            return;
        }
        _add(a,b,x,k*2+1,l,(l+r)/2);
        _add(a,b,x,k*2+2,(l+r)/2,r);
        T l_val = node_min[k*2+1] + node_acc[k*2+1];
        T r_val = node_min[k*2+2] + node_acc[k*2+2];
        node_min[k] = min(l_val,r_val);
    }

    T _get_min(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return (node_min[k] + node_acc[k]);
        T l_val = _get_min(a,b,k*2+1,l,(l+r)/2);
        T r_val = _get_min(a,b,k*2+2,(l+r)/2,r);
        return (min(l_val,r_val) + node_acc[k]);
    }

};

int main() {
    
    StarrySkyTreeMin<ll> inst(100010);

    int n,q; cin >> n >> q;
    REP(i,q) {
        int com; cin >> com;
        if(com == 0) {
            ll s,t,x; cin >> s >> t >> x;
            inst.add(s,t+1,x);
        } else {   
            int a; cin >> a;
            cout << inst.get_min(a,a+1) << endl;
        }
    }    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:22: error: 'll' was not declared in this scope
   53 |     StarrySkyTreeMin<ll> inst(100010);
      |                      ^~
a.cc:53:24: error: template argument 1 is invalid
   53 |     StarrySkyTreeMin<ll> inst(100010);
      |                        ^
a.cc:59:15: error: expected ';' before 's'
   59 |             ll s,t,x; cin >> s >> t >> x;
      |               ^~
      |               ;
a.cc:59:30: error: 's' was not declared in this scope
   59 |             ll s,t,x; cin >> s >> t >> x;
      |                              ^
a.cc:59:35: error: 't' was not declared in this scope
   59 |             ll s,t,x; cin >> s >> t >> x;
      |                                   ^
a.cc:59:40: error: 'x' was not declared in this scope
   59 |             ll s,t,x; cin >> s >> t >> x;
      |                                        ^
a.cc:60:18: error: request for member 'add' in 'inst', which is of non-class type 'int'
   60 |             inst.add(s,t+1,x);
      |                  ^~~
a.cc:63:26: error: request for member 'get_min' in 'inst', which is of non-class type 'int'
   63 |             cout << inst.get_min(a,a+1) << endl;
      |                          ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#define REP(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;

template <class T> struct StarrySkyTreeMin {

    int N;
    vector<T> node_acc, node_min;
    const T INF = numeric_limits<T>::max() / 2;
  
    StarrySkyTreeMin (int n) {
        N = 4 * (int)log2(n);
        node_acc.resize(N*2,0);
        node_min.resize(N*2,0); 
    }

    void add(int l, int r, T val) {
        _add(l,r,val,0,0,N);
    }
    
    T get_min(int l, int r) {
        return _get_min(l,r,0,0,N);
    }

    void _add(int a, int b, T x, int k, int l, int r) {
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            node_acc[k] += x;
            return;
        }
        _add(a,b,x,k*2+1,l,(l+r)/2);
        _add(a,b,x,k*2+2,(l+r)/2,r);
        T l_val = node_min[k*2+1] + node_acc[k*2+1];
        T r_val = node_min[k*2+2] + node_acc[k*2+2];
        node_min[k] = min(l_val,r_val);
    }

    T _get_min(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return (node_min[k] + node_acc[k]);
        T l_val = _get_min(a,b,k*2+1,l,(l+r)/2);
        T r_val = _get_min(a,b,k*2+2,(l+r)/2,r);
        return (min(l_val,r_val) + node_acc[k]);
    }

};

int main() {
    
    StarrySkyTreeMin<long long> inst(100010);

    int n,q; cin >> n >> q;
    REP(i,q) {
        int com; cin >> com;
        if(com == 0) {
            ll s,t,x; cin >> s >> t >> x;
            inst.add(s,t+1,x);
        } else {   
            int a; cin >> a;
            cout << inst.get_min(a,a+1) << endl;
        }
    }    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:13: error: 'll' was not declared in this scope
   59 |             ll s,t,x; cin >> s >> t >> x;
      |             ^~
a.cc:59:30: error: 's' was not declared in this scope
   59 |             ll s,t,x; cin >> s >> t >> x;
      |                              ^
a.cc:59:35: error: 't' was not declared in this scope
   59 |             ll s,t,x; cin >> s >> t >> x;
      |                                   ^
a.cc:59:40: error: 'x' was not declared in this scope
   59 |             ll s,t,x; cin >> s >> t >> x;
      |                                        ^
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
int n; //the sieze of the target array
int l; // the real size of tree;
int q; //number of querys
int *D; //segment tree, D[i] = min value in range node i
int s;
int t;
int x;
int com;
int INF;
int array2tree(int k){return k+n-1;}
int parent(int k){return (k-1)/2;}
int left_child(int k){return 2*k+1;}
int right_child(int k){return 2*k+2;}
int MIN(int ki){ if(D[left_child(ki)] > D[right_child(ki)]){return D[right_child(ki)];}else{return D[left_child(ki)];}    }
int min(int a, int b){if (a > b){return b;}else{return a;} }

void initRMQ();
void update_leaf();
void update(int ki, int ks, int kt);
int find(int ki, int ks, int kt);
void fetch();

int main(){
	scanf("%d %d",&n,&q);
	initRMQ();
	while(q>0){
		fetch();
		q--;
	}
	return 1;
}

void initRMQ(){
	INF = INT_MAX;
	int i = 1;
	while( i< n ){
		i *= 2;
	}
	if(i>1){
	l = 2*i-1-1;
	}else {l = 1;};
	D = new int[l];
	if(!D){printf("new a D array falied \n");return;}
	for(i = 0; i<l;i++){
		D[i] = INF;
	}

}// end of initRMQ

void fetch(){
	scanf("%d",&com);
	if(com){
		scanf("%d %d",&s, &t);
		t++;
		printf("%d\n",find(0,0,n));
	}else{
		scanf("%d %d %d",&s,&t,&x);
		t++;
		//update_leaf();
		update(0,0,l);
	}
}
int find(int ki, int ks, int kt){
	int V1 = INF;
	int V2 = INF;
	int V3 = INF;
	//check range
	if(l == 1){return D[0];}
	if(kt <= s  || t <= ks ){return INF;}

	if(s <= ks && kt < t){
		return D[ki];
	}
	// start recursive
	int mid = (ks+kt)/2;
	if(ki < l-n){ // if ki not leaf
		if(left_child(ki)<l){
			V1 = find(left_child(ki),ks,mid);
		}
		if(right_child(ki)<l){
			V2 = find(right_child(ki),mid,kt);
		}
		return min(V1, V2);
	}else{ // if ki is leaf
	
		if(s<=(ki - (l-n))<t){
			V3 = D[ki];
		}
		return V3;
	}

}
void update_leaf(){
	int i;
	int ks = s+ n -1;
	int kt = t + n-1;
	for(i = ks; i <= kt; i++){
		D[i] = x;
	}
}
void update(int ki, int ks, int kt){
	int i;
	int mid = (ks+kt)/2;
	//check range
	if(kt <= s  || t <= ks ){return;}

	
	if(s <= ks && kt <= t){
		if(ki < l-n){
			update(left_child(ki),ks, mid);
			update(right_child(ki), mid, kt);
		}else {
		if(ks != kt){
			update(ki+1,ks+1,kt);
		}
		}

		D[ki] = x;
		return;
	}

	// start recursive
	if(ki < l-n){
	update(left_child(ki),ks, mid);
	update(right_child(ki), mid, kt);
	D[ki] = MIN(ki);
	}else {if(ks != kt){
		update(ki+1, ks+1, kt);
	}}

	
}// end of update





Compiler output:
main.c:3:10: fatal error: iostream: No such file or directory
    3 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

template<class T>
class lpsg_tree {
private:
    vector<T> lazy;
    vector<T> seg;
    T def;
    lli num;
    void push(lli k){
        if(lazy[k] == def) return;
        set(k*2+1,lazy[k]);
        set(k*2+2,lazy[k]);
        lazy[k] = def;
    }
    void set(lli k,T x){
        lazy[k] = x;seg[k] = x;
    }
    void update(lli a,lli b,T x,lli k,lli l,lli r){
        if(r <= a || b <= l) return;
        if(a <= l && r <= b) set(k,x);
        else {
            push(k);
            update(a,b,x,k*2+1,l,(r+l)/2);
            update(a,b,x,k*2+2,(l+r)/2,r);
            seg[k] = func(seg[k*2+1],seg[k*2+2]);
        }
    }
    T func(T a,T b){
        return min(a,b);
    }
    T query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return seg[k];
        push(k);
        T vl = query(a,b,k*2+1,l,(l+r)/2);
        T vr = query(a,b,k*2+2,(l+r)/2,r);
        return func(vl,vr);
    }
public:
    lpsg_tree(){}
    lpsg_tree(lli n,lli d = INT_MAX):lazy(n*4,d),seg(n*4,d){
        def = d;
        num = 1;
        while(n > num) num <<= 1;
    }
    void update(lli a,lli b,lli x){
        update(a,b,x,0,0,num);
    }
    T query(lli a,lli b){
        return query(a,b,0,0,num);
    }

};


lpsg_tree<lli> sg;
lli n,q;
lli c,s,t,x;

int main(){
    cin >> n >> q;
    sg = lpsg_tree<lli> (n);
    for(lli i = 0;i < q;i++){
        cin >> c;
        if(c){
            cin >> s >> t;
            cout << sg.query(s,t+1) << endl;
        }else{
            cin >> s >> t >> x;
            sg.update(s,t+1,x);
        }
    }
    return 0;
}

Compiler output:
a.cc:61:29: error: 'INT_MAX' was not declared in this scope
   61 |     lpsg_tree(lli n,lli d = INT_MAX):lazy(n*4,d),seg(n*4,d){
      |                             ^~~~~~~
a.cc:11:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <cmath>
  +++ |+#include <climits>
   11 | #include <string>
Language: C++

#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

template<class T>
class lpsg_tree {
private:
    vector<T> lazy;
    vector<T> seg;
    T def;
    lli num;
    void push(lli k){
        if(lazy[k] == def) return;
        set(k*2+1,lazy[k]);
        set(k*2+2,lazy[k]);
        lazy[k] = def;
    }
    void set(lli k,T x){
        lazy[k] = x;seg[k] = x;
    }
    void update(lli a,lli b,T x,lli k,lli l,lli r){
        if(r <= a || b <= l) return;
        if(a <= l && r <= b) set(k,x);
        else {
            push(k);
            update(a,b,x,k*2+1,l,(r+l)/2);
            update(a,b,x,k*2+2,(l+r)/2,r);
            seg[k] = func(seg[k*2+1],seg[k*2+2]);
        }
    }
    T func(T a,T b){
        return min(a,b);
    }
    T query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return seg[k];
        push(k);
        T vl = query(a,b,k*2+1,l,(l+r)/2);
        T vr = query(a,b,k*2+2,(l+r)/2,r);
        return func(vl,vr);
    }
public:
    lpsg_tree(){}
    lpsg_tree(lli n,lli d = INT_MAX):lazy(n*4,d),seg(n*4,d){
        def = d;
        num = 1;
        while(n > num) num <<= 1;
    }
    void update(lli a,lli b,lli x){
        update(a,b,x,0,0,num);
    }
    T query(lli a,lli b){
        return query(a,b,0,0,num);
    }

};


lpsg_tree<lli> sg;
lli n,q;
lli c,s,t,x;

int main(){
    cin >> n >> q;
    sg = lpsg_tree<lli> (n,INT_MAX);
    for(lli i = 0;i < q;i++){
        cin >> c;
        if(c){
            cin >> s >> t;
            cout << sg.query(s,t+1) << endl;
        }else{
            cin >> s >> t >> x;
            sg.update(s,t+1,x);
        }
    }
    return 0;
}

Compiler output:
a.cc:61:29: error: 'INT_MAX' was not declared in this scope
   61 |     lpsg_tree(lli n,lli d = INT_MAX):lazy(n*4,d),seg(n*4,d){
      |                             ^~~~~~~
a.cc:11:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <cmath>
  +++ |+#include <climits>
   11 | #include <string>
a.cc: In function 'int main()':
a.cc:82:28: error: 'INT_MAX' was not declared in this scope
   82 |     sg = lpsg_tree<lli> (n,INT_MAX);
      |                            ^~~~~~~
a.cc:82:28: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

template<class T>
class lpsg_tree {
private:
    vector<T> lazy;
    vector<T> seg;
    T def;
    lli num;
    void push(lli k){
        if(lazy[k] == def) return;
        set(k*2+1,lazy[k]);
        set(k*2+2,lazy[k]);
        lazy[k] = def;
    }
    void set(lli k,T x){
        lazy[k] = x;seg[k] = x;
    }
    void update(lli a,lli b,T x,lli k,lli l,lli r){
        if(r <= a || b <= l) return;
        if(a <= l && r <= b) set(k,x);
        else {
            push(k);
            update(a,b,x,k*2+1,l,(r+l)/2);
            update(a,b,x,k*2+2,(l+r)/2,r);
            seg[k] = func(seg[k*2+1],seg[k*2+2]);
        }
    }
    T func(T a,T b){
        return min(a,b);
    }
    T query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return seg[k];
        push(k);
        T vl = query(a,b,k*2+1,l,(l+r)/2);
        T vr = query(a,b,k*2+2,(l+r)/2,r);
        return func(vl,vr);
    }
public:
    lpsg_tree(){}
    lpsg_tree(lli n,lli d = INT_MAX):lazy(n*4,d),seg(n*4,d){
        def = d;
        num = 1;
        while(n > num) num <<= 1;
    }
    void update(lli a,lli b,lli x){
        update(a,b,x,0,0,num);
    }
    T query(lli a,lli b){
        return query(a,b,0,0,num);
    }

};


lpsg_tree<lli> sg;
lli n,q;
lli c,s,t,x;

int main(){
    cin >> n >> q;
    sg = lpsg_tree<lli> (n,2147483647);
    for(lli i = 0;i < q;i++){
        cin >> c;
        if(c){
            cin >> s >> t;
            cout << sg.query(s,t+1) << endl;
        }else{
            cin >> s >> t >> x;
            sg.update(s,t+1,x);
        }
    }
    return 0;
}

Compiler output:
a.cc:61:29: error: 'INT_MAX' was not declared in this scope
   61 |     lpsg_tree(lli n,lli d = INT_MAX):lazy(n*4,d),seg(n*4,d){
      |                             ^~~~~~~
a.cc:11:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <cmath>
  +++ |+#include <climits>
   11 | #include <string>
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;

public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);

        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[i*2+1], node[i*2+2]);
    }

    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }

    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }

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


int main() {
    int n;
    cin >> n >> q;
    LazySegmentTree seg( vector<int>(n, INT_MAX) );
    rep(i,q){
        int query;
        cin >> query;
        if(query == 0){
            int s,t,x;
            cin >> s >> t >> x;
            seg.update(s,t+1,x);
        }
        else{
            int s, t;
            cin >> s >> t;
            cout << seg.find(s,t+1) << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:17: error: 'q' was not declared in this scope
   80 |     cin >> n >> q;
      |                 ^
Language: C++

open Printf
open Scanf

let () =
  let n, q = scanf "%d %d " (fun a b -> (a, b)) in
  let b = 300 in
  let iv = 2147483647 in
  let ar = Array.make n iv in
  let ubk = Array.make ((n + b - 1) / b) None in
  let mbk = Array.make ((n + b - 1) / b) iv in
  let wb i = match ubk.(i) with
      None -> ()
    | Some v -> let rec iter j =
                  if j = b then ubk.(i) <- None
                  else begin
                      ar.(i*b+j) <- v;
                      iter (j+1)
                    end in
                iter 0;
                mbk.(i) <- v
  in
  let update s t x =
    let rec iter i =
      if i >= t then ()
      else
        if i mod b = 0 && i + b <= t then
          begin
            ubk.(i / b) <- Some x;
            mbk.(i / b) <- x;
            iter (i + b)
          end
        else
          begin
            (match ubk.(i / b) with
               None -> ()
             | Some _ -> wb (i / b));
            ar.(i) <- x;
            mbk.(i / b) <- min mbk.(i / b) x;
            iter (i + 1)
          end
    in iter s
  in
  let find s t =
    let rec iter i m =
      if i >= t then m
      else
        if i mod b = 0 && i + b <= t then
          iter (i + b) (min m mbk.(i / b))
        else
          iter (i + 1) (min m ar.(i))
    in
    iter s iv
  in
  let rec loop c =
    if c = 0 then ()
    else
      begin
        (let com = scanf "%d " (fun u -> u) in
        if com = 0 then
          let s, t, x = scanf "%d %d %d " (fun u v w -> (u, v+1, w)) in
          update s t x
        else
          let s, t = scanf "%d %d " (fun u v -> (u, v+1)) in
          find s t |> printf "%d\n");
        loop (c - 1)
      end
  in
  loop q

Compiler output:
a.cc:1:1: error: 'open' does not name a type
    1 | open Printf
      | ^~~~
a.cc:17:28: error: expected constructor, destructor, or type conversion before '(' token
   17 |                       iter (j+1)
      |                            ^
a.cc:20:17: error: 'mbk' does not name a type
   20 |                 mbk.(i) <- v
      |                 ^~~
a.cc:29:13: error: 'mbk' does not name a type
   29 |             mbk.(i / b) <- x;
      |             ^~~
a.cc:30:18: error: expected constructor, destructor, or type conversion before '(' token
   30 |             iter (i + b)
      |                  ^
a.cc:37:13: error: 'ar' does not name a type; did you mean 'char'?
   37 |             ar.(i) <- x;
      |             ^~
      |             char
a.cc:38:13: error: 'mbk' does not name a type
   38 |             mbk.(i / b) <- min mbk.(i / b) x;
      |             ^~~
a.cc:39:18: error: expected constructor, destructor, or type conversion before '(' token
   39 |             iter (i + 1)
      |                  ^
a.cc:65:14: error: expected constructor, destructor, or type conversion before '(' token
   65 |         loop (c - 1)
      |              ^
Language: C++

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

//begin
template<class T>
class SqrtDecompositionRangeAddRangeSum {
  int N, K;
  int sqrtN;
  vector<T> data;
  vector<T> bucket_sum;
  vector<T> bucket_add;
  SqrtDecompositionRangeAddRangeSum(int n) : N(n) {
    while (sqrtN * sqrtN <= N){
      sqrtN++;
    }
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucket_sum.assign(K, 0);
    bucket_add.assign(K, 0);
  }
  // [s, t)
  void add(int s, int t, T x) {
    int p = s / sqrtN;
    int q = q / sqrtN;
    for (int k = p; k <= q; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        bucket_add[k] += x;
      } else {
        for (int i = max(s, l); i < min(t, r); ++i) {
          data[i] += x;
          bucket_sum[k] += x;
        }
      }
    }
  }
  // [s, t)
  T get_sum(int s, int t) {
    int p = s / sqrtN;
    int q = q / sqrtN;
    T sum = 0;
    for (int k = p; k <= q; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        sum += bucket_sum[k] + bucket_add[k] * sqrtN;
      } else {
        for (int i = max(s, l); i < min(t, r); ++i) {
          sum += data[i] + bucket_add[k];
        }
      }
    }
    return sum;
  }
  T get_value(int i){
    int k = i / sqrtN;
    return data[i] + bucket_add[k];
  }
};
//end
signed main() {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  SqrtDecompositionRangeAddRangeSum<long long> decomp(N);
  while (Q--) {
    int c;
    cin >> c;
    if (c == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      decomp.add(s, t + 1, x);
    } else {
      int s, t;
      cin >> s >> t;
      cout << decomp.get_sum(s, t + 1) << endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:56: error: 'SqrtDecompositionRangeAddRangeSum<T>::SqrtDecompositionRangeAddRangeSum(int) [with T = long long int]' is private within this context
   70 |   SqrtDecompositionRangeAddRangeSum<long long> decomp(N);
      |                                                        ^
a.cc:14:3: note: declared private here
   14 |   SqrtDecompositionRangeAddRangeSum(int n) : N(n) {
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:77:17: error: 'void SqrtDecompositionRangeAddRangeSum<T>::add(int, int, T) [with T = long long int]' is private within this context
   77 |       decomp.add(s, t + 1, x);
      |       ~~~~~~~~~~^~~~~~~~~~~~~
a.cc:24:8: note: declared private here
   24 |   void add(int s, int t, T x) {
      |        ^~~
a.cc:81:29: error: 'T SqrtDecompositionRangeAddRangeSum<T>::get_sum(int, int) [with T = long long int]' is private within this context
   81 |       cout << decomp.get_sum(s, t + 1) << endl;
      |               ~~~~~~~~~~~~~~^~~~~~~~~~
a.cc:42:5: note: declared private here
   42 |   T get_sum(int s, int t) {
      |     ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <vector>
using namespace std;
 
//begin
template<class T>
class SqrtDecompositionRangeAddRangeSum {
  int N, K;
  int sqrtN;
  vector<T> data;
  vector<T> bucket_sum;
  vector<T> bucket_add;
  SqrtDecompositionRangeAddRangeSum(int n) : N(n) {
    while (sqrtN * sqrtN <= N){
      sqrtN++;
    }
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucket_sum.assign(K, 0);
    bucket_add.assign(K, 0);
  }
  // [s, t)
  void add(int s, int t, T x) {
    int p = s / sqrtN;
    int q = q / sqrtN;
    for (int k = p; k <= q; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        bucket_add[k] += x;
      } else {
        for (int i = max(s, l); i < min(t, r); ++i) {
          data[i] += x;
          bucket_sum[k] += x;
        }
      }
    }
  }
  // [s, t)
  T get_sum(int s, int t) {
    int p = s / sqrtN;
    int q = q / sqrtN;
    T sum = 0;
    for (int k = p; k <= q; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= s || t <= l)
        continue;
      if (s <= l && r <= t) {
        sum += bucket_sum[k] + bucket_add[k] * sqrtN;
      } else {
        for (int i = max(s, l); i < min(t, r); ++i) {
          sum += data[i] + bucket_add[k];
        }
      }
    }
    return sum;
  }
  T get_value(int i){
    int k = i / sqrtN;
    return data[i] + bucket_add[k];
  }
};
//end
signed main() {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  SqrtDecompositionRangeAddRangeSum<long long> decomp(N);
  while (Q--) {
    int c;
    cin >> c;
    if (c == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      decomp.add(s, t + 1, (long long)x);
    } else {
      int s, t;
      cin >> s >> t;
      cout << decomp.get_sum(s, t + 1) << endl;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:56: error: 'SqrtDecompositionRangeAddRangeSum<T>::SqrtDecompositionRangeAddRangeSum(int) [with T = long long int]' is private within this context
   70 |   SqrtDecompositionRangeAddRangeSum<long long> decomp(N);
      |                                                        ^
a.cc:14:3: note: declared private here
   14 |   SqrtDecompositionRangeAddRangeSum(int n) : N(n) {
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:77:17: error: 'void SqrtDecompositionRangeAddRangeSum<T>::add(int, int, T) [with T = long long int]' is private within this context
   77 |       decomp.add(s, t + 1, (long long)x);
      |       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:24:8: note: declared private here
   24 |   void add(int s, int t, T x) {
      |        ^~~
a.cc:81:29: error: 'T SqrtDecompositionRangeAddRangeSum<T>::get_sum(int, int) [with T = long long int]' is private within this context
   81 |       cout << decomp.get_sum(s, t + 1) << endl;
      |               ~~~~~~~~~~~~~~^~~~~~~~~~
a.cc:42:5: note: declared private here
   42 |   T get_sum(int s, int t) {
      |     ^~~~~~~
Language: C++


#include <vector>
using namespace std;

//Base class for Segment Trees
template <class T>
class segtree_base
{
protected:
	size_t width;
	vector<T> vec;
	T def;
	virtual T query_raw(int l_, int r_, int a_, int b_, int k_) = 0;
public:
	segtree_base(size_t size_, const T& def_ = T()) : def(def_)
	{
		width = 1;
		while (width < size_)width *= 2;
		vec.resize(width * 2 - 1, def);
	}
	T query(int left, int right)
	{
		return query_raw(left, right, 0, width, 0);
	}
	virtual ~segtree_base() {}
};


#include <algorithm>
//Range Sum + Range Add Tree
template <class T>
class rsaq_tree : public segtree_base<T>
{
protected:
	vector<T>lazy;
public:
	rsaq_tree(size_t size_, const T& def = 0) :segtree_base<T>(size_, def)
	{
		lazy.resize(this->vec.size());
	}
	void init(const vector<int>&base)
	{
		for (int i = 0; i < width; i++) this->vec[i + n - 1] = base[i];
		for (int i = n - 2; i >= 0; i--) this->vec[i] = this->vec[i * 2 + 1] + this->vec[i * 2 + 2];
	}
	void update(int left, int right, int val)
	{
		update_raw(left, right, val, 0, this->width, 0);
	}
private:
	void eval(int k_, int a_, int b_)
	{
		if (lazy[k_] != 0) {
			this->vec[k_] += lazy[k_];
			if (b_ - a_ > 1) {
				lazy[2 * k_ + 1] += lazy[k_] / 2;
				lazy[2 * k_ + 2] += lazy[k_] / 2;
			}
			lazy[k_] = 0;
		}
	}
	void update_raw(int l_, int r_, int x_, int a_, int b_, int k_)
	{
		eval(k_, a_, b_);
		if (r_ <= a_ || b_ <= l_) return;
		if (l_ <= a_ && b_ <= r_) {
			lazy[k_] += (b_ - a_) * x_;
			eval(k_, a_, b_);
		}
		else {
			update_raw(l_, r_, x_, a_, (a_ + b_) / 2, 2 * k_ + 1);
			update_raw(l_, r_, x_, (a_ + b_) / 2, b_, 2 * k_ + 2);
			this->vec[k_] = this->vec[2 * k_ + 1] + this->vec[2 * k_ + 2];
		}
	}
	T query_raw(int l_, int r_, int a_, int b_, int k_)override
	{
		eval(k_, a_, b_);
		if (r_ <= a_ || b_ <= l_) return this->def;
		if (l_ <= a_ && b_ <= r_) return this->vec[k_];
		T vl = query_raw(l_, r_, a_, (a_ + b_) / 2, 2 * k_ + 1);
		T vr = query_raw(l_, r_, (a_ + b_) / 2, b_, 2 * k_ + 2);
		return vl + vr;
	}
};

#include <iostream>

int main()
{
	int n, q;
	cin >> n >> q;
	rsaq_tree<long long>tree(n);
	for (int i = 0; i < q; ++i)
	{
		int com;
		cin >> com;
		if (com)
		{
			int s, t;
			cin >> s >> t;
			cout << tree.query(s - 1, t) << endl;
		}
		else
		{
			int s, t, x;
			cin >> s >> t >> x;
			tree.update(s - 1, t, x);
		}
	}
	return 0;
}

Compiler output:
a.cc: In member function 'void rsaq_tree<T>::init(const std::vector<int>&)':
a.cc:43:37: error: 'width' was not declared in this scope
   43 |                 for (int i = 0; i < width; i++) this->vec[i + n - 1] = base[i];
      |                                     ^~~~~
a.cc:43:63: error: 'n' was not declared in this scope
   43 |                 for (int i = 0; i < width; i++) this->vec[i + n - 1] = base[i];
      |                                                               ^
a.cc:44:30: error: 'n' was not declared in this scope
   44 |                 for (int i = n - 2; i >= 0; i--) this->vec[i] = this->vec[i * 2 + 1] + this->vec[i * 2 + 2];
      |                              ^
Language: C++


#include <vector>
using namespace std;

//Base class for Segment Trees
template <class T>
class segtree_base
{
protected:
	size_t width;
	vector<T> vec;
	T def;
	virtual T query_raw(int l_, int r_, int a_, int b_, int k_) = 0;
public:
	segtree_base(size_t size_, const T& def_ = T()) : def(def_)
	{
		width = 1;
		while (width < size_)width *= 2;
		vec.resize(width * 2 - 1, def);
	}
	T query(int left, int right)
	{
		return query_raw(left, right, 0, width, 0);
	}
	virtual ~segtree_base() {}
};


#include <algorithm>
//Range Sum + Range Add Tree
template <class T>
class rsaq_tree : public segtree_base<T>
{
protected:
	vector<T>lazy;
public:
	rsaq_tree(size_t size_, const T& def = 0) :segtree_base<T>(size_, def)
	{
		lazy.resize(this->vec.size());
	}
	void init(const vector<int>&base)
	{
		for (int i = 0; i < this->width; i++) this->vec[i + n - 1] = base[i];
		for (int i = n - 2; i >= 0; i--) this->vec[i] = this->vec[i * 2 + 1] + this->vec[i * 2 + 2];
	}
	void update(int left, int right, int val)
	{
		update_raw(left, right, val, 0, this->width, 0);
	}
private:
	void eval(int k_, int a_, int b_)
	{
		if (lazy[k_] != 0) {
			this->vec[k_] += lazy[k_];
			if (b_ - a_ > 1) {
				lazy[2 * k_ + 1] += lazy[k_] / 2;
				lazy[2 * k_ + 2] += lazy[k_] / 2;
			}
			lazy[k_] = 0;
		}
	}
	void update_raw(int l_, int r_, int x_, int a_, int b_, int k_)
	{
		eval(k_, a_, b_);
		if (r_ <= a_ || b_ <= l_) return;
		if (l_ <= a_ && b_ <= r_) {
			lazy[k_] += (b_ - a_) * x_;
			eval(k_, a_, b_);
		}
		else {
			update_raw(l_, r_, x_, a_, (a_ + b_) / 2, 2 * k_ + 1);
			update_raw(l_, r_, x_, (a_ + b_) / 2, b_, 2 * k_ + 2);
			this->vec[k_] = this->vec[2 * k_ + 1] + this->vec[2 * k_ + 2];
		}
	}
	T query_raw(int l_, int r_, int a_, int b_, int k_)override
	{
		eval(k_, a_, b_);
		if (r_ <= a_ || b_ <= l_) return this->def;
		if (l_ <= a_ && b_ <= r_) return this->vec[k_];
		T vl = query_raw(l_, r_, a_, (a_ + b_) / 2, 2 * k_ + 1);
		T vr = query_raw(l_, r_, (a_ + b_) / 2, b_, 2 * k_ + 2);
		return vl + vr;
	}
};

#include <iostream>

int main()
{
	int n, q;
	cin >> n >> q;
	rsaq_tree<long long>tree(n);
	for (int i = 0; i < q; ++i)
	{
		int com;
		cin >> com;
		if (com)
		{
			int s, t;
			cin >> s >> t;
			cout << tree.query(s - 1, t) << endl;
		}
		else
		{
			int s, t, x;
			cin >> s >> t >> x;
			tree.update(s - 1, t, x);
		}
	}
	return 0;
}

Compiler output:
a.cc: In member function 'void rsaq_tree<T>::init(const std::vector<int>&)':
a.cc:43:69: error: 'n' was not declared in this scope
   43 |                 for (int i = 0; i < this->width; i++) this->vec[i + n - 1] = base[i];
      |                                                                     ^
a.cc:44:30: error: 'n' was not declared in this scope
   44 |                 for (int i = n - 2; i >= 0; i--) this->vec[i] = this->vec[i * 2 + 1] + this->vec[i * 2 + 2];
      |                              ^
Language: C++


#include <vector>
using namespace std;

//Base class for Segment Trees
template <class T>
class segtree_base
{
protected:
	size_t width;
	vector<T> vec;
	T def;
	virtual T query_raw(int l_, int r_, int a_, int b_, int k_) = 0;
public:
	segtree_base(size_t size_, const T& def_ = T()) : def(def_)
	{
		width = 1;
		while (width < size_)width *= 2;
		vec.resize(width * 2 - 1, def);
	}
	T query(int left, int right)
	{
		return query_raw(left, right, 0, width, 0);
	}
	virtual ~segtree_base() {}
};


#include <algorithm>
//Range Sum + Range Add Tree
template <class T>
class rsaq_tree : public segtree_base<T>
{
protected:
	vector<T>lazy;
public:
	rsaq_tree(size_t size_, const T& def = 0) :segtree_base<T>(size_, def)
	{
		lazy.resize(this->vec.size());
	}
	void init(const vector<int>&base)
	{
		for (int i = 0; i < this->width; i++) this->vec[i + n - 1] = base[i];
		for (int i = this->width - 2; i >= 0; i--) this->vec[i] = this->vec[i * 2 + 1] + this->vec[i * 2 + 2];
	}
	void update(int left, int right, int val)
	{
		update_raw(left, right, val, 0, this->width, 0);
	}
private:
	void eval(int k_, int a_, int b_)
	{
		if (lazy[k_] != 0) {
			this->vec[k_] += lazy[k_];
			if (b_ - a_ > 1) {
				lazy[2 * k_ + 1] += lazy[k_] / 2;
				lazy[2 * k_ + 2] += lazy[k_] / 2;
			}
			lazy[k_] = 0;
		}
	}
	void update_raw(int l_, int r_, int x_, int a_, int b_, int k_)
	{
		eval(k_, a_, b_);
		if (r_ <= a_ || b_ <= l_) return;
		if (l_ <= a_ && b_ <= r_) {
			lazy[k_] += (b_ - a_) * x_;
			eval(k_, a_, b_);
		}
		else {
			update_raw(l_, r_, x_, a_, (a_ + b_) / 2, 2 * k_ + 1);
			update_raw(l_, r_, x_, (a_ + b_) / 2, b_, 2 * k_ + 2);
			this->vec[k_] = this->vec[2 * k_ + 1] + this->vec[2 * k_ + 2];
		}
	}
	T query_raw(int l_, int r_, int a_, int b_, int k_)override
	{
		eval(k_, a_, b_);
		if (r_ <= a_ || b_ <= l_) return this->def;
		if (l_ <= a_ && b_ <= r_) return this->vec[k_];
		T vl = query_raw(l_, r_, a_, (a_ + b_) / 2, 2 * k_ + 1);
		T vr = query_raw(l_, r_, (a_ + b_) / 2, b_, 2 * k_ + 2);
		return vl + vr;
	}
};

#include <iostream>

int main()
{
	int n, q;
	cin >> n >> q;
	rsaq_tree<long long>tree(n);
	for (int i = 0; i < q; ++i)
	{
		int com;
		cin >> com;
		if (com)
		{
			int s, t;
			cin >> s >> t;
			cout << tree.query(s - 1, t) << endl;
		}
		else
		{
			int s, t, x;
			cin >> s >> t >> x;
			tree.update(s - 1, t, x);
		}
	}
	return 0;
}

Compiler output:
a.cc: In member function 'void rsaq_tree<T>::init(const std::vector<int>&)':
a.cc:43:69: error: 'n' was not declared in this scope
   43 |                 for (int i = 0; i < this->width; i++) this->vec[i + n - 1] = base[i];
      |                                                                     ^
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<class T>
struct Lazy_BIT {
	vector<T> x, lazy;
#define SZ(a) (a&-a)
#define LEFT(a) (a - SZ(a))
#define UP(a) (a + SZ(a))

	Lazy_BIT(int n):x(n+1),lazy(n+1){}
	void sum(int r) {
		T ret = 0;
		for (int k = r; 0 < k; k = LEFT(k)) {
			ret += lazy[k] * (r-LEFT(k)) + x[k];
			for (int cp = UP(k); LEFT(k) == LEFT(cp) && k < x.size(); cp = UP(cp)) {
				ret += lazy[cp] * (r - LEFT(cp));
			}
		}
	}
	void add(int r, int v) {
		for (int k = r; 0 < k; k = LEFT(k)) {
			lazy[k] += v;
			for (int cp = UP(k); LEFT(k) == LEFT(cp) && k < x.size(); cp = UP(cp)) {
				x[cp] += a * (r - LEFT(cp));
			}
		}
	}


};


int main()
{
	int n, q;
	cin >> n >> q;
	Lazy_BIT<ll> fen(n);

	REP(i, q) {
		int m;
		scanf("%d", &m);
		if (m) {
			int s, t;
			scanf("%d %d", &s, &t);

			printf("%lld\n", fen.sum(t) - fen.sum(s-1));
		}
		else {
			int s, t, x;
			scanf("%d %d %d", &s, &t, &x);

			fen.add(t,x);
			fen.add(s-1, -x);
		}
	}

	return 0;
}


Compiler output:
a.cc: In member function 'void Lazy_BIT<T>::add(int, int)':
a.cc:66:42: error: 'a' was not declared in this scope
   66 |                                 x[cp] += a * (r - LEFT(cp));
      |                                          ^
a.cc: In function 'int main()':
a.cc:88:53: error: invalid operands of types 'void' and 'void' to binary 'operator-'
   88 |                         printf("%lld\n", fen.sum(t) - fen.sum(s-1));
      |                                          ~~~~~~~~~~ ^ ~~~~~~~~~~~~
      |                                                 |            |
      |                                                 void         void
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<class T>
struct Lazy_BIT {
	vector<T> x, lazy;
#define SZ(a) (a&-a)
#define LEFT(a) (a - SZ(a))
#define UP(a) (a + SZ(a))

	Lazy_BIT(int n) :x(n + 1), lazy(n + 1) {}
	T sum(int r) {
		T ret = 0;
		for (int k = r; 0 < k; k = LEFT(k)) {
			ret += lazy[k] * (r - LEFT(k)) + x[k];
			for (int cp = UP(k); LEFT(k) == LEFT(cp) && k < x.size(); cp = UP(cp)) {
				ret += lazy[cp] * (r - LEFT(cp));
			}
		}
	}
	void add(int r, int v) {
		for (int k = r; 0 < k; k = LEFT(k)) {
			lazy[k] += v;
			for (int cp = UP(k); LEFT(k) == LEFT(cp) && k < x.size(); cp = UP(cp)) {
				x[cp] += a * (r - LEFT(cp));
			}
		}
	}


};


int main()
{
	int n, q;
	cin >> n >> q;
	Lazy_BIT<ll> fen(n);

	REP(i, q) {
		int m;
		scanf("%d", &m);
		if (m) {
			int s, t;
			scanf("%d %d", &s, &t);

			printf("%lld\n", fen.sum(t) - fen.sum(s - 1));
		}
		else {
			int s, t, x;
			scanf("%d %d %d", &s, &t, &x);

			fen.add(t, x);
			fen.add(s - 1, -x);
		}
	}

	return 0;
}


Compiler output:
a.cc: In member function 'void Lazy_BIT<T>::add(int, int)':
a.cc:66:42: error: 'a' was not declared in this scope
   66 |                                 x[cp] += a * (r - LEFT(cp));
      |                                          ^
a.cc: In instantiation of 'T Lazy_BIT<T>::sum(int) [with T = long long int]':
a.cc:88:28:   required from here
   88 |                         printf("%lld\n", fen.sum(t) - fen.sum(s - 1));
      |                                          ~~~~~~~^~~
a.cc:61:9: warning: no return statement in function returning non-void [-Wreturn-type]
   61 |         }
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;

ll dat[2<<18], add[2<<18];
int segn = 1;
void init(int n){
	while(segn < n)segn *= 2;
}

void lazy_update(int k, int l, int r){
	if(k*2+2 >= segn*2-1)return ;
	dat[k] += add[k]*(r-l);
	add[k*2+1] += add[k];
	add[k*2+2] += add[k];
	add[k] = 0;
}

void update(int a, int b, int x, int k, int l, int r){
	lazy_update(k, l, r);
	if(b <= l || r <= a)return ;
	if(a <= l && r <= b){
		add[k] += x;
		lazy_update(k, l, r);
		return ;
	}
	update(a, b, x, k*2+1, l, (l+r)/2);
	update(a, b, x, k*2+2, (l+r)/2, r);
	dat[k] = dat[k*2+1]+dat[k*2+2];
}

ll get(int a, int b, int k, int l, int r){
	lazy_update(k, l, r);
	if(b <= l || r <= a)return 0;
	if(a <= l && r <= b)return dat[k];
	ll vl = get(a, b, k*2+1, l, (l+r)/2);
	ll vr = get(a, b, k*2+2, (l+r)/2, r);
	return vl+vr;
}

int main(){
	int n, q, c, s, t, x;
	scanf("%d%d", &n, &q);
	timerstart();
	init(n);
	for(int i = 0;i < q;i++){
		scanf("%d", &c);
		if(!c){
			scanf("%d%d%d", &s, &t, &x);
			update(s-1, t, x, 0, 0, segn);
		}else{
			scanf("%d%d", &s, &t);
			ll res = get(s-1, t, 0, 0, segn);
			printf("%lld\n", res);
		}
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:9: error: 'timerstart' was not declared in this scope; did you mean 'timer_t'?
   45 |         timerstart();
      |         ^~~~~~~~~~
      |         timer_t
Language: C++

#include <bits/stdc++.h>

using namespace std;

const long long MAXN = 1000110;
unsigned long long tree[4*MAXN], lazy[4*MAXN];

void push(long long node, long long start, long long end, unsigned long long val){
	tree[node] += (end - start + 1) * val;
	if(start != end){
		lazy[2*node] += val;
		lazy[2*node+1] += val;
	}
}

void updateRange(long long node, long long start, long long end, long long l, long long r, unsigned long long val){
	if(lazy[node]){
		push(node, start, end, lazy[node]);
		lazy[node] = 0;
	}
	if(start > end or start > r or end < l) return;
	if(l <= start and end <= r){
		push(node, start, end, val);
		return;
	}
	long long mid = (start + end)/2;
	updateRange(2*node, start, mid, l, r, val);
	updateRange(2*node+1, mid+1, end, l, r, val);
	tree[node] = tree[2*node] + tree[2*node+1];
}

long long queryRange(long long node, long long start, long long end, long long l, long long r){
	if(start > end or start > r or end < l) return 0;
	if(lazy[node]){
		push(node, start, end, lazy[node]);
		lazy[node] = 0;
	}
	if(l <= start and end <= r) return tree[node];
	long long mid = (start + end)/2;
	long long p1 = queryRange(2*node, start, mid, l, r);
	long long p2 = queryRange(2*node+1, mid+1, end, l, r);
	return p1 + p2;
}

long long main(){
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long n, q;
	cin >> n >> q;
	
	unsigned long long op, s, t, x;
	while(q--){
		cin >> op;
		if(op) {
			cin >> s >> t;
			cout << queryRange(1, 1, n, s, t) << '\n';
		}
		else {
			cin >> s >> t >> x;
			updateRange(1, 1, n, s, t, x);			
		}
	}	

	return 0;
} // br1



Compiler output:
cc1plus: error: '::main' must return 'int'