Language: C++

#include <iostream>
#include <vector>
using namespace std;
struct SegTree{
	//
	int n;
	vector<ll> dat,laz;
	//
	SegTree(int n_){
		init(n_);
	}
	//
	void init(int n_){
		n=1;
		while(n<n_){
			n*=2;
		}
		for(int i=0;i<2*n-1;i++){
			dat.push_back(0);
			laz.push_back(0);
		}
	}
	//
	void eval(int l,int k){
		if(k*2+1<n*2-1){
			laz[k*2+1]+=laz[k];
			laz[k*2+2]+=laz[k];
		}
		dat[k]+=laz[k]*l;
		laz[k]=0;
	}
	//
	ll update(int a,int b,int x,int k=0,int l=0,int r=-1){
		if(r==-1){
			r=n;
		}
		eval(r-l,k);
		if(r<=a||b<=l){
			return dat[k]+laz[k]*(r-l);
		}else if(a<=l&&r<=b){
			return dat[k]+(laz[k]+=x)*(r-l);
		}else{
			eval(r-l,k);
			ll va=update(a,b,x,k*2+1,l,(l+r)/2);
			ll vb=update(a,b,x,k*2+2,(l+r)/2,r);
			return dat[k]=va+vb;
		}
	}
	//
	ll query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1){
			r=n;
		}
		eval(r-l,k);
		if(r<=a||b<=l){
			return 0;
		}else if(a<=l&&r<=b){
			return dat[k];
		}else{
			ll va=query(a,b,k*2+1,l,(l+r)/2);
			ll vb=query(a,b,k*2+2,(l+r)/2,r);
			return va+vb;
		}
	}
	//
};
int main(){
	int N,Q;
	cin>>N>>Q;
	SegTree Seg(N);
	while(Q--){
		int C;
		cin>>C;
		if(C==1){
			int S,T;
			cin>>S>>T;
			cout<<Seg.query(S-1,T)<<endl;
		}else{
			int S,T,X;
			cin>>S>>T>>X;
			Seg.update(S-1,T,X);
		}
	}
	return 0;
}


Compiler output:
a.cc:7:16: error: 'll' was not declared in this scope
    7 |         vector<ll> dat,laz;
      |                ^~
a.cc:7:18: error: template argument 1 is invalid
    7 |         vector<ll> dat,laz;
      |                  ^
a.cc:7:18: error: template argument 2 is invalid
a.cc:33:9: error: 'll' does not name a type
   33 |         ll update(int a,int b,int x,int k=0,int l=0,int r=-1){
      |         ^~
a.cc:50:9: error: 'll' does not name a type
   50 |         ll query(int a,int b,int k=0,int l=0,int r=-1){
      |         ^~
a.cc: In member function 'void SegTree::init(int)':
a.cc:19:29: error: request for member 'push_back' in '((SegTree*)this)->SegTree::dat', which is of non-class type 'int'
   19 |                         dat.push_back(0);
      |                             ^~~~~~~~~
a.cc:20:29: error: request for member 'push_back' in '((SegTree*)this)->SegTree::laz', which is of non-class type 'int'
   20 |                         laz.push_back(0);
      |                             ^~~~~~~~~
a.cc: In member function 'void SegTree::eval(int, int)':
a.cc:26:28: error: invalid types 'int[int]' for array subscript
   26 |                         laz[k*2+1]+=laz[k];
      |                            ^
a.cc:26:40: error: invalid types 'int[int]' for array subscript
   26 |                         laz[k*2+1]+=laz[k];
      |                                        ^
a.cc:27:28: error: invalid types 'int[int]' for array subscript
   27 |                         laz[k*2+2]+=laz[k];
      |                            ^
a.cc:27:40: error: invalid types 'int[int]' for array subscript
   27 |                         laz[k*2+2]+=laz[k];
      |                                        ^
a.cc:29:20: error: invalid types 'int[int]' for array subscript
   29 |                 dat[k]+=laz[k]*l;
      |                    ^
a.cc:29:28: error: invalid types 'int[int]' for array subscript
   29 |                 dat[k]+=laz[k]*l;
      |                            ^
a.cc:30:20: error: invalid types 'int[int]' for array subscript
   30 |                 laz[k]=0;
      |                    ^
a.cc: In function 'int main()':
a.cc:77:35: error: 'struct SegTree' has no member named 'query'
   77 |                         cout<<Seg.query(S-1,T)<<endl;
      |                                   ^~~~~
a.cc:81:29: error: 'struct SegTree' has no member named 'update'
   81 |                         Seg.update(S-1,T,X);
      |                             ^~~~~~