Language: C++

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

typedef long long ll;
#define int ll;

const int N=2e5+5;
int t[4*N]={0},lazy[4*N]={0};

void push(int node)
{
  for(auto child:{2*node,2*node+1})
  {
    t[child]+=lazy[node];
    lazy[child]+=lazy[node];
  }
  lazy[node]=0;
}

void update(int node, int tl, int tr, int l, int r, int add)
{
  if(l>r)
    return;
  if(tl==l&&tr==r)
  {
    t[node]+=add;
    lazy[node]+=add;
  }
  else
  {
    push(node);
    int tm=(tl+tr)>>1;
    update(2*node,tl,tm,l,min(r,tm),add);
    update(2*node+1,tm+1,tr,max(l,tm+1),r,add);
    t[node]=min(t[2*node],t[2*node+1]);
  }
}

int query(int node, int tl, int tr, int l, int r)
{
  if(l>r)
    return 0;
  if(tl==l&&tr==r)
    return t[node];
  push(node);
  int tm=(tl+tr)>>1;
  return min(query(2*node,tl,tm,l,min(r,tm)),query(2*node+1,tm+1,tr,max(l,tm+1),r));
  
}


int main()
{
  ll n,m,tot=0,l,r,x;
  cin>>n>>m;
  vector<pair<ll,ll>> en[n+1];
  for(int i=0;i<m;i++)
  {
    cin>>l>>r>>x;
    tot+=x;
    en[r].push_back({l,x});
  }
  ll best=tot;
  
  for(int i=1;i<=n+1;i++)
  {
    for(auto p:en[i-1])
    {
      l=p.first;
      x=p.second;
      update(1,0,N-1,0,l-1,x);
    }
    best=query(1,0,N-1,0,i-1);
    update(1,0,N-1,i,i,best);
  }
  cout<<tot-best;
  
  
}

Compiler output:
a.cc:5:13: error: declaration does not declare anything [-fpermissive]
    5 | #define int ll;
      |             ^~
a.cc:7:7: note: in expansion of macro 'int'
    7 | const int N=2e5+5;
      |       ^~~
a.cc:7:11: error: 'N' does not name a type
    7 | const int N=2e5+5;
      |           ^
a.cc:5:13: error: declaration does not declare anything [-fpermissive]
    5 | #define int ll;
      |             ^~
a.cc:8:1: note: in expansion of macro 'int'
    8 | int t[4*N]={0},lazy[4*N]={0};
      | ^~~
a.cc:8:5: error: 't' does not name a type; did you mean 'tm'?
    8 | int t[4*N]={0},lazy[4*N]={0};
      |     ^
      |     tm
a.cc:8:15: error: expected unqualified-id before ',' token
    8 | int t[4*N]={0},lazy[4*N]={0};
      |               ^
a.cc:8:23: error: 'N' was not declared in this scope
    8 | int t[4*N]={0},lazy[4*N]={0};
      |                       ^
a.cc:8:25: error: expected constructor, destructor, or type conversion before '=' token
    8 | int t[4*N]={0},lazy[4*N]={0};
      |                         ^
a.cc:5:15: error: expected ')' before ';' token
    5 | #define int ll;
      |               ^
a.cc:10:11: note: in expansion of macro 'int'
   10 | void push(int node)
      |           ^~~
a.cc:10:10: note: to match this '('
   10 | void push(int node)
      |          ^
a.cc:10:15: error: 'node' does not name a type
   10 | void push(int node)
      |               ^~~~
a.cc:5:15: error: expected ')' before ';' token
    5 | #define int ll;
      |               ^
a.cc:20:13: note: in expansion of macro 'int'
   20 | void update(int node, int tl, int tr, int l, int r, int add)
      |             ^~~
a.cc:20:12: note: to match this '('
   20 | void update(int node, int tl, int tr, int l, int r, int add)
      |            ^
a.cc:20:17: error: 'node' does not name a type
   20 | void update(int node, int tl, int tr, int l, int r, int add)
      |                 ^~~~
