Language: C++

#include<cstdio>
#include<cassert>
#include<iostream>
#include<algorithm>
#include<vector>
#define pb push_back
using namespace std;
typedef __int64 LL;
const int N=2e5+5;
const LL INF=1e18;
vector<LL>pos,neg;
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		if(a>0)pos.pb(a);
		else if(a<0)neg.pb(a);
	}
	sort(pos.begin(),pos.end());
	sort(neg.begin(),neg.end());
	int ne=neg.size()*pos.size();
	int po=pos.size()*(pos.size()-1)/2+neg.size()*(neg.size()-1)/2;
	int ze=n*(n-1)/2-ne-po;
	if(k<=ne)
	{
		LL l=-INF,r=0,ans;
		while(l<=r)
		{
			LL mid=(l+r)/2,num=0;
			for(int i=0;i<neg.size();i++)
			{
				LL t=mid%neg[i]?mid/neg[i]+1:mid/neg[i];
				int x=lower_bound(pos.begin(),pos.end(),t)-pos.begin();
				num+=pos.size()-x;
			}
			if(num<k)l=mid+1;
			else r=mid-1,ans=mid;
		}
		cout<<ans;
	}
	else if(k<=ne+ze)puts("0");
	else
	{
		LL l=0,r=INF,ans;
		while(l<=r)
		{
			LL mid=(l+r)/2,num=0;
			for(int i=0;i<pos.size();i++)
			{
				if(pos[i]*pos[i]<=mid)num--;
				LL t=mid/pos[i];
				int x=lower_bound(pos.begin(),pos.end(),t+1)-pos.begin();
				if(x)assert(pos[x-1]*pos[i]<=mid);
				//cout<<pos[x]<<" "<<pos[i]<<" "<<pos[x]*pos[i]<<endl;
				if(x<pos.size())assert(pos[x]*pos[i]>mid);
				num+=x;
			}
			for(int i=0;i<neg.size();i++)
			{
				if(neg[i]*neg[i]<=mid)num--;
				LL t=mid/neg[i];
				int x=lower_bound(neg.begin(),neg.end(),t)-neg.begin();
				assert(neg[x]*neg[i]<=mid);
				if(x)assert(neg[x-1]*neg[i]>mid);
				num+=neg.size()-x;
			}
			assert(num%2==0);
			num=num/2+ze+ne;
		//	cout<<mid<<" "<<num<<endl;
			if(num<k)l=mid+1;
			else r=mid-1,ans=mid;
		}
		cout<<ans;
	}
	return 0;
}


Compiler output:
a.cc:8:9: error: '__int64' does not name a type; did you mean '__int64_t'?
    8 | typedef __int64 LL;
      |         ^~~~~~~
      |         __int64_t
a.cc:10:7: error: 'LL' does not name a type
   10 | const LL INF=1e18;
      |       ^~
a.cc:11:8: error: 'LL' was not declared in this scope
   11 | vector<LL>pos,neg;
      |        ^~
a.cc:11:10: error: template argument 1 is invalid
   11 | vector<LL>pos,neg;
      |          ^
a.cc:11:10: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:6:12: error: request for member 'push_back' in 'pos', which is of non-class type 'int'
    6 | #define pb push_back
      |            ^~~~~~~~~
a.cc:20:28: note: in expansion of macro 'pb'
   20 |                 if(a>0)pos.pb(a);
      |                            ^~
a.cc:6:12: error: request for member 'push_back' in 'neg', which is of non-class type 'int'
    6 | #define pb push_back
      |            ^~~~~~~~~
a.cc:21:33: note: in expansion of macro 'pb'
   21 |                 else if(a<0)neg.pb(a);
      |                                 ^~
a.cc:23:18: error: request for member 'begin' in 'pos', which is of non-class type 'int'
   23 |         sort(pos.begin(),pos.end());
      |                  ^~~~~
