stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <stdio.h>

#include <vector>

#include <queue>

#include <string>

#include <cmath>

#include <map>

#include <string.h>

#define ll long long



using namespace std;



const int MAXN = 2000;



int row, col, q;

char area[MAXN + 5][MAXN + 5];

int pref[5][MAXN + 5][MAXN + 5];



int main(){

	

	cin >> row >> col >> q;

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

		for(int j = 1; j <= col; j ++){

			cin >> area[i][j];

		}

	}

	for(int k = 1; k <= 3; k ++){

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

			for(int j = 1; j <= col; j ++){

				pref[k][i][j] = pref[k][i - 1][j] 

					+ pref[k][i][j - 1] - pref[k][i - 1][j - 1];

				if(k == 1)pref[k][i][j] += (area[i][j] - '0');

				else if(k == 2){

					if(area[i][j - 1] == '1' && area[i][j] == '1')

						pref[k][i][j] += 1;

				}else{

					if(area[i - 1][j] == '1' && area[i][j] == '1')

						pref[k][i][j] += 1;

				}

			}

		}

	}

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

		int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;

		int ans = 0;

		for(int j = 1; j <= 3; j ++){

			int cur = 0;

			if(j == 1) cur = pref[j][r2][c2] - pref[j][r1 - 1][c2] - 

						pref[j][r2][c1 - 1] + pref[j][r1 - 1][c1 - 1];

			if(j == 2) cur = pref[j][r2][c2] - pref[j][r1 - 1][c2] - 

						pref[j][r2][c1] + pref[j][r1 - 1][c1];

			if(j == 3) cur = pref[j][r2][c2] - pref[j][r1][c2] -

						pref[j][r2][c1 - 1] + pref[j][r1][c1 - 1];

			// cout << j <<" "<< cur << endl;

			if(j == 1)ans += cur;

			else ans -= cur;

		}

		cout << ans << endl;

	}



	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

const int MAXN=2005;



int N,M,Q;

bool grid[MAXN][MAXN];



int V[MAXN][MAXN],E1[MAXN][MAXN],E2[MAXN][MAXN];



int main()

{

	scanf("%d%d%d",&N,&M,&Q);

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

		for(int j=1,x;j<=M;j++)

		{

			scanf("%1d",&x);

			grid[i][j]=x;

		}

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

		for(int j=1;j<=M;j++)

			V[i][j]=V[i-1][j]+V[i][j-1]-V[i-1][j-1]+grid[i][j];

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

		for(int j=1;j<=M;j++)

			E1[i][j]=E1[i-1][j]+E1[i][j-1]-E1[i-1][j-1]+(grid[i][j]&&grid[i][j-1]);

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

		for(int j=1;j<=M;j++)

			E2[i][j]=E2[i-1][j]+E2[i][j-1]-E2[i-1][j-1]+(grid[i][j]&&grid[i-1][j]);

	

	while(Q--)

	{

		int x1,y1,x2,y2;

		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);

		printf("%d\n",

		(V[x2][y2]-V[x2][y1-1]-V[x1-1][y2]+V[x1-1][y1-1])

		-(E1[x2][y2]-E1[x2][y1]-E1[x1-1][y2]+E1[x1-1][y1])

		-(E2[x2][y2]-E2[x2][y1-1]-E2[x1][y2]+E2[x1][y1-1]));

	}

	

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <queue>

using namespace std;



typedef long long LL;