a.cc:20:27: error: 'tl' does not name a type; did you mean 'tm'?
   20 | void update(int node, int tl, int tr, int l, int r, int add)
      |                           ^~
      |                           tm
a.cc:20:35: error: 'tr' does not name a type; did you mean 'tm'?
   20 | void update(int node, int tl, int tr, int l, int r, int add)
      |                                   ^~
      |                                   tm
a.cc:20:43: error: 'l' does not name a type; did you mean 'll'?
   20 | void update(int node, int tl, int tr, int l, int r, int add)
      |                                           ^
      |                                           ll
a.cc:20:50: error: 'r' does not name a type
   20 | void update(int node, int tl, int tr, int l, int r, int add)
      |                                                  ^
a.cc:20:57: error: 'add' does not name a type
   20 | void update(int node, int tl, int tr, int l, int r, int add)
      |                                                         ^~~
a.cc:5:13: error: declaration does not declare anything [-fpermissive]
    5 | #define int ll;
      |             ^~
a.cc:39:1: note: in expansion of macro 'int'
   39 | int query(int node, int tl, int tr, int l, int r)
      | ^~~
a.cc:5:15: error: expected ')' before ';' token
    5 | #define int ll;
      |               ^
a.cc:39:11: note: in expansion of macro 'int'
   39 | int query(int node, int tl, int tr, int l, int r)
      |           ^~~
a.cc:39:10: note: to match this '('
   39 | int query(int node, int tl, int tr, int l, int r)
      |          ^
a.cc:5:15: error: expected constructor, destructor, or type conversion before ';' token
    5 | #define int ll;
      |               ^
a.cc:39:11: note: in expansion of macro 'int'
   39 | int query(int node, int tl, int tr, int l, int r)
      |           ^~~
a.cc:39:15: error: 'node' does not name a type
   39 | int query(int node, int tl, int tr, int l, int r)
      |               ^~~~
a.cc:39:25: error: 'tl' does not name a type; did you mean 'tm'?
   39 | int query(int node, int tl, int tr, int l, int r)
      |                         ^~
      |                         tm
a.cc:39:33: error: 'tr' does not name a type; did you mean 'tm'?
   39 | int query(int node, int tl, int tr, int l, int r)
      |                                 ^~
      |                                 tm
a.cc:39:41: error: 'l' does not name a type; did you mean 'll'?
   39 | int query(int node, int tl, int tr, int l, int r)
      |                                         ^
      |                                         ll
a.cc:39:48: error: 'r' does not name a type
   39 | int query(int node, int tl, int tr, int l, int r)
      |                                                ^
a.cc:5:13: error: declaration does not declare anything [-fpermissive]
    5 | #define int ll;
      |             ^~
a.cc:52:1: note: in expansion of macro 'int'
   52 | int main()
      | ^~~
a.cc:52:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | int main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:5:13: error: declaration does not declare anything [-fpermissive]
    5 | #define int ll;
      |             ^~
a.cc:57:7: note: in expansion of macro 'int'
   57 |   for(int i=0;i<m;i++)
      |       ^~~
a.cc:57:11: error: 'i' was not declared in this scope
   57 |   for(int i=0;i<m;i++)
      |           ^
a.cc:57:18: error: expected ')' before ';' token
   57 |   for(int i=0;i<m;i++)
      |      ~           ^
      |                  )
a.cc:57:19: error: 'i' was not declared in this scope
   57 |   for(int i=0;i<m;i++)
      |                   ^
a.cc:5:13: error: declaration does not declare anything [-fpermissive]
    5 | #define int ll;
      |             ^~
a.cc:65:7: note: in expansion of macro 'int'
   65 |   for(int i=1;i<=n+1;i++)
      |       ^~~
a.cc:65:21: error: expected ')' before ';' token
   65 |   for(int i=1;i<=n+1;i++)
      |      ~              ^
      |                     )