Language: C++

#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main() {
  int64_t n, k, a, b, c, xm, x0, ans, tmp;
  cin >> n >> k;
  vector<int64_t> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  xm = lower_bound(v.begin(), v.end(), 0);
  x0 = upper_bound(v.begin(), v.end(), 0);
  a = xm*(xm-1)/2;
  c = (n-x0)*(n-x0-1)/2;
  b = n*(n-1)/2 - a - c;
  if(k > a + b){
    tmp = 72057594037927936;
    rep(i, 56){
      int64_t l = 0
      rep(j, n) l += upper_bound(v.begin(), v.end(), tmp/v[j]);
      if(k > l) tmp += pow(2, 55-i);
      else tmp -= pow(2, 55-i);
    }
    rep(j, n) k -= upper_bound(v.begin(), v.end(), tmp/v[j]);
    if(k > 0) ++tmp;
    ans = tmp;
  }
  else if(k > a) ans = 0;
  else{
    tmp = -72057594037927936;
    rep(i, 56){
      int64_t l = 0
      rep(j, n) l += upper_bound(v.begin(), v.end(), tmp/v[j]);
      if(k > l) tmp += pow(2, 55-i);
      else tmp -= pow(2, 55-i);
    }
    rep(j, n) k -= upper_bound(v.begin(), v.end(), tmp/v[j]);
    if(k > 0) ++tmp;
    ans = tmp;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:19: error: cannot convert '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' to 'int64_t' {aka 'long int'} in assignment
   13 |   xm = lower_bound(v.begin(), v.end(), 0);
      |        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      |                   |
      |                   __gnu_cxx::__normal_iterator<long int*, std::vector<long int> >
a.cc:14:19: error: cannot convert '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' to 'int64_t' {aka 'long int'} in assignment
   14 |   x0 = upper_bound(v.begin(), v.end(), 0);
      |        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      |                   |
      |                   __gnu_cxx::__normal_iterator<long int*, std::vector<long int> >
a.cc:4:19: error: expected ',' or ';' before 'for'
    4 | #define rep(i, n) for(int i = 0; i < n; ++i)
      |                   ^~~
a.cc:22:7: note: in expansion of macro 'rep'
   22 |       rep(j, n) l += upper_bound(v.begin(), v.end(), tmp/v[j]);
      |       ^~~
a.cc:22:11: error: 'j' was not declared in this scope
   22 |       rep(j, n) l += upper_bound(v.begin(), v.end(), tmp/v[j]);
      |           ^
a.cc:4:34: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(int i = 0; i < n; ++i)
      |                                  ^
a.cc:26:17: error: no match for 'operator-=' (operand types are 'int64_t' {aka 'long int'} and '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >')
   26 |     rep(j, n) k -= upper_bound(v.begin(), v.end(), tmp/v[j]);
      |               ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:19: error: expected ',' or ';' before 'for'
    4 | #define rep(i, n) for(int i = 0; i < n; ++i)
      |                   ^~~
a.cc:35:7: note: in expansion of macro 'rep'
   35 |       rep(j, n) l += upper_bound(v.begin(), v.end(), tmp/v[j]);
      |       ^~~
a.cc:35:11: error: 'j' was not declared in this scope
   35 |       rep(j, n) l += upper_bound(v.begin(), v.end(), tmp/v[j]);
      |           ^
a.cc:4:34: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(int i = 0; i < n; ++i)
      |                                  ^
a.cc:39:17: error: no match for 'operator-=' (operand types are 'int64_t' {aka 'long int'} and '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >')
   39 |     rep(j, n) k -= upper_bound(v.begin(), v.end(), tmp/v[j]);
      |               ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~