int main() {

    LL A, B, C;

    cin >> A >> B >> C;

    LL ans1 = 0;

    if (A%2 != 0) {

        ans1 = B*C;

    }

    LL ans2 = 0;

    if (C%2 != 0) {

        ans2 = B*A;

    }

    LL ans3 = 0;

    if (B%2 != 0) {

        ans3 = A*C;

    }

    LL ans = min(ans1,ans2);

    ans = min(ans, ans3);

    cout << ans << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

#define ll long long



int main(){

	ll a, b, c;

	scanf("%lld%lld%lld", &a, &b ,&c);

	if(a >= b && a >= c){

		if(a % 2) printf("%lld\n", b * c);

		else printf("0\n");

	}else if(b >= a && b >= c){

		if(b % 2) printf("%lld\n", a * c);

		else printf("0\n");

	}else if(c >= a && c >= b){

		if(c % 2) printf("%lld\n", a * b);

		else printf("0\n");

	}

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

	long long a, b, c;

	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)

		cout << 0 << endl;

	else

		cout << min(min(a*b, b*c), a*c) << endl;

	//system("Pause");

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

#define ll long long



int main(){

	ll a, b, c;

	scanf("%lld%lld%lld", &a, &b ,&c);

	if(a >= b && a >= c){

		if(a % 2) printf("%lld\n", b * c);

		else printf("0\n");

	}else if(b >= a && b >= c){

		if(b % 2) printf("%lld\n", a * c);

		else printf("0\n");

	}else if(c >= a && c >= b){

		if(c % 2) printf("%lld\n", a * b);

		else printf("0\n");

	}

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

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



int main(){

  int N;

  cin >> N;

  vector<int> a(N);

  rep(i,N){

    cin >> a[i];

  }



  int count = 0;

  bool flag = true;

    

  while(flag == true){

    rep(i,N){

    	if(a[i]%2 == 0){

      		a[i] = a[i]/2;

        }

      	else {

          flag = false;

          break ;

        }

    }

    if(flag == false) break;

    count++;

  }

  

  cout << count << endl;

  

  return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

using namespace std;



int N, A[200];



int main()

{

	int dmin = 100;

	scanf("%d", &N);

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

		int A;

		scanf("%d", &A);

		int d = 0;

		while (A % 2 == 0) {

			A /= 2;

			++d;

		}

		dmin = min(dmin, d);

	}

	printf("%d\n", dmin);

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main(){

  int n;  cin >> n;

  int ans = 1<<30;

  while(n--){

    int a;  cin >> a;

    int cnt = 0;

    while(a % 2 == 0){

      a >>= 1;

      cnt++;

    }

    ans = min(ans, cnt);

  }



  cout << ans << endl;



  return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#define min(x, y) ((x)<(y) ? (x) : (y))

int main(){

  int n;  scanf("%d", &n);

	int ans = 1<<30;

  while(n--){

    int a;  scanf("%d", &a);

    int count = 0;

    while(a % 2 == 0){

      count++;

      a >>= 1;

    }

    ans = min(ans, count);

  }

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

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

#include <vector>

#include <cstdlib>

using namespace std;







int main() {

    int N;

    cin >> N;

    vector<int> vec(N);

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

      int val;

      cin >> val;

      vec[i] = val;

    }



    int ans = 0;



    while (true) {

        bool odd = false;

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

            if (vec[i] % 2 != 0) odd = true;

        }



        if (odd) break;



        for (int i = 0; i < N; ++i) {vec[i] /= 2;}

        ++ans;

    }

    cout << ans << "\n";

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

using namespace std;



int main() {

    int N;

    scanf("%d\n", &N);

    int A[N];

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

      scanf("%d\n", &A[i]);

    }

 

    int ans = 0;

    while (true) {

        bool odd = false;

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

            if (A[i] % 2) odd = true;

        }

        if (odd) break;

        for (int i = 0; i < N; ++i) {A[i] /= 2;}

        ++ans;

    }

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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";

}


// Optimized solution to the same problem (faster):
#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";

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

    ll answer;

    while(l<=r)

    {

        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)answer=mid,r=mid-1;

        else l=mid+1;

    }

    cout<<answer<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

#define ll long long

using namespace std;

const ll inf=1e18+10;

ll n,k,ans,a[200005];

ll find1(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;

}

ll 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 cnt=0;   //找比 x 小的积 

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

		if(a[i]>=0) cnt+=find1(i,x)-i;

		else cnt+=n-find2(i,x)+1;

	}

	return cnt>=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;

	while(l<=r){

		ll mid=l+r>>1;

		if(check(mid)){

			ans=mid;

			r=mid-1;

		}

		else l=mid+1;

	}

	printf("%lld",ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

using namespace std;

typedef long long ll;

ll N,K;

ll arr[1000010];

 

bool judge(ll x){

    ll cnt = 0;

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

        if(arr[i]>=0){

            ll l = i+1,r = N,mid;

            if(arr[i]*arr[l]>=x) continue;//二分中无解的情况

            while(l<r){

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

                if(arr[i]*arr[mid] < x) l = mid;

                else r = mid-1;

            }

            cnt += l-i;

        }else{ //和负数乘会变号，情况和上面相反

            ll l = i+1,r = N,mid;

            if(arr[i]*arr[N] >= x) continue;//二分中无解的情况

            if(arr[i]*arr[l]<x){//特殊情况

                cnt += N-l+1;

                continue;

            }

            while(l<r){

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

                if(arr[i]*arr[mid] >= x) l = mid;

                else r = mid-1;

            }

            cnt += N-l;

        }

    }

    return cnt < K;

}

 

int main(){

    cin>>N>>K;

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

    sort(arr+1,arr+N+1);

    ll l = -1e18-10,r = 1e18+10,mid;

    while(l<r){

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

        if(judge(mid)) l = mid;

        else r = mid-1;

    }

    cout<<l<<endl;

    return 0;



}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

#define ll long long

using namespace std;

const ll inf=1e18+10;

ll n,k,ans,a[200005];

ll find1(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;

}

