Language: C++

#include<bits/stdc++.h>
#define ll __int64
#define pb push_back
using namespace std;
const ll mod=1e9+7;
vector<ll>pos,neg;
bool cmp(int x,int y){return y<x;}
int main()
{
	int n,k,a;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a>0)pos.pb(a);
		else if(a<0)neg.pb(a);
	}
	int ps=0,ns=0;
	if(!pos.empty())ps=pos.size();
	if(!neg.empty())ns=neg.size();
	if((ps+ns/2*2>=k&&k%2==0)||(ps&&ps-1+ns/2*2>=k-1&&k%2==1))
	{
		ll ans=1,i=0,j=0;
		if(ps)sort(pos.begin(),pos.end(),cmp);
		if(ns)sort(neg.begin(),neg.end());
		if(k&1)ans=pos[i++],k--;
		while(k)
		{
			if(i+1<ps&&j+1<ns)
			{
				ll t1=pos[i]*pos[i+1],t2=neg[j]*neg[j+1];
				if(t1>t2)ans=ans*(t1%mod)%mod,i+=2;
				else ans=ans*(t2%mod)%mod,j+=2;
			}
			else if(i+1<ps)ans=ans*(pos[i]*pos[i+1]%mod)%mod,i+=2;
			else ans=ans*(neg[j]*neg[j+1]%mod)%mod,j+=2;
			k-=2;
		}
		cout<<ans<<endl;
	}
	else
	{

		if(ps+ns!=n)puts("0");
		else
		{
			ll ans=1;
			int i=0,j=0;
			if(ps)sort(pos.begin(),pos.end());
			if(ns)sort(neg.begin(),neg.end(),cmp);
			while(k--)
			{
				if(i<ps&&j<ns)
				{
					if(pos[i]<=abs(neg[j]))ans*=pos[i++],ans%=mod;
					else ans*=(neg[j++]+mod)%mod,ans%=mod;
				}
				else if(i<ps)ans*=pos[i++],ans%=mod;
				else ans*=(neg[j++]+mod)%mod,ans%=mod;

			}
			cout<<ans<<endl;
		}
	}
	return 0;
}


Compiler output:
a.cc:2:12: error: '__int64' does not name a type; did you mean '__int64_t'?
    2 | #define ll __int64
      |            ^~~~~~~
a.cc:5:7: note: in expansion of macro 'll'
    5 | const ll mod=1e9+7;
      |       ^~
a.cc:2:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
    2 | #define ll __int64
      |            ^~~~~~~
a.cc:6:8: note: in expansion of macro 'll'
    6 | vector<ll>pos,neg;
      |        ^~
a.cc:6:10: error: template argument 1 is invalid
    6 | vector<ll>pos,neg;
      |          ^
a.cc:6:10: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:3:12: error: request for member 'push_back' in 'pos', which is of non-class type 'int'
    3 | #define pb push_back
      |            ^~~~~~~~~
a.cc:15:28: note: in expansion of macro 'pb'
   15 |                 if(a>0)pos.pb(a);
      |                            ^~
a.cc:3:12: error: request for member 'push_back' in 'neg', which is of non-class type 'int'
    3 | #define pb push_back
      |            ^~~~~~~~~
a.cc:16:33: note: in expansion of macro 'pb'
   16 |                 else if(a<0)neg.pb(a);
      |                                 ^~
a.cc:19:17: error: request for member 'empty' in 'pos', which is of non-class type 'int'
   19 |         if(!pos.empty())ps=pos.size();
      |                 ^~~~~
a.cc:19:32: error: request for member 'size' in 'pos', which is of non-class type 'int'
   19 |         if(!pos.empty())ps=pos.size();
      |                                ^~~~
a.cc:20:17: error: request for member 'empty' in 'neg', which is of non-class type 'int'
   20 |         if(!neg.empty())ns=neg.size();
      |                 ^~~~~
a.cc:20:32: error: request for member 'size' in 'neg', which is of non-class type 'int'
   20 |         if(!neg.empty())ns=neg.size();
      |                                ^~~~
a.cc:2:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
    2 | #define ll __int64
      |            ^~~~~~~
a.cc:23:17: note: in expansion of macro 'll'
   23 |                 ll ans=1,i=0,j=0;
      |                 ^~
a.cc:24:32: error: request for member 'begin' in 'pos', which is of non-class type 'int'
   24 |                 if(ps)sort(pos.begin(),pos.end(),cmp);
      |                                ^~~~~
a.cc:24:44: error: request for member 'end' in 'pos', which is of non-class type 'int'
   24 |                 if(ps)sort(pos.begin(),pos.end(),cmp);
      |                                            ^~~
a.cc:25:32: error: request for member 'begin' in 'neg', which is of non-class type 'int'
   25 |                 if(ns)sort(neg.begin(),neg.end());
      |                                ^~~~~
a.cc:25:44: error: request for member 'end' in 'neg', which is of non-class type 'int'
   25 |                 if(ns)sort(neg.begin(),neg.end());
      |                                            ^~~
a.cc:26:24: error: 'ans' was not declared in this scope; did you mean 'ns'?
   26 |                 if(k&1)ans=pos[i++],k--;
      |                        ^~~
      |                        ns
a.cc:26:32: error: 'i' was not declared in this scope
   26 |                 if(k&1)ans=pos[i++],k--;
      |                                ^
a.cc:29:28: error: 'i' was not declared in this scope
   29 |                         if(i+1<ps&&j+1<ns)
      |                            ^
a.cc:29:36: error: 'j' was not declared in this scope
   29 |                         if(i+1<ps&&j+1<ns)
      |                                    ^
