Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
using namespace std;
const int maxn = 200005;
typedef long long ll;
ll a[maxn]={0};
int n;
ll find1(ll m){
    ll ret=0;
    ll num=0;
    long double f = 1.0;
    for(int i=0;i<n;i++){
        if(a[i]<0){// m>a[i]*a[j]
                   // a[j]>=m/a[i];
            num=lower_bound(a,a+n,f*m/a[i])-a;
            num=n-num;
        }
        else if(a[i]==0){
            if(m>=0)
                num=n;
            else
                num=0;
        }
        else{
                //m>=a[i]*a[j]
                //a[j]=<m/a[i]
            num=upper_bound(a,a+n,f*m/a[i])-a;
        }
        ret+=num;
        if(a[i]*a[i]<=m)
            ret--;
        //cout << num << endl;
    }
    //cout << ret/2 << endl;
    return ret/2;
}
ll find2(ll m){
    ll ret=0;
    ll num=0;
    long double f = 1.0;
    for(int i=0;i<n;i++){
        if(a[i]<0){// m<=a[i]*a[j]
                   // a[j]<=m/a[i];
            num=upper_bound(a,a+n,f*m/a[i])-a;
        }
        else if(a[i]==0){
            if(m<=0)
                num=n;
            else
                num=0;
        }
        else{
                //m=<a[i]*a[j]
                //a[j]>=m/a[i]
            num=lower_bound(a,a+n,f*m/a[i])-a;
            num=n-num;
        }
        ret+=num;
        if(a[i]*a[i]>=m)
            ret--;
    }
    return ret/2;
}
unordered_map<ll,int>mm;
int check(ll ans){
    for(int i=0;i<n;i++){
        if(a[i]!=0&&ans%a[i]==0){
                if(mm[ans/a[i]])
            return 1;
        }
    }
    return 0;
}
void pp(ll a){
    cout << find1(a)<<endl;
    cout << find2(a)<<endl;
}
int main()
{
    ll k;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >>a[i];
        mm[a[i]]++;
    }
    vector<ll>dd;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            dd.push_back(a[i]*a[j]);
        }
    }
    sort(dd.begin(),dd.end());
    sort(a,a+n);
    ll l = -1e18,r=1e18;
    ll m = (l+r)/2;
    ll ans = 0 ;
    find1(0);
    ll ans1,ans2;
    while(l<r){
        ans1=find1(m);
        ans2=find2(m);
        //cout << ans1 << " " << ans2 << endl;
        //cout << l << " " << r <<endl;
        if(ans1>=k&&ans2>=(1ll*n*(n-1)/2-k+1)){
            ans = m ;
            break;
        }
        else if(ans1>=k){
            r=m+1;
        }
        else
            l=m;
        m=(l+r)/2;
        //cout << l <<  " " << r << endl;
    }
    cout << ans << endl;
    //pp(ans);
    //cout <<dd[k-1]<<" "<<dd[k]<<" "<<dd[k+1]<<endl;
    //cout << l << endl;
    //cout << r <<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:88:5: error: 'vector' was not declared in this scope
   88 |     vector<ll>dd;
      |     ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include <unordered_map>
  +++ |+#include <vector>
    5 | using namespace std;
a.cc:88:14: error: expected primary-expression before '>' token
   88 |     vector<ll>dd;
      |              ^
a.cc:88:15: error: 'dd' was not declared in this scope
   88 |     vector<ll>dd;
      |               ^~