Language: C++

#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}


int main(){
    ll n,k;
    cin >> n>>k;
    ll a[n];
    ll ans;
    vector<ll> A,B,C;
    int kk=0;
    rep(i,n){
        cin >> a[i];
        A.push_back(a[i]);
        if(a[i]<0){
            kk++;
            B.push_back(-a[i]);
        }else{
            C.push_back(a[i]);
        }
    }
    sort(A.begin(),A.end());//全部
    sort(B.begin(),B.end());//負
    sort(C.begin(),C.end());//正
    kk=kk*(n-kk);
    if(k>kk){
        k=k-kk;
        ll l=0,r=1000000000000000007;
        while(r-l>1){
            ll q=(l+r)/2;
            ll temp=0;
            rep(i,n){
                ll p=q/a[i];
                else{
                    temp+=upper_bound(A.begin(),A.end(),p)-A.begin();
                }
            }
            if(temp<k){
                l=q;
            }else{
                r=q;
            }
        }
        if(r-l==1){
            ll temp=0;
            rep(i,n){
                ll p=l/A[i];
                if(A[i]==0){
                    temp=A.size();
                }else{
                    temp+=upper_bound(A.begin(),A.end(),p)-A.begin();
                }
            }
            if(temp==k){
                r=l;
            }else{
                l=r;
            }
        }
        ans=(l+r)/2;
    }else{
        k=kk-k;
        ll l=0,r=1000000000000000007;
        while(r-l>1){
            ll q=(l+r)/2;
            ll temp=0;
            rep(i,B.size()){
                ll p=q/B[i];
                if(B[i]==0){
                    temp+=C.size();
                }else{
                    temp+=upper_bound(C.begin(),C.end(),p)-C.begin();
                }
            }
            if(temp<k){
                l=q;
            }else{
                r=q;
            }
        }
        if(r-l==1){
            ll temp=0;
            rep(i,B.size()){
                ll p=l/B[i];
                if(B[i]==0){
                    temp+=C.size();
                }else{
                    temp+=upper_bound(C.begin(),C.end(),p)-C.begin();
                }
            }
            if(temp==k){
                r=l;
            }else{
                l=r;
            }
        }
        ans=-(l+r)/2;
    }
    cout<<ans<<endl;
    //while()
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:86:17: error: 'else' without a previous 'if'
   86 |                 else{
      |                 ^~~~