criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll MOD = 1000000007;

int main(){
    ll n, k; cin >> n >> k;
    vector<pair<ll,ll>> data;
    vector<ll> pl, mi;
    rep(i,n){
        ll s; cin >> s;
        if(s > 0) data.push_back(make_pair(s,1)), pl.pb(s);
        else if(s < 0) data.push_back(make_pair(-s,-1)), mi.pb(-s);
    }

    ll kk = data.size();
    ll pp = pl.size();
    ll mm = mi.size();
    sort(all(data),greater<pair<ll,ll>>());
    sort(all(pl),greater<ll>());
    sort(all(mi),greater<ll>());

    if(k > kk){ cout << 0 << endl; return 0; }

    if(pp == 0 && k%2 == 1){
        if(n != kk){ cout << 0 << endl; return 0; }
        ll ans1 = 1;
        rep(i,k) ans1 *= mi[n-1-i], ans1 %= MOD;
        cout << MOD - ans1 << endl; return 0;
    }

    ll ans = 1, num = 1;
    ll plc = 0, mic = 0;
    rep(i,k){
        ans *= data[i].first;
        ans %= MOD;
        num *= data[i].second;
        if(data[i].second == 1) plc++;
        else mic++;
    }
    if(num == 1){ cout << ans << endl; return 0; }
    if(pp = plc && mm = mic){ cout << MOD - ans << endl; return 0; }

    ll ans2 = 1;
    rep(i,plc-1) ans2 *= pl[i], ans2 %= MOD;
    rep(i,mic-1) ans2 *= mi[i], ans2 %= MOD;
    ll save1 = 0, save2 = 0;
    if(pp > plc) save1 = pl[plc-1]*pl[plc]%MOD;
    if(mm > mic) save2 = mi[mic-1]*mi[mic]%MOD;
    if(save1 < save2) save1 = save2
    cout << ans*save1%MOD << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:17: error: lvalue required as left operand of assignment
   53 |     if(pp = plc && mm = mic){ cout << MOD - ans << endl; return 0; }
      |             ~~~~^~~~~
a.cc:61:36: error: expected ';' before 'cout'
   61 |     if(save1 < save2) save1 = save2
      |                                    ^
      |                                    ;
   62 |     cout << ans*save1%MOD << endl;
      |     ~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll MOD = 1000000007;

int main(){
    ll n, k; cin >> n >> k;
    vector<pair<ll,ll>> data;
    vector<ll> pl, mi;
    rep(i,n){
        ll s; cin >> s;
        if(s > 0) data.push_back(make_pair(s,1)), pl.pb(s);
        else if(s < 0) data.push_back(make_pair(-s,-1)), mi.pb(-s);
    }

    ll kk = data.size();
    ll pp = pl.size();
    ll mm = mi.size();
    sort(all(data),greater<pair<ll,ll>>());
    sort(all(pl),greater<ll>());
    sort(all(mi),greater<ll>());

    // if(k > kk){ cout << 0 << endl; return 0; }

    if(pp == 0 && k%2 == 1){
        if(n != kk){ cout << 0 << endl; return 0; }
        ll ans1 = 1;
        rep(i,k) ans1 *= mi[n-1-i], ans1 %= MOD;
        cout << MOD - ans1 << endl; return 0;
    }

    ll ans = 1, num = 1;
    ll plc = 0, mic = 0;
    rep(i,k){
        ans *= data[i].first;
        ans %= MOD;
        num *= data[i].second;
        if(data[i].second == 1) plc++;
        else mic++;
    }
    if(num == 1){ cout << ans << endl; return 0; }
    if(pp = plc && mm = mic){ cout << MOD - ans << endl; return 0; }

    ll ans2 = 1;
    rep(i,plc-1) ans2 *= pl[i], ans2 %= MOD;
    rep(i,mic-1) ans2 *= mi[i], ans2 %= MOD;
    ll save1 = 0, save2 = 0;
    if(pp > plc) save1 = pl[plc-1]*pl[plc]%MOD;
    if(mm > mic) save2 = mi[mic-1]*mi[mic]%MOD;
    if(save1 < save2) save1 = save2
    cout << ans*save1%MOD << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:17: error: lvalue required as left operand of assignment
   53 |     if(pp = plc && mm = mic){ cout << MOD - ans << endl; return 0; }
      |             ~~~~^~~~~
a.cc:61:36: error: expected ';' before 'cout'
   61 |     if(save1 < save2) save1 = save2
      |                                    ^
      |                                    ;
   62 |     cout << ans*save1%MOD << endl;
      |     ~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long n,k,a[200001],ans=1,mod=1000000007;
bool cmp(long long x,long long y)
{
	return x>y; 
}
int main()
{
	scanf("%lld%lld",&n,&k);
	if(k==1)
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%lld",&a[i]);
			ans=max(ans,a[i]);
		}
		cout(ans+mod)%mod;
		
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]=(a[i]+mod)%mod;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=k;i++)
		ans=(ans*a[i])%mod;
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:21: error: no match for call to '(std::ostream {aka std::basic_ostream<char>}) (long long int)'
   18 |                 cout(ans+mod)%mod;
      |                 ~~~~^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef 1000000007 M;

int main()
{
ll n,k;
cin>>n>>k;
ll arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];

ll res = 1;
    for (ll i=0; i<k; i++)
      {
          res *= arr[i];
       res%=M;
    }

    ll prev_product = res;


    for (int i=1; i<=n-k; i++)
    {
        ll curr_product = (prev_product/arr[i-1]) *
                            arr[i+k-1];
         curr_product%=M;
        res = max(res, curr_product);
        prev_product = curr_product;
    }
     if(res<0)
    cout<<(res+((pow(10,9))+7))<<endl;
    
return 0;
}


Compiler output:
a.cc:4:9: error: expected unqualified-id before numeric constant
    4 | typedef 1000000007 M;
      |         ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:18:13: error: 'M' was not declared in this scope
   18 |        res%=M;
      |             ^
