Language: C++

#include <bits/stdc++.h>

#define IsDigit(c) ('0' <= (c) && (c) <= '9')

#define MAX 5 + 30

using namespace std;

typedef pair<int, int> Pii;

inline int read()
{
	int x = 0; bool f = true;
	char c = getchar();
	for (; ! IsDigit(c); c = getchar()) if (c == '-') f = false;
	for (; IsDigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ '0');
	return f ? x : -x;
}
inline void write(int x)
{
    if (x < 0)
	{
        putchar('-');
		x = -x;
	}
    if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}

int n, T, Max, Ans, f[MAX];

vector<Pii> A;
vector<int> B;

inline bool mycmp(Pii x, Pii y)
{
	return x.first * (y.second + 1) > y.first * (x.second + 1);
}

signed main()
{
	n = read(); T = read(); Max = log(T) + 1;
	for (register int x, y, i = 1; i <= n; i++)
	{
		x = read(); y = read();
		if (x != 0) A.push_back(make_pair(x, y));
		    else B.push_back(y + 1);
	}
	
	for (register int i = 1; i <= Max; i++)
		f[i] = T + 1;
	sort(A.begin(), A.end(), mycmp);
	sort(B.begin(), B.end());
	for (register int i = 1; i < B.size(); i++) B[i] += B[i - 1];	
	
	f[0] = 0;
	for (register int i = 0; i < A.size(); i++)
		for (register int j = Max; j; j--)
			    f[j] = min(f[j], (f[j - 1] + 1) * (A[i].first + 1) + A[i].second);
	for (register int i = 0	; i <= Max; i++)
		if (f[i] <= T) Ans = max(Ans, i + (B.empty() ? 0 : upper_bound(B.begin(), B.end(), T - f[i]) - B.begin()));
	write(Ans);
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |         for (register int x, y, i = 1; i <= n; i++)
      |                           ^
a.cc:43:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |         for (register int x, y, i = 1; i <= n; i++)
      |                              ^
a.cc:43:33: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |         for (register int x, y, i = 1; i <= n; i++)
      |                                 ^
a.cc:50:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   50 |         for (register int i = 1; i <= Max; i++)
      |                           ^
a.cc:54:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   54 |         for (register int i = 1; i < B.size(); i++) B[i] += B[i - 1];
      |                           ^
a.cc:57:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   57 |         for (register int i = 0; i < A.size(); i++)
      |                           ^
a.cc:58:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   58 |                 for (register int j = Max; j; j--)
      |                                   ^
a.cc:60:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   60 |         for (register int i = 0 ; i <= Max; i++)
      |                           ^
a.cc:61:41: error: no matching function for call to 'max(int&, long int)'
   61 |                 if (f[i] <= T) Ans = max(Ans, i + (B.empty() ? 0 : upper_bound(B.begin(), B.end(), T - f[i]) - B.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: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:61:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   61 |                 if (f[i] <= T) Ans = max(Ans, i + (B.empty() ? 0 : upper_bound(B.begin(), B.end(), T - f[i]) - B.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:61:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |                 if (f[i] <= T) Ans = max(Ans, i + (B.empty() ? 0 : upper_bound(B.begin(), B.end(), T - f[i]) - B.begin()));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~