stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define ull unsigned long long

#define mp make_pair

typedef pair<int,int> pii;

ll a[200009];

ll n;ll k;

int main()

{

    scanf("%d%lld",&n,&k);

    for(int i=0;i<n;i++)scanf("%lld",&a[i]);

    sort(a,a+n);

    ll l=-1e18,r=1e18;

    while(r-l>1)

    {

        ll mid=(l+r)/2;ll cnt=0;

        for(int i=0;i<n;i++)

        {

            if(a[i]>0){

                cnt+=upper_bound(a,a+n,(long double)mid/a[i])-a;

            }

            else if(a[i]<0){

                cnt+=n-(lower_bound(a,a+n,(long double)mid/a[i])-a);

            }

            else if(mid>=0)cnt+=n;

            if(a[i]*a[i]<=mid)cnt--;

        }

        if(cnt>=k*2)r=mid;

        else l=mid;

    }

    cout<<r<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.11114328071915x):
#include<iostream>

#include<algorithm>

using namespace std;

long long a[200005],n,k,ans,po[200005],o,ne[200005],e;

bool check(long long val){

    long long res=0;

    for(int i=1;i<=o;i++){

        long long l=i,r=o,mid,fin=i;

        while(l<=r){

            mid=(l+r)>>1;

            if(po[i]*po[mid]<val){

                fin=mid;

                l=mid+1;

            }else r=mid-1;

        }

        res+=fin-i;

    }

    for(int i=1;i<=e;i++){

        long long l=i,r=e,mid,fin=i;

        while(l<=r){

            mid=(l+r)>>1;

            if(ne[i]*ne[mid]<val){

                fin=mid;

                l=mid+1;

            }else r=mid-1;

        }

        res+=fin-i;

    }

    return res<=k-1;

}

bool checkx(long long val){

    long long res=0;

    for(int i=1;i<=e;i++){

        long long l=1,r=o,mid,fin=o+1;

        while(l<=r){

            mid=(l+r)>>1;

            if(ne[i]*po[mid]>val){

                fin=mid;

                r=mid-1;

            }else l=mid+1;

        }

        // cout<<fin<<" ";

        res+=o+1-fin;

    }

    // if(val==5)

        // cout<<res<<"Snoop\n";

    return res<=k-1;

}//也就是越大的反而越小。

int main(){

    cin>>n>>k;

    for(int i=1;i<=n;i++){

        cin>>a[i];

        if(a[i]>0)

            po[++o]=a[i];

        else ne[++e]=-a[i];

    }

    sort(po+1,po+o+1);

    po[0]=po[o+1]=1e8;

    sort(ne+1,ne+e+1);

    ne[0]=ne[e+1]=1e8;

    if(o*e>=k){

        long long l=0,r=1e18,mid;

        while(l<=r){

            mid=(l+r)>>1;

            // cout<<mid<<"SnoopDogg\n";

            if(checkx(mid)){//个数小于等于k-1（大于

                r=mid-1;

                ans=mid;

            }else l=mid+1;

        }

        cout<<-ans<<'\n';

    }else {

        k-=o*e;

        long long l=0,r=1e18,mid;

        while(l<=r){

            mid=(l+r)>>1;

            if(check(mid)){//个数小于或等于k-1（小于

                l=mid+1;

                ans=mid;

            }else r=mid-1;

        }

        cout<<ans<<'\n';

    }

}

/*

也就是它会有(n-1)*n/2个乘积，要找到第K小的那一个。

首先要把负数和正数分开。

我有了！二分结果。

然后枚举每一个点，二分找到使结果小于该结果的最大标号。

然后要是等于k-1，那么就对了。

答案就是每个行的最大标号的下一个取min。

先写一个正数的吧。

去掉了负数那一块居然只少了一个点……

分析一下，当答案是非正数的时候，现在我把0分到负数那一块去，

对于负数数组内的i，求正数数组内最小的使两者乘积大于规定的值

*/
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define ull unsigned long long

#define mp make_pair

typedef pair<int,int> pii;

ll a[200009];

ll n;ll k;

int main()