ll 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 cnt=0;   //找比 x 小的积 

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

		if(a[i]>=0) cnt+=find1(i,x)-i;

		else cnt+=n-find2(i,x)+1;

	}

	return cnt>=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;

	while(l<=r){

		ll mid=l+r>>1;

		if(check(mid)){

			ans=mid;

			r=mid-1;

		}

		else l=mid+1;

	}

	printf("%lld",ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

//#include<bits/stdc++.h>

#include<cstring>

#include<vector>

#include<string>

#include<stack>

#include<queue>

#include<cmath>

#include<cstdio>

#include<vector>

#include<set>

#include<map>

#include<algorithm>

using namespace std;

typedef long long ll;





const ll mod = 1e9;



vector<ll> q,p;



bool ok(ll x,ll n,ll k)

{

    ll ans = 0;

    sort(q.begin(),q.end(),greater<ll>());

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

    int s1 = q.size(),s2 = p.size();

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

    {

        int l = i,r = s1-1;

        while(l < r)

        {

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

            if(q[i]*q[mid] <= x) l = mid;

            else r = mid - 1;

        }

        if(l > i) ans += l -i ;

    }

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

    {

        int l = i,r = s2 - 1;

        while(l < r)

        {

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

            if(p[i]*p[mid] <= x) l = mid;

            else r = mid - 1;

        }

        if(l > i) ans += l - i ;

    }

    if(ans >= k) return 1;

    reverse(q.begin(),q.end());

    reverse(p.begin(),p.end());

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

    {

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

        while(l < r)

        {

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

            if(q[i] * p[mid] <=  x) l = mid;

            else r = mid - 1;

        }

        if(l != -1) ans += l + 1;

    }

    return ans >= k;





}

int main()

{

    ll n,k,a;

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



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

    {

        scanf("%lld",&a);

        if(a<0) q.push_back(a);

        else  p.push_back(a);

    }

    ll l = - mod * mod ,r = mod *mod;

    while(l < r)

    {

        ll mid = l + r >>1;

        if(ok(mid,n,k)) r = mid;

        else l = mid + 1;

    }

    cout << r;

}








// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

#define ll long long

using namespace std;

const ll inf=1e18+10;

ll n,k,ans,a[200005];

ll find1(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;

}

ll 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 cnt=0;   //找比 x 小的积 

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

		if(a[i]>=0) cnt+=find1(i,x)-i;

		else cnt+=n-find2(i,x)+1;

	}

	return cnt>=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;

	while(l<=r){

		ll mid=l+r>>1;

		if(check(mid)){

			ans=mid;

			r=mid-1;

		}

		else l=mid+1;

	}

	printf("%lld",ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

//#include<bits/stdc++.h>

#include<cstring>

#include<vector>

#include<string>

#include<stack>

#include<queue>

#include<cmath>

#include<cstdio>

#include<vector>

#include<set>

#include<map>

#include<algorithm>

using namespace std;

typedef long long ll;





const ll mod = 1e9;



vector<ll> q,p;



bool ok(ll x,ll n,ll k)

{

    ll ans = 0;

    sort(q.begin(),q.end(),greater<ll>());

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

    int s1 = q.size(),s2 = p.size();

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

    {

        int l = i,r = s1-1;

        while(l < r)

        {

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

            if(q[i]*q[mid] <= x) l = mid;

            else r = mid - 1;

        }

        if(l > i) ans += l -i ;

    }

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

    {

        int l = i,r = s2 - 1;

        while(l < r)

        {

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

            if(p[i]*p[mid] <= x) l = mid;

            else r = mid - 1;

        }

        if(l > i) ans += l - i ;

    }

    if(ans >= k) return 1;

   // reverse(q.begin(),q.end());

    reverse(p.begin(),p.end());

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

    {

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

        while(l < r)

        {

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

            if(q[i] * p[mid] <=  x) l = mid;

            else r = mid - 1;

        }

        if(l != -1) ans += l + 1;

    }

    return ans >= k;





}

int main()

{

    ll n,k,a;

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



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

    {

        scanf("%lld",&a);

        if(a<0) q.push_back(a);

        else  p.push_back(a);

    }

    ll l = - mod * mod ,r = mod *mod;

    while(l < r)

    {

        ll mid = l + r >>1;

        if(ok(mid,n,k)) r = mid;

        else l = mid + 1;

    }

    cout << r;

}








// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>

#define ll long long

using namespace std;

const ll inf=1e18+10;

ll n,k,ans,a[200005];

ll find1(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;

}

ll 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 cnt=0;   //找比 x 小的积 

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

		if(a[i]>=0) cnt+=find1(i,x)-i;

		else cnt+=n-find2(i,x)+1;

	}

	return cnt>=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;

	while(l<=r){

		ll mid=l+r>>1;

		if(check(mid)){

			ans=mid;

			r=mid-1;

		}

		else l=mid+1;

	}

	printf("%lld",ans);

	return 0;

}

// Fastest known solution for this problem: