Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

#ifdef I64d_OJ
#define LL __int64
#endif // I64d_OJ
//#ifdef I64d_OJ
//#define LL long long
//#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read()
{
    int x=0,c=1;
    char ch=' ';
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    while(ch=='-')c*=-1,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-'0',ch=getchar();
    return x*c;
}
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e5+10;

///--------------------START-------------------------
int N,X;
int b[MAXN],l[MAXN],r[MAXN];

struct Node{
    int b,l,r;
    LL tot;
}node[MAXN];

bool cmp(const Node& a,const Node& b){
    return a.tot>b.tot;
}

void work(){
    scanf("%d%d",&N,&X);
    for(int i=1;i<=N;i++) scanf("%d%d%d",&b[i],&l[i],&r[i]);
    LL total=0;
    for(int i=1;i<=N;i++){
        total+=(LL)b[i]*l[i];
        node[i].b=b[i];
        node[i].l=l[i];
        node[i].r=r[i];
        node[i].tot=(LL)b[i]*l[i]+(LL)(X-b[i])*r[i];
    }
//    printf("total = %lld\n",total);
    sort(node+1,node+1+N,cmp);
//    for(int i=1;i<=N;i++){
//        printf("%d %d %d %lld\n",node[i].b,node[i].l,node[i].r,node[i].tot);
//    }
    LL ans=0;
    int st=1;
    for(int i=1;i<=N;i++){
        if(total<=node[i].tot){
            st=i;
            break;
        }
        else{
            total-=node[i].tot;
//            printf("--- total = %lld ---\n",total);
            ans+=X;
        }
    }
//    printf("ans = %lld, st = %d, total = %lld\n",ans,st,total);
    LL tmpans=INF;
    for(int i=st;i<=N;i++){
        if(node[i].tot<total) continue;
        int bb=node[i].b,ll=node[i].l,rr=node[i].r;
        if((LL)bb*ll>=total){
            LL tmp=(total/ll)+((total%ll)>0);
            tmpans=min(tmp,tmpans);
//            printf("tmp = %lld\n",tmp);
        }
        else{
            LL tmp=bb;
//            printf("bb -> tmp = %lld\n",tmp);
            LL tmptotal=total-(LL)bb*ll;
//            printf("total = %d\n",total);
            tmp+=(tmptotal/rr)+((tmptotal%rr)>0);
//            printf("tmp = %lld\n",tmp);
            tmpans=min(tmpans,tmp);
        }
    }
    printf("%I64d\n",ans+tmpans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}





Compiler output:
a.cc:29:21: error: expected initializer before 'ULL'
   29 | typedef unsigned LL ULL;
      |                     ^~~
a.cc:23:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
   23 | #define LL __int64
      |            ^~~~~~~
a.cc:33:14: note: in expansion of macro 'LL'
   33 | typedef pair<LL,LL> pLL;
      |              ^~
a.cc:23:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
   23 | #define LL __int64
      |            ^~~~~~~
a.cc:33:17: note: in expansion of macro 'LL'
   33 | typedef pair<LL,LL> pLL;
      |                 ^~
a.cc:33:19: error: template argument 1 is invalid
   33 | typedef pair<LL,LL> pLL;
      |                   ^
a.cc:33:19: error: template argument 2 is invalid
a.cc:23:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   23 | #define LL __int64
      |            ^~~~~~~
a.cc:76:5: note: in expansion of macro 'LL'
   76 |     LL tot;
      |     ^~
a.cc: In function 'bool cmp(const Node&, const Node&)':
a.cc:80:14: error: 'const struct Node' has no member named 'tot'
   80 |     return a.tot>b.tot;
      |              ^~~
a.cc:80:20: error: 'const struct Node' has no member named 'tot'
   80 |     return a.tot>b.tot;
      |                    ^~~
a.cc: In function 'void work()':
a.cc:23:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
   23 | #define LL __int64
      |            ^~~~~~~
a.cc:86:5: note: in expansion of macro 'LL'
   86 |     LL total=0;
      |     ^~
a.cc:88:9: error: 'total' was not declared in this scope
   88 |         total+=(LL)b[i]*l[i];
      |         ^~~~~
a.cc:92:17: error: 'struct Node' has no member named 'tot'
   92 |         node[i].tot=(LL)b[i]*l[i]+(LL)(X-b[i])*r[i];
      |                 ^~~
a.cc:99:8: error: expected ';' before 'ans'
   99 |     LL ans=0;
      |        ^~~
a.cc:102:12: error: 'total' was not declared in this scope
  102 |         if(total<=node[i].tot){
      |            ^~~~~
a.cc:102:27: error: 'struct Node' has no member named 'tot'
  102 |         if(total<=node[i].tot){
      |                           ^~~
a.cc:107:28: error: 'struct Node' has no member named 'tot'
  107 |             total-=node[i].tot;
      |                            ^~~
a.cc:109:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
  109 |             ans+=X;
      |             ^~~
      |             abs
a.cc:113:8: error: expected ';' before 'tmpans'
  113 |     LL tmpans=INF;
      |        ^~~~~~
a.cc:115:20: error: 'struct Node' has no member named 'tot'
  115 |         if(node[i].tot<total) continue;
      |                    ^~~
a.cc:115:24: error: 'total' was not declared in this scope
  115 |         if(node[i].tot<total) continue;
      |                        ^~~~~
a.cc:117:16: error: expected ')' before 'bb'
  117 |         if((LL)bb*ll>=total){
      |           ~    ^~
      |                )
a.cc:118:16: error: expected ';' before 'tmp'
  118 |             LL tmp=(total/ll)+((total%ll)>0);
      |                ^~~
a.cc:119:13: error: 'tmpans' was not declared in this scope; did you mean 'tmpnam'?
  119 |             tmpans=min(tmp,tmpans);
      |             ^~~~~~
      |             tmpnam
a.cc:119:24: error: 'tmp' was not declared in this scope; did you mean 'tm'?
  119 |             tmpans=min(tmp,tmpans);
      |                        ^~~
      |                        tm
a.cc:123:16: error: expected ';' before 'tmp'
  123 |             LL tmp=bb;
      |                ^~~
a.cc:125:16: error: expected ';' before 'tmptotal'
  125 |             LL tmptotal=total-(LL)bb*ll;
      |                ^~~~~~~~
a.cc:127:13: error: 'tmp' was not declared in this scope; did you mean 'tm'?
  127 |             tmp+=(tmptotal/rr)+((tmptotal%rr)>0);
      |             ^~~
      |             tm
a.cc:127:19: error: 'tmptotal' was not declared in this scope
  127 |             tmp+=(tmptotal/rr)+((tmptotal%rr)>0);
      |                   ^~~~~~~~
a.cc:129:13: error: 'tmpans' was not declared in this scope; did you mean 'tmpnam'?
  129 |             tmpans=min(tmpans,tmp);
      |             ^~~~~~
      |             tmpnam
a.cc:132:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
  132 |     printf("%I64d\n",ans+tmpans);
      |                      ^~~
      |                      abs
a.cc:132:26: error: 'tmpans' was not declared in this scope; did you mean 'tmpnam'?
  132 |     printf("%I64d\n",ans+tmpans);
      |                          ^~~~~~
      |                          tmpnam