#include #define int long long //#define int __int128 using namespace std; inline int read() { int x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();} while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();} return x*f; } void write(int x) { if(x<0)putchar('-'),x=-x; if(x<10)putchar(x+'0'); else write(x/10),putchar(x%10+'0'); } const int N=3e5; const int mod=1e9+7; int n,w,h; int top; int W[N]; int f[N]; int root(int x){ if(f[x]==x)return x; return f[x]=root(f[x]); } int ans[20]; bool fl; int sum; signed main(){ n=read(),w=read(),h=read(); for(int i=0;i<=w;i++)f[i]=i; for(int i=1;i<=n;++i){ int a=read(),b=read(),x=read(); for(int j=f[x];j<=a+x-1&&j!=0;){ W[j]+=b; if(W[j]>=h){ W[j]=LONG_LONG_MIN; ans[fl]++; sum++; f[j]=root(f[j+1]); j=f[j]; // cout<ans[1]?"A":"B")<<"\n"; //cout<