a.cc:23:30: error: request for member 'end' in 'pos', which is of non-class type 'int'
   23 |         sort(pos.begin(),pos.end());
      |                              ^~~
a.cc:24:18: error: request for member 'begin' in 'neg', which is of non-class type 'int'
   24 |         sort(neg.begin(),neg.end());
      |                  ^~~~~
a.cc:24:30: error: request for member 'end' in 'neg', which is of non-class type 'int'
   24 |         sort(neg.begin(),neg.end());
      |                              ^~~
a.cc:25:20: error: request for member 'size' in 'neg', which is of non-class type 'int'
   25 |         int ne=neg.size()*pos.size();
      |                    ^~~~
a.cc:25:31: error: request for member 'size' in 'pos', which is of non-class type 'int'
   25 |         int ne=neg.size()*pos.size();
      |                               ^~~~
a.cc:26:20: error: request for member 'size' in 'pos', which is of non-class type 'int'
   26 |         int po=pos.size()*(pos.size()-1)/2+neg.size()*(neg.size()-1)/2;
      |                    ^~~~
a.cc:26:32: error: request for member 'size' in 'pos', which is of non-class type 'int'
   26 |         int po=pos.size()*(pos.size()-1)/2+neg.size()*(neg.size()-1)/2;
      |                                ^~~~
a.cc:26:48: error: request for member 'size' in 'neg', which is of non-class type 'int'
   26 |         int po=pos.size()*(pos.size()-1)/2+neg.size()*(neg.size()-1)/2;
      |                                                ^~~~
a.cc:26:60: error: request for member 'size' in 'neg', which is of non-class type 'int'
   26 |         int po=pos.size()*(pos.size()-1)/2+neg.size()*(neg.size()-1)/2;
      |                                                            ^~~~
a.cc:30:17: error: 'LL' was not declared in this scope
   30 |                 LL l=-INF,r=0,ans;
      |                 ^~
a.cc:31:23: error: 'l' was not declared in this scope
   31 |                 while(l<=r)
      |                       ^
a.cc:31:26: error: 'r' was not declared in this scope
   31 |                 while(l<=r)
      |                          ^
a.cc:33:27: error: expected ';' before 'mid'
   33 |                         LL mid=(l+r)/2,num=0;
      |                           ^~~~
      |                           ;
a.cc:34:43: error: request for member 'size' in 'neg', which is of non-class type 'int'
   34 |                         for(int i=0;i<neg.size();i++)
      |                                           ^~~~
a.cc:36:35: error: expected ';' before 't'
   36 |                                 LL t=mid%neg[i]?mid/neg[i]+1:mid/neg[i];
      |                                   ^~
      |                                   ;
a.cc:37:55: error: request for member 'begin' in 'pos', which is of non-class type 'int'
   37 |                                 int x=lower_bound(pos.begin(),pos.end(),t)-pos.begin();
      |                                                       ^~~~~
a.cc:37:67: error: request for member 'end' in 'pos', which is of non-class type 'int'
   37 |                                 int x=lower_bound(pos.begin(),pos.end(),t)-pos.begin();
      |                                                                   ^~~
a.cc:37:73: error: 't' was not declared in this scope
   37 |                                 int x=lower_bound(pos.begin(),pos.end(),t)-pos.begin();
      |                                                                         ^
a.cc:37:80: error: request for member 'begin' in 'pos', which is of non-class type 'int'
   37 |                                 int x=lower_bound(pos.begin(),pos.end(),t)-pos.begin();
      |                                                                                ^~~~~
a.cc:38:33: error: 'num' was not declared in this scope; did you mean 'enum'?
   38 |                                 num+=pos.size()-x;
      |                                 ^~~
      |                                 enum
a.cc:38:42: error: request for member 'size' in 'pos', which is of non-class type 'int'
   38 |                                 num+=pos.size()-x;
      |                                          ^~~~
a.cc:40:28: error: 'num' was not declared in this scope; did you mean 'enum'?
   40 |                         if(num<k)l=mid+1;
      |                            ^~~
      |                            enum
