Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
const int mod = INF;
const int MAX = 1 << 25;
ll dp[200005][35];
int main()
{
	ios_base::sync_with_stdio(0);
	int n , t;
	cin >> n >> t;
	vector<pair<ll , ll> > p;
	vector<int> zh;
	for(int i = 0; i < n; i++)
	{
		int a , b;
		cin >> a >> b;
		if(a == 0)
			zh.pb(b);
		else
			p.pb({a , b});
	}
	sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
			(p2.x * (p1.y + 1)));
	sort(zh.begin() , zh.end());
	ll sum = 0;
	for(auto &x : zh)
	{
		sum += x + 1;
		x = sum;
	}
	for(int i = 0; i <= n; i++)
		for(int j = 0; j < 35; j++)
			dp[i][j] = INF;
	
	dp[0][0] = 0;
	n = sz(p);
	for(int j = 0; j < 34; j++)
	{
		for(int i = 0; i < n; i++)
		{
			
			dp[i + 1][j] = min(dp[i + 1][j] , dp[i][j]);
			dp[i + 1][j + 1] = min(dp[i + 1][j + 1] , (dp[i][j] + 1) * p[i].x + p[i].y);
			
		}
	}
			
	int ans = 0;
	for(int j = 0; j < 34; j++)
		if(dp[n][j] <= t)
		{
			int v = (upper_bound(zh.begin() , zh.end() , t - dp[n][j]) - zh.begin());
			ans = max(ans , j + v);
		}
	cout << ans;
}


Compiler output:
a.cc: In lambda function:
a.cc:32:44: error: expected ';' before ')' token
   32 |                         (p2.x * (p1.y + 1)));
      |                                            ^
      |                                            ;
a.cc:32:44: error: expected primary-expression before ')' token
a.cc:33:14: error: 'zh' is not captured
   33 |         sort(zh.begin() , zh.end());
      |              ^~
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:21:21: note: 'std::vector<int> zh' declared here
   21 |         vector<int> zh;
      |                     ^~
a.cc:33:27: error: 'zh' is not captured
   33 |         sort(zh.begin() , zh.end());
      |                           ^~
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:21:21: note: 'std::vector<int> zh' declared here
   21 |         vector<int> zh;
      |                     ^~
a.cc:35:23: error: 'zh' is not captured
   35 |         for(auto &x : zh)
      |                       ^~
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:21:21: note: 'std::vector<int> zh' declared here
   21 |         vector<int> zh;
      |                     ^~
a.cc:40:29: error: 'n' is not captured
   40 |         for(int i = 0; i <= n; i++)
      |                             ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:18:13: note: 'int n' declared here
   18 |         int n , t;
      |             ^
a.cc:45:9: error: 'n' is not captured
   45 |         n = sz(p);
      |         ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:18:13: note: 'int n' declared here
   18 |         int n , t;
      |             ^
a.cc:45:16: error: 'p' is not captured
   45 |         n = sz(p);
      |                ^
a.cc:9:21: note: in definition of macro 'sz'
    9 | #define sz(a) (int)(a.size())
      |                     ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:20:32: note: 'std::vector<std::pair<long long int, long long int> > p' declared here
   20 |         vector<pair<ll , ll> > p;
      |                                ^
a.cc:48:36: error: 'n' is not captured
   48 |                 for(int i = 0; i < n; i++)
      |                                    ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:18:13: note: 'int n' declared here
   18 |         int n , t;
      |             ^
a.cc:52:84: error: 'p' is not captured
   52 |                         dp[i + 1][j + 1] = min(dp[i + 1][j + 1] , (dp[i][j] + 1) * p[i].x + p[i].y);
      |                                                                                    ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:20:32: note: 'std::vector<std::pair<long long int, long long int> > p' declared here
   20 |         vector<pair<ll , ll> > p;
      |                                ^
a.cc:52:93: error: 'p' is not captured
   52 |                         dp[i + 1][j + 1] = min(dp[i + 1][j + 1] , (dp[i][j] + 1) * p[i].x + p[i].y);
      |                                                                                             ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:20:32: note: 'std::vector<std::pair<long long int, long long int> > p' declared here
   20 |         vector<pair<ll , ll> > p;
      |                                ^
a.cc:59:23: error: 'n' is not captured
   59 |                 if(dp[n][j] <= t)
      |                       ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:18:13: note: 'int n' declared here
   18 |         int n , t;
      |             ^
a.cc:59:32: error: 't' is not captured
   59 |                 if(dp[n][j] <= t)
      |                                ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:18:17: note: 'int t' declared here
   18 |         int n , t;
      |                 ^
a.cc:61:46: error: 'zh' is not captured
   61 |                         int v = (upper_bound(zh.begin() , zh.end() , t - dp[n][j]) - zh.begin());
      |                                              ^~
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:21:21: note: 'std::vector<int> zh' declared here
   21 |         vector<int> zh;
      |                     ^~
a.cc:61:59: error: 'zh' is not captured
   61 |                         int v = (upper_bound(zh.begin() , zh.end() , t - dp[n][j]) - zh.begin());
      |                                                           ^~
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:21:21: note: 'std::vector<int> zh' declared here
   21 |         vector<int> zh;
      |                     ^~
a.cc:61:70: error: 't' is not captured
   61 |                         int v = (upper_bound(zh.begin() , zh.end() , t - dp[n][j]) - zh.begin());
      |                                                                      ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:18:17: note: 'int t' declared here
   18 |         int n , t;
      |                 ^
a.cc:61:77: error: 'n' is not captured
   61 |                         int v = (upper_bound(zh.begin() , zh.end() , t - dp[n][j]) - zh.begin());
      |                                                                             ^
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:18:13: note: 'int n' declared here
   18 |         int n , t;
      |             ^
a.cc:61:86: error: 'zh' is not captured
   61 |                         int v = (upper_bound(zh.begin() , zh.end() , t - dp[n][j]) - zh.begin());
      |                                                                                      ^~
a.cc:31:37: note: the lambda has no capture-default
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |                                     ^
a.cc:21:21: note: 'std::vector<int> zh' declared here
   21 |         vector<int> zh;
      |                     ^~
a.cc: In function 'int main()':
a.cc:65:2: error: expected ')' at end of input
   65 | }
      |  ^
      |  )
a.cc:31:13: note: to match this '('
   31 |         sort(p.begin() , p.end() , [](pair<ll, ll> p1, pair<ll, ll> p2){return (p1.x * (p2.y + 1)) <
      |             ^
a.cc:65:2: error: expected '}' at end of input
   65 | }
      |  ^
a.cc:16:1: note: to match this '{'
   16 | {
      | ^