Language: C++

#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
#define fl(i,a,n) for(int i=a;i<=n;i++)
#define pb push_back
#define pob pop_back
#define int long long int
#define ff first
#define ss second
#define pi 3.1415926535898
#define vi vector<int>
#define mi map<int,int>
#define umi unordered_map<int,int>
#define endl "\n"
#define w(x) int x; cin>>x; while(x--)
#define db(x) cout<<(#x)<<" "<<(x)<<"\n";
#define ios ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
//using namespace boost::multiprecision;
int mod=1000000007;
int gcd(int a,int b){
	return (b == 0) ? a :gcd(b, a % b);
}
int lcm(int a,int b){
	return (a*b)/gcd(a,b);
}
//void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
}
int paircount(vi v,int prod){
	int ans=0;
	for(int i=1;i<v.size();i++){
		int l,r;
		r=i-1;
		l=0;
		if(v[i]>0){
			if(v[i]*v[l]>prod){
				continue;
			}
			if(v[i]*v[r]<=prod){
				ans+=i;
				//db(r);db(i);
				continue;
			}
			int s=0,e=i-1;
			int mid;
			while(s<=e){
				mid=(s+e)/2;
				if(v[i]*v[mid]<=prod){
					s=mid+1;
				}
				else{
					e=mid-1;
				}
				//db(s);db(e);
			}
			//db(mid);db(i);
			ans+=s;
		}
		else if(v[i]<0){
			if(v[i]*v[r]>prod){
				continue;
			}
			if(v[i]*v[l]<=prod){
				ans+=i;
				//db(r);db(i);
				continue;
			}
			int s=0,e=i-1;
			int mid;
			while(s<=e){
				mid=(s+e)/2;
				if(v[i]*v[mid]<=prod){
					e=mid-1;
				}
				else{
					s=mid+1;
				}

			}
			//db(mid);db(i);
			ans+=e;
		}
		else{
			if(prod>=0){
				ans+=i;
			}
		}
		//db(ans);
	}
	return ans;
}
int32_t main(){

	ios
	c_p_c();
	//w(t)
	{
		int n,k;cin>>n>>k;
		vi v(n);
		fl(i,0,n-1){
			cin>>v[i];
		}
		sort(v.begin(),v.end());
		int s=-1e18,e=1e18;
		int mid=0;
		int ans=0;
		while(s<=e){
			mid=(s+e)/2;
			int temp=paircount(v,mid);
			//db(mid);db(temp);
			if(temp==k){
				ans=mid;
			}
			if(temp<k){
				s=mid+1;
			}
			else{
				e=mid-1;
			}

		}
		cout<<s<<endl;
		//cout<<paircount(v,0);
	}

	return 0;
} 


Compiler output:
a.cc:27:34: error: expected constructor, destructor, or type conversion before '(' token
   27 |         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |                                  ^
a.cc:27:39: error: 'cin' does not name a type
   27 |         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |                                       ^~~
a.cc:27:51: error: 'cout' does not name a type
   27 |         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      |                                                   ^~~~
a.cc:29:16: error: expected constructor, destructor, or type conversion before '(' token
   29 |         freopen("input.txt", "r", stdin);
      |                ^
a.cc:30:16: error: expected constructor, destructor, or type conversion before '(' token
   30 |         freopen("output.txt", "w", stdout);
      |                ^
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
a.cc: In function 'int32_t main()':
a.cc:99:9: error: 'c_p_c' was not declared in this scope
   99 |         c_p_c();
      |         ^~~~~