Language: C++

a#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
ll b[100009];
pll p[100009];
pll d[100009];
ll n,x;
ll e[100009];
bool comparion(pll r,pll t)
{
    if(r.ff==t.ff)
        return b[r.ss]>=b[t.ss];
    return r.ff>=t.ff;
}
bool check(ll q,ll val)
{
    for(ll i=0;i<n;i++)
    {
        if(e[i])
            continue;
        ll z=q-b[i];
        z*=p[i].ss;
        if(z>=val)
            return 1;
        if((q*p[i].ff)>=val)
            return 1;
    }
    return 0;
}
int main()
{  
    FAST
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "rt" , stdin);
        freopen("output.txt" , "wt" , stdout);
    #endif
    cin>>n>>x;
    ll q=0;
    for(ll i=0;i<n;i++)
    {
        cin>>b[i]>>p[i].ff>>p[i].ss;
        q+=b[i]*p[i].ff;
        d[i].ff=((p[i].ss*(x-b[i]))+(b[i]*p[i].ff));
        d[i].ss=i;
    }
    sort(d,d+n,comparion);
    ll ans=0;
    ll s=0;
    ll j,i;
    while(s<n)
    {
        i=d[s].ss;
        j=(x*(p[i].ss))-(b[i]*(p[i].ss-p[i].ff));
        if(j>q)
            break;
        q-=j;
        ans+=x;
        e[i]=1;
        s++;
    }
    i=x;
    ll l=0,u=x,mid;
    while(l<=u)
    {
        mid=(l+u)/2;
        if(check(mid,q))
        {
            u=mid-1;
            i=mid;
        }
        else
        {
            l=mid+1;
        }
    }
    ans+=i;
    cout<<ans;
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | a#include<bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'a' does not name a type
    1 | a#include<bits/stdc++.h>
      | ^
a.cc:13:13: error: 'pair' does not name a type
   13 | #define pll pair<ll,ll>
      |             ^~~~
a.cc:30:1: note: in expansion of macro 'pll'
   30 | pll p[100009];
      | ^~~
a.cc:13:13: error: 'pair' does not name a type
   13 | #define pll pair<ll,ll>
      |             ^~~~
a.cc:31:1: note: in expansion of macro 'pll'
   31 | pll d[100009];
      | ^~~
a.cc:13:13: error: 'pair' was not declared in this scope
   13 | #define pll pair<ll,ll>
      |             ^~~~
a.cc:34:16: note: in expansion of macro 'pll'
   34 | bool comparion(pll r,pll t)
      |                ^~~
a.cc:4:12: error: expected primary-expression before 'long'
    4 | #define ll long long int
      |            ^~~~
a.cc:13:18: note: in expansion of macro 'll'
   13 | #define pll pair<ll,ll>
      |                  ^~
a.cc:34:16: note: in expansion of macro 'pll'
   34 | bool comparion(pll r,pll t)
      |                ^~~
a.cc:4:12: error: expected primary-expression before 'long'
    4 | #define ll long long int
      |            ^~~~
a.cc:13:21: note: in expansion of macro 'll'
   13 | #define pll pair<ll,ll>
      |                     ^~
a.cc:34:16: note: in expansion of macro 'pll'
   34 | bool comparion(pll r,pll t)
      |                ^~~
a.cc:13:13: error: 'pair' was not declared in this scope
   13 | #define pll pair<ll,ll>
      |             ^~~~
a.cc:34:22: note: in expansion of macro 'pll'
   34 | bool comparion(pll r,pll t)
      |                      ^~~
a.cc:4:12: error: expected primary-expression before 'long'
    4 | #define ll long long int
      |            ^~~~
a.cc:13:18: note: in expansion of macro 'll'
   13 | #define pll pair<ll,ll>
      |                  ^~
a.cc:34:22: note: in expansion of macro 'pll'
   34 | bool comparion(pll r,pll t)
      |                      ^~~
a.cc:4:12: error: expected primary-expression before 'long'
    4 | #define ll long long int
      |            ^~~~
a.cc:13:21: note: in expansion of macro 'll'
   13 | #define pll pair<ll,ll>
      |                     ^~
a.cc:34:22: note: in expansion of macro 'pll'
   34 | bool comparion(pll r,pll t)
      |                      ^~~
a.cc:34:27: error: expression list treated as compound expression in initializer [-fpermissive]
   34 | bool comparion(pll r,pll t)
      |                           ^
a.cc: In function 'bool check(long long int, long long int)':
a.cc:47:12: error: 'p' was not declared in this scope
   47 |         z*=p[i].ss;
      |            ^
a.cc: In function 'int main()':
a.cc:3:14: error: 'ios_base' has not been declared
    3 | #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
      |              ^~~~~~~~
a.cc:57:5: note: in expansion of macro 'FAST'
   57 |     FAST
      |     ^~~~
a.cc:3:47: error: 'cin' was not declared in this scope
    3 | #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
      |                                               ^~~
a.cc:57:5: note: in expansion of macro 'FAST'
   57 |     FAST
      |     ^~~~
a.cc:3:55: error: 'NULL' was not declared in this scope
    3 | #define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
      |                                                       ^~~~
a.cc:57:5: note: in expansion of macro 'FAST'
   57 |     FAST
      |     ^~~~
a.cc:1:1: note: 'NULL' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | a#include<bits/stdc++.h>
a.cc:59:38: error: 'stdin' was not declared in this scope
   59 |         freopen("input.txt" , "rt" , stdin);
      |                                      ^~~~~
a.cc:1:1: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | a#include<bits/stdc++.h>
a.cc:59:9: error: 'freopen' was not declared in this scope
   59 |         freopen("input.txt" , "rt" , stdin);
      |         ^~~~~~~
a.cc:60:39: error: 'stdout' was not declared in this scope
   60 |         freopen("output.txt" , "wt" , stdout);
      |                                       ^~~~~~
a.cc:60:39: note: 'stdout' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:66:20: error: 'p' was not declared in this scope
   66 |         cin>>b[i]>>p[i].ff>>p[i].ss;
      |                    ^
a.cc:68:9: error: 'd' was not declared in this scope
   68 |         d[i].ff=((p[i].ss*(x-b[i]))+(b[i]*p[i].ff));
      |         ^
a.cc:71:10: error: 'd' was not declared in this scope
   71 |     sort(d,d+n,comparion);
      |          ^
a.cc:71:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   71 |     sort(d,d+n,comparion);
      |     ^~~~
      |     short
a.cc:78:15: error: 'p' was not declared in this scope
   78 |         j=(x*(p[i].ss))-(b[i]*(p[i].ss-p[i].ff));
      |               ^
a.cc:102:5: error: 'cout' was not declared in this scope
  102 |     cout<<ans;
      |     ^~~~