a.cc:28:24: error: 'M' was not declared in this scope
   28 |          curr_product%=M;
      |                        ^
Language: C++

#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010, p = 1e9+7;
ll bin_pow(ll v, ll t) {
	ll res = 1;
	for (;t;t>>=1, v = v * v % p)
		if (t&1)
			res = res * v % p;
	return res;
}

signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (auto &i : a)
		cin >> i;
	AA = a;

	priority_queue<ll> pos, neg;
	int c0 = 0;
	for (auto i : a) {
		if (i == 0) {
			++c0;
			continue;
		}
		(i>0?pos:neg).push(abs(i));
	}
	//cerr << c0 << '\n';
	if (c0) if (pos.size() + neg.size() < k || (pos.size()+neg.size()==k && (neg.size()&1))) {
		return cout << 0 << '\n', 0;
	}

	if (pos.empty() && (k&1)) {
		if (c0)
			return cout << 0 << '\n', 0;
		sort(a.begin(), a.end(), greater<>());
		ll res = 1;
		for (int i = 0;i < k;++i)
			res = res * a[i] % p;
		if (res < 0) res += p;
		cout << res << '\n';
		return 0;
	}
//	for (int i = 0;i < n;++i)
//		pos.pb(0), neg.pb(0);

	ll res = 1, si = 1, cnt = 0;
	int i = 0, j = 0;
	int lstp = -1, lstn = -1;
	while (cnt < k) {
		if (pos.empty() || (neg.size() && neg.top() >= pos.top())) {
			res = res * neg.top() % p;
			lstn = neg.top();
			neg.pop();
			si *= -1;
		}
		else {
			res = res * pos.top() % p;
			lstp = pos.top();
			pos.pop();
		}
		++cnt;
	}
	if (res < 0) res += p;
	if (si == -1) {
		ll a, b, c, d;
		a = lstp, b = lstn, c = (pos.size()?pos.top():-1), d = (neg.size()?neg.top():-1);
		cerr << "A B C D " << a << ' ' << b << ' ' << c << ' ' << d << '\n';
		assert((a!=-1&&d!=-1) || (c!=-1 && b!= -1) || c0);
		if ((a==-1||d==-1) && (c==-1||b==-1))
//			return cout << minneg() << '\n', 0;
//			res = 0;
		if (a != -1 && d != -1 && (b==-1||c==-1||(d*b>=a*c))) 
			res = res * bin_pow(a, p-2) % p * d % p;
		else 
			res = res * bin_pow(b, p-2) % p * c % p;

	}
	if (res < 0) res += p;
		cout << res << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'AA' was not declared in this scope
   21 |         AA = a;
      |         ^~
Language: C++

#include<iostream>
using namespace std;
int main(void)
{
  #define MAX 200000 
  const unsigned long int max = 1000000007; 
  unsigned long int value =0;
  unsigned long int N,K;
  cin>>N>>K;
  long int inp;
  long int values[MAX]={0};
  for(int i=0;i<N;i++)
  {
    cin>>inp;
    MAX[i]=inp;
  }
  long int lar=values[0]*values[1];
    for(int j=2;j<N;j++)
    {
      if(lar<(values[j-1]*values[j])
         {
           lar=values[j-1]*values[j];
         }
    }
    if(lar<0)
         {
           value=lar+max;
           cout<<value<<endl;
         }
    else
         {
           cout<<lar<<endl
         }
  
}
 
  
 
                      

Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: invalid types 'int[int]' for array subscript
   15 |     MAX[i]=inp;
      |        ^
a.cc:20:37: error: expected ')' before '{' token
   20 |       if(lar<(values[j-1]*values[j])
      |         ~                           ^
      |                                     )
   21 |          {
      |          ~                           
a.cc:24:5: error: expected primary-expression before '}' token
   24 |     }
      |     ^
a.cc:32:27: error: expected ';' before '}' token
   32 |            cout<<lar<<endl
      |                           ^
      |                           ;
   33 |          }
      |          ~
Language: C++

#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N, K, A[MAXN];
bool cmp(int x, int y){
	return abs(x) > abs(y);
}
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N >> K;
	FOR(i,1,N) cin >> A[i];
	int ans = 1;
	if (K == N){
		FOR(i,1,K) ans *= A[i], ans %= MOD;
		ans = (ans + MOD)%MOD;
		cout<<ans;
		exit(0);
	}
	int p = 0, z = 0, n = 0;
	FOR(i,1,N){
		if (A[i] > 0) p++;
		else if (A[i] == 0) z++;
		else n++;
	}
	
	if (p==0){
		if (K%2==0){
			FOR(i,1,N) A[i] = abs(A[i]);
			sort(A+1, A+1+N, greater<int>());
			FOR(i,1,K) ans *= A[i], ans %= MOD;
			ans = (ans + MOD)%MOD;
			cout<<ans;
			exit(0);
		}
		else{
			if (z > 0){
				cout<<0;
				exit(0);
			}
			FOR(i,1,N) A[i] = abs(A[i]);
			sort(A+1, A+1+N);
			FOR(i,1,K) ans *= -A[i], ans %= MOD;
			ans = (ans + MOD)%MOD;
			cout<<ans;
			exit(0);
		}
	}
	sort(A+1, A+1+N, cmp);
	int negs = 0, rempos = -1, remneg = -1;
	FOR(i,K+1,N) {
		if (A[i] > 0) rempos = max(rempos, A[i]);
		if (A[i] < 0) remneg = max(remneg, abs(A[i]));
	}
	FOR(i,1,K){
		//db(A[i]);
		if (A[i] < 0) negs++;
	}
	if (negs % 2==0){
		FOR(i,1,K) ans *= A[i], ans %= MOD;
		ans = (ans + MOD)%MOD;
		cout<<ans;
		exit(0);
	}
	pi replacepo
	DEC(i,K,1){
		if (A[i] >= 0 && remneg != -1){
			//db(A[i]), db(remneg);
			FOR(j,1,K){
				if (j==i) ans *= -remneg;
				else ans *= A[j];
				ans %= MOD;
			}
			ans = (ans + MOD)%MOD;
			cout<<ans;
			exit(0);
		}
		else if (A[i] < 0 && rempos != -1){
			FOR(j,1,K){
				if (j==i) ans *= rempos;
				else ans *= A[j];
				ans %= MOD;
			}
			ans = (ans + MOD)%MOD;
			cout<<ans;
			exit(0);
		}
	}
	cout << 0;
}
/*
5 3
-100 -1 -1 1000 1000
*/


