Link to this code:
https://cses.fi/paste/eea715c7a1a4c5a026d9e4//*
author: @ankingcodes
created: 2021-07-15 13:45:44.426881
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define mod 1000000007
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> pbds;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> pairpbds;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, k; cin>>n>>k;
vector<pair<ll, ll>> a;
for (int i=0;i<n;i++) {
ll x; cin >> x;
a.push_back({ x, i });
}
sort(begin(a), end(a));
int l=0, r=n-1;
bool flag = false;
while(l < r) {
ll sum = a[l].first + a[r].first;
if (sum == k) {
flag = true;
break;
} else if (sum < k) l++;
else r--;
}
if (flag) cout << a[l].second+1 << " " << a[r].second+1 << endl;
else cout << "IMPOSSIBLE";
return 0;
}