Language: C++

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1000000001
#define mod 1000000007

ll N,T;
vector<P> ps;
ll dp[200010][31];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>N>>T;
  rep(i,N){
  	ll a,b;
  	cin>>a>>b;
  	ps.push_back(P(a+1,a+b+1));
  }
  sort(all(ps),[](const P& a,const P& b){
  	if(a.fi==1&&b.fi==1) return a.se < b.se;
  	else return b.fi*a.se+b.se < a.fi*b.se+a.se;
  });

  ll M=N;
  rep(i,N){
  	if(ps[i].fi==1){
  		M=i;
  		break;
  	}
  }
  const ll K=30;
  rep(i,M+1)rep(j,K+1)dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,M)rep(j,K+1){
  	if(dp[i][j]==INF)continue;
  	minch(dp[i+1][j],dp[i][j]);
  	if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
  }

  ll res=0;
  rep(j,K+1){
  	if(dp[M][j]>T)continue;
  	ll crtt=dp[M][j];
  	ll crtcnt=j;
  	repl(i,M,N){
  		if(crtt+ps[i].se<=T){
  			crtt+=ps[i].se;
  			crtcnt++;
  		}else{
  			break;
  		}
  	}
  	maxch(res,crtcnt);
  }
  cout<<res<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:41: error: no matching function for call to 'min(long long int, int)'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:22: note: in definition of macro 'mmin'
   15 | #define mmin(x,y) (x<y?x:y)
      |                      ^
a.cc:57:19: note: in expansion of macro 'minch'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                   ^~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:57:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:22: note: in definition of macro 'mmin'
   15 | #define mmin(x,y) (x<y?x:y)
      |                      ^
a.cc:57:19: note: in expansion of macro 'minch'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                   ^~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:57:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:22: note: in definition of macro 'mmin'
   15 | #define mmin(x,y) (x<y?x:y)
      |                      ^
a.cc:57:19: note: in expansion of macro 'minch'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                   ^~~~~
a.cc:57:41: error: no matching function for call to 'min(long long int, int)'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:26: note: in definition of macro 'mmin'
   15 | #define mmin(x,y) (x<y?x:y)
      |                          ^
a.cc:57:19: note: in expansion of macro 'minch'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                   ^~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:57:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:26: note: in definition of macro 'mmin'
   15 | #define mmin(x,y) (x<y?x:y)
      |                          ^
a.cc:57:19: note: in expansion of macro 'minch'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                   ^~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:57:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:26: note: in definition of macro 'mmin'
   15 | #define mmin(x,y) (x<y?x:y)
      |                          ^
a.cc:57:19: note: in expansion of macro 'minch'
   57 |         if(j+1<=K)minch(dp[i+1][j+1],min(ps[i].fi*dp[i][j]+ps[i].se,INF));
      |                   ^~~~~