Language: C++

#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

ll calc2(ll n,ll k,std::vector<ll> a){

  using namespace std;
   	const ll INF = (ll)(1e18)+100;
    sort(a.begin(), a.end());
    ll count[3] = {0};  //0:- 1:0 2:+   負、0、正それぞれの個数
    rep(i, 0,n){
        if(a[i] < 0)    count[0]++;
        else if(a[i] > 0)   count[2]++;
        else            count[1]++;
    }
    ll cdic[3] = {0};  //0:-  1:0  2:+ となるペアの個数、累積をとる
    cdic[0] = count[0]*count[2];
    cdic[1] = cdic[0] + count[1]*(count[0]+count[1]+count[2]) - count[1]*(count[1]+1)/2;
    cdic[2] = cdic[1] + count[0]*(count[0]-1)/2 + count[2]*(count[2]-1)/2;
    ll ans = 0;
    if(k <= cdic[0]){
        //ansが負
        vector<ll>pos;
        vector<ll>neg;
        rep(i, 0,n){
            if(a[i] < 0)        neg.push_back(a[i]);
            else if(a[i] > 0)   pos.push_back(a[i]);
        }
        ll ok = -INF, ng = 0;
        while(ok + 1 < ng){
            ll x = (ok+ng)/2;   //x未満がk未満
            ll ck = 0;
            rep(i, 0,pos.size()){ //正を固定して負を二分探索
                ll ok2 = -1, ng2 = neg.size();
                while(ok2 + 1 < ng2){
                    ll t = (ok2+ng2)/2;
                    if(pos[i]*neg[t] < x)   ok2 = t;
                    else                    ng2 = t;
                }
                ck += ng2;
            }
            if(ck < k)  ok = x;
            else        ng = x;
        }
        ans = ok;
    }else if(k <= cdic[1]){
        //ansが0
    }else{
        //ansが正
        k -= cdic[1];
        vector<ll>pos;
        vector<ll>neg;
        rep(i,0,n){
            if(a[i] < 0)        neg.push_back(a[i]);
            else if(a[i] > 0)   pos.push_back(a[i]);
        }
        rep(i,0, neg.size())  neg[i] = 0 - neg[i];
        sort(neg.begin(), neg.end());
        ll ok = 0, ng = INF;
        while(ok + 1 < ng){
            ll x = (ok+ng)/2;   //x未満がk未満
            ll ck = 0;
            //pos
            rep(i, 0,pos.size()){
                ll ok2 = -1, ng2 = pos.size();
                while(ok2 + 1 < ng2){
                    ll t = (ok2+ng2)/2;
                    if(pos[i]*pos[t] < x)   ok2 = t;
                    else                    ng2 = t;
                }
                ck += ng2;
                if(pos[i]*pos[i] < x)   ck--;
            }
            //neg
            rep(i, 0,neg.size()){
                ll ok2 = -1, ng2 = neg.size();
                while(ok2 + 1 < ng2){
                    ll t = (ok2+ng2)/2;
                    if(neg[i]*neg[t] < x)   ok2 = t;
                    else                    ng2 = t;
                }
                ck += ng2;
                if(neg[i]*neg[i] < x)    ck--;
            }
            if(ck/2 < k)  ok = x;
            else        ng = x;
        }
        ans = ok;
    }
    return ans;
}

int main(){
	ll n,k;
    std::cin>>n>>k;
    std::vector<ll> a(n);
    rep(i,0,n)std::cin>>a[i];
    
    std::cout<<calc2(n,k,a)<<"\n";
}

Compiler output:
a.cc:40:1: error: 'll' does not name a type; did you mean 'all'?
   40 | ll calc2(ll n,ll k,std::vector<ll> a){
      | ^~
      | all
a.cc: In function 'int main()':
a.cc:129:9: error: 'll' was not declared in this scope; did you mean 'all'?
  129 |         ll n,k;
      |         ^~
      |         all
a.cc:130:15: error: 'n' was not declared in this scope; did you mean 'yn'?
  130 |     std::cin>>n>>k;
      |               ^
      |               yn
a.cc:130:18: error: 'k' was not declared in this scope
  130 |     std::cin>>n>>k;
      |                  ^
a.cc:131:19: error: template argument 2 is invalid
  131 |     std::vector<ll> a(n);
      |                   ^
a.cc:132:26: error: invalid types 'int[long long int]' for array subscript
  132 |     rep(i,0,n)std::cin>>a[i];
      |                          ^
a.cc:134:16: error: 'calc2' was not declared in this scope
  134 |     std::cout<<calc2(n,k,a)<<"\n";
      |                ^~~~~