a.cc:31:36: error: expected ';' before 't1'
   31 |                                 ll t1=pos[i]*pos[i+1],t2=neg[j]*neg[j+1];
      |                                    ^~
a.cc:32:36: error: 't1' was not declared in this scope; did you mean 'y1'?
   32 |                                 if(t1>t2)ans=ans*(t1%mod)%mod,i+=2;
      |                                    ^~
      |                                    y1
a.cc:32:39: error: 't2' was not declared in this scope; did you mean 'tm'?
   32 |                                 if(t1>t2)ans=ans*(t1%mod)%mod,i+=2;
      |                                       ^~
      |                                       tm
a.cc:32:42: error: 'ans' was not declared in this scope; did you mean 'ns'?
   32 |                                 if(t1>t2)ans=ans*(t1%mod)%mod,i+=2;
      |                                          ^~~
      |                                          ns
a.cc:32:54: error: 'mod' was not declared in this scope; did you mean 'modf'?
   32 |                                 if(t1>t2)ans=ans*(t1%mod)%mod,i+=2;
      |                                                      ^~~
      |                                                      modf
a.cc:33:38: error: 'ans' was not declared in this scope; did you mean 'ns'?
   33 |                                 else ans=ans*(t2%mod)%mod,j+=2;
      |                                      ^~~
      |                                      ns
a.cc:33:50: error: 'mod' was not declared in this scope; did you mean 'modf'?
   33 |                                 else ans=ans*(t2%mod)%mod,j+=2;
      |                                                  ^~~
      |                                                  modf
a.cc:35:40: error: 'ans' was not declared in this scope; did you mean 'ns'?
   35 |                         else if(i+1<ps)ans=ans*(pos[i]*pos[i+1]%mod)%mod,i+=2;
      |                                        ^~~
      |                                        ns
a.cc:35:65: error: 'mod' was not declared in this scope; did you mean 'modf'?
   35 |                         else if(i+1<ps)ans=ans*(pos[i]*pos[i+1]%mod)%mod,i+=2;
      |                                                                 ^~~
      |                                                                 modf
a.cc:36:30: error: 'ans' was not declared in this scope; did you mean 'ns'?
   36 |                         else ans=ans*(neg[j]*neg[j+1]%mod)%mod,j+=2;
      |                              ^~~
      |                              ns
a.cc:36:55: error: 'mod' was not declared in this scope; did you mean 'modf'?
   36 |                         else ans=ans*(neg[j]*neg[j+1]%mod)%mod,j+=2;
      |                                                       ^~~
      |                                                       modf
a.cc:39:23: error: 'ans' was not declared in this scope; did you mean 'ns'?
   39 |                 cout<<ans<<endl;
      |                       ^~~
      |                       ns
a.cc:2:12: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
    2 | #define ll __int64
      |            ^~~~~~~
a.cc:47:25: note: in expansion of macro 'll'
   47 |                         ll ans=1;
      |                         ^~
a.cc:49:40: error: request for member 'begin' in 'pos', which is of non-class type 'int'
   49 |                         if(ps)sort(pos.begin(),pos.end());
      |                                        ^~~~~
a.cc:49:52: error: request for member 'end' in 'pos', which is of non-class type 'int'
   49 |                         if(ps)sort(pos.begin(),pos.end());
      |                                                    ^~~
a.cc:50:40: error: request for member 'begin' in 'neg', which is of non-class type 'int'
   50 |                         if(ns)sort(neg.begin(),neg.end(),cmp);
      |                                        ^~~~~
a.cc:50:52: error: request for member 'end' in 'neg', which is of non-class type 'int'
   50 |                         if(ns)sort(neg.begin(),neg.end(),cmp);
      |                                                    ^~~
a.cc:55:47: error: invalid types 'int[int]' for array subscript
   55 |                                         if(pos[i]<=abs(neg[j]))ans*=pos[i++],ans%=mod;
      |                                               ^
a.cc:55:59: error: invalid types 'int[int]' for array subscript
   55 |                                         if(pos[i]<=abs(neg[j]))ans*=pos[i++],ans%=mod;
      |                                                           ^
a.cc:55:64: error: 'ans' was not declared in this scope; did you mean 'ns'?
   55 |                                         if(pos[i]<=abs(neg[j]))ans*=pos[i++],ans%=mod;
      |                                                                ^~~
      |                                                                ns
a.cc:55:72: error: invalid types 'int[int]' for array subscript
   55 |                                         if(pos[i]<=abs(neg[j]))ans*=pos[i++],ans%=mod;
      |                                                                        ^
a.cc:55:83: error: 'mod' was not declared in this scope; did you mean 'modf'?
   55 |                                         if(pos[i]<=abs(neg[j]))ans*=pos[i++],ans%=mod;
      |                                                                                   ^~~
      |                                                                                   modf
a.cc:56:46: error: 'ans' was not declared in this scope; did you mean 'ns'?
   56 |                                         else ans*=(neg[j++]+mod)%mod,ans%=mod;
      |                                              ^~~
      |                                              ns
a.cc:56:55: error: invalid types 'int[int]' for array subscript
   56 |                                         else ans*=(neg[j++]+mod)%mod,ans%=mod;
      |                                                       ^
a.cc:56:61: error: 'mod' was not declared in this scope; did you mean 'modf'?
   56 |                                         else ans*=(neg[j++]+mod)%mod,ans%=mod;
      |                                                             ^~~
      |                                                             modf
a.cc:58:46: error: 'ans' was not declared in this scope; did you mean 'ns'?
   58 |                                 else if(i<ps)ans*=pos[i++],ans%=mod;
      |                                              ^~~
      |                                              ns
a.cc:58:54: error: invalid types 'int[int]' for array subscript
   58 |                                 else if(i<ps)ans*=pos[i++]