Compiler output:
a.cc:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:16:20: error: expected initializer before 'for'
   16 | #define DEC(i,a,b) for(int i=(a);i>=(b);i--)
      |                    ^~~
a.cc:87:9: note: in expansion of macro 'DEC'
   87 |         DEC(i,K,1){
      |         ^~~
a.cc:87:13: error: 'i' was not declared in this scope
   87 |         DEC(i,K,1){
      |             ^
a.cc:16:34: note: in definition of macro 'DEC'
   16 | #define DEC(i,a,b) for(int i=(a);i>=(b);i--)
      |                                  ^
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
long long a[200005];
double pre[200005];
int flag[200005]={0};
int haszeoro[2000005]={0};
int main()
{
    //cout << log(-10)<<endl;
    int n,k;
    cin >> n >> k;
    pre[0]=0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        flag[i]=flag[i-1];
        haszeoro[i]=haszeoro[i-1];
        if(a[i]<0){
            flag[i]++;
        }
        else if(a[i]==0)
            haszeoro[i]++;
        pre[i]=log(abs(a[i]))+pre[i-1];
    }
    double maxnum = 0 ;
    int index = 1 ;
    int f = 0 ;
    if(haszeoro[n]>0){
        for(int i=1;i+k<=n;i++){
            if(haszeoro[i+k]-haszeoro[i]>0){
                continue;
            }
            if((flag[i+k]-flag[i])%2==0){
                if(pre[i+k]-pre[i]>maxnum){
                    maxnum = pre[i+k]-pre[i];
                    index = i ;
                }
            }
        }
    }
    else{
        maxnum = pre[k];
        index = 0 ;
        f = flag[k];
        for(int i=0;i+k<=n;i++){
            if((flag[i+k]-flag[i])%2==0){
                if(pre[i+k]-pre[i]>maxnum){
                    maxnum = pre[i+k]-pre[i];
                    index = i ;
                }
                f=0;
            }
            else if(f%2==1){
                if(pre[i+k]-pre[i]<maxnum){
                    maxnum = pre[i+k]-pre[i];
                    index = i ;
                }
            }
        }
    }
    long long num  = 1;
    for(int i=index+1;i<=index+k;i++){
        num=(num*a[i])%mod;
    }
    cout << (num+mod)%mod <<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:16: error: 'log' was not declared in this scope; did you mean 'long'?
   25 |         pre[i]=log(abs(a[i]))+pre[i-1];
      |                ^~~
      |                long
Language: C++

#from codechef previous problem
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define mod 1000000007
#define endl '\n'

long long int i,j,k,n,m,p,x,y,z;
vector<long long int> v1,v2;

int main(){
	p=1;
	
	while(p--){
		scanf("%lld %lld",&n,&k);
		assert(n>=k);
		v1.clear();
		v2.clear();
		
		long long int ans=1;
		
		for(i=1 ; i<=n ; i++){
			scanf("%lld",&x);
			assert(abs(x)<=1000000000);
			if(x>0)
				v1.pb(x);
			if(x<0)
				v2.pb(-x);
		}
					sort(v1.begin(),v1.end());
		sort(v2.begin(),v2.end());	
		if(v1.size()+v2.size()<k){
			puts("0");
			continue;
		}
		if(v2.size()%2 and k!=n and v1.size()+v2.size()==k){
			puts("0");
			continue;
		}

		if(v1.size()+v2.size()==k and k==n){
			
			for(i=0 ; i<v1.size(); i++)
				ans = ans*v1[i]%mod;
			for(i=0 ; i<v2.size() ; i++)
				ans = (ans*(-v2[i]))%mod;
				
			cout << (ans+mod)%mod << endl;
			
			continue;
		}
		if(!v1.size()){
			if(k%2){
				if(v2.size() != n){
					puts("0");
					continue;
				}
				
				for(i=0 ; i<k ; i++)
					ans = ans*(-v2[i])%mod;
			}
			else
				for(i=v2.size()-1 ; i>=v2.size()-k ; i--)
					ans = ans*(v2[i])%mod;
			
			cout << (ans%mod+mod)%mod << endl;
			continue;
		}

		
		int t2 = (int)v2.size()-1;
		int t1 = (int)v1.size()-1;

		
		if(k%2){
			ans = v1[t1];
			t1--;
			k--;
		}
		
		while(k){
			if(t1<1){
				ans = ans*v2[t2]%mod*v2[t2-1]%mod;
				t2-=2;
			}
			else if(t2<1){
				ans = ans*v1[t1]%mod*v1[t1-1]%mod;
				t1-=2;

			}
			else if(v2[t2]*v2[t2-1]>v1[t1]*v1[t1-1]){
				ans = ans*v2[t2]%mod*v2[t2-1]%mod;
				t2-=2;
			}
			else{
				ans = ans*v1[t1]%mod*v1[t1-1]%mod;
				t1-=2;
			}
			k-=2;
		}
		
		cout << (ans+mod)%mod << endl;
	}
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #from
    1 | #from codechef previous problem
      |  ^~~~
Language: C++

//E 
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
const int p = 1e9+7;
ll raw[maxn]; 
struct Node{
	ll w,cnt;
	Node(ll w = 0,ll cnt = 0):w(w),cnt(cnt){}
	bool operator < (Node & x){
		return w == x.w?cnt < x.cnt:w < x.w;
	}
}node[maxn];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	int postive = 0,neg = 0;
	for(int i = 1;i <= n;i++){
		cin >> raw[i];
		if(raw[i] > 0)postive++;
		else if(raw[i] < 0)neg++;
	}
//	cout << postive << endl;
	if(!postive){
		sort(raw+1,raw+n+1);
		ll ans = 1;
		if(neg%2)for(int i = 1;i <= k;i++)ans = (ans*raw[i]%p + p)%p;
		else for(int i = n;i >= n-k+1;i--)ans = (ans*raw[i]%p + p)%p;
		cout << ans;
		return 0;
	}
	sort(raw+1,raw+n+1);
	int idx = 0,i = 1;
	if(neg%2)i = 2;
	ll mul = 0;
	for(;i <= n;i++){
		if(raw[i] < 0){
			if(!mul)mul = raw[i];
			else{
				 node[++idx] = Node(mul*raw[i],2); 
				mul = 0;
			}
		}
		else node[++idx] = Node(raw[i],1);
	}
//	cout << idx << endl;
	sort(node+1,node+idx+1);
	ll ans = 1;
	while(k){
		if(k >= node[idx].cnt){
			k -= node[idx].cnt;
			int w = node[idx].w;
//			cout << w << endl;
			ans = (ans*node[idx--].w%p + p)%p;
		}
	}
	cout << (ans%p + p)%p;
	return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int ma(vector<int>A, int n, int k) 
{ 
    // sorting given input array 
    sort(A.begin(), A.end()); 
  
    // variable to store final product of all element 
    // of sub-sequence of size k 
    long long product = 1; 
  
    // CASE I 
    // If max element is 0 and 
    // k is odd then max product will be 0 
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
  
    // CASE II 
    // If all elements are negative and 
    // k is odd then max product will be 
    // product of rightmost-subarray of size k 
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) 
            product *= A[i]%mod; 
        return product%mod; 
    } 
  
    // else 
    // i is current left pointer index 
    int i = 0; 
  
    // j is current right pointer index 
    int j = n - 1; 
  
    // CASE III 
    // if k is odd and rightmost element in 
    // sorted array is positive then it 
    // must come in subsequence 
    // Multiplying A[j] with product and 
    // correspondingly changing j 
    if (k & 1) { 
        product *= A[j]%mod; 
        j--; 
        k--; 
    } 
  
    // CASE IV 
    // Now k is even 
    // Now we deal with pairs 
    // Each time a pair is multiplied to product 
    // ie.. two elements are added to subsequence each time 
    // Effectively k becomes half 
    // Hence, k >>= 1 means k /= 2 
    k >>= 1; 
  
    // Now finding k corresponding pairs 
    // to get maximum possible value of product 
    for (int itr = 0; itr < k; itr++) { 
  
        // product from left pointers 
        long long left_product = (A[i]%mod) * (A[i + 1]%mod); 
  
        // product from right pointers 
        long long right_product = (A[j]%mod)* (A[j - 1]%mod); 
  
        // Taking the max product from two choices 
        // Correspondingly changing the pointer's position 
        if (left_product > right_product) { 
            product *= left_product%mod; 
            i += 2; 
        } 
        else { 
            product *= right_product%mod; 
            j -= 2; 
        } 
    } 
  
    // Finally return product 
    return product%mod; 
} 

int main() {
	int n;
	cin>>n;
	
   vector<int>a(n);
   for(int i=0;i<n;i++){
   	cin>>a[i];
   }
   sort(a.begin(),a.end());
   cout<<(ma+mod)%mod<<endl;
   
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:92:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   92 |    cout<<(ma+mod)%mod<<endl;
      |           ~~^~~~
a.cc:92:18: error: invalid operands of types 'int (*)(std::vector<int>, int, int)' and 'int' to binary 'operator%'
   92 |    cout<<(ma+mod)%mod<<endl;
      |          ~~~~~~~~^~~~
      |             |     |
      |             |     int
      |             int (*)(std::vector<int>, int, int)
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	vector<ll> p, m;
	rep(i, n) {
		ll a;
		cin >> a;
		if (a >= 0)
			p.push_back(a);
		else
			m.push_back(a);
	}
	sort(all(p), greater<ll>());
	sort(all(m));
	int a = p.size(), b = m.size();
	if (n == k) {
		ll ans = 1;
		for (auto s : p) ans = ans * s % MOD;
		for (auto s : m) ans = ans * s % MOD;
		ans = (ans + MOD) % MOD;
		cout << ans << endl;
		return 0;
	}
	if (p.size() == 0 and k % 2) {
		ll ans = 1;
		rep(i, k) ans = ans * m[b - 1 - i] % MOD;
		ans = (ans + MOD) % MOD;
		cout << ans << endl;
		return 0;
	}
	vector<ll> P, M;
	ll A;
	rep(i, a / 2) P.push_back(p[i * 2] * p[i * 2 + 1] % MOD);
	if (a % 2) A = *p.rbegin();
	rep(i, b / 2) M.push_back(m[i * 2] * m[i * 2 + 1] % MOD);
	auto itp = P.begin(), itm = M.begin();
	ll ans = 1, cnp = 0;
	while (k > 1) {
		if (a % 2 == 0 and k % 2and a - cnp == 2) {
			ans = ans * (*itm) % MOD;
			itm++;
			k -= 2;
		} else if (itp == P.end()) {
			ans = ans * (*itm) % MOD;
			itm++;
			k -= 2;
		} else if (itm == M.end()) {
			ans = ans * (*itp) % MOD;
			cnp += 2;
			itp++;
			k -= 2;
		} else {
			if ((*itp) > (*itm)) {
				ans = ans * (*itp) % MOD;
				cnp += 2;
				itp++;
			} else {
				ans = ans * (*itm) % MOD;
				itm++;
			}
			k -= 2;
		}
	}
	if (k == 1) {
		ans = ans * p[cnp] % MOD;
		ans = (ans + MOD) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:40: error: unable to find numeric literal operator 'operator""and'
   57 |                 if (a % 2 == 0 and k % 2and a - cnp == 2) {
      |                                        ^~~~
a.cc:57:44: error: expected ')' before 'a'
   57 |                 if (a % 2 == 0 and k % 2and a - cnp == 2) {
      |                    ~                       ^~
      |                                            )
Language: C++

#include <bits/stdc++.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n,k;
	cin>>n>>k;
	vector<int> pos;
	vector<int> neg;
	for(int i=0,a;i<n;i++)
	{
	cin>>a;
	if(a>=0)
	pos.push_back(a);
	else
	neg.push_back(a);
	
	}
	sort(pos.begin(),pos.end(),greater<int>());
	sort(neg.begin(),neg.end());
	ll ans=1;
	for(int i=0;i<k;){
		if(k>1)
		{
			int a=*pos.begin()*(*pos.begin()+1);
			int b=*neg.begin()*(*neg.begin()+1);
			if(b>=a)
			{
				i+=2;
				ans*=b%mod;
				erase(neg.begin(),neg.begin()+1);
			}
			else{
				i+=2;
				ans*=a%mod;
				erase(pos.begin(),pos.begin()+1);
			}
	}
	else{
		ans*=*pos.begin()%mod;
		i+=1;
		erase(pos.begin());
	}
	
}
cout<<ans<<endl;
	
	
	
	
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:33: error: 'erase' was not declared in this scope
   34 |                                 erase(neg.begin(),neg.begin()+1);
      |                                 ^~~~~
a.cc:39:33: error: 'erase' was not declared in this scope
   39 |                                 erase(pos.begin(),pos.begin()+1);
      |                                 ^~~~~
a.cc:45:17: error: 'erase' was not declared in this scope
   45 |                 erase(pos.begin());
      |                 ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
# define ll long long
ll mod=pow(10,9)+7;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    ll n,k;
    cin>>n>>k;
    ll ar[n];
    for(ll i=0;i<n;i++)
        cin>>ar[i];
    sort(ar,ar+n);
    if((ar[0]<0 && ar[n-1]<0)||n==k){
        ll ans=1;
        for(ll i=n-1;i>n-1-k;i--){
            ans=((ans%mod)*(ar[i]%mod))%mod;
            ans+=mod;ans=ans%mod;
        }
        cout<<ans<<endl;
    }
    else if(ar[0]>0 && ar[n-1]>0){
        ll ans=1;
        for(ll i=n-1;i>n-1-k;i--){
            ans=((ans%mod)*(ar[i]%mod))%mod;
            ans+=mod;ans=ans%mod;
        }
        cout<<ans<<endl;
    }
    else{
        if(k%2==1){
            if(k==n-1){
                    
                ll ans=1;
                for(ll i=0;i<n;i++){
                    if(ar[i+1]>0)
                        break;
                    ans=((ans%mod)*(v[i]%mod))%mod;
                    if(ans<0)
                    ans+=mod;ans=ans%mod;
                }
                for(ll i=n-1;i>=0;i--){
                    if(ar[i]<0)
                        break;
                    ans=((ans%mod)*(v[i]%mod))%mod;
                    if(ans<0)
                    ans+=mod;ans=ans%mod;
                }
                cout<<ans<<endl;
                return 0;
            }
            vector<ll> v;
            for(ll i=0;i<n;i+=2){
                if(ar[i]>0 && ar[i+1]>0)
                    break;
                v.push_back(ar[i]*ar[i+1]);
            }
            for(ll i=n-2;i>0;i-=2){
                if(ar[i]<0 && ar[i-1]<0)
                    break;
                v.push_back(ar[i]*ar[i-1]);
            }
            sort(v.begin(),v.end());
            ll ans=ar[n-1];
            for(ll i=v.size()-1;i>v.size()-1-k/2;i--){
                ans=((ans%mod)*(v[i]%mod))%mod;
                if(ans<0)
                ans+=mod;ans=ans%mod;
            }
            cout<<ans<<endl;
        }
        else{
            vector<ll> v;
            for(ll i=0;i<n;i+=2){
                if(ar[i]>0 && ar[i+1]>0)
                    break;
                v.push_back(ar[i]*ar[i+1]);
            }
            for(ll i=n-1;i>0;i-=2){
                if(ar[i]<0 && ar[i-1]<0)
                    break;
                v.push_back(ar[i]*ar[i-1]);
            }
            sort(v.begin(),v.end());
            ll ans=1;
            for(ll i=v.size()-1;i>v.size()-1-k/2;i--){
                ans=((ans%mod)*(v[i]%mod))%mod;
                if(ans<0)
                ans+=mod;ans=ans%mod;
            }
            cout<<ans<<endl;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:37: error: 'v' was not declared in this scope
   42 |                     ans=((ans%mod)*(v[i]%mod))%mod;
      |                                     ^
a.cc:49:37: error: 'v' was not declared in this scope
   49 |                     ans=((ans%mod)*(v[i]%mod))%mod;
      |                                     ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
 
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
 
 
 
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
 
 
//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}
 
 
 
int main() {
 
	long long N,K;
    long long A[200100],abA[200100];
    long long ans;

    cin >> N,K;
    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N,[](int i, int j) -> bool {
    return abs(i) < abs(j);});
    ans=0;
    for 
    cout << ans << endl;
	cin >> ans;
 
	return 0;
 
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:5: error: expected '(' before 'cout'
   57 |     cout << ans << endl;
      |     ^~~~
      |     (
a.cc:60:9: error: expected primary-expression before 'return'
   60 |         return 0;
      |         ^~~~~~
a.cc:58:20: error: expected ')' before 'return'
   58 |         cin >> ans;
      |                    ^
      |                    )
   59 | 
   60 |         return 0;
      |         ~~~~~~      
a.cc:57:5: note: to match this '('
   57 |     cout << ans << endl;
      |     ^~~~
Language: C++

#include <bits/stdc++.h>

#define llint long long int
#define MOD (1000000000 + 7)

using namespace std;

int main(){
    int N, K;

    cin >> N >> K;

    vector<llint> A(N);

    for(int i = 0; i < N; i ++){
        cin >> A[i];
    }
    int count_plus = 0;

    for(int i = 0; i < N; i ++){
        if(A[i] > 0){
            count_plus ++;
        }
    }
    if(count_plus == 0 && K % 2 == 1){
        // 非正数
        for(int i = 0; i < N; i ++){
            if(A[i] < 0){
                A[i] = -A[i];
            }
        }
        sort(A.begin(), A.end());

        llint ans = 1;

        for(int i = 0; i < K; i ++){
            ans *= A[i];
            ans %= MOD;
        }
        ans = (MOD - ans) % MOD;

        cout << ans << endl;
    }else{
        // 正数
        vector<llint> plus, not_plus;

        for(int i = 0; i < N; i ++){
            if(A[i] > 0){
                plus.push_back(A[i]);
            }else{
                not_plus.push_back(-A[i]);
            }
        }
        sort(plus.begin(), plus.end(), greater<llint>());
        sort(not_plus.begin(), not_plus.end(), greater<llint>());

        vector<pair<llint, bool>> all;

        for(int i = 0; i + 1 < plus.size(); i += 2){
            all.push_back(make_pair(plus[i] * plus[i + 1], true));
        }
        for(int i = 0; i + 1 < not_plus.size(); i += 2){
            all.push_back(make_pair(not_plus[i] * not_plus[i + 1], false));
        }
        sort(all.begin(), all.end(), greater<pair<llint, bool>>());

        llint ans = 1;
        int count = 0;

        for(int i = 0, j = 0; i + 1 < K; i += 2, j ++){
            ans *= all[j].firast % MOD;
            ans %= MOD;

            if(all[j].second){
                count += 2;
            }
        }
        if(K % 2 == 1){
            ans *= plus[count];
            ans %= MOD;
        }
        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, bool> >, std::pair<long long int, bool> >::value_type' {aka 'struct std::pair<long long int, bool>'} has no member named 'firast'; did you mean 'first'?
   71 |             ans *= all[j].firast % MOD;
      |                           ^~~~~~
      |                           first
Language: C++

/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#define ln mp::cpp_int;
#define ll    long long
#define int long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

ln maxk(int A[], int n, int k) 
{ 
    sort(A, A + n); 
  
    ln product = 1; 
  
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
  
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) 
            product =(product%mod) * A[i]; 
        return product%mod; 
    } 
  
    int i = 0; 
  
    int j = n - 1; 
  
    
    if (k & 1) { 
        product =(product%mod) *  A[j]; 
        j--; 
        k--; 
    } 
    k >>= 1; 
  
    for (int itr = 0; itr < k; itr++) { 
  
        int left_product = A[i] * A[i + 1]; 
  
        int right_product = A[j] * A[j - 1]; 
  
        if (left_product > right_product) { 
            product =(product%mod) *  left_product; 
            i += 2; 
        } 
        else { 
            product =(product%mod) *  right_product; 
            j -= 2; 
        } 
    } 
  
    return product%mod; 
} 

void virus(){
    ll len,k;
    cin>>len>>k;
    ll a[len];
    for(auto i=0;i<len;i++) cin>>a[i];
    ln ans = maxk(a,len,k);
    if(ans<0) cout<<mod-ans;
    else cout<<ans%mod;

}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Compiler output:
a.cc:9:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    9 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#define int long long;
using namespace std;
const int mod=1e9+7;
int n,k,a[200001],ans=1;
bool cmp(int x,int y)
{
	return x>y; 
}
signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]=(a[i]+mod)%mod;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=k;i++)
		ans=(ans*a[i])%mod;
	cout<<ans;
	return 0;
}

Compiler output:
a.cc:2:18: error: declaration does not declare anything [-fpermissive]
    2 | #define int long long;
      |                  ^~~~
a.cc:4:7: note: in expansion of macro 'int'
    4 | const int mod=1e9+7;
      |       ^~~
a.cc:4:11: error: 'mod' does not name a type
    4 | const int mod=1e9+7;
      |           ^~~
a.cc:2:18: error: declaration does not declare anything [-fpermissive]
    2 | #define int long long;
      |                  ^~~~
a.cc:5:1: note: in expansion of macro 'int'
    5 | int n,k,a[200001],ans=1;
      | ^~~
a.cc:5:5: error: 'n' does not name a type
    5 | int n,k,a[200001],ans=1;
      |     ^
a.cc:2:22: error: expected ')' before ';' token
    2 | #define int long long;
      |                      ^
a.cc:6:10: note: in expansion of macro 'int'
    6 | bool cmp(int x,int y)
      |          ^~~
a.cc:6:9: note: to match this '('
    6 | bool cmp(int x,int y)
      |         ^
a.cc:6:14: error: 'x' does not name a type
    6 | bool cmp(int x,int y)
      |              ^
a.cc:6:20: error: 'y' does not name a type
    6 | bool cmp(int x,int y)
      |                    ^
a.cc: In function 'int main()':
a.cc:12:27: error: 'n' was not declared in this scope; did you mean 'yn'?
   12 |         scanf("%lld%lld",&n,&k);
      |                           ^
      |                           yn
a.cc:12:30: error: 'k' was not declared in this scope
   12 |         scanf("%lld%lld",&n,&k);
      |                              ^
a.cc:2:18: error: declaration does not declare anything [-fpermissive]
    2 | #define int long long;
      |                  ^~~~
a.cc:13:13: note: in expansion of macro 'int'
   13 |         for(int i=1;i<=n;i++)
      |             ^~~
a.cc:13:17: error: 'i' was not declared in this scope
   13 |         for(int i=1;i<=n;i++)
      |                 ^
a.cc:13:25: error: expected ')' before ';' token
   13 |         for(int i=1;i<=n;i++)
      |            ~            ^
      |                         )
a.cc:13:26: error: 'i' was not declared in this scope
   13 |         for(int i=1;i<=n;i++)
      |                          ^
a.cc:18:14: error: 'a' was not declared in this scope
   18 |         sort(a+1,a+1+n,cmp);
      |              ^
a.cc:2:18: error: declaration does not declare anything [-fpermissive]
    2 | #define int long long;
      |                  ^~~~
a.cc:19:13: note: in expansion of macro 'int'
   19 |         for(int i=1;i<=k;i++)
      |             ^~~
a.cc:19:25: error: expected ')' before ';' token
   19 |         for(int i=1;i<=k;i++)
      |            ~            ^
      |                         )
a.cc:21:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |         cout<<ans;
      |               ^~~
      |               abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,mod=1e9+7;
typedef long long ll;
int n,m,k,a[N],b[N],d[N],z;
long double aa[N],bb[N];
ll ma[N],mb[N];
int main()
{
    int s;scanf("%d%d",&s,&k);
    while(s--)
    {
        int x;scanf("%d",&x);
        if(x>0) a[++n]=x;
        else if(x<0) b[++m]=-x;
        else z++;
    }
    if(n) sort(a+1,a+1+n,greater<int>());
    if(m) sort(b+1,b+1+m,greater<int>());
    ma[0]=mb[0]=1;
    for(int i=1;i<=n;i++) aa[i]=aa[i-1]+log2((long double)a[i]),ma[i]=ma[i-1]*a[i]%mod;
    for(int i=1;i<=m;i++) bb[i]=bb[i-1]+log2((long double)b[i]),mb[i]=mb[i-1]*b[i]%mod;
    if(n+m<k){printf("0\n");return 0;}
    if(n+m==k)
    {
        if(m&1)
        {
            if(z) printf("0\n");
            else
                printf("%lld\n",(ma[n]*mb[m]%mod*-1+mod)%mod);
        }
        else
        {
            printf("%lld\n",(ma[n]*mb[m]%mod+mod)%mod);
        }
        return 0;
    }
    if(!n)
    {
        if(k&1)
        {
            if(z) printf("0\n");
            else
            {
                reverse(b+1,b+1+m);
                ll ans=1;
                for(int i=1;i<=k;i++) ans=ans*b[i]%mod;
                printf("%lld\n",(ans*-1+mod)%mod);
            }
        }
        else
        {
            printf("%lld\n",(mb[k]+mod)%mod);
        }
        return 0;
    }
    assert(0);
    printf("%lld\n",ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
   58 |     printf("%lld\n",ans);
      |                     ^~~
      |                     abs
Language: C++


			return 0;
		}
		else
		{
			printf("%lld",max());
			return 0;
		}
	}
}

