Language: C++

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <LL,LL>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,t,x,y,dp[200010][40],ans=0;
vector <pii> v;
vector <LL> vv;

bool cmp(pii a,pii b)
{
	return b.fi*(a.se+1)<a.fi*(b.se+1);
}

int main()
{
	cin>>n>>t;
	rep(i,n)
	{
		cin>>x>>y;
		if(x>0) v.pb(mpr(x,y));
		else vv.pb(y);
	}
	sort(v.begin(),v.end(),cmp);
	sort(vv.begin(),vv.end());
	for(int i=1;i<vv.size();i++) vv[i]=vv[i-1]+vv[i]+1;
	rep(i,200005) rep(j,38) dp[i][j]=1e18;
	dp[0][0]=0;
	rep(i,v.size())
	{
		rep(j,35)
		{
			if(dp[i][j]==1e18) continue;
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			if(dp[i][j]+1+v[i].fi*(dp[i][j]+1)+v[i].se<=t)
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+1+v[i].fi*(dp[i][j]+1)+v[i].se);
		}
	}
	rep(i,35)
	{
		if(dp[v.size()][i]==1e18) continue;
		ans=max(ans,i+upper_bound(vv.begin(),vv.end(),t-dp[v.size()][i]-1)-vv.begin()-1+1);
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:24: error: no matching function for call to 'max(long long int&, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
   52 |                 ans=max(ans,i+upper_bound(vv.begin(),vv.end(),t-dp[v.size()][i]-1)-vv.begin()-1+1);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:52:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type' {aka 'long int'})
   52 |                 ans=max(ans,i+upper_bound(vv.begin(),vv.end(),t-dp[v.size()][i]-1)-vv.begin()-1+1);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:52:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |                 ans=max(ans,i+upper_bound(vv.begin(),vv.end(),t-dp[v.size()][i]-1)-vv.begin()-1+1);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~