Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define gcd __gcd
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep1(i, n) for (int i=1; i<=(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
template<typename _def> using ordered_set=tree<_def, null_type, less<_def>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

struct store {
    int a, b;
    store(int a, int b): a(a), b(b) {}
    bool operator< (const store& oth) const {return (ll)a*(oth.b+1)>(ll)oth.a*(b+1);}
};

const ll INF=1e18;
ll dp[2][33];

int32_t main() {
    fastio;
    int n, t; cin>>n>>t;
    vector<store> stores;
    vector<store> zeroes;
    rep(i, n) {
        int a, b; cin>>a>>b;
        if(a!=0) stores.eb(a, b);
        else zeroes.eb(a, b);
    }
    sort(all(stores));
    sort(all(zeroes));
    rep(i, 2) rep(j, 33) dp[i][j]=INF;
    dp[0][0]=0;
    rep(i, stores.size()) {
        rep(j, 33) dp[(i+1)&1][j]=INF;
        auto s=stores[i];
        rep(j, 33) {
            if(dp[i&1][j]==INF) continue;
            dp[(i+1)&1][j]=min(dp[(i+1)&1][j], dp[i&1][j]);
            ll c=(dp[i&1][j]+1)*(s.a+1)+s.b;
            if(c<=t&&j<32) dp[(i+1)&1][j+1]=min(dp[(i+1)&1][j+1], c);
        }
    }
    int ans=0;
    vll pf(zeroes.size()+1, 0);
    rep1(i, zeroes.size()) pf[i]=pf[i-1]+zeroes[i].b+1;
	rep(i, 33) {
		ll res=t-dp[stores.size()&1][i];
		if(res<0) continue;
		ans=max(ans, upper_bound(all(pf), res)-pf.begin()+i-1);
	}
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:83:24: error: no matching function for call to 'max(int&, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
   83 |                 ans=max(ans, upper_bound(all(pf), res)-pf.begin()+i-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:83:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type' {aka 'long int'})
   83 |                 ans=max(ans, upper_bound(all(pf), res)-pf.begin()+i-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:83:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   83 |                 ans=max(ans, upper_bound(all(pf), res)-pf.begin()+i-1);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~