This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
 
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e18
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
 
// input
template<class T> void IN(T& x) {cin >> x;}
template<class H, class... T> void IN(H& h, T&... t) {IN(h); IN(t...); }
 
// output
template<class T1, class T2> void OUT(const pair<T1,T2>& x);
template<class T> void OUT(const vector<T>& x);
template<class T> void OUT(const T& x) {cout << x;}
template<class H, class... T> void OUT(const H& h, const T&... t) {OUT(h); OUT(t...); }
template<class T1, class T2> void OUT(const pair<T1,T2>& x) {OUT(x.fi,' ',x.se);}
template<class T> void OUT(const vector<T>& x) {RE(i,x.size()) OUT(i==0?"":" ",x[i]);}
template<class... T> void OUTL(const T&... t) {OUT(t..., "\n"); }
template<class H> void OUTLS(const H& h) {OUTL(h); }
template<class H, class... T> void OUTLS(const H& h, const T&... t) {OUT(h,' '); OUTLS(t...); }
 
// dp
template<class T> bool ckmin(T&a, T&b) { bool bl = a > b; a = min(a,b); return bl;}
template<class T> bool ckmax(T&a, T&b) { bool bl = a < b; a = max(a,b); return bl;}
 
void program();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    program();
}
 
 
//===================//
//   begin program   //
//===================//
 
const int MX = 5e5+10;
const int N = (1<<20);
ll n, w;
ll s[MX], q[MX];
ld fract[MX];
int sf[MX];
int sq[MX];
bitset<MX> used;
ll SUMQ[MX];
void addSUMQ(int i, ll value) {
    for(i++; i<=n; i+=i&-i) SUMQ[i] += value;
}
ll getSUMQ(int i) {
    if(i < 0) return 0;
    ll ans = 0;
    for(i++; i; i-=i&-i) ans += SUMQ[i];
    return ans;
}
ll CNT[MX];
void addCNT(int i, ll value) {
    for(i++; i<=n; i+=i&-i) CNT[i] += value;
}
ll getCNT(int i) {
    if(i < 0) return 0;
    ll ans = 0;
    for(i++; i; i-=i&-i) ans += CNT[i];
    return ans;
}
void program() {
    IN(n,w);
    RE(i,n) IN(s[i],q[i]);
    RE(i,n) fract[i] = ld(s[i])/ld(q[i]);
    RE(i,n) sq[i] = i;
    sort(sq,sq+n,[](int i, int j) {return q[i]<q[j];});
    RE(i,n) sf[i] = i;
    sort(sf,sf+n,[](int i, int j) {
        return fract[sq[i]]<fract[sq[j]];
    });
    int ans = 0;
    int bestI = -1;
    ld minEndPrice = 1e18;
    RE(i,n) {
        int j = sq[sf[i]];
        ld f = fract[j];
        addSUMQ(sf[i],q[j]);
        addCNT (sf[i],1);
        int lb=0, ub=n;
        while(lb != ub) {
            int mid=(lb+ub+1)/2;
            ld tot = getSUMQ(mid-1);
            if(tot*f <= ld(w)) lb=mid;
            else ub=mid-1;
        }
        int res = getCNT(lb-1);
        ld endPrice = getSUMQ(lb-1)*f;
        if(res > ans || (res == ans && endPrice <= minEndPrice)) {
            ans = res;
            bestI = i;
            minEndPrice = endPrice;
        }
    }
    RE(i,MX) SUMQ[i] = CNT[i] = 0;
    used.reset();
    RE(i,n) {
        int j = sq[sf[i]];
        ld f = fract[j];
        addSUMQ(sf[i],q[j]);
        addCNT (sf[i],1);
        used[sf[i]] = 1;
        if(i == bestI) {
            int lb=0, ub=n;
            while(lb != ub) {
                int mid=(lb+ub+1)/2;
                ld tot = getSUMQ(mid-1);
                if(tot*f <= ld(w)) lb=mid;
                else ub=mid-1;
            }
            int res = getCNT(lb-1);
            ld endPrice = getSUMQ(lb-1)*f;
            vi v;
            RE(i,lb) if(used[i]) v.pb(sq[i]+1);
            sort(all(v));
            OUTL(res);
            FOR(u,v) OUTL(u);
        }
    }
}
Compilation message (stderr)
hiring.cpp: In function 'void program()':
hiring.cpp:155:16: warning: unused variable 'endPrice' [-Wunused-variable]
  155 |             ld endPrice = getSUMQ(lb-1)*f;
      |                ^~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |