Language: C++

/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
int n,T;
pair<int,int>p[200005];
bool cmp(pair<int,int>a,pair<int,int>b){
	return a.first/(a.second+1)>b.first/(b.second+1);
}
int dp[20];
void update(int a,int b){
	for(int i=18;i>=0;i--){
		dp[i+1]=min(dp[i+1],a*dp[i]+b+1);
		dp[i+1]=min(dp[i+1],inf);
	}
}
signed main(){
	cin>>n>>T;
	for(int i=1;i<=n;i++){
		cin>>p[i].first>>p[i].second;
	}
	sort(p+1,p+n+1,cmp);
	vector<int>got;
	for(int i=1;i<20;i++)dp[i]=inf;
	dp[0]=0;
	for(int i=1;i<=n;i++){
		if(p[i].first==0){
			got.push_back(p[i].second+1);
		}else{ 
			update(p[i].first,p[i].second);
		}
	}
	sort(got.begin(),got.end());
	for(int i=1;i<got.size();i++)got[i]+=got[i-1];
	int ans=0;
	for(int i=0;i<20;i++){
//		cerr<<i<<" "<<dp[i]<<endl;
		if(dp[i]<=T)ans=max(ans,i+upper_bound(got.begin(),got.end(),T-dp[i])-got.begin());
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:36: 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)'
   62 |                 if(dp[i]<=T)ans=max(ans,i+upper_bound(got.begin(),got.end(),T-dp[i])-got.begin());
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:11:
/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:62:36: 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'})
   62 |                 if(dp[i]<=T)ans=max(ans,i+upper_bound(got.begin(),got.end(),T-dp[i])-got.begin());
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:62:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   62 |                 if(dp[i]<=T)ans=max(ans,i+upper_bound(got.begin(),got.end(),T-dp[i])-got.begin());
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~