Problem:
Score: 400 points

Problem Statement

We have N integers A_1, A_2, ..., A_N.

There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Constraints

All values in input are integers.

2 \leq N \leq 2 \times 10^5

1 \leq K \leq \frac{N(N-1)}{2}

-10^9 \leq A_i \leq 10^9\ (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the answer.

Sample Input 1

4 3
3 3 -4 -2

Sample Output 1

-6

There are six ways to form a pair. The products of those pairs are 9, -12, -6, -12, -6, 8.

Sorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The third number in this list is -6.

Sample Input 2

10 40
5 4 3 2 -1 0 0 0 0 0

Sample Output 2

6

Sample Input 3

30 413
-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0

Sample Output 3

448283280358331064

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k;
main() {
    file("threesum");
    ios;
    cin >> n >> k;

    vi v;
    int zr = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x) v.eb(x);
        else ++zr;
    }

    n = v.size();
    sort(all(v));

    int l = -INF2, r = INF2;

    auto f = [&](int x) {
        int cnt = 0;
        if (0 < x) cnt += n * zr * 2 + zr * (zr - 1);
        for (int i = 0; i < n; ++i) {
            if (v[i] > 0) {
                if (v[0] * v[i] >= x) continue;
                int L = 0, R = n - 1;
                while (L <= R) {
                    int mid = (L + ((R - L) >> 1));
                    if (v[i] * v[mid] < x) L = mid + 1;
                    else R = mid - 1;
                }
                --L;
                int y = L;
                if (i <= L) --L;
                cnt += L + 1;

            } else {
                if (v[i] * v[n - 1] >= x) continue;
                int L = 0, R = n - 1;
                while (L <= R) {
                    int mid = (L + ((R - L) >> 1));
                    if (v[i] * v[mid] < x) R = mid - 1;
                    else L = mid + 1;
                }
                ++R;
                R = n - R;
                if (v[i] * v[i] < x) --R;
                cnt += R;
            }
        }
        cnt>>=1;
        return cnt;
    };

    while (l <= r) if (f(md) >= k) r = md - 1; else l = md + 1;

    cout<<l-1;
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**
10 40
5 4 3 2 -1 0 0 0 0 0

-4 -2 3 3

-12 -12 -6 -6


*/