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

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

using namespace std;

typedef long long ll;

const int MAX_N = 200000;

template<typename T> class LazyRMQ {
    public:
    int n;
    T inf = INT_MAX;
    vector<T> data, lazy;
    
    LazyRMQ(int m, T init_value=INT_MAX){
        // 2のべき乗にする
        n = 1;
        while(n < m) n <<= 1;
        data.assign(2*n-1, init_value);
        lazy.assign(2*n-1, 0);
        inf = init_value;
    }

    void eval(int k, int kl, int kr){
        if(data[k] == inf) data[k] = 0;
        if(lazy[k] == 0) return;
        data[k] += lazy[k];
        if(kr - kl > 1){
            lazy[2*k+1] += lazy[k];
            lazy[2*k+2] += lazy[k];
        }
        lazy[k] = 0;
    }

    // [s,t)
    void add(int s, int t, T x, int k, int kl, int kr){
        eval(k, kl, kr);
        if(kr <= s || t <= kl) return;
        if(s <= kl && kr <= t){
            lazy[k] += x;
            eval(k, kl, kr);
            return;
        }
        int kc = (kl+kr)/2;
        add(s, t, x, 2*k+1, kl, kc);
        add(s, t, x, 2*k+2, kc, kr);
        data[k] = max(data[2*k+1], data[2*k+2]);
    }

    void add(int s, int t, T x) {
        add(s, t, x, 0, 0, tree.n);
    }

    // [s,t)
    T find(int s, int t, int k, int kl, int kr){
        eval(k, kl, kr);
        if(kr <= s || t <= kl) return inf;
        if(s <= kl && kr <= t) return data[k];
        int kc = (kl+kr)/2;
        T vl = find(s, t, 2*k+1, kl, kc);
        T vr = find(s, t, 2*k+2, kc, kr);
        return max(vl, vr);
    }

    T find(int s, int t) {
        return find(s, t, 0, 0, tree.n);
    }
};

int main() {
    int n,m,l,r; ll a;
    cin >> n >> m;
    vector<pair<int, ll>> ranges[n+1];
    for(int i=0;i<m;++i) {
        cin >> l >> r >> a;
        ranges[r].emplace_back(l, a);
    }

    LazyRMQ<ll> tree(n+2, -(1<<30));
    for(int i=1;i<=n;++i) {
        ll opt = tree.find(0, i);
        tree.add(i, i+1, opt);
        for(pair<int, ll> p: ranges[i]) {
            tree.add(p.first, i+1, p.second);
        }
    }

    cout << tree.find(0, n+1) << endl;
}

Compiler output:
a.cc: In member function 'void LazyRMQ<T>::add(int, int, T)':
a.cc:53:28: error: 'tree' was not declared in this scope; did you mean 'free'?
   53 |         add(s, t, x, 0, 0, tree.n);
      |                            ^~~~
      |                            free
