Language: C++

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

ll dat[131072*2], add[131072*2];
int segn = 1;
void init(int n){
	while(segn < n)segn *= 2;
	//for(int i = 0;i < segn*2;i++)dat[i] = inf;
}

void lazy_update(int k, int l, int r){
	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]+add[k*2+1]+dat[k*2+2]+add[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];
	int vl = get(a, b, k*2+1, l, (l+r)/2);
	int 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);
	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:4:1: error: expected initializer before 'const'
    4 | const int inf = 1e9;
      | ^~~~~
a.cc:6:1: error: 'll' does not name a type
    6 | ll dat[131072*2], add[131072*2];
      | ^~
a.cc: In function 'void lazy_update(int, int, int)':
a.cc:14:9: error: 'dat' was not declared in this scope
   14 |         dat[k] += add[k]*(r-l);
      |         ^~~
a.cc:14:19: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   14 |         dat[k] += add[k]*(r-l);
      |                   ^~~
      |                   std::filesystem::perm_options::add
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here
  219 |       add       = 0x2,
      |       ^~~
a.cc: In function 'void update(int, int, int, int, int, int)':
a.cc:24:17: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   24 |                 add[k] += x;
      |                 ^~~
      |                 std::filesystem::perm_options::add
/usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here
  219 |       add       = 0x2,
      |       ^~~
a.cc:30:9: error: 'dat' was not declared in this scope
   30 |         dat[k] = dat[k*2+1]+add[k*2+1]+dat[k*2+2]+add[k*2+2];
      |         ^~~
a.cc:30:29: error: 'add' was not declared in this scope; did you mean 'std::filesystem::perm_options::add'?
   30 |         dat[k] = dat[k*2+1]+add[k*2+1]+dat[k*2+2]+add[k*2+2];
      |                             ^~~
      |                             std::filesystem::perm_options::add
/usr/include/c++/14/bits/fs_fwd.h:219:7: note: 'std::filesystem::perm_options::add' declared here
  219 |       add       = 0x2,
      |       ^~~
a.cc: At global scope:
a.cc:33:1: error: 'll' does not name a type
   33 | ll get(int a, int b, int k, int l, int r){
      | ^~
a.cc: In function 'int main()':
a.cc:53:25: error: 'll' was not declared in this scope
   53 |                         ll res = get(s-1, t, 0, 0, segn);
      |                         ^~
a.cc:54:42: error: 'res' was not declared in this scope
   54 |                         printf("%lld\n", res);
      |                                          ^~~