Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
{
    ll a,b;
    bool operator<(const Market &o)const
    {
        if(o.a || a)
            return o.a*b < a*o.b;
        else
            return b < o.b;
    }
};
void solve(ll T, vector<Market> m)
{
    vector<Market>m1,m0;
    for(auto x:m)
    {
        if(x.a==0)m0.push_back(x);
        else m1.push_back(x);
    }
    sort(m1.begin(),m1.end());
    sort(m0.begin(),m0.end());
    vector<ll> dp(34,INT_MAX);
    dp[0] = 0;
    for(int i=0;i<m1.size();++i)
    {
        int j = 32;
        while(j >= 0 && dp[j] >= T) j--;
        for(;j>=0;--j)
        {
            if(dp[j] * m1[i].a + m1[i].b + dp[j] < dp[j+1])
                dp[j+1] = dp[j] * m1[i].a + m1[i].b + dp[j];
        }
    }
    int ans = 0;
    int j = 0;
    for(int i=0;i<=32;++i)
        if(dp[i] <= T)
        {    
            ans = i;
            j = i;
        }
    ll sum = 0;
    for(int i=0;i<m0.size();++i)
    {
        sum += m0[i].b;
        if(sum > T) break;
        while(j>=0 && dp[j] + sum > T)
        {
            j--;
        }
        ans = max(ans,j + i + 1);
    }
    cout<<ans<<endl;
}

int main()
{
    ll N;
    cin>>N;
    ll T;
    cin>>T;
    vector<Market> dat(N);
    for(int i = 0 ; i < N ; i++)
    {
        cin>>dat[i].a>>dat[i].b;
        dat[i].b += dat[i].a + 1;
    }
    solve(T, move(dat));
    return 0;
}


Compiler output:
a.cc:4:1: error: expected unqualified-id before '{' token
    4 | {
      | ^
a.cc:14:25: error: 'Market' was not declared in this scope
   14 | void solve(ll T, vector<Market> m)
      |                         ^~~~~~
a.cc:14:31: error: template argument 1 is invalid
   14 | void solve(ll T, vector<Market> m)
      |                               ^
a.cc:14:31: error: template argument 2 is invalid
a.cc: In function 'void solve(ll, int)':
a.cc:16:12: error: 'Market' was not declared in this scope
   16 |     vector<Market>m1,m0;
      |            ^~~~~~
a.cc:16:18: error: template argument 1 is invalid
   16 |     vector<Market>m1,m0;
      |                  ^
a.cc:16:18: error: template argument 2 is invalid
a.cc:17:16: error: 'begin' was not declared in this scope
   17 |     for(auto x:m)
      |                ^
a.cc:17:16: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:17:16: error: 'end' was not declared in this scope
   17 |     for(auto x:m)
      |                ^
a.cc:17:16: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:19:22: error: request for member 'push_back' in 'm0', which is of non-class type 'int'
   19 |         if(x.a==0)m0.push_back(x);
      |                      ^~~~~~~~~
a.cc:20:17: error: request for member 'push_back' in 'm1', which is of non-class type 'int'
   20 |         else m1.push_back(x);
      |                 ^~~~~~~~~
a.cc:22:13: error: request for member 'begin' in 'm1', which is of non-class type 'int'
   22 |     sort(m1.begin(),m1.end());
      |             ^~~~~
a.cc:22:24: error: request for member 'end' in 'm1', which is of non-class type 'int'
   22 |     sort(m1.begin(),m1.end());
      |                        ^~~
a.cc:23:13: error: request for member 'begin' in 'm0', which is of non-class type 'int'
   23 |     sort(m0.begin(),m0.end());
      |             ^~~~~
a.cc:23:24: error: request for member 'end' in 'm0', which is of non-class type 'int'
   23 |     sort(m0.begin(),m0.end());
      |                        ^~~
a.cc:26:22: error: request for member 'size' in 'm1', which is of non-class type 'int'
   26 |     for(int i=0;i<m1.size();++i)
      |                      ^~~~
a.cc:32:26: error: invalid types 'int[int]' for array subscript
   32 |             if(dp[j] * m1[i].a + m1[i].b + dp[j] < dp[j+1])
      |                          ^
a.cc:32:36: error: invalid types 'int[int]' for array subscript
   32 |             if(dp[j] * m1[i].a + m1[i].b + dp[j] < dp[j+1])
      |                                    ^
a.cc:33:37: error: invalid types 'int[int]' for array subscript
   33 |                 dp[j+1] = dp[j] * m1[i].a + m1[i].b + dp[j];
      |                                     ^
a.cc:33:47: error: invalid types 'int[int]' for array subscript
   33 |                 dp[j+1] = dp[j] * m1[i].a + m1[i].b + dp[j];
      |                                               ^
a.cc:45:22: error: request for member 'size' in 'm0', which is of non-class type 'int'
   45 |     for(int i=0;i<m0.size();++i)
      |                      ^~~~
a.cc:47:18: error: invalid types 'int[int]' for array subscript
   47 |         sum += m0[i].b;
      |                  ^
a.cc: In function 'int main()':
a.cc:64:12: error: 'Market' was not declared in this scope
   64 |     vector<Market> dat(N);
      |            ^~~~~~
a.cc:64:18: error: template argument 1 is invalid
   64 |     vector<Market> dat(N);
      |                  ^
a.cc:64:18: error: template argument 2 is invalid
a.cc:67:17: error: invalid types 'int[int]' for array subscript
   67 |         cin>>dat[i].a>>dat[i].b;
      |                 ^
a.cc:67:27: error: invalid types 'int[int]' for array subscript
   67 |         cin>>dat[i].a>>dat[i].b;
      |                           ^
a.cc:68:12: error: invalid types 'int[int]' for array subscript
   68 |         dat[i].b += dat[i].a + 1;
      |            ^
a.cc:68:24: error: invalid types 'int[int]' for array subscript
   68 |         dat[i].b += dat[i].a + 1;
      |                        ^