a.cc: In member function 'T LazyRMQ<T>::find(int, int)':
a.cc:68:33: error: 'tree' was not declared in this scope; did you mean 'free'?
   68 |         return find(s, t, 0, 0, tree.n);
      |                                 ^~~~
      |                                 free
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef struct line
{
	int lp,rp,value;
	bool operator < (const struct line & n)const
	{
		return rp<n.lp;
	}
}LINE,*PLINE;
LINE arr[200000];
long long linetree[1<<19],lazy[1<<19];
long long query(int index,int lb,int rb,int lq,int rq)
{
	if(lb==lq&&rb==rq)
		return linetree[index];
	long long mid=(lb+rb)>>1;
	if(lazy[index]!=0)
	{
		linetree[index<<1]+=(mid-lb+1)*lazy[index];
		linetree[index<<1|1]+=(rb-mid)*lazy[index];
		lazy[index<<1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	if(rq<=mid)
	{	
		return query(index<<1,lb,mid,lq,rq);
	}
	else if(lq>mid)
	{
		return query(index<<1|1,mid+1,rb,lq,rq);	
	}
	else
	{
		return max(query(index<<1,lb,mid,lq,mid),query(index<<1|1,mid+1,rb,mid+1,rq));
	}
}
void update(int index,int lb, int rb,int lq,int rq,long long value)
{
	if(lb==lq&&rb==rq)
	{
		linetree[index]+=(rb-lb+1)*value;
		lazy[index]+=value;
		return;
	}
	long long mid=(lb+rb)>>1;
	if(lazy[index]!=0)
	{
		linetree[index<<1]+=(mid-lb+1)*lazy[index];
		linetreeindex<<1|1]+=(rb-mid)*lazy[index];
		lazy[index<<1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	if(rq<=mid)
	{	
		update(index<<1,lb,mid,lq,rq,value);
	}
	else if(lq>mid)
	{
		update(index<<1|1,mid+1,rb,lq,rq,value);	
	}
	else
	{
		update(index<<1,lb,mid,lq,mid,value);
		update(index<<1|1,mid+1,rb,mid+1,rq,value);
	}
	linetree[index]=linetree[index<<1]+linetree[index<<1|1];
}
int main()
{
	int i,j,k,cnt=0;
	int n,m;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d %d",&arr[i].lp,&arr[i].rp,&arr[i].value);
	}
	sort(arr,arr+m);
	for(i=0;i<n;i++)
	{
		update(1,0,n,i,i,query(1,0,n,0,i-1));
		while(arr[cnt].rp==i)
		{
			update(1,0,n,arr[cnt].lp,arr[cnt].rp,arr[cnt].value);
			cnt++;
		}
	}
	printf("%d",linetree[1]);
}

Compiler output:
a.cc: In function 'void update(int, int, int, int, int, long long int)':
a.cc:51:17: error: 'linetreeindex' was not declared in this scope; did you mean 'linetree'?
   51 |                 linetreeindex<<1|1]+=(rb-mid)*lazy[index];
      |                 ^~~~~~~~~~~~~
      |                 linetree
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef struct line
{
	int lp,rp,value;
	bool operator < (const struct line & n)const
	{
		return rp<n.lp;
	}
}LINE,*PLINE;
LINE arr[200000];
long long linetree[1<<19],lazy[1<<19];
long long query(int index,int lb,int rb,int lq,int rq)
{
	if(lb==lq&&rb==rq)
		return linetree[index];
	long long mid=(lb+rb)>>1;
	if(lazy[index]!=0)
	{
		linetree[index<<1]+=(mid-lb+1)*lazy[index];
		linetree[index<<1|1]+=(rb-mid)*lazy[index];
		lazy[index<<1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	if(rq<=mid)
	{	
		return query(index<<1,lb,mid,lq,rq);
	}
	else if(lq>mid)
	{
		return query(index<<1|1,mid+1,rb,lq,rq);	
	}
	else
	{
		return max(query(index<<1,lb,mid,lq,mid),(query(index<<1|1,mid+1,rb,mid+1,rq));
	}
}
void update(int index,int lb, int rb,int lq,int rq,long long value)
{
	if(lb==lq&&rb==rq)
	{
		linetree[index]+=(rb-lb+1)*value;
		lazy[index]+=value;
		return;
	}
	long long mid=(lb+rb)>>1;
	if(lazy[index]!=0)
	{
		linetree[index<<1]+=(mid-lb+1)*lazy[index];
		linetreeindex<<1|1]+=(rb-mid)*lazy[index];
		lazy[index<<1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	if(rq<=mid)
	{	
		update(index<<1,lb,mid,lq,rq,value);
	}
	else if(lq>mid)
	{
		update(index<<1|1,mid+1,rb,lq,rq,value);	
	}
	else
	{
		update(index<<1,lb,mid,lq,mid,value);
		update(index<<1|1,mid+1,rb,mid+1,rq,value);
	}
	linetree[index]=linetree[index<<1]+linetree[index<<1|1];
}
int main()
{
	int i,j,k,cnt=0;
	int n,m;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d %d",&arr[i].lq,&arr[i].rq,&arr[i].value);
	}
	sort(arr,arr+m);
	for(i=0;i<n;i++)
	{
		update(1,0,n,i,i,query(1,0,n,0,i-1));
		while(arr[cnt].rp==i)
		{
			update(1,0,n,arr[cnt].lp,arr[cnt].rp,arr[cnt].value);
			cnt++;
		}
	}
	printf("%d",linetree[1]);
}

Compiler output:
a.cc: In function 'long long int query(int, int, int, int, int)':
a.cc:36:95: error: expected ')' before ';' token
   36 |                 return max(query(index<<1,lb,mid,lq,mid),(query(index<<1|1,mid+1,rb,mid+1,rq));
      |                           ~                                                                   ^
      |                                                                                               )
a.cc: In function 'void update(int, int, int, int, int, long long int)':
a.cc:51:17: error: 'linetreeindex' was not declared in this scope; did you mean 'linetree'?
   51 |                 linetreeindex<<1|1]+=(rb-mid)*lazy[index];
      |                 ^~~~~~~~~~~~~
      |                 linetree
a.cc: In function 'int main()':
a.cc:78:42: error: 'LINE' {aka 'struct line'} has no member named 'lq'; did you mean 'lp'?
   78 |                 scanf("%d %d %d",&arr[i].lq,&arr[i].rq,&arr[i].value);
      |                                          ^~
      |                                          lp
a.cc:78:53: error: 'LINE' {aka 'struct line'} has no member named 'rq'; did you mean 'rp'?
   78 |                 scanf("%d %d %d",&arr[i].lq,&arr[i].rq,&arr[i].value);
      |                                                     ^~
      |                                                     rp
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;
const long long INF = 1e18;
const int MaxN = 2e5 + 25;

int n, m;

struct segmentTree{
    long long tree[MaxN * 4];
    long long p[MaxN * 4];

    clear()
    {
        memset(p, 0, sizeof(p));
        memset(tree, 0, sizeof(tree));
    }

    void up(int pref, int delta)
    {
        up(1, 0, n + 1, 0, pref, delta);
    }
    void upPos(int pos, int delta)
    {
        up(1, 0, n + 1, pos, pos, delta);
    }
    void up(int x, int l, int r, int ll, int rr, int delta)
    {
        if(l > rr || r < ll)
            return;
        if(l >= ll && r <= rr)
        {
            tree[x] += delta;
            p[x] += delta;
            return;
        }

        push(x);
        int mid = (l + r) / 2;

        up(x + x, l, mid, ll, rr, delta);
        up(x + x + 1, mid + 1, r, ll, rr, delta);

        tree[x] = min(tree[x + x], tree[x + x + 1]);
    }

    void push(int x)
    {
        if(p[x])
        {
            tree[x + x] += p[x];
            tree[x + x + 1] += p[x];
            p[x + x] += p[x];
            p[x + x + 1] += p[x];
            p[x] = 0;
        }
    }

    int getMin()
    {
        return tree[1];
    }
} segmentTree;

vector<pair<int, int> > v[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    cin >> n >> m;

    long long sum = 0;

    for(int i = 1; i <= m; ++i)
    {
        int l, r, a;
        cin >> l >> r >> a;
        v[r].push_back(make_pair(l, a));

        sum += a;
    }

    for(int i = 1; i <= n + 1; ++i)
    {
        for(auto p : v[i - 1])
            segmentTree.up(p.first - 1, p.second);
        segmentTree.upPos(i, segmentTree.getMin());
    }

    cout << sum - segmentTree.getMin() << '\n';

    return 0;
}



Compiler output:
a.cc:15:5: error: ISO C++ forbids declaration of 'clear' with no type [-fpermissive]
   15 |     clear()
      |     ^~~~~
a.cc: In member function 'int segmentTree::clear()':
a.cc:19:5: warning: no return statement in function returning non-void [-Wreturn-type]
   19 |     }
      |     ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

#define int long long
#define pii pair<int, int>
#define ld long double

#define form(i, n) for (int i = 0; i < (n); ++i)
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford(i, n) for (int i = (n-1); i >= 0; --i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)

#define chmax(x, v) x = max(x, (v));

void solve();
signed main()
{
#ifdef LOCAL_HUGO
	freopen("in.txt", "r", stdin);
#else
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	solve();
}

const int e2 = 18;
const int p2 = 1 << e2;
const int ph = 2 * p2;
const int inf = LLONG_MAX / 2LL;
int lazyadd[ph];
int segmax[ph];
pii inv[ph];

void build()
{
	form2(i, p2, ph) inv[i] = { i - p2, i - p2 };
	ford(i, p2) inv[i] = { inv[2 * i].first, inv[2 * i + 1].second };
}

void apply(int nod)
{
	segmax[nod] += lazyadd[nod];
	if (nod < p2) {
		lazyadd[2 * nod] += lazyadd[nod];
		lazyadd[2 * nod + 1] += lazyadd[nod];
	}
	lazyadd[nod] = 0;
}

int bg, bd, val;
void add(int nod)
{
	apply(nod);
	if (bd < inv[nod].first || inv[nod].second < bg) {}
	else if (bg <= inv[nod].first && inv[nod].second <= bd) { lazyadd[nod] += val; apply(nod); }
	else if (nod < p2) { add(2 * nod); add(2 * nod + 1); segmax[nod] = max(segmax[2 * nod], segmax[2 * nod + 1]); }
}

int gmax(int nod)
{
	apply(nod);
	if (bd < inv[nod].first || inv[nod].second < bg) { return -inf; }
	else if (bg <= inv[nod].first && inv[nod].second <= bd) { return segmax[nod]; }
	else if (nod < p2) { return max(gmax(2 * nod), gmax(2 * nod + 1)); }
	else { return -inf; }
}

void add2(int gauche, int droite, int valeur)
{
	bg = gauche;
	bd = droite;
	val = valeur;
	add(1);
}

int smax(int gauche, int droite)
{
	bg = gauche;
	bd = droite;
	return gmax(1);
}
const int borne = 2 * (int)(1e5) + 5;
int l[borne];
int r[borne];
int a[borne];
int n, k;
vector<int> al[borne];
vector<int> ar[borne];

void solve()
{
	build();
	cin >> n >> k;
	form(i, k)
	{
		cin >> l[i] >> r[i] >> a[i];
		al[l[i]].push_back(i);
		ar[r[i]+1].push_back(i);
	}

	int rep = 0;
	form2(i, 1, n+1)
	{
		for (int x : al[i]) {
			add2(0, l[x] - 1, a[x]);
		}
		for (int x : ar[i]) {
			add2(0, l[x] - 1, -a[x]);
		}
		int ss = smax(0, i - 1);
		chmax(rep, ss);
		add2(i, i, ss);
	}

	cout << rep << '\n';
}

Compiler output:
a.cc:38:17: error: 'LLONG_MAX' was not declared in this scope
   38 | const int inf = LLONG_MAX / 2LL;
      |                 ^~~~~~~~~
a.cc:10:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <queue>
  +++ |+#include <climits>
   10 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
struct SEG{
	ll seg[1<<19],la[1<<19];
	SEG(void){for(int i=0;i<1<<19;i++)seg[i]=-INF,la[i]=0;}
	void lazy(int l,int r,int k){
		seg[k]+=la[k];
		if(r-l>0){
			la[k*2+1]+=la[k];
			la[k*2+2]+=la[k];
		}
		la[k]=0;
	}
	void up(int a,int l,int r,int k,ll x){
		while(r-l>0){
			lazy(l,r,k);
			if(a<=(l+r-1)/2){
				k=k*2+1;
				r=(l+r-1)/2;
			}else{
				k=k*2+2;
				l=(l+r+1)/2;
			}
		}
		lazy(l,r,k);
		seg[k]=max(seg[k],x);
		while(k>0){
			k=(k-1)/2;
			seg[k]=max(seg[k*2+1],seg[k*2+2]);
		}
	}
	void add(int a,int b,int l,int r,int k,ll x){
		lazy(l,r,k);
		if(r<a||b<l)return;
		if(a<=l&&r<=b){
			la[k]+=x;
			lazy(l,r,k);
			return;
		}
		add(a,b,l,(l+r-1)/2,k*2+1,x);
		add(a,b,(l+r+1)/2,r,k*2+2,x);
		seg[k]=max(seg[k*2+1],seg[k*2+2]);
	}
	ll que(int a,int b,int l,int r,int k){
		lazy(l,r,k);
		if(r<a||b<l)return 0;
		if(a<=l&&r<=b)return seg[k];
		return max(que(a,b,l,(l+r-1)/2,k*2+1),que(a,b,(l+r+1)/2,r,k*2+2));
	}
};
struct t{
	ll a,b,c;
	bool operator<(const t &q)const{
		return a<q.a;
	}
};
ll n,m,ans;
vector<t>q;
SEG seg;
int main(void){
    scanf("%lld%lld",&n,&m);
    for(int i=0;i<m;i++){
		ll l,r,x;
		scanf("%lld%lld%lld",&l,&r,&x);
		q.PB(t{l,l-1,x});
		q.PB(t{r+1,l-1,-x});
	}
	sort(q.begin(),q.end());
	int p=0;
	seg.up(0,0,(1<<18)-1,0,seg.que(0,i-1,0,(1<<18)-1,0));
	for(int i=1;i<=n+1;i++){
		while(p<q.size()&&q[p].a<=i){
			seg.add(0,q[p].b,0,(1<<18)-1,0,q[p].c);
			p++;
		}
		ans=max(ans,seg.que(0,i-1,0,(1<<18)-1,0));
		seg.up(i,0,(1<<18)-1,0,seg.que(0,i-1,0,(1<<18)-1,0));
	}
	printf("%lld\n",ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:78:42: error: 'i' was not declared in this scope
   78 |         seg.up(0,0,(1<<18)-1,0,seg.que(0,i-1,0,(1<<18)-1,0));
      |                                          ^
Language: C++

//#include <cmath>
//#include <ctime>
#include <cstdio>
//#include <cstdlib>
//#include <cstring>

//#include <map>
//#include <set>
//#include <queue>
//#include <string>
#include <vector>
//#include <sstream>
//#include <iostream>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 200005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

int l[MAXN], r[MAXN];

LL a[MAXN];

vector<int> L[MAXN];
vector<int> R[MAXN];

int root, lc[MAXN * 2], rc[MAXN * 2];
LL mx[MAXN * 2], tag[MAXN * 2], ans, qans;

int n, m, tot;

void build(int &x, int l, int r) {
    x = ++tot;
    mx[x] = tag[x] = 0;
    if (l < r) {
        int mid = (l + r) >> 1;
        build(lc[x], l, mid);
        build(rc[x], mid + 1, r);
    }
}


void add(int x, LL val) {
    mx[x] += val;
    tag[x] += val;
}

void push_down(int x) {
    if (tag[x] != 0ll) {
        add(lc[x], tag[x]);
        add(rc[x], tag[x]);
        tag[x] = 0ll;
    }
}

void push_up(int x) {
    mx[x] = max(mx[lc[x]], mx[rc[x]]);
}

void modify(int x, int l, int r, int ll, int rr, LL val) {
    if (ll <= l && r <= rr) {
        add(x, val);
        return;
    }
    push_down(x);
    int mid = (l + r) >> 1;
    if (ll <= mid) modify(lc[x], l, mid, ll, rr, val);
    if (rr > mid) modify(rc[x], mid + 1, r, ll, rr, val);
    push_up(x);
}

void query(int x, int l, int r, int ll, int rr) {
    if (ll <= l && r <= rr) {
        qans = max(qans, mx[x]);
        return;
    }
    push_down(x);
    int mid = (l + r) >> 1;
    if (ll <= mid) query(lc[x], l, mid, ll, rr);
    if (rr > mid) query(rc[x], mid + 1, r, ll, rr);
}

int main() {
    n = getint();
    m = getint();
    for (int i = 1; i <= m; ++i) {
        l[i] = getint();
        r[i] = getint();
        a[i] = getint();
        L[l[i]].push_back(i);
        R[r[i]].push_back(i);
    }
    build(root, 0, 200001);
    for (int i = 1; i <= n + 1; ++i) {
        for (auto j : L[i])
            modify(root, 0, 200001, 0, l[j] - 1, a[j]);
        qans = LONG_LONG_MIN;
        query(root, 0, 200001, 0, i - 1);
        ans = max(ans, qans);
        #ifdef DEBUGMODE
        printf("%lld\n", qans);
        #endif
        
        modify(root, 0, 200001, i, i, qans);
        for (auto j : R[i])
            modify(root, 0, 200001, 0, l[j] - 1, -a[j]);
    }

    printf("%lld", ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:111:16: error: 'LONG_LONG_MIN' was not declared in this scope
  111 |         qans = LONG_LONG_MIN;
      |                ^~~~~~~~~~~~~
Language: C++

#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

static const int MAX_SIZE =
    1 << 17; // segment tree のサイズ。この実装では2べきにする必要がある。 2^17
             // ≒ 1.3 * 10^5

typedef long long ll;
ll segMin[2 * MAX_SIZE - 1] = {0}, segAdd[2 * MAX_SIZE - 1] = {0};

//区間[a, b)に値xを加算する.
void add(int a, int b, ll x, int k = 0, int l = 0, int r = MAX_SIZE) {
  if (r <= a || b <= l)
    return; //もし交差しない区間であれば終える.

  if (a <= l &&
      r <= b) { //もし今みている区間[l, r)が[a, b)に完全に内包されていれば
    segAdd[k] += x; //区間[l, r)にkを加算する.
    return;
  }

  add(a, b, x, k * 2 + 1, l,
      (l + r) / 2); //子の区間に(必要があれば)xを加算する.
  add(a, b, x, k * 2 + 2, (l + r) / 2, r); //〃

  //親の区間の最小値は, 子の区間の最小値 + 自分に一様に加算されている値
  //である.一様に加算される値は更新しなくて良い.
  segMin[k] = min(segMin[k * 2 + 1] + segAdd[k * 2 + 1],
                  segMin[k * 2 + 2] + segAdd[k * 2 + 2]);
}

ll getMin(int a, int b, int k = 0, int l = 0, int r = MAX_SIZE) {
  if (r <= a || b <= l)
    return (LLONG_MAX);

  if (a <= l && r <= b)
    return (segMin[k] +
            segAdd[k]); //完全に内包されていれば,その区間の最小値を返す.

  ll left = getMin(a, b, k * 2 + 1, l, (l + r) / 2); //子の区間の最小値を求める.
  ll right = getMin(a, b, k * 2 + 2, (l + r) / 2, r); //子の区間の最小値を求める

  return (min(left, right) + segAdd[k]); //親の区間の最小値は, 子の区間の最小値
                                         //+ 自分に一様に加算されている値 である
                                         //(大切なので2回書きました!!)
}
// ref: http://kagamiz.hatenablog.com/entry/2012/12/18/220849

struct N {
  int l, r;
  long long a;
};

int main() {
  int n, m;
  cin >> m >> n;

  vector<N> ns(n);
  for (int i = 0; i < n; i++)
    cin >> ns[i].l >> ns[i].r >> ns[i].a;
  map<int, vector<N>> rmp, lmp;
  for (int i = 0; i < n; i++) {
    rmp[ns[i].r].push_back(ns[i]);
    lmp[ns[i].l].push_back(ns[i]);
    add(ns[i].l, ns[i].r + 1, ns[i].a);
  }
  long long ans = 0;
  long long sum = 0;
  long long tmp;
  for (int i = 1; i <= m; i++) {
    if (lmp.find(i) != lmp.end()) {
      for (auto &s : lmp[i])
        sum += s.a;
    }
    tmp = -getMin(0, i) + sum;
    ans = max(ans, tmp);
    add(i, i + 1, -tmp);
    if (rmp.find(i) != rmp.end()) {
      for (auto &s : rmp[i]) {
        sum -= s.a;
        add(s.l, s.r + 1, -s.a);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'll getMin(int, int, int, int, int)':
a.cc:45:13: error: 'LLONG_MAX' was not declared in this scope
   45 |     return (LLONG_MAX);
      |             ^~~~~~~~~
a.cc:12:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <vector>
  +++ |+#include <climits>
   12 |
Language: C++

#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

ll const MAX = 800000;
ll const A_MAX = 200005;
ll tree[MAX];
ll lazy[MAX];
ll n_ = 1;

void init(ll n) {
	while (n_ <= n) {
		n_ *= 2;
	}
	REP(i, 1, n_ * 2) {
		tree[i] = lazy[i] = 0;
	}
}

void add_o(ll u, ll v, ll x, ll k, ll l, ll r) {
	if (u <= l && r <= v) {
		lazy[k] += x;
	}
	else if (!(r <= u || v <= l)) {
		add_o(u, v, x, k * 2, l, (l + r) / 2);
		add_o(u, v, x, k * 2 + 1, (l + r) / 2, r);
	}
	tree[k] = max(tree[k * 2], tree[k * 2 + 1]) + lazy[k];
}

ll query_o(ll u, ll v, ll k, ll l, ll r) {
	if (lazy[k] != 0) {
		lazy[k * 2] += lazy[k];
		lazy[k * 2 + 1] += lazy[k];
		tree[k * 2] += lazy[k];
		tree[k * 2 + 1] += lazy[k];
		lazy[k] = 0;
	}
	if (u <= l && r <= v) {
		return tree[k];
	}
	else if (r <= u || v <= l) {
		return -1e18;
	}
	else {
		ll ans1 = query_o(u, v, k * 2, l, (l + r) / 2);
		ll ans2 = query_o(u, v, k * 2 + 1, (l + r) / 2, r);
		return max(ans1, ans2);
	}
}


void add(ll l, ll r, ll x) {
	add_o(l, r, x, 1, 0, n_);
}

ll query(ll l, ll r) {
	return query_o(l, r, 1, 0, n_);
}

ll n, m;

struct range {
	ll l; ll r; ll v;
};
range a[A_MAX], b[A_MAX];
ll maxv[MAX] = {};
bool ord1(range x, range y) {
	return x.l < y.l;
}
bool ord2(range x, range y) {
	return x.r < y.r;
}

int main() {
	cin >> n >> m;
	REP(i, 1, m) {
		ll x, y, z;
		cin >> x >> y >> z;
		a[i] = b[i] = { x,y + 1,z };
	}
	init(n);
	SORT_O(a, m, ord1);
	SORT_O(b, m, ord2);
	a[m + 1] = b[m + 1] = { 1e18, 1e18, 1e18 };
	ll cur_a = 1; ll cur_b = 1;
	REP(i, 1, n) {
		while (a[cur_a].l == i) {
			add(0, a[cur_a].l, a[cur_a].v);
			cur_a++;
			//cout << i << " " << a[cur_a].l << " " << a[cur_a].v << endl;
		}
		while (b[cur_b].r == i) {
			add(0, b[cur_b].l, -b[cur_b].v);
			//cout << i << " " << b[cur_b].l << " " << -b[cur_b].v << endl;

			cur_b++;
		}
		ll x = query(0, i);
		add(i, i + 1, x);
		maxv[i] = x;
	}
	ll ans = 0;
	REP(i, 1, n) {
		ans = max(maxv[i], ans);
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:107:33: error: narrowing conversion of '1.0e+18' from 'double' to 'll' {aka 'long long int'} [-Wnarrowing]
  107 |         a[m + 1] = b[m + 1] = { 1e18, 1e18, 1e18 };
      |                                 ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int64 INF = 1LL << 58;

template< typename Monoid, typename OperatorMonoid = Monoid >
struct LazySegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;
  using G = function< Monoid(Monoid, OperatorMonoid) >;
  using H = function< OperatorMonoid(OperatorMonoid, OperatorMonoid) >;
  using P = function< OperatorMonoid(OperatorMonoid, int) >;

  int sz;
  vector< Monoid > data;
  vector< OperatorMonoid > lazy;
  const F f;
  const G g;
  const H h;
  const P p;
  const Monoid M1;
  const OperatorMonoid OM0;


  LazySegmentTree(int n, const F f, const G g, const H h, const P p,
                  const Monoid &M1, const OperatorMonoid OM0)
      : f(f), g(g), h(h), p(p), M1(M1), OM0(OM0) {
    sz = 1;
    while(sz < n) sz <<= 1;
    data.assign(2 * sz, M1);
    lazy.assign(2 * sz, OM0);
  }

  void set(int k, const Monoid &x) {
    data[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      data[k] = f(data[2 * k + 0], data[2 * k + 1]);
    }
  }

  void propagate(int k, int len) {
    if(lazy[k] != OM0) {
      if(k < sz) {
        lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
        lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
      }
      data[k] = g(data[k], p(lazy[k], len));
      lazy[k] = OM0;
    }
  }

  Monoid update(int a, int b, const OperatorMonoid &x, int k, int l, int r) {
    propagate(k, r - l);
    if(r <= a || b <= l) {
      return data[k];
    } else if(a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      propagate(k, r - l);
      return data[k];
    } else {
      return data[k] = f(update(a, b, x, 2 * k + 0, l, (l + r) >> 1),
                         update(a, b, x, 2 * k + 1, (l + r) >> 1, r));
    }
  }

  Monoid update(int a, int b, const OperatorMonoid &x) {
    return update(a, b, x, 1, 0, sz);
  }


  Monoid query(int a, int b, int k, int l, int r) {
    propagate(k, r - l);
    if(r <= a || b <= l) {
      return M1;
    } else if(a <= l && r <= b) {
      return data[k];
    } else {
      return f(query(a, b, 2 * k + 0, l, (l + r) >> 1),
               query(a, b, 2 * k + 1, (l + r) >> 1, r));
    }
  }

  Monoid query(int a, int b) {
    return query(a, b, 1, 0, sz);
  }

  Monoid operator[](const int &k) {
    return query(k, k + 1);
  }
};


int main() {
  int N, M;
  cin >> N >> M;
  vector< pair< int, int > > ev[200001];

  for(int i = 0; i < M; i++) {
    int l, r, x;
    cin >> l >> r >> x;
    --l;
    --r;
    ev[r].emplace_back(l, x);
  }

  auto f = [](int64 a, int64 b) { return max(a, b); };
  auto g = [](int64 a, int64  b) { return a + b; };
  auto p = [](pi a, int p) { return a; };

  LazySegmentTree< int64 > seg(N+1, f, g, g, p, 0, 0);
  for(int i = 0; i < N; i++) {
    seg.update(i, i + 1, seg.query(0, i));
    for(auto &p : ev[i]) seg.update(p.first, i + 1, p.second);
  }
  cout << seg.query(0, N+1) << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:113:15: error: 'pi' has not been declared
  113 |   auto p = [](pi a, int p) { return a; };
      |               ^~
Language: C++

#include <bits/stdc++.h>
#include <iostream>

using namespace std;
//State
//dp[i][j]: The maximum value we can get by using blocks from
// 0...i and sum of blocks in the tower = j

//Initialization
//dp[0][W[0]] = V[0]

//Transitions
//dp[i][j] = max(V[j]+dp[i-W[0]][j-1], dp[i][j-1])

//Order of evaluation
//Rowise or Columnwise

//Answer: argmax(dp[0...W_max][N])

struct B{
	long long w;
	long long s;
	long long v;
};

vector<vector<long long>> dp(10004,vector<long long>(1004,0));

bool compare(B b1, B b2){
	return (b1.w+b1.s<=b2.w+b2.s);
}

long long main(){
	long long N;
	cin >> N;
	vector<B> boxes(N);
	for(long long i=0; i<N; i++){
	    long long w, s, v;
		cin >> w >> s >> v;
		boxes[i].w = w;
		boxes[i].s = s;
		boxes[i].v = v;
	}
	sort(boxes.begin(), boxes.end(), compare);
	
	dp[boxes[0].w][0] = boxes[0].v;
	long long W_max = 10004;
	for(long long j=1; j<N; j++){
		for(long long i=0; i<W_max; i++){
			if(i-boxes[j].w>=0 && boxes[j].s+boxes[j].w-i>=0){
				dp[i][j] = max(dp[i-boxes[j].w][j-1]+boxes[j].v, dp[i][j-1]);
			}
			else{
				dp[i][j] = dp[i][j-1];
			}
		}
	}
	long long result = 0;
	for(long long i=0; i<W_max; i++){
	    if(result<dp[i][N-1]) result = dp[i][N-1];
	}
	cout << result << endl;
}







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

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    static long dp[][];
    static long max(int pos , int sum , block arr[])
    {
        if(sum > 10000 && pos != n)
        return Integer.MIN_VALUE;
        
        if(pos == arr.length)
        return 0;
        
        if(dp[pos][sum] != -1)
        return dp[pos][sum];
        
        if(arr[pos].s >= sum)
        {
            dp[pos][sum] = Math.max(arr[pos].v+max(pos+1,sum+arr[pos].w,arr),max(pos+1,sum,arr));
        }
        
        else
        {
            dp[pos][sum] = max(pos+1,sum,arr);
        }
        return dp[pos][sum];
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		block arr[] = new block[n];
		for(int i = 0 ; i < n ; i++)
		{
		    arr[i] = new block(sc.nextInt(),sc.nextInt(),sc.nextInt());
		}
		
		Arrays.sort(arr,new Compare());
		dp = new long[n][10001];
		for(int i = 0 ; i < n ; i++)
		{
		    for(int j = 0 ; j <= 10000 ; j++)
		    {
		        dp[i][j] = -1;
		    }
		}
		System.out.println(max(0,0,arr));
	}
}

class block
{
    int w , s , v;
    public block(int w , int s , int v)
    {
        this.w = w;
        this.s = s;
        this.v = v;
    }
}

class Compare implements Comparator<block>
{
    public int compare(block a , block b)
    {
        return a.s+a.w-b.s-b.w;
    }
}


Compiler output:
Main.java:8: error: class Codechef is public, should be declared in a file named Codechef.java
public class Codechef
       ^
Main.java:13: error: cannot find symbol
        if(sum > 10000 && pos != n)
                                 ^
  symbol:   variable n
  location: class Codechef
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long


vector<vector<ll> >v;
vector<vector<ll> >dp;

bool compare(vector<ll>&a,vector<ll>&b){
    ll w1 = a[0],s1=a[1],w2=b[0],s2=b[1];
    return w1+s1 >= w2+s2;
}
void solve(){
  ll n;cin>>n;
  v.resize(n,vector<ll>(3));
  dp.resize(n,vector<ll>(10001));
  for(ll i=0;i<n;i++){
    cin>>v[i][0]>>v[i][1]>>v[i][2];
  }
  sort(v.begin(),v.end(),compare);
  for(ll i=0;i<=v[0][1];i++){
    dp[0][i]=v[0][2];
  }
  for(ll i=1;i<n;i++){
    for(ll j=0;j<=10001;j++){
        ll val_1 = dp[i-1][j];
        if(j<=v[i][1]){
            ll val_2 = v[i][2];
            if(j+v[i][0]<10001){
                val_2+=dp[i-1][j+v[i][0]];
            }
        }
        dp[i][j] = max(val_1,val_2);
    }
  }
  cout <<dp[n-1][0]<<"\n";

}

int main(){
//    cin.tie(0);
//    cout.tie(0);
//    cin.sync_with_stdio(0);
//    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:34:30: error: 'val_2' was not declared in this scope; did you mean 'val_1'?
   34 |         dp[i][j] = max(val_1,val_2);
      |                              ^~~~~
      |                              val_1
Language: C++


#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
//const int mod=998244353;



struct node{
    ll s,w,v;
    bool inline operator < (const node &a) const{return this->s+this->w<a.s+a.w;}
};


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,y,l,r;
    cin >> n;
    vector<node> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i].w >> v[i].s >> v[i].v;
    }
    sort(all(v));
    m=20000;
    vll dp(m,0);
    for(int i=0; i<n; i++){
        for(int j=(int)v[i].s; j>=0; j--){
            assert(j+v[i].w<m);
            dp[j+v[i].w]=max(dp[j+v[i].w],dp[j]+v[i].v);
        }
    }
    cout << *max_element(all(dp)) << el;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:13: error: 'assert' was not declared in this scope
   69 |             assert(j+v[i].w<m);
      |             ^~~~~~
a.cc:25:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   24 | #include <random>
  +++ |+#include <cassert>
   25 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int S = 1e4 + 10;
const int inf = 1e13 + 10;
vector<int> cur(S,0),nex(S,0);

struct data
{
    int w,s,v;
    
    inline bool operator<(const data & o)
    {
        return s + w < o.s + o.w;
    }
};

signed main()
{
    fast;
    
    int n;
    cin >> n;
  
    data a[n];
    
    f(i,n) cin >> a[i].w >> a[i].s >> a[i].v;
    
    sort(a,a+n);
    
    f(i,n)
    {
        f(j,S) nex[j] = cur[j];
        
        //try to take ith element if possible
        for(int j=a[i].s;j>=0;j--)
            nex[min(j+a[i].w,S-1)] = max(nex[min(j+a[i].w,S-1)],cur[j] + a[i].v);
       
        swap(cur,nex);
    }
    
    int res = -inf;
    
    for(auto x : cur) res = max(res,x);
    
    cout << res;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:5: error: reference to 'data' is ambiguous
   34 |     data a[n];
      |     ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:17:8: note:                 'struct data'
   17 | struct data
      |        ^~~~
a.cc:36:19: error: 'a' was not declared in this scope
   36 |     f(i,n) cin >> a[i].w >> a[i].s >> a[i].v;
      |                   ^
a.cc:38:10: error: 'a' was not declared in this scope
   38 |     sort(a,a+n);
      |          ^
Language: C++

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 1000;
const int MAXS = 10000;
ll dp[MAXN + 5][2 * MAXS + 5];

auto maxx(auto& a, auto b){a = max(a, b);}

void reorder(auto& v, const auto& mapping) {
  auto v2 = v;
  rep(i, 0, sz(v))
    v[i] = v[mapping[i]];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi w(n), s(n), v(n);
  rep(i, 0, n) {
    cin >> w[i] >> s[i] >> v[i];
  }
  vi ind(n);
  iota(all(ind), 0);
  sort(all(ind), [&](int i, int j) {return s[i] + w[i] < s[j] + w[j];});


  auto bla = reorder(v, ind);
  reorder(w, ind);
  reorder(s, ind);

  
  rep(i, 0, MAXN + 1) rep(j, 0, 2 * MAXS + 1)
    dp[i][j] = -1;
  dp[0][0] = 0;
  rep(i, 0, n) {
    for (int weight = MAXS; weight >= 0; weight--) {
      if (dp[i][weight] == -1) continue;
      maxx(dp[i + 1][weight], dp[i][weight]);
      if (weight <= s[i]) {
	maxx(dp[i + 1][weight + w[i]], dp[i][weight] + v[i]);
      }
    }
  }
  auto res = 0LL;
  rep(i, 0, n + 1)
    maxx(res, *max_element(all(dp[i])));
  cout << res << '\n';
}


Compiler output:
a.cc:21:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | auto maxx(auto& a, auto b){a = max(a, b);}
      |           ^~~~
a.cc:21:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | auto maxx(auto& a, auto b){a = max(a, b);}
      |                    ^~~~
a.cc:23:14: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   23 | void reorder(auto& v, const auto& mapping) {
      |              ^~~~
a.cc:23:29: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   23 | void reorder(auto& v, const auto& mapping) {
      |                             ^~~~
a.cc: In function 'int main()':
a.cc:44:8: error: deduced type 'void' for 'bla' is incomplete
   44 |   auto bla = reorder(v, ind);
      |        ^~~
Language: C++

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 1000;
const int MAXS = 10000;
ll dp[MAXN + 5][2 * MAXS + 5];

auto maxx(auto& a, auto b){a = max(a, b);}

auto reorder(auto& vec, const auto& mapping) {
  auto vec2 = v;
  rep(i, 0, sz(v))
    vec[i] = vec2[mapping[i]];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi w(n), s(n), v(n);
  rep(i, 0, n) {
    cin >> w[i] >> s[i] >> v[i];
  }
  vi ind(n);
  iota(all(ind), 0);
  sort(all(ind), [&](int i, int j) {return s[i] + w[i] < s[j] + w[j];});


  reorder(v, ind);
  reorder(w, ind);
  reorder(s, ind);

  
  rep(i, 0, MAXN + 1) rep(j, 0, 2 * MAXS + 1)
    dp[i][j] = -1;
  dp[0][0] = 0;
  rep(i, 0, n) {
    for (int weight = MAXS; weight >= 0; weight--) {
      if (dp[i][weight] == -1) continue;
      maxx(dp[i + 1][weight], dp[i][weight]);
      if (weight <= s[i]) {
	maxx(dp[i + 1][weight + w[i]], dp[i][weight] + v[i]);
      }
    }
  }
  auto res = 0LL;
  rep(i, 0, n + 1)
    maxx(res, *max_element(all(dp[i])));
  cout << res << '\n';
}


Compiler output:
a.cc:21:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | auto maxx(auto& a, auto b){a = max(a, b);}
      |           ^~~~
a.cc:21:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | auto maxx(auto& a, auto b){a = max(a, b);}
      |                    ^~~~
a.cc:23:14: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   23 | auto reorder(auto& vec, const auto& mapping) {
      |              ^~~~
a.cc:23:31: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   23 | auto reorder(auto& vec, const auto& mapping) {
      |                               ^~~~
a.cc: In function 'auto reorder(auto:30&, const auto:31&)':
a.cc:24:15: error: 'v' was not declared in this scope; did you mean 'vi'?
   24 |   auto vec2 = v;
      |               ^
      |               vi
Language: C++

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 1000;
const int MAXS = 10000;
const ll INF = 1e15;
ll dp[MAXN + 5][MAXS + 5];

auto maxx(auto& a, auto b){a = max(a, b);}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi w(n), s(n), v(n);
  rep(i, 0, n) {
    cin >> w[i] >> s[i] >> v[i];
  }
  vi ind(n);
  iota(all(ind), 0);
  sort(all(ind),
       [&](int i, int j) {
	 return tie(s[i], w[i]) < tie(s[j], w[j]);
       });

  int maxs = *max_element(all(s));

  rep(i, 0, MAXN + 1) rep(j, 0, MAXS + 1)
    dp[i][j] = -INF;
  dp[0][0] = 0;
  rep(it, 0, n) {
    int i = ind[it];
    if (i > 0) {
      for (int weight = MAXS; weight >= 0; weight--)
	dp[it + 1][weight] = dp[it][weight];
    }
    for (int weight = MAXS; weight >= 0; weight--) {
      if (weight + w[i] <= maxs)
	maxx(dp[it + 1][weight + w[i]], dp[it][weight] + v[i]);
      
    }
  }

  cout << *max_element(all(dp[n]) << '\n';
    
}


Compiler output:
a.cc:22:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   22 | auto maxx(auto& a, auto b){a = max(a, b);}
      |           ^~~~
a.cc:22:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   22 | auto maxx(auto& a, auto b){a = max(a, b);}
      |                    ^~~~
a.cc: In function 'int main()':
a.cc:59:35: error: invalid operands of types 'long long int*' and 'char' to binary 'operator<<'
   59 |   cout << *max_element(all(dp[n]) << '\n';
      |                                   ^~ ~~~~
      |                                      |
      |                                      char
Language: C++

ll n;
ll memo[1020][20'020];

ll W[1020];
ll S[1020];
ll V[1020];

vi I;
ll comp(ll a, ll b) {
    return (W[a]+S[a]) > (W[b]+S[b]);
}

ll dp(ll at, ll can_put) {
    if(at >= n) return 0;
    if(can_put == 0) return 0;
    if(memo[at][can_put] != -1) return memo[at][can_put];

    ll mx = dp(at+1,can_put);

    if(W[I[at]] <= can_put) {
        mx = max(mx, dp(at+1,  min(can_put - W[I[at]], S[I[at]])) + V[I[at]]);
    }

    return memo[at][can_put] = mx;
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> n;
    rep(i,0,n) {
        cin >> W[i] >> S[i] >> V[i];
    }

    rep(i,0,n) I.pb(i);
    sort(I.begin(), I.end(), comp);
    cout << dp(0,20'000) << endl;
    return 0;
}


Compiler output:
a.cc:1:1: error: 'll' does not name a type
    1 | ll n;
      | ^~
a.cc:2:1: error: 'll' does not name a type
    2 | ll memo[1020][20'020];
      | ^~
a.cc:4:1: error: 'll' does not name a type
    4 | ll W[1020];
      | ^~
a.cc:5:1: error: 'll' does not name a type
    5 | ll S[1020];
      | ^~
a.cc:6:1: error: 'll' does not name a type
    6 | ll V[1020];
      | ^~
a.cc:8:1: error: 'vi' does not name a type; did you mean 'void'?
    8 | vi I;
      | ^~
      | void
a.cc:9:1: error: 'll' does not name a type
    9 | ll comp(ll a, ll b) {
      | ^~
a.cc:13:1: error: 'll' does not name a type
   13 | ll dp(ll at, ll can_put) {
      | ^~
a.cc: In function 'int main()':
a.cc:28:5: error: 'cin' was not declared in this scope
   28 |     cin.sync_with_stdio(false);
      |     ^~~
a.cc:29:12: error: 'memo' was not declared in this scope
   29 |     memset(memo,-1,sizeof(memo));
      |            ^~~~
a.cc:29:5: error: 'memset' was not declared in this scope
   29 |     memset(memo,-1,sizeof(memo));
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | ll n;
a.cc:30:12: error: 'n' was not declared in this scope
   30 |     cin >> n;
      |            ^
a.cc:31:9: error: 'i' was not declared in this scope
   31 |     rep(i,0,n) {
      |         ^
a.cc:31:5: error: 'rep' was not declared in this scope
   31 |     rep(i,0,n) {
      |     ^~~
a.cc:36:10: error: 'I' was not declared in this scope
   36 |     sort(I.begin(), I.end(), comp);
      |          ^
a.cc:36:30: error: 'comp' was not declared in this scope
   36 |     sort(I.begin(), I.end(), comp);
      |                              ^~~~
a.cc:36:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   36 |     sort(I.begin(), I.end(), comp);
      |     ^~~~
      |     short
a.cc:37:5: error: 'cout' was not declared in this scope
   37 |     cout << dp(0,20'000) << endl;
      |     ^~~~
a.cc:37:13: error: 'dp' was not declared in this scope
   37 |     cout << dp(0,20'000) << endl;
      |             ^~
a.cc:37:29: error: 'endl' was not declared in this scope
   37 |     cout << dp(0,20'000) << endl;
      |                             ^~~~
Language: C++

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

struct tower{
    ll w , s , v ;
    structure(ll w = 0, ll s = 0, ll v = 0) : w(w), s(s), v(v) {}
    inline void read(){
        scanf("%lld %lld %lld" , &w , &s ,&v);
    }
    inline bool operator < (const tower &p){
        return ((p.w + p.s) > (w + s));
    }
};
tower t[N];
int n;
ll dp[1000+5][100000+4];
bool memoize[1000+5][100000+4];
inline ll solve(int pos, ll weight)
{
      if (pos > n) return 0;
      if (weight > 10000) return 0;
      ll &ret = dp[pos][weight];
      bool &mem = memoize[pos][weight];
      if (mem) return ret;
      mem = 1;
      ret = 0;
      if (weight <= t[pos].s)
      {
            ret = max(ret, t[pos].v + solve(pos+1, weight + t[pos].w));
      }
      ret = max(ret, solve(pos+1, weight));
      return ret;
}
int main(){


    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i){
        t[i].read();
    }
    sort(t + 1 , t + n + 1);
    for(int i = 0 ; i < n ; ++i){
        cout << t[i].w << " " << t[i].s << " " << t[i].v << endl;
    }
    printf("%lld", solve(0, 0));

    return 0;
}


Compiler output:
a.cc:8:5: error: ISO C++ forbids declaration of 'structure' with no type [-fpermissive]
    8 |     structure(ll w = 0, ll s = 0, ll v = 0) : w(w), s(s), v(v) {}
      |     ^~~~~~~~~
a.cc: In member function 'int tower::structure(ll, ll, ll)':
a.cc:8:47: error: only constructors take member initializers
    8 |     structure(ll w = 0, ll s = 0, ll v = 0) : w(w), s(s), v(v) {}
      |                                               ^
a.cc:8:65: warning: no return statement in function returning non-void [-Wreturn-type]
    8 |     structure(ll w = 0, ll s = 0, ll v = 0) : w(w), s(s), v(v) {}
      |                                                                 ^
Language: C++

#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e3 + 5, M = 1e4 + 5, up = 1e4;
const ll LINF = 1e18 + 5;
int n;
struct node
{
	int w, s, v;
	bool operator < (const node& x) { return w + s > x.w + x.s; }
}p[N];
ll dp[N][M];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1; i<=n; i++)
 		cin >> p[i].w >> p[i].s >> p[i].v;
 	sort(p+1, p+n+1);
 	for(int i=1; i<=n; i++)
 	{
 		for(int j=0; j<=up; j++)
 		{
 			dp[i][j] = dp[i-1][j];
 			if(j>=p[i].w) dp[i][min(p[i].s, j-p[i].w)] = max(dp[i][min(p[i].s, j-p[i].w)], dp[i][j]+p[i].v);
 	}
 	ll ans = 0;
 	for(int i=0; i<=up; i++) ans = max(ans, dp[n][i]);
 	cout << ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:2: error: expected '}' at end of input
   39 | }
      |  ^
a.cc:21:1: note: to match this '{'
   21 | {
      | ^