Compiler output:
a.cc:2:25: error: expected unqualified-id before 'return'
    2 |                         return 0;
      |                         ^~~~~~
a.cc:3:17: error: expected declaration before '}' token
    3 |                 }
      |                 ^
a.cc:4:17: error: expected unqualified-id before 'else'
    4 |                 else
      |                 ^~~~
a.cc:9:9: error: expected declaration before '}' token
    9 |         }
      |         ^
a.cc:10:1: error: expected declaration before '}' token
   10 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long int
int mod=1e9+7;
int32_t main(){
    int n,k,ans=1,pos=0,neg=0,z=0,t,ok=1,s=1,e=n;
    cin>>n>>k;
    int a[n+1];
    vector<int>vpos,vneg;
    for(i=1;i<=n;i++){cin>>a[i];
        if(a[i]>0){pos++;}
        if(a[i]<0)neg++;
        if(a[i]==0)z++;
    }
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    if(n==k){
        for(i=1;i<=n;i++){ans*=a[i];ans%=mod;}
        ans=(ans+mod)%mod;
        cout<<ans;return 0;
    }
    if(!neg){
        for(i=1;i<=k;i++){ans*=a[i];ans%=mod;}
        cout<<ans;
        return 0;
    }
    t=min(k,neg);
    if(t%2)t--;
    if(t+pos<k)ok=0;
    if(!ok&&z){cout<<"0";return 0;}
if(!ok){
    for(i=1;i<=k;i++){ans*=a[i];ans%=mod;}
    ans=(ans+mod)%mod;
    cout<<ans;return 0;
}
 if(k%2){
     ans=a[1];
     k--;
     s=2;
 } 
 while(k){
     if(a[s]*a[s+1]>a[e]*a[e-1]){
         ans*=a[s];
         ans%=mod;
         ans*=a[s+1];ans%=mod;
         s+=2;
     }else{
         ans*=a[e];
         ans%=mod;
         ans*=a[e-1];
         ans%=mod;
         ans=(ans+mod)%mod;
         e-=2;
     }
     k-=2;
 }
 cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:10:9: error: 'i' was not declared in this scope
   10 |     for(i=1;i<=n;i++){cin>>a[i];
      |         ^
a.cc:18:13: error: 'i' was not declared in this scope
   18 |         for(i=1;i<=n;i++){ans*=a[i];ans%=mod;}
      |             ^
a.cc:23:13: error: 'i' was not declared in this scope
   23 |         for(i=1;i<=k;i++){ans*=a[i];ans%=mod;}
      |             ^
a.cc:32:9: error: 'i' was not declared in this scope
   32 |     for(i=1;i<=k;i++){ans*=a[i];ans%=mod;}
      |         ^
Language: C++

#include <iostream>

typedef int64_t ll;

using namespace std;

const ll mod = 1e9 + 7;
ll n, k, a[200005], l, r, tot, ans, lb, rb;

void calcmin() {
    l = lb, r = rb;
    while (tot < k) {
        ll lv = mod, rv = mod;
        if (l >= 1) lv = -a[l];
        if (r <= n) rv = a[r];
        if (rv < lv) {
            ans = ans * rv % mod;
            r++;
        }
        else {
            ans = ans * (-lv) % mod;
            l--;
        }
        tot++;
    }
}

void calcmax() {
    if (k % 2 == 1) {
        ans *= a[n];
        r = n - 1;
        tot = 1;
    }
    while (tot < k && (l < lb || r > rb)) {
        ll lv = 0, rv = 0;
        if (l < lb) lv = a[l] * a[l + 1];
        if (r > rb) rv = a[r] * a[r - 1];
        if (rv > lv) {
            rv %= mod;
            ans = ans * rv % mod;
            r -= 2;
        }
        else {
            lv %= mod;
            ans = ans * lv % mod;
            l += 2;
        }
        tot += 2;
    }
    if (tot == k - 1) {
        if (r == rb) {
            ans = ans * a[rb] % mod;
        }
        else if (l == lb) {
            ans = ans * a[lb] % mod;
        }
    }
}

int main() {
    cin >> n >> k;
    for (ll i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    l = 1, r = n, tot = 0, ans = 1, lb = 0, rb = n + 1;
    for (ll i = 1; i <= n; i++) {
        if (a[i] < 0) {
            lb = max(lb, i);
        } 
        if (a[i] > 0) {
            rb = min(rb, i);
        }
    }
    if ((n - rb + 1 + lb == k && lb % 2 == 1) || 
    n - rb + 1 + lb < k || (rb == n + 1 && k % 2 == 1)) {
        if (rb - lb > 1) {
            cout << 0 << endl;
            return 0;
        }
        else {
            calcmin();
        }
    }
    else {
        calcmax();
    }
    
    cout << (ans + mod) % mod << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:63:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   63 |     sort(a + 1, a + n + 1);
      |     ^~~~
      |     short
Language: C++

#include<bits/stdc++.h> 
using namespace std; 
long long  mod=1000000007;
long long maxProductSubarrayOfSizeK(long long A[], long long n, long long  k) 
{ 

   
    sort(A, A + n); 

  

     

    

    long long product = 1; 

  

    

    if (A[n - 1] == 0 && (k & 1)) 

        return 0; 

  

  
   

    if (A[n - 1] <= 0 && (k & 1)) { 

        for (long long i = n - 1; i >= n - k; i--) 

            product *= (A[i]%mod); 

        return product%mod; 

    } 

  

    // else 

    // i is current left pointer index 

    long long i = 0; 

  

    // j is current right pointer index 

    long long j = n - 1; 

  

    // CASE III 

    // if k is odd and rightmost element in 

    // sorted array is positive then it 

    // must come in subsequence 

    // Multiplying A[j] with product and 

    // correspondingly changing j 

    if (k & 1) { 

        product *= (A[j]%mod); 

        j--; 

        k--; 

    } 

  

    

    k >>= 1; 

  

    // Now finding k corresponding pairs 

    // to get maximum possible value of product 

    for (long long itr = 0; itr < k; itr++) { 

  

        // product from left pointers 

        long long left_product = ((A[i]%mod) * (A[i + 1]%mod)); 

  

        
        long long  right_product =(( A[j]%mod) *( A[j - 1]%mod)); 

  

        
        if (left_product > right_product) { 

            product *= (left_product%mod); 

            i += 2; 

        } 

        else { 

            product *=(right_product %mod); 

            j -= 2; 

        } 

    } 

    return product%mod; 
} 

int main(){
  long long nn, kk; 
  cin>>nn>>kk; 
  long long arr[nn]; 
  for(long long ln=0;ln<n;ln++){
    cin>>arr[ln]; 
    }
  cout << maxProductSubarrayOfSizeK(arr, nn, kk); 

  
  
   
   
    
  
  
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:132:25: error: 'n' was not declared in this scope; did you mean 'ln'?
  132 |   for(long long ln=0;ln<n;ln++){
      |                         ^
      |                         ln
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int MOD = 1e9 + 7;

void step(int& l, int& r, int& ans, vector <int> & pls, vector <int> &mns) {
    if (l == mns.size() - 1)
        ans = ans * pls[r--] % MOD;
    else if (r == 0 || r == -1 || abs(mns[l]) > abs(pls[r]))
        ans = ans * (mns[l++] + MOD) % MOD;
    else
        ans = ans * pls[r--] % MOD;
}

void solve() {
    int n, k, ans = 1;
    cin >> n >> k;
    vector <int> pls, mns;
    loop(i, n) {
        int x; cin >> x;
        if (x > 0)
            pls.pb(x);
        else
            mns.pb(x);
    }
    sort(all(mns)); sort(all(pls));
    if (n == k) {
        loop(i, mns.size())
            ans = ans * (mns[i] + MOD) % MOD;
        loop(i, pls.size())
            ans = ans * pls[i] % MOD;
    }
    else if (!pls.size()) {
        for (int i = (k & 1 ? n - 1 : 0); (k & 1 ? i >= n - k : i < k); (k & 1 ? --i : ++i))
            ans = ans * (mns[i] + MOD) % MOD;
    }
    else if (!mns.size()) {
        for (int i = n - 1; i >= n - k; --i)
            ans = ans * pls[i] % MOD
    }
    else {
        if (k & 1) {
            ans = pls.back();
            pls.pop_back(); --k;
        }
        if (k) {
            int l = 0, r = (int)pls.size() - 1;
            for (int i = 0; i < k - 1; ++i)
                step(l, r, ans, pls, mns);
            if (l % 2 == 0)
                ans = ans * pls[r] % MOD;
            else
                ans = ans * (mns[l] + MOD) % MOD;
        }
    }
    cout << ans;
        
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:79:37: error: expected ';' before '}' token
   79 |             ans = ans * pls[i] % MOD
      |                                     ^
      |                                     ;
   80 |     }
      |     ~