Language: C++

#include<bits/stdc++.h>
 namespace std;
typedef long long ll;
#deine rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(obj) (obj).begin(),(obj).end()

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,l,r,zero=0;
    cin>>n>>k;
    vector<ll> a,b;
    rep(i,n){
      ll j;
      cin>>j;
      if(j>0) a.push_back(j);
      else if(j<0){
        b.push_back(j);
      }
      else zero++;
    }
    sort(all(a));
    sort(all(b));
    int t=a.size()*b.size();
    int tmp=zero*(zero-1)/2;
    tmp+=zero*(a.size()+b.size());
    int ia=a.size()-1;
    int ib=b.size()-1;
    if(k<t){
      l=2*a.at(ia)*b.at(0);
      r=0;
      while(l+1<r){
        int tot=0;
        ll mid=(l+r)/2;
        for(int i=a.size()-1;i>=0;i--){
          if(a.at(i)*b.at(0)<mid){
            tot+=b.size();
            continue;
          }
          for(int j=b.size()-1;j>=0;j--){
              if(a.at(i)*b.at(j)<mid)tot++;
              else{
                break;
              }
          }
        }
        if(tot<k)l=mid;
        else{
          r=mid;
        }
      }
    }

    else if((t+tmp)>k){
      cout<<0<<endl;
      return 0;
    }

    else{
      k=k-t-tmp;
      l=0;
      if(a.size()!=0)r=2*a.at(ia)*a.at(ia);
      if(b.size()!=0)r=max(r,2*b.at(0)*b.at(0));

      while(l+1<r){
        int tot=0;
        ll mid=(l+r)/2;
        for(int i=0;i<a.size()-1;i++){
          int k=lower_bound(a.begin()+i+1,a.end(),mid/a.at(i))-a.begin();
          tot=tot+k-i-1;
        }
        for(int i=b.size()-1;i>0;i--){
          if(b.at(i)*b.at(0)<mid){
            tot+=i;
            continue;
          }
          for(int j=i-1;j>=0;j--){
              if(b.at(i)*b.at(j)<mid)tot++;
              else{
                break;
              }
          }
        }
        if(tot<k)l=mid;
        else{
          r=mid;
        }
      }
    }
    cout<<l<<endl;
    return 0;


Compiler output:
a.cc:4:2: error: invalid preprocessing directive #deine; did you mean #define?
    4 | #deine rep(i,n) for(ll i=0;i<(ll)(n);i++)
      |  ^~~~~
      |  define
a.cc:2:15: error: expected '{' before ';' token
    2 |  namespace std;
      |               ^
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |     cin.tie(0);
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:9:5: error: 'ios' has not been declared
    9 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:12:5: error: 'vector' was not declared in this scope
   12 |     vector<ll> a,b;
      |     ^~~~~~
a.cc:12:5: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:12:14: error: expected primary-expression before '>' token
   12 |     vector<ll> a,b;
      |              ^
a.cc:12:16: error: 'a' was not declared in this scope
   12 |     vector<ll> a,b;
      |                ^
a.cc:12:18: error: 'b' was not declared in this scope
   12 |     vector<ll> a,b;
      |                  ^
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     rep(i,n){
      |         ^
a.cc:13:5: error: 'rep' was not declared in this scope
   13 |     rep(i,n){
      |     ^~~
a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   22 |     sort(all(a));
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:55:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   55 |       cout<<0<<endl;
      |       ^~~~
      |       std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:55:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   55 |       cout<<0<<endl;
      |                ^~~~
      |                std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:63:24: error: 'max' was not declared in this scope; did you mean 'std::max'?
   63 |       if(b.size()!=0)r=max(r,2*b.at(0)*b.at(0));
      |                        ^~~
      |                        std::max
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:69:17: error: 'lower_bound' was not declared in this scope; did you mean 'std::lower_bound'?
   69 |           int k=lower_bound(a.begin()+i+1,a.end(),mid/a.at(i))-a.begin();
      |                 ^~~~~~~~~~~
      |                 std::lower_bound
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: 'std::lower_bound' declared here
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
a.cc:90:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   90 |     cout<<l<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:90:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   90 |     cout<<l<<endl;
      |              ^~~~
      |              std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:91:14: error: expected '}' at end of input
   91 |     return 0;
      |              ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^