Language: C++

#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=400005;

struct {
	ll sum,lazy;	
} S[maxn];
int n,q;

void update(int id,int ql,int qr,int v,int l,int r) {
	if (ql==l && qr==r) {
		S[id].lazy+=v;
		return;
	}
	int m=l+r>>1;
	if (qr<=m) update(id<<1,ql,qr,v,l,m);
	else if (ql>m) update(id<<1|1,ql,qr,v,m+1,r);
	else update(id<<1,ql,m,v,l,m), update(id<<1|1,m+1,qr,v,m+1,r);
	S[id].sum=S[id<<1].sum+S[id<<1|1].sum+S[id<<1].lazy*(m-l+1)+S[id<<1|1].lazy*(r-m);
}

int query(int id,int ql,int qr,int l,int r) {
	int m=l+r>>1;
	ll lz=S[id].lazy*(qr-ql+1);
	if (ql==l && qr==r) return lz+S[id].sum;
	if (qr<=m) return lz+query(id<<1,ql,qr,l,m);
	else if (ql>m) return lz+query(id<<1|1,ql,qr,m+1,r);
	else return lz+query(id<<1,ql,m,l,m)+query(id<<1|1,m+1,qr,m+1,r);
}

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		int s,t,x;
		if (op) {
			cin>>s>>t;
			cout<<query(1,s,t,1,n)<<'\n';
		}
		else {
			cin>>s>>t>>x;
			update(1,s,t,x,1,n);
		}
	}
}


Compiler output:
a.cc:7:9: error: 'll' does not name a type
    7 |         ll sum,lazy;
      |         ^~
a.cc: In function 'void update(int, int, int, int, int, int)':
a.cc:13:23: error: 'struct<unnamed>' has no member named 'lazy'
   13 |                 S[id].lazy+=v;
      |                       ^~~~
a.cc:20:15: error: 'struct<unnamed>' has no member named 'sum'
   20 |         S[id].sum=S[id<<1].sum+S[id<<1|1].sum+S[id<<1].lazy*(m-l+1)+S[id<<1|1].lazy*(r-m);
      |               ^~~
a.cc:20:28: error: 'struct<unnamed>' has no member named 'sum'
   20 |         S[id].sum=S[id<<1].sum+S[id<<1|1].sum+S[id<<1].lazy*(m-l+1)+S[id<<1|1].lazy*(r-m);
      |                            ^~~
a.cc:20:43: error: 'struct<unnamed>' has no member named 'sum'
   20 |         S[id].sum=S[id<<1].sum+S[id<<1|1].sum+S[id<<1].lazy*(m-l+1)+S[id<<1|1].lazy*(r-m);
      |                                           ^~~
a.cc:20:56: error: 'struct<unnamed>' has no member named 'lazy'
   20 |         S[id].sum=S[id<<1].sum+S[id<<1|1].sum+S[id<<1].lazy*(m-l+1)+S[id<<1|1].lazy*(r-m);
      |                                                        ^~~~
a.cc:20:80: error: 'struct<unnamed>' has no member named 'lazy'
   20 |         S[id].sum=S[id<<1].sum+S[id<<1|1].sum+S[id<<1].lazy*(m-l+1)+S[id<<1|1].lazy*(r-m);
      |                                                                                ^~~~
a.cc: In function 'int query(int, int, int, int, int)':
a.cc:25:9: error: 'll' was not declared in this scope; did you mean 'ql'?
   25 |         ll lz=S[id].lazy*(qr-ql+1);
      |         ^~
      |         ql
a.cc:26:36: error: 'lz' was not declared in this scope; did you mean 'l'?
   26 |         if (ql==l && qr==r) return lz+S[id].sum;
      |                                    ^~
      |                                    l
a.cc:26:45: error: 'struct<unnamed>' has no member named 'sum'
   26 |         if (ql==l && qr==r) return lz+S[id].sum;
      |                                             ^~~
a.cc:27:27: error: 'lz' was not declared in this scope; did you mean 'l'?
   27 |         if (qr<=m) return lz+query(id<<1,ql,qr,l,m);
      |                           ^~
      |                           l
a.cc:28:31: error: 'lz' was not declared in this scope; did you mean 'l'?
   28 |         else if (ql>m) return lz+query(id<<1|1,ql,qr,m+1,r);
      |                               ^~
      |                               l
a.cc:29:21: error: 'lz' was not declared in this scope; did you mean 'l'?
   29 |         else return lz+query(id<<1,ql,m,l,m)+query(id<<1|1,m+1,qr,m+1,r);
      |                     ^~
      |                     l