a.cc:40:36: error: 'mid' was not declared in this scope
   40 |                         if(num<k)l=mid+1;
      |                                    ^~~
a.cc:41:32: error: 'mid' was not declared in this scope
   41 |                         else r=mid-1,ans=mid;
      |                                ^~~
a.cc:41:38: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |                         else r=mid-1,ans=mid;
      |                                      ^~~
      |                                      abs
a.cc:43:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |                 cout<<ans;
      |                       ^~~
      |                       abs
a.cc:48:17: error: 'LL' was not declared in this scope
   48 |                 LL l=0,r=INF,ans;
      |                 ^~
a.cc:49:23: error: 'l' was not declared in this scope
   49 |                 while(l<=r)
      |                       ^
a.cc:49:26: error: 'r' was not declared in this scope
   49 |                 while(l<=r)
      |                          ^
a.cc:51:27: error: expected ';' before 'mid'
   51 |                         LL mid=(l+r)/2,num=0;
      |                           ^~~~
      |                           ;
a.cc:52:43: error: request for member 'size' in 'pos', which is of non-class type 'int'
   52 |                         for(int i=0;i<pos.size();i++)
      |                                           ^~~~
a.cc:54:39: error: invalid types 'int[int]' for array subscript
   54 |                                 if(pos[i]*pos[i]<=mid)num--;
      |                                       ^
a.cc:54:46: error: invalid types 'int[int]' for array subscript
   54 |                                 if(pos[i]*pos[i]<=mid)num--;
      |                                              ^
a.cc:54:51: error: 'mid' was not declared in this scope
   54 |                                 if(pos[i]*pos[i]<=mid)num--;
      |                                                   ^~~
a.cc:54:55: error: 'num' was not declared in this scope; did you mean 'enum'?
   54 |                                 if(pos[i]*pos[i]<=mid)num--;
      |                                                       ^~~
      |                                                       enum
a.cc:55:35: error: expected ';' before 't'
   55 |                                 LL t=mid/pos[i];
      |                                   ^~
      |                                   ;
a.cc:56:55: error: request for member 'begin' in 'pos', which is of non-class type 'int'
   56 |                                 int x=lower_bound(pos.begin(),pos.end(),t+1)-pos.begin();
      |                                                       ^~~~~
a.cc:56:67: error: request for member 'end' in 'pos', which is of non-class type 'int'
   56 |                                 int x=lower_bound(pos.begin(),pos.end(),t+1)-pos.begin();
      |                                                                   ^~~
a.cc:56:73: error: 't' was not declared in this scope
   56 |                                 int x=lower_bound(pos.begin(),pos.end(),t+1)-pos.begin();
      |                                                                         ^
a.cc:56:82: error: request for member 'begin' in 'pos', which is of non-class type 'int'
   56 |                                 int x=lower_bound(pos.begin(),pos.end(),t+1)-pos.begin();
      |                                                                                  ^~~~~
In file included from /usr/include/c++/14/cassert:44,
                 from a.cc:2:
a.cc:57:48: error: invalid types 'int[int]' for array subscript
   57 |                                 if(x)assert(pos[x-1]*pos[i]<=mid);
      |                                                ^
a.cc:57:57: error: invalid types 'int[int]' for array subscript
   57 |                                 if(x)assert(pos[x-1]*pos[i]<=mid);
      |                                                         ^
a.cc:57:62: error: 'mid' was not declared in this scope
   57 |                                 if(x)assert(pos[x-1]*pos[i]<=mid);
      |                                                              ^~~
a.cc:59:42: error: request for member 'size' in 'pos', which is of non-class type 'int'
   59 |                                 if(x<pos.size())assert(pos[x]*pos[i]>mid);
      |                                          ^~~~
a.cc:59:59: error: invalid types 'int[int]' for array subscript
   59 |                                 if(x<pos.size())assert(pos[x]*pos[i]>mid);
      |