Link to this code: https://cses.fi/paste/191a74d3535857ca30e397/
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;

const int N = 2e5 + 5;

int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
	cin >> n >> x;

	pair<int, int> a[N];
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}

	sort(a, a + n);
	
	int l = 0, r = n - 1, 
		sum = a[l].first + a[r].first;
	
	while (l < r) {
		if (sum == x) {
			cout << a[l].second << ' ' << a[r].second << '\n';
			return 0;
		}
		else if (sum > x) {
			sum -= a[r].first;
			r--;
			sum += a[r].first;
		}
		else {
			sum -= a[l].first;
			l++;
			sum += a[l].first;
		}
	}

	cout << "IMPOSSIBLE";
}