{

    scanf("%d%lld",&n,&k);

    for(int i=0;i<n;i++)scanf("%lld",&a[i]);

    sort(a,a+n);

    ll l=-1e18,r=1e18;

    while(r-l>1)

    {

        ll mid=(l+r)/2;ll cnt=0;

        for(int i=0;i<n;i++)

        {

            if(a[i]>0){

                cnt+=upper_bound(a,a+n,(long double)mid/a[i])-a;

            }

            else if(a[i]<0){

                cnt+=n-(lower_bound(a,a+n,(long double)mid/a[i])-a);

            }

            else if(mid>=0)cnt+=n;

            if(a[i]*a[i]<=mid)cnt--;

        }

        if(cnt>=k*2)r=mid;

        else l=mid;

    }

    cout<<r<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1256966867120097x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N=200001;

const ll inf=(ll)1e18;

ll n,a[N],k,num=0;



int Find(int now,ll x)

{

	int l=now+1,r=n,best=now;

	while(l<=r)

	{

		int mid=(l+r)>>1;

		if(a[now]*a[mid]<=x) l=mid+1,best=mid;

		else r=mid-1;

	}

	return best;

}



int Find2(int now,ll x)

{

	int l=now+1,r=n,best=n+1;

	while(l<=r)

	{

		int mid=(l+r)>>1;

		if(a[now]*a[mid]<=x) r=mid-1,best=mid;

		else l=mid+1;

	}

	return best;

}



bool check(ll x)

{

	ll ret=0;

	for(int i=1;i<n;i++)

	{

		if(a[i]>=0) ret+=Find(i,x)-i;

		else ret+=n-Find2(i,x)+1;

	}

	return ret>=k;

}



int main()

{

	scanf("%lld%lld",&n,&k);

	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);

	sort(a+1,a+n+1);

	ll l=-inf,r=inf,ans=-1;

	while(l<=r)

	{

		ll mid=(l+r)>>1;

		if(check(mid)) r=mid-1,ans=mid;

		else l=mid+1;

	}

	cout<<ans<<endl;

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define ull unsigned long long

#define mp make_pair

typedef pair<int,int> pii;

ll a[200009];

ll n;ll k;

int main()

{

    scanf("%d%lld",&n,&k);

    for(int i=0;i<n;i++)scanf("%lld",&a[i]);

    sort(a,a+n);

    ll l=-1e18,r=1e18;

    while(r-l>1)

    {

        ll mid=(l+r)/2;ll cnt=0;

        for(int i=0;i<n;i++)

        {

            if(a[i]>0){

                cnt+=upper_bound(a,a+n,(long double)mid/a[i])-a;

            }

            else if(a[i]<0){

                cnt+=n-(lower_bound(a,a+n,(long double)mid/a[i])-a);

            }

            else if(mid>=0)cnt+=n;

            if(a[i]*a[i]<=mid)cnt--;

        }

        if(cnt>=k*2)r=mid;

        else l=mid;

    }

    cout<<r<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.108600963790711x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

ll n,k;

ll a[200005];

ll l=-1e18-5,r=1e18+5,mid,ans;

int main()

{

//	freopen("data1.in","r",stdin);

//	freopen("jindian.out","w",stdout);

	cin>>n>>k;

	for(int i=1;i<=n;++i)

	{

		cin>>a[i];

	}

	sort(a+1,a+1+n);

//	for(int i=1;i<=n;++i)

//  {

//      printf("%lld ",a[i]);

//  }

//  printf("\n");

	while(l<=r)

	{

		mid=(l+r)>>1;

		ll cnt=0;

//		printf("%lld\n",mid);

		for(int i=1;i<n;++i)

		{

			int li=i+1,ri=n,midi,tmp=0;

			while(li<=ri)

			{

				midi=(li+ri)>>1;

				if(a[i]*a[midi]<=mid)

				{

					if(a[i]>0)

					li=midi+1;

					else

					ri=midi-1;

					tmp=midi;

				}

				else

				{

					if(a[i]>0)

					ri=midi-1;

					else

					li=midi+1;

				}

			}

//			printf("%lld %lld\n",a[i],a[tmp]);

			if(tmp==0)

			continue;

			if(a[i]>0)

			cnt+=tmp-i;

			else

			cnt+=n-tmp+1;

		}

//		printf("%d\n",cnt);

		if(cnt>=k)

		{

			r=mid-1;

			ans=mid;

		}

		else

		{

			l=mid+1;

		}

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define ull unsigned long long

#define mp make_pair

typedef pair<int,int> pii;

ll a[200009];

ll n;ll k;

int main()

{

    scanf("%d%lld",&n,&k);

    for(int i=0;i<n;i++)scanf("%lld",&a[i]);

    sort(a,a+n);

    ll l=-1e18,r=1e18;

    while(r-l>1)

    {

        ll mid=(l+r)/2;ll cnt=0;

        for(int i=0;i<n;i++)

        {

            if(a[i]>0){

                cnt+=upper_bound(a,a+n,(long double)mid/a[i])-a;

            }

            else if(a[i]<0){

                cnt+=n-(lower_bound(a,a+n,(long double)mid/a[i])-a);

            }

            else if(mid>=0)cnt+=n;

            if(a[i]*a[i]<=mid)cnt--;

        }

        if(cnt>=k*2)r=mid;

        else l=mid;

    }

    cout<<r<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.0998533572557943x):
#include<bits/stdc++.h>

using namespace std;

typedef long long LL; 



int n;

LL k;

LL a[200005];



int find(LL v, int l)

{

	int r=n, mid, ol=l;

	if (v < a[l]) return 0;

	while (l < r)

	{

		mid=(l+r+1)>>1;

		if (a[mid] <= v) l = mid;

		else r = mid-1; 

	}

	return l-ol+1;

}



LL fl(LL a, LL b)

{

	int sgn = 1;

	if (a < 0) sgn *= -1;

	if (b < 0) sgn *= -1;

	if (sgn >= 0) return abs(a)/abs(b);

	else return -abs(a)/abs(b)-1;

}



LL cl(LL a, LL b)

{

	if (a % b == 0) return a/b;

	return fl(a, b)+1;

}



LL second(LL mid)

{

	LL ret=0;

	// a[i]*a[j] <= mid

    for(int i=1;i<n;++i)

    {

    	if (a[i]==0)

    	{

    		if (mid >= 0) ret += n-i; 

		}

		else if (a[i] > 0)

		{

			//a[j] <= mid/a[i]

			ret += find(fl(mid, a[i]), i+1);

		}

		else 

		{

			// a[j] >= mid/a[i]

			ret += n-i-find(cl(mid, a[i])-1, i+1);

		}

	}

	return ret;

}

LL first()

{

	LL l=-1e18, r=1e18, mid;

	while( l < r )

	{

		mid=l+(r-l)/2;

		LL c = second(mid);

		if (c < k) l = mid+1; 

		else r = mid;

	}

	return l;

}

int main()

{

    scanf("%d%lld", &n, &k);

    for(int i=1;i<=n;++i)

        scanf("%lld", &a[i]);

    sort(a+1,a+1+n);

    cout << first() << endl;

    //cout << second(110610286983069417) << endl;

    //cout << second(448283280358331064) << endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main() {

  long N, K;

  cin >> N >> K;

  vector<long> A(N);

  for (int i = 0; i < N; i++) cin >> A.at(i);

  sort(A.begin(), A.end());

  long L = -2e18, R = 2e18;

  while (R - L > 1) {

    long M = (L + R) / 2, sum = 0;

    for (int i = 0; i < N; i++) {

      if (A.at(i) < 0) sum += N - (upper_bound(A.begin(), A.end(), (long double)M / A.at(i)) - A.begin());

      if (A.at(i) > 0) sum += lower_bound(A.begin(), A.end(), (long double)M / A.at(i)) - A.begin();

      if (A.at(i) == 0) sum += (M > 0) ? N : 0;

      if (A.at(i) * A.at(i) < M) sum--;

    }

    (sum / 2 < K) ? L = M : R = M;

  }

  cout << L << "\n";

}


// Faster C++ solution for the same problem (measured speedup: 1.1008203527813025x):
#include <bits/stdc++.h>

using namespace std;



int main() {

  long N, K;

  cin >> N >> K;

  vector<long> A(N);

  for (auto &a : A) cin >> a;

  sort(A.begin(), A.end());



  long L = -2e18, R = 2e18;

  while (R - L > 1) {

    long M = (L + R) / 2, cnt = 0;

    for (int i = 0; i < N; i++) {

      if (A.at(i) >= 0) {

        int l = i, r = N;

        while (r - l > 1) {

          int m = (l + r) / 2;

          (A.at(i) * A.at(m) < M) ? l = m : r = m;

        }

        cnt += l - i;

      } else {

        int l = i, r = N;

        while (r - l > 1) {

          int m = (l + r) / 2;

          (A.at(i) * A.at(m) < M) ? r = m : l = m;

        }

        cnt += N - r;

      }

    }

    (cnt < K) ? L = M : R = M;

  }

  cout << L << "\n";

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



#define int long long

int lb=-2e18,ub=2e18;



signed main() {

    int n,k,a[200000];

    cin>>n>>k;

    for(int i=0;i<n;i++) cin>>a[i];

    sort(a,a+n);



    while(ub-lb>1){

        int mid=(ub+lb)/2,cnt=0;

        for(int i=0;i<n;i++){

            if(a[i]<0)

            	cnt+=min(n-(lower_bound(a,a+n,(long double)mid/a[i])-a),n-i);

            else if(a[i]>0)

            	cnt+=upper_bound(a+i,a+n,(long double)mid/a[i])-(a+i);

            else if(mid>=0)

            	cnt+=n-i;

			if(a[i]*a[i]<=mid) cnt--;

        }

        (cnt>=k?ub:lb)=mid;

    }

    cout<<ub<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1494720471894149x):
#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N=2*1e5+100;

int n,f,z,k,a[N],b[N],w,zero;

bool check(int mid)

{

	int cnt=0;

	if (mid==0)

	  cnt+=z*f+zero;

	if (mid<0)

	{

		for (int i=1;i<=f;i++)

		{

			int aim=(mid%a[i]==0)?mid/a[i]:(mid/a[i]+1);

			int pos=lower_bound(b+1,b+1+z,aim)-b;

			cnt+=z-pos+1;

		}

	}

	if (mid>0)

	{

		

		for (int i=1;i<=f;i++)

		{

			if (-a[i]>mid) continue;

			a[i]=-a[i];

			int aim=mid/a[i];

			aim=-aim;

			a[i]=-a[i];

			int pos=lower_bound(a+1,a+1+f,aim)-a;

			cnt+=f-pos+1;

			if (i>=pos) cnt--;

		}

		for (int i=1;i<=z;i++)

		{

			if (b[i]>mid) continue;

			int aim=mid/b[i];

			int pos=upper_bound(b+1,b+1+z,aim)-b;

			cnt+=pos-1;

			if (i<=pos-1) cnt--;

		}

		cnt/=2;

		cnt+=z*f+zero;

	}

	return cnt>=k;

}

signed main()

{

	scanf("%lld%lld",&n,&k);

	for (int i=1;i<=n;i++)

	{

		int num;

		scanf("%lld",&num);

		if (num<0) a[++f]=num;

		if (num>0) b[++z]=num;

		if (num==0) zero++;

	}

	zero=zero*(zero-1)/2+zero*(f+z);

	sort(a+1,a+1+f);

	sort(b+1,b+1+z);

	int l=-1e18,r=1e18;

	while (l<r)

	{

		int mid=(l+r)>>1;

		if (check(mid)) r=mid;

		else l=mid+1;

	}

	printf("%lld\n",r);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



#define int long long

int lb=-2e18,ub=2e18;



signed main() {

    int n,k,a[200000];

    cin>>n>>k;

    for(int i=0;i<n;i++) cin>>a[i];

    sort(a,a+n);



    while(ub-lb>1){

        int mid=(ub+lb)/2,cnt=0;

        for(int i=0;i<n;i++){

            if(a[i]<0)

            	cnt+=min(n-(lower_bound(a,a+n,(long double)mid/a[i])-a),n-i);

            else if(a[i]>0)

            	cnt+=upper_bound(a+i,a+n,(long double)mid/a[i])-(a+i);

            else if(mid>=0)

            	cnt+=n-i;

			if(a[i]*a[i]<=mid) cnt--;

        }

        (cnt>=k?ub:lb)=mid;

    }

    cout<<ub<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1482180281746834x):
#include <iostream>

#include <cstdio>

#include <algorithm>

using namespace std;

typedef long long ll;

typedef double db;

const int N = 200010;

ll a[N],b[N],k,x,s; // a b=-a

int n;

int les(ll* arr,int L,int R,ll y) {

    int M,B=-1;

    while(L<=R) {

        M=(L+R)>>1;

        if(arr[M]<y) B=M,L=M+1;

        else R=M-1;

    }

    return B;

}

int lar(ll *arr,int L,int R,ll y) {

    int M,B=-1;

    while(L<=R) {

        M=(L+R)>>1;

        if(arr[M]>y) B=M,R=M-1;

        else L=M+1;

    }

    return B;

}

ll ceild(ll a,ll b){

    if(a%b==0) return a/b;

    return a/b+1;

}

ll floord(ll a,ll b){

    if(a%b==0||a>0&&b>0||a<0&&b<0) return a/b; 

    return a/b-1;

    // return (ll)ceil((db)a/(db)b);

}

int check(ll val) {

    ll ls=0,lr=0,eq;

    int tmp;

    // cout<<ls<<" "<<lr<<endl;

    for(int i=1;i<=n;i++) {

        // printf("a[%d]=%lld\n",i,a[i]);

        if(a[i]>0){

            tmp=les(a,i+1,n,ceild(val,a[i]));

            if(tmp!=-1) ls+=(ll)(tmp-i);

            // printf("+less tmp : %d ls:%d\n",tmp,ls);

            tmp=lar(a,i+1,n,floord(val,a[i]));

            if(tmp!=-1) lr+=(ll)(n-tmp+1);

            // printf("+large tmp : %d lr:%d\n",tmp,lr);

        }

        else if(a[i]<0){

            tmp=lar(a,i+1,n,floord(val,a[i]));

            if(tmp!=-1) ls+=(ll)(n-tmp+1);

            // printf("-less tmp : %d ls:%d\n",tmp,ls);

            tmp=les(a,i+1,n,ceild(val,a[i]));

            if(tmp!=-1) lr+=(ll)(tmp-i);

            // printf("-large tmp : %d lr:%d\n",tmp,lr);

        }

        else {

            if(val>0)ls+=(ll)(n-i);

            if(val<0)lr+=(ll)(n-i);

        }

    }

    eq=s-lr;

    // cout<<ls<<" _ "<<eq<<" _ "<<lr<<endl;

    if(k<=ls) return 1;// less

    if(k<=eq) return 2;// eq

    return 3;//large

}

int main() {

    scanf("%d%lld",&n,&k);

    s=(n-1ll)*n/2ll;

    for(int i=1;i<=n;i++) {

        scanf("%lld",&x);

        a[i]=x;

    }

    sort(a+1,a+n+1);

    ll L=-1e18,R=1e18,M,ans;

    while(L<=R) {

        M=(L+R)>>1;

        int d=check(M);

        // cout<<L<<" "<<R<<" "<<M<<" "<<d<<endl;

        if(d==2) {ans=M;break;}

        else if(d==1) R=M-1;

        else L=M+1,ans=M;

        // system("pause");

    }

    printf("%lld\n",ans);

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



#define int long long

int lb=-2e18,ub=2e18;



signed main() {

    int n,k,a[200000];

    cin>>n>>k;

    for(int i=0;i<n;i++) cin>>a[i];

    sort(a,a+n);



    while(ub-lb>1){

        int mid=(ub+lb)/2,cnt=0;

        for(int i=0;i<n;i++){

            if(a[i]<0)

            	cnt+=min(n-(lower_bound(a,a+n,(long double)mid/a[i])-a),n-i);

            else if(a[i]>0)

            	cnt+=upper_bound(a+i,a+n,(long double)mid/a[i])-(a+i);

            else if(mid>=0)

            	cnt+=n-i;

			if(a[i]*a[i]<=mid) cnt--;

        }

        (cnt>=k?ub:lb)=mid;

    }

    cout<<ub<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1147413722378365x):
#include <bits/stdc++.h>

using namespace std;



#define sz(x) int(x.size())

#define pii pair<int, int>

#define All(x) (x).begin(), (x).end()

#define mp make_pair

#define Task "abc"



typedef long long ll;

const int maxn = 2e5 + 10;

const ll mod = 1e9 + 7;



ll a[maxn];

int n;

ll k;



bool ok(ll mid){

  ll cnt = 0;

  for (int i = 1; i < n; ++i){

    if (a[i] == 0){

      if (mid >= 0) cnt += n - i;

      continue;

    }

    ll d = mid / a[i];

    if (a[i] > 0){

      if (abs(mid) % a[i] != 0){

        if ( (d == 0 && mid < 0) || d < 0) --d;

      }

      int pos = upper_bound(a + i + 1, a + n + 1, d) - a;

      --pos;

      cnt += pos - i;

    } else {

      if (abs(mid) % abs(a[i]) != 0){

        if ((d == 0 && mid < 0) || d > 0) d++;

      }

      int pos = lower_bound(a + i + 1, a + n + 1, d) - a;

      cnt += n - pos + 1;

    }

  }

  return cnt >= k;

}



int main(){

  ios_base::sync_with_stdio(0); cin.tie(NULL);

//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);

  cin >> n >> k;

  for (int i = 1; i <= n; ++i) cin >> a[i];

  sort(a + 1, a + n + 1);

  ll inf = 1e18;

  ll l = -inf, r = inf;

  while (l <= r){

    ll mid = (l + r) / 2;

    if (ok(mid)) r = mid - 1;

    else l = mid + 1;

  }

  cout << r + 1;

return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



#define int long long

int lb=-2e18,ub=2e18;



signed main() {

    int n,k,a[200000];

    cin>>n>>k;

    for(int i=0;i<n;i++) cin>>a[i];

    sort(a,a+n);



    while(ub-lb>1){

        int mid=(ub+lb)/2,cnt=0;

        for(int i=0;i<n;i++){

            if(a[i]<0)

            	cnt+=min(n-(lower_bound(a,a+n,(long double)mid/a[i])-a),n-i);

            else if(a[i]>0)

            	cnt+=upper_bound(a+i,a+n,(long double)mid/a[i])-(a+i);

            else if(mid>=0)

            	cnt+=n-i;

			if(a[i]*a[i]<=mid) cnt--;

        }

        (cnt>=k?ub:lb)=mid;

    }

    cout<<ub<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1323857153438939x):
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;



vector<ll> pos, neg, zero;





ll count_below(ll x){

    ll ans = 0, p = pos.size(), n = neg.size(), z = zero.size();



    if(x == 0){

        return p*n;

    }

    else if(x < 0){

        x = -x;

        for(ll y : pos){

            ans += n - (upper_bound(neg.begin(), neg.end(), x/y) - neg.begin());

        }



        return ans;

    }

    else{

        ans += p*n + z * (p+n) + z * (z-1)/2;





        for(int i = 1; i<p ; i++){

            ans += upper_bound(pos.begin(), pos.begin()+i, (x-1)/pos[i]) - pos.begin();

        }



        for(int i = 1; i<n ; i++){

            ans += upper_bound(neg.begin(), neg.begin()+i, (x-1)/neg[i]) - neg.begin();

        }



        return ans;

    }

}



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0); cout.tie(0);



    int n;

    ll k;

    cin>>n>>k;

    k--;



    for(int i = 0; i<n; i++){

        ll x;

        cin>>x;

        if(x == 0) zero.push_back(x);

        if(x > 0) pos.push_back(x);

        if(x < 0) neg.push_back(-x);

    }



    sort(pos.begin(), pos.end());

    sort(neg.begin(), neg.end());



    ll lo = -1e18, hi = 1e18;



    while(lo <= hi){

        ll mid = (lo + hi) / 2;



        if(count_below(mid) <= k)

            lo = mid + 1;

        else

            hi = mid - 1;

    }



    cout<<hi<<endl;



    return 0;

}

///
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define rep(i,N) for(int i=0;i<(int64_t)N;i++)

typedef int64_t LL;

int main()

{

  int NG,OK,BASE;

  LL N,K,M,L=numeric_limits<LL>::min()/3,R=LLONG_MAX/3,count;

  bool minus;

  cin>>N>>K;

  vector<LL> A(N,0);

  rep(i,N)cin>>A.at(i);

  sort(A.begin(),A.end());

  while(R-L>1)

  {

    M=(L+R)/2,count=0;

    rep(i,N)

    {

      NG=i,OK=N;

      minus=(A.at(i)<0)?true:false;

      while(OK-NG>1)

      {

        BASE=(NG+OK)/2;

        if(A.at(i)*A.at(BASE)<=M)(minus)?OK=BASE:NG=BASE;

        else(minus)?NG=BASE:OK=BASE;

      }

      count+=(minus)?N-OK:NG-i;

    }

    (count<K)?L=M:R=M;

  }

  cout<<R<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 4.845223342007062x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<limits.h>

typedef long long LL;

#define rep(i,N) for(int i=0;i<(LL)N;i++)

int compare(const LL*a,const LL*b){if(*a<*b)return -1;else if(*a==*b)return 0;else return 1;}

signed main(void)

{

  int NG,OK,BASE,minus;

  LL N,K,L=-pow(16,16)/16,M,R=LLONG_MAX/3,count;

  count=scanf("%lld %lld",&N,&K);

  LL A[N];

  rep(i,N)count=scanf("%lld",&A[i]);

  qsort(A,N,sizeof(LL),(int(*)(const void*,const void*))compare);

  while(R-L>1)

  {

    M=(L+R)/2,count=0;

    rep(i,N)

    {

      NG=i,OK=N,minus=(A[i]<0);

      while(OK-NG>1)

      {

        BASE=(NG+OK)/2;

        if(A[i]*A[BASE]<=M){if(minus)OK=BASE;else NG=BASE;}

        else{if(minus)NG=BASE;else OK=BASE;}

      }

      count+=(minus)?N-OK:NG-i;

    }

    if(count<K)L=M;else R=M;

  }

  return printf("%lld\n",R),0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define rep(i,N) for(int i=0;i<(long long)N;i++)

typedef int64_t LL;

int main()

{

  int NG,OK,BASE;

  LL N,K,L=-pow(16,16)/16,M,R=LLONG_MAX/3,count;

  bool minus;

  cin>>N>>K;

  vector<LL> A(N,0);

  rep(i,N)cin>>A.at(i);

  sort(A.begin(),A.end());

  while(R-L>1)

  {

    M=(L+R)/2,count=0;

    rep(i,N)

    {

      NG=i,OK=N;

      minus=(A.at(i)<0)?true:false;

      while(OK-NG>1)

      {

        BASE=(NG+OK)/2;

        if(A.at(i)*A.at(BASE)<=M)(minus)?OK=BASE:NG=BASE;

        else(minus)?NG=BASE:OK=BASE;

      }

      count+=(minus)?N-OK:NG-i;

    }

    (count<K)?L=M:R=M;

  }

  cout<<R<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 4.843926924672087x):
#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<limits.h>

typedef long long LL;

#define rep(i,N) for(int i=0;i<(LL)N;i++)

int compare(const LL*a,const LL*b){if(*a<*b)return -1;else if(*a==*b)return 0;else return 1;}

signed main(void)

{

  int NG,OK,BASE,minus;

  LL N,K,L=-pow(16,16)/16,M,R=LLONG_MAX/3,count;

  count=scanf("%lld %lld",&N,&K);

  LL A[N];

  rep(i,N)count=scanf("%lld",&A[i]);

  qsort(A,N,sizeof(LL),(int(*)(const void*,const void*))compare);

  while(R-L>1)

  {

    M=(L+R)/2,count=0;

    rep(i,N)

    {

      NG=i,OK=N,minus=(A[i]<0);

      while(OK-NG>1)

      {

        BASE=(NG+OK)/2;

        if(A[i]*A[BASE]<=M){if(minus)OK=BASE;else NG=BASE;}

        else{if(minus)NG=BASE;else OK=BASE;}

      }

      count+=(minus)?N-OK:NG-i;

    }

    if(count<K)L=M;else R=M;

  }

  return printf("%lld\n",R),0;

}