criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.math.BigInteger;
import java.util.*;

public class TLE {

  private static final BigInteger MOD = BigInteger.valueOf(1000000007);

  public static void main(String[] args) {
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    int[] A = new int[n];
    for (int i = 0; i < n; i++) {
      A[i] = scanner.nextInt();
    }
    List<Integer> pos = new ArrayList<>();
    List<Integer> neg = new ArrayList<>();
    int zero = 0;
    long all = 1;
    for (int i : A) {
      if (i > 0) {
        pos.add(i);
      } else if (i < 0) {
        neg.add(i);
      } else {
        zero++;
      }
      all = (all * i) % MOD.intValue();
    }
    if (pos.size() + neg.size() < k || (n == k && zero > 0)) {
      System.out.println(0);
      return;
    }
    if (n == k) {
      System.out.println(Math.floorMod(all, MOD.intValue()));
      return;
    }
    pos.sort(Comparator.reverseOrder());
    neg.sort(Comparator.reverseOrder());
    BigInteger[] posMulLft = new BigInteger[pos.size() + 1];
    BigInteger[] negMulLft = new BigInteger[neg.size() + 1];
    BigInteger[] negMulRgt = new BigInteger[neg.size() + 1];
    posMulLft[0] = BigInteger.ONE;
    negMulLft[0] = BigInteger.ONE;
    negMulRgt[negMulRgt.length - 1] = BigInteger.ONE;
    for (int i = 1; i < Math.min(k + 1, posMulLft.length); i++) {
      posMulLft[i] = posMulLft[i - 1].multiply(BigInteger.valueOf(pos.get(i - 1)));
    }
    for (int i = 1; i < Math.min(k + 1, negMulLft.length); i++) {
      negMulLft[i] = negMulLft[i - 1].multiply(BigInteger.valueOf(neg.get(i - 1)));
    }
    for (int i = negMulRgt.length - 2, j = k; i >= 0 && j >= 0; i--, j--) {
      negMulRgt[i] = negMulRgt[i + 1].multiply(BigInteger.valueOf(neg.get(i)));
    }
    BigInteger res = BigInteger.valueOf(Long.MIN_VALUE);
    for (int i = 0; i < Math.min(k + 1, posMulLft.length); i++) {
      if (k - i < negMulLft.length) {
        res = posMulLft[i].multiply(negMulLft[k - i]).max(res);
      }
    }
    for (int i = 0; i < Math.min(k + 1, negMulRgt.length); i++) {
      if (k - i < posMulLft.length) {
        res = negMulRgt[negMulRgt.length - 1 - i].multiply(posMulLft[k - i]).max(res);
      }
    }
    System.out.println(res.mod(MOD));
  }

  private static final Scanner scanner = new Scanner(System.in);
}


Compiler output:
Main.java:4: error: class TLE is public, should be declared in a file named TLE.java
public class TLE {
       ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main(){
  ll n;cin >>n;
  ll k;cin >>k;
  ll ans=1;
  vector<ll>am;
  vector<ll>ap;
  vector<ll>az;
  ll tmp;
  for(ll i=0;i<n;i++){
    cin >>tmp;
    if(tmp==0)az.push_back(tmp);
    else if(tmp>0)ap.push_back(tmp);
    else am.push_back(tmp);
  }
  ll size=ap.size()+am.size();
  if(size<k){cout <<0<<endl;return 0;}
  if(n==k){
    for(auto i:am){
      ans*=i;
      ans%=1000000007;
    }
    for(auto i:ap){
      ans*=i;
      ans%=1000000007;
    }
    if(ans>0){
    cout <<ans<<endl;
    return 0;
    }
    else{
      cout <<ans+1000000007;<<endl;
    return 0;
    }
  }
  ll sizep=ap.size();
  if(sizep==0&&k%2==1){
    sort(am.begin(),am.end());
    reverse(am.begin(),am.end());
    for(ll i=0;i<k;i++){
      ans*=am.at(i);
      ans%=1000000007;
    }
    cout <<ans+1000000007<<endl;
    return 0;
  }
    if(sizep==0&&k%2==0){
    sort(am.begin(),am.end());
    for(ll i=0;i<k;i++){
      ans*=am.at(i);
      ans%=1000000007;
    }
    cout <<ans<<endl;
    return 0;
  }
  sort(am.begin(),am.end());
  sort(ap.begin(),ap.end());
  reverse(ap.begin(),ap.end());
  
  vector<ll>ampair;
  ll amsize=am.size();
  if(amsize%2==0){
    for(ll i=0;i+1<amsize;i+=2){
      ampair.push_back(am.at(i)*am.at(i+1));
    }
  }
  else{
    for(ll i=0;i+1<amsize-1;i+=2){
      ampair.push_back(am.at(i)*am.at(i+1));
    }
  }
  vector<pair<ll,int>>aabs;
  for(auto amp:ampair){
    aabs.push_back({amp,-1});
  }
  for(auto apt:ap){
    aabs.push_back({apt,1});
  }
  sort(aabs.begin(),aabs.end());
  reverse(aabs.begin(),aabs.end());
  
  ll tmp2=k;
  ll ai=0;
  while(1){
    ans*=aabs.at(ai).first;
    if(aabs.at(ai).second==-1){
      if(tmp2-2<0){
        ans/=aabs.at(ai).first;
        ai++;
        continue;
      }
      else{
        ans%=1000000007;
        ai++;
        tmp2-=2;
      }
    }
    else{
      ans%=1000000007;
      ai++;
      tmp2-=1;
    }
    if(tmp2==0){
      cout <<ans<<endl;
      return 0;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:29: error: expected primary-expression before '<<' token
   35 |       cout <<ans+1000000007;<<endl;
      |                             ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define test int t ; cin>>t ; while(t--)
#define ll long long
#define inp(n) cin>>n;
#define loopp(i,a,b) for(ll i=a;i<b;i++)
#define loopn(i,a,b) for(ll i=a;i>=b;i--)
#define vel vector<ll>

void pos(vel vp,vel vn,int k)
{
    int sp=vp.size();
    int sn=vn.size();
    int p1=0,p2=0;
    ll ans=1;
    ll mod = 1000000007;
    while(p1+1<sp && p2+1<sn && k>0)
    {
        ll m1=vp[p1]*vp[p1+1];
        ll m2=vn[p2]*vn[p2+1];
        //cout<<m1<<"  "<<m2<<endl;
        if(k==1)
        {
            ans=(ans*(vp[p1]%mod))%mod;
            k-=1;
        }
        else if(m1<m2)
        {
            //cout<<ans<<" "<<mod<<" "<<m2<<endl;
            //cout<<m2%mod<<" "<<ans%mod<<endl;
            ans=((ans%mod)*(m2%mod))%mod;
            p2+=2;
            k-=2;
            //cout<<k<<" GHH"<<ans<<endl;
        }
        else
        {
            ans=(ans*(m1%mod))%mod;
            p1+=2;
            k-=2;
        }
        //cout<<k<<" GHH12"<<endl;
    }
    //cout<<"HGJ"<<endl;
    if(k==1)
    {
        if(p1==sp && sn>=2)
        {
            ans=ans/vp[sp-1];
            ll m2=vn[p2]*vn[p2+1];
            ans=(ans*(m2%mod))%mod;
            p2+=2;
            p1-=1;    
            k-=1
        }
    }
    if(k>0)
    {
        while(p1+1<sp && k>0)
        {
            ll m1=vp[p1]*vp[p1+1];
            if(k==1)
            {
                ans=(ans*(vp[p1]%mod))%mod;
                k-=1;
            }
            else
            {
                ans=(ans*(m1%mod))%mod;
                p1+=2;
                k-=2;
            }
        }
        while(p2+1<sn && k>0)
        {
            ll m2=vn[p2]*vn[p2+1];
            //cout<<m2<<endl;
            if(k==1)
            {
                //cout<<ans<<endl;
                ans=(ans*(vp[sn-1]%mod))%mod;
                //cout<<ans<<endl;
                k-=1;
            }
            else
            {
                ans=(ans*(m2%mod))%mod;
                p2+=2;
                k-=2;
            }
        }
    }
    if(k==1)
        ans=(ans*(vp[p1]%mod))%mod;
    cout<<ans<<endl;
}
void neg(vel vp,vel vn,int k)
{
    int sp=vp.size();
    int sn=vn.size();
    int p1=sp-1,p2=sn-1;
    ll ans=1;
    ll mod = 1000000007;
    while(k>0)
    {
        ans=(ans*(vn[p2])%mod)%mod;
        //cout<<"HH: "<<ans<<endl;
        p2--;
        k--;
    }
    cout<<(ans+mod)%mod<<endl;
}
int main()
{
    int n;inp(n);
    int k;inp(k);
    vel vp,vn;
    ll a;
    loopp(i,0,n)
    {
        inp(a);
        if(a<0)
            vn.push_back(a);
        else
            vp.push_back(a);
    }
    sort(vp.begin(),vp.end(),greater<ll>());
    //cout<<"H"<<endl;
    sort(vn.begin(),vn.end());
    int sp=vp.size();
    int sn=vn.size();
    if(sp==0 && k%2!=0)
        neg(vp,vn,k);
    else
        pos(vp,vn,k);
    return 0;
}


Compiler output:
a.cc: In function 'void pos(std::vector<long long int>, std::vector<long long int>, int)':
a.cc:54:17: error: expected ';' before '}' token
   54 |             k-=1
      |                 ^
      |                 ;
   55 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);

  const int M = 1e9 + 7;

  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());

  if (N == K || A.back() < 0) {
    int res = 1;
    for (int i = 0; i < K; ++i) res = (int64_t) res * *((K & 1 ? A.rbegin() : A.begin()) + i) % M;
    if (res < 0) res += M;
    cout << res << endl;
  } else {
    int res = 1;
    int i = 0, j = N - 1;
    if (K & 1) --K, res = A[j--];
    for (; K; K -= 2) {
      int64_t v0 = (int64_t) A[i] * A[i + 1];
      int64_t v1 = (int64_t) A[j] * A[j - 1];
      if (v0 > v1) res = (int64_t) res * (v0 % M) % M, i += 2;
      else res = (int64_t) res * (v1 % M) % M, j -= 2;
    }
    if (res < 0) res += M;
    cout << res << endl;
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:18:64: error: operands to '?:' have different types 'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} and 'std::vector<int>::iterator'
   18 |     for (int i = 0; i < K; ++i) res = (int64_t) res * *((K & 1 ? A.rbegin() : A.begin()) + i) % M;
      |                                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

import sys
input = sys.stdin.readline
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
b = []
c = []
for x in a:
    if x > 0:
        b.append(x)
    elif x < 0:
        c.append(-x)
flg = 0
if len(b):
    if n == k:
        if len(c) % 2 == 0:
            flg = 1
    else:
        flg = 1
else:
    if k % 2 == 0:
        flg = 1
ans = 0
mod = 1000000007
if flg:
    if len(b) + len(c) < k:
        pass
    else:
        b.sort()
        b.reverse()
        c.sort()
        c.reverse()
        for i in range(1, len(b)):
            b[i] *= b[i - 1]
        for i in range(1, len(c)):
            c[i] *= c[i - 1]
        # print(' '.join(map(str, c)))
        for i in range(0, n):
            x = 1
            cnt = 2 * i + (k % 2)
            if cnt < 0 or cnt > len(b):
                continue
            if cnt:
                x = b[cnt - 1]
            cnt2 = k - cnt
            if cnt2 < 0 or cnt2 > len(c):
                continue
            if cnt2:
                print
                x = x * c[cnt2 - 1]
            ans = max(ans, x)
            # print(ans)
        ans = ans % mod
        ans = ans + mod
        ans = ans % mod
else:
    if len(b) + len(c) != n:
        pass
    else:
        for i in range(0, n):
            if a[i] < 0:
                a[i] = -a[i]
        a.sort()
        ans = 1
        for i in range(0, k):
            ans *= a[i]
            # print(a[i], ans)
        ans = -ans
        ans = ans % mod
        ans = ans + mod
        ans = ans % mod
print(ans)


Compiler output:
a.cc:38:11: error: invalid preprocessing directive #print
   38 |         # print(' '.join(map(str, c)))
      |           ^~~~~
a.cc:53:15: error: invalid preprocessing directive #print
   53 |             # print(ans)
      |               ^~~~~
a.cc:68:15: error: invalid preprocessing directive #print
   68 |             # print(a[i], ans)
      |               ^~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define MOD 1e9+7
#define ll long long
#define pb push_back
#define mp make_pair
bool isPrime(ll n) 
{ 
    
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
   
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
int minthis(int a, int b){
if(a < b){
return a;
}
return b;
}
int maxthis(int a, int b){
if(a > b){
return a;
}
return b;
}
int gcd(int a, int b){
    if( a<0 ) a = -a;
    if( b<0 ) b = -b;
    while( b!=0 ){
        a %= b;
        if( a==0 ) return b;
        b %= a;
    }
    return a;
}
 
int findLargestDivisor(int n) 
{ 
	int max = 1;
    for (int i = 2; i < n; i++) {        
        if(n %(i) == 0) { 
            max = i;
        } 
    }
    return max;     
} 
 
 
ll power(ll x, ll y)  
{  
    ll temp;  
    if(y == 0)  
        return 1;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return temp * temp;  
    else
    {  
        if(y > 0)  
            return x * temp * temp;  
        else
            return (temp * temp) / x;  
    }  
}  


void solve(){		
	ll mod = 1000000007;
	int n,k;
	cin >> n >> k;
	vector<int> arr(n);
	bool haspos = false; 
	bool hasneg = false;
	ll ans = 1;
	vector<int> pos;
	vector<int> neg;
	vector<int> total;
	for(int i = 0 ; i < n ; i++){
		cin >> arr[i];
		if(arr[i]>=0) haspos = true;pos.pb(arr[i]);
		if(arr[i] < 0) hasneg = true;neg.pb(arr[i]);
	}
	if(!haspos){		
		if(k%2 == 0){
			sort(arr.begin(), arr.end());
			int i = 0;
			while(k--){
				ans*=arr[i];i++;
			}
			cout << ((-1*ans)%mod+mod)%mod << "\n";return;
		}
		else{
			sort(arr.rbegin() , arr.rend());
			int i = 0;
			while(k--){
				ans *= arr[i];i++;
			}
			cout << (mod+ans)%mod << "\n";return;
		}		
	}
	if(!hasneg){
		sort(arr.rbegin() , arr.rend());
		int i = 0;
		while(k--){
			ans *= arr[i];i++;
		}
		cout << ans%mod << "\n";return;
	}
	if(k == n){
		for(int i = 0 ; i < n ; i++){
			ans*=arr[i];
		}
		cout << ans << "\n";return;
	}
	
	sort(neg.begin(), neg.end());
	for(int i = 0 ; i < neg.size() ; i+=2){
		total.pb(neg[i]*neg[i+1]);
	}
	
	int po = pos.size();
	int tot = total.size();
	int idxpos = 0;
	int idxtotal = 0;
	sort(pos.rbegin(), pos.rend());
	while(k>=2){
		if(idxpos < po && idxtotal < tot && (ans*pos[idxpos] >= ans*total[idxtotal])){
			ans*=pos[idxpos]; idxpos++; k--;
		}
		else if(idxpos < po-1 && idxtotal < tot && (ans*pos[idxpos]*pos[idxpos+1] >= ans*total[idxtotal])) ans*=pos[idxpos]*pos[idxpos+1];k-=2;idxpos+=2;
		else if(idxtotal < tot){
			ans*=total[idxtotal];idxtotal++;k-=2;
		}
	}
	if(k && idxpos < po)
	cout << (ans*pos[idxpos])%mod << "\n";
	else if(k) cout << ((ans*neg[neg.size()-1])+mod)%mod << "\n";	
	else cout << ans%mod << "\n";
	
}
  
int main(){ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;    
    //cin >> t;
    while(t--){
		solve();
	}
    return 0; 
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:138:17: error: 'else' without a previous 'if'
  138 |                 else if(idxtotal < tot){
      |                 ^~~~
Language: C


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;
ll a[N];
int f[5];
bool cmp(int x,int y)
{
    return abs(x)<abs(y);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    memset(f,0,sizeof f);
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]>=0) f[1]++;
        else f[2]++;
    }
    int l=1,r=n;
    ll ans=1;
     if(!f[1]&&m%2==1){
        sort(a+1,a+1+n,cmp);
        for(int i=1;i<=m;i++){
            ans=a[i]*ans%mod;
        }
    }
    else {
        sort(a+1,a+1+n,greater<int>());
    while(m>0){
        if(m%2) ans=ans*a[l]%mod,l++,m--;
        else if(m>=2){
           if(a[l]*a[l+1]>=a[r]*a[r-1]){
              ans=ans*a[l]%mod*a[l+1]%mod;
              l+=2;
              m-=2;
           }
           else{
            ans=ans*a[r-1]%mod*a[r]%mod;
            r-=2;
            m-=2;
           }
        }
    }
    }
    cout<<(ans%mod+mod)%mod<<endl;
    return 0;
}

Compiler output:
main.c:2:10: fatal error: bits/stdc++.h: No such file or directory
    2 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cout<<elem;}cerr<<endl;}

//解説参考. 解法2.
int main(){
	int n,k;
	cin>>n>>k;
	
	vector<llong> a,b;
	REP(i,n){
		llong in;
		cin>>in;
		if(in<0) a.push_back(in);
		else b.push_back(in);
	}
	sort(ALL(a));
	sort(ALL(b),greater<llong>());
	
	if(a.size()=b.size()==n){
		llong anss=1;
		REP(i,a.size()) anss=anss*(MOD+a[i])%MOD;
		REP(i,b.size()) anss=anss*b[i]%MOD:
		cout<<anss<<endl;
		return 0;
	}
	
	if(a.size()==n and k%2==1){
		llong anss=1;
		for(int i=a.size()-1;i>=a.size()-k;--i) anss=anss*(MOD+a[i])%MOD;
		cout<<anss<<endl;
		return 0;
	}
	
	llong ans=1;
	int pa=0, pb=0;
	while(k>0){
		if(k<=1){
			ans=ans*b[pb++]%MOD;
			k--;
		}else{
			if(a.size()-pa>=2 and (b.size()-pb<=1 or (b.size()-pb>=2 and a[pa]*a[pa+1]>=b[pb]*b[pb+1]))){
				REP(i,2) ans=ans*(MOD+a[pa++])%MOD;
				k-=2;
			}else{
				ans=ans*b[pb++]%MOD;
				k--;
			}
		}
	}
	
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:18: error: lvalue required as left operand of assignment
   31 |         if(a.size()=b.size()==n){
      |            ~~~~~~^~
a.cc:34:51: error: expected ';' before ':' token
   34 |                 REP(i,b.size()) anss=anss*b[i]%MOD:
      |                                                   ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

int main (void) {
    bool has_zero = false;
    int N, K;
    cin >> N >> K;
    vector<int> ap, am;
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        if ( a > 0 ) ap.push_back(a);
        else if ( a < 0 ) am.push_back(a);
        else has_zero = true;
    }

    sort(ap.begin(), ap.end(), greater<int>());
    sort(am.begin(), am.end());

    int psize = ap.size();
    int msize = am.size();

    if ( K > psize + msize ) {
        assert(has_zero);
        cout << 0 << endl;
        return 0;
    }
    else if ( K == psize + msize ) {
        if ( msize % 2 == 1 ) {
            if ( has_zero ) {
                cout << 0 << endl;
                return 0;
            }
        }
        for ( int i = 0; i < psize; i++ ) {
            ans *= ap.at(i);
            ans %= MOD;
        }
        for ( int i = 0; i < msize; i++ ) {
            ans *= am.at(i);
            if ( ans < 0 )
                ans = (ans%MOD+MOD)%MOD;
            else
                ans %= MOD;
        }

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

    long long ans = 1;
    int pidx = 0;
    int midx = 0;

    /* 負の数しかない場合、特別扱いする */
    if ( ap.empty() ) {
        if ( has_zero ) {
            cout << 0 << endl;
            return 0;
        }
        midx = msize - 1;
        while ( K > 0 ) {
            ans *= am.at(midx);
            if ( ans < 0 )
                ans = (ans%MOD+MOD)%MOD;
            else
                ans %= MOD;
            midx--;
            K--;
        }
        cout << ans << endl;
        return 0;
    }


    if ( K % 2 != 0 ) {
        ans = ap.at(0);
        pidx = 1;
        K--;
    }

    while ( K > 0 ) {
        long long p;
        long long m;

        if ( pidx >= psize - 1 ) {
            assert(midx < msize-1);
            ans *= ((long long)am.at(midx) * am.at(midx+1)) % MOD;
            ans %= MOD;
            midx += 2;
            goto NLOOP;
        }
        if ( midx >= msize - 1 ) {
            assert(pidx < psize-1);
            ans *= ((long long)ap.at(pidx) * ap.at(pidx+1)) % MOD;
            ans %= MOD;
            pidx += 2;
            goto NLOOP;
        }

        p = (long long)ap.at(pidx) * ap.at(pidx+1);
        m = (long long)am.at(midx) * am.at(midx+1);

        if ( p > m ) {
            ans *= p % MOD;
            ans %= MOD;
            pidx += 2;
        }
        else {
            ans *= m % MOD;
            ans %= MOD;
            midx += 2;
        }
NLOOP:
        K -= 2;
    }

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



Compiler output:
a.cc: In function 'int main()':
a.cc:39:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |             ans *= ap.at(i);
      |             ^~~
      |             abs
a.cc:43:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |             ans *= am.at(i);
      |             ^~~
      |             abs
a.cc:50:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, K;
vector<pair<ll,ll>> A;
vector<ll> p2, m2;

signed main(){
    cin >> N >> K;
    rep(i, N){
        ll a;
        cin >> a;
        if(a == 0) A.pb({ 0,1 });
        else A.pb({ abs(a), a/abs(a) });
    }
    sort(all(A));
    reverse(all(A));

    if(K == N){
        ll ans = 1;
        rep(i, N){
            ans *= (A[i].first*A[i].second + MOD) % MOD;
            ans %= MOD;
        }
        cout << ans << endl;
        return 0;
    }

    bool allM = true;
    rep(i, N) allM &= (A[i].second == -1);
    if(allM && K%2 == 1){
        ll ans = 1;
        reverse(all(A));
        rep(i, K){
            ans *= MOD-A[i].first;
            ans %= MOD;
        }
        cout << ans << endl;
        return 0;
    }
    if(allM && K%2 == 0){
        ll ans = 1;
        rep(i, K){
            ans *= (A[i].first*A[i].second + MOD) % MOD;
            ans %= MOD;
        }
        cout << ans << endl;
        return 0;
    }

    int cnt = 0;
    rep(i, K){
        if(A[i].second == -1) cnt++;
    }
    if(cnt%2 == 0){
        ll ans = 1;
        rep(i, K) ans = ans * A[i].first % MOD;
        cout << ans << endl;
    }
    else{
        int p = -1, m = -1;
        rep(i, K){
            if(A[i].second == 1) p = i;
            if(A[i].second == -1) m = i;
        }
        ll ans = 1;
        rep(i, K){
            if(i == p || i == m) continue;
            ans = ans * A[i].first % MOD;
        }
        int p2 = -1, m2 = -1;
        for(int i=N-1; i>=K; i--){
            if(A[i].second == 1) p2 = i;
            if(A[i].second == -1) m2 = i;
        }

        if(p == -1){
            ans *= A[p2].first;
            ans %= MOD;
            cout << ans << endl;
            return 0;
        
        if(p == -1 || p2 == -1){
            ans *= A[m].first;
            ans %= MOD;
            ans *= A[m2].first;
            ans %= MOD;
            cout << ans << endl;
            return 0;
        }
        if(m == -1 || m2 == -1){
            ans *= A[p].first;
            ans %= MOD;
            ans *= A[p2].first;
            ans %= MOD;
            cout << ans << endl;
            return 0;
        }

        ll x1 = A[m].first*A[m2].first;
        ll x2 = A[p].first*A[p2].first;
        cout << max(x1, x2)%MOD * ans % MOD << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:118:2: error: expected '}' at end of input
  118 | }
      |  ^
a.cc:22:14: note: to match this '{'
   22 | signed main(){
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,K;
P B[200005];
int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>K;
rep(i,N){
    ll a;
    cin>>a;
    if(a>0){
        B[i].first=a;
        B[i].second=1;
    }
    if(a==0){
        B[i].first=a;
        B[i].second=0;
    }
    if(a<0){
        B[i].first=-a;
        B[i].second=-1;
    }
}
sort(B,B+N);
ll cnt=0;
ll x1=INF;
ll y1=INF;
ll x2=INF;
ll y2=INF;
for(ll i=N-1; i>=N-K; i--){
    if(B[i].second==0){
        cout<<0<<endl; 
        exit(0);
    }
    if(B[i].second==-1){
        cnt++;
        x1=i;
    }
    if(B[i].second==1){
        y1=i;
    }
}
rep(i,N-K){
    if(B[i].second>=0) x2=i;
    if(B[i].second<=0) y2=i;
}
ll ans=1;
if(cnt%2==0){
    for(ll i=N-1; i>=N-K; i--){
    ll mul=B[i].first;
    if(B[i].second==-1) mul=-mul+mod;
    ans=ans*mul%mod;
    }
    cout<<ans<<endl; 
    exit(0);
}
if((x1==INF||x2==INF)&&(y1==INF||y2==INF)){
    rep(i,K){
    ll mul=B[i].first;
    if(B[i].second==-1) mul=-mul+mod;
    ans=ans*mul%mod;
    }
    cout<<ans<<endl; 
    exit(0);
}
ll ans1=1;
ll ans2=1;
if(y1==INF||y2==INF){
    for(ll i=N-1; i>=N-K; i--){
    ll mul;
    if(i==x1){
        mul=B[x2].first;
        if(B[x2].second==-1) mul=-mul+mod;
    }
    else{
        mul=B[i].first;
        if(B[i].second==-1) mul=-mul+mod;
    }
    ans1=ans1*mul%mod;
    }
    cout<<ans1<<endl; 
    exit(0);
}else{
    for(ll i=N-1; i>=N-K; i--){
    ll mul;
    if(i==y1){
        mul=B[y2].first;
        if(B[y2].second==-1) mul=-mul+mod;
    }
    else{
        mul=B[i].first;
        if(B[i].second==-1) mul=-mul+mod;
    }
    ans2=ans2*mul%mod;
    }
    cout<<ans2<<endl; 
    exit(0);
}
if(B[y1].first*B[x2].first=<B[y2].first*B[x1].first){
    for(ll i=N-1; i>=N-K; i--){
    ll mul;
    if(i==x1){
        mul=B[x2].first;
        if(B[x2].second==-1) mul=-mul+mod;
    }
    else{
        mul=B[i].first;
        if(B[i].second==-1) mul=-mul+mod;
    }
    ans1=ans1*mul%mod;
    }
    cout<<ans1<<endl;
}else{
    for(ll i=N-1; i>=N-K; i--){
    ll mul;
    if(i==y1){
        mul=B[y2].first;
        if(B[y2].second==-1) mul=-mul+mod;
    }
    else{
        mul=B[i].first;
        if(B[i].second==-1) mul=-mul+mod;
    }
    ans2=ans2*mul%mod;
    }
    cout<<ans2<<endl;
}

}
    


Compiler output:
a.cc: In function 'int main()':
a.cc:109:28: error: expected primary-expression before '<' token
  109 | if(B[y1].first*B[x2].first=<B[y2].first*B[x1].first){
      |                            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
 
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    rep(i, N) a[i] = abs(a[i]);
    sort(a.rbegin(), a.rend());
 
    ll res = 1;
    rep(i, K) res *= a[i];
    int b = pow(10, 9) + 7;
    cout << (res % b) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'll' was not declared in this scope
   13 |     ll res = 1;
      |     ^~
a.cc:14:15: error: 'res' was not declared in this scope; did you mean 'rep'?
   14 |     rep(i, K) res *= a[i];
      |               ^~~
      |               rep
a.cc:16:14: error: 'res' was not declared in this scope; did you mean 'rep'?
   16 |     cout << (res % b) << endl;
      |              ^~~
      |              rep
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    rep(i, N) a[i] = abs(a[i]);
    sort(a.rbegin(), a.rend());

    ll res = 1;
    rep(i, K) res *= a[i];
    int b = pow(10, 9) + 7;
    cout << (res % b) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'i' was not declared in this scope
    8 |     rep(i, N) cin >> a[i];
      |         ^
a.cc:8:5: error: 'rep' was not declared in this scope
    8 |     rep(i, N) cin >> a[i];
      |     ^~~
a.cc:12:5: error: 'll' was not declared in this scope
   12 |     ll res = 1;
      |     ^~
a.cc:15:14: error: 'res' was not declared in this scope
   15 |     cout << (res % b) << endl;
      |              ^~~
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> >
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

int mul(int a, int b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}
void solve(){
    int n, k, ans = 1, K; cin >> n >> k;
     K = k;
    vector <int> p, neg, z;
    vector<pair<ll,ll>>v;
    for(ll i=0;i<n;i++){
        ll x, s; cin >> x;
    if(x > 0) {
      p.push_back(x);
      s = 1;
    }
    if(x < 0) {
      neg.push_back(abs(x));
      s = -1;
    }
    if(x == 0) {
      z.push_back(x);
      s = 1;
    }
    v.push_back({abs(x), s});
    }
    sort(p.begin(),p.end());
    sort(neg.begin(),neg.end());
    sort(v.begin(),v.end());
    int i=p.size()-1,j=neg.size()-1;
    if(k%2){
        if(!p.empty()){
            ans=mul(ans,p[i]);
            i--;
            k--;
        }
    }
    while(k && (i>0 || j>0)){
        int a = -INF, b = -INF;
     if(i >= 1) {
       a = p[i] * p[i-1];
     }
     if(j >= 1) {
       b = neg[j] * neg[j-1];
     }
     if(a > b) {
       ans = mul(ans, a);
       k-=2; i-=2;
     }
     else {
       ans = mul(ans, b);
       k-=2; j-=2;
     }
    }
    if(k) {
    if(!z.empty()) {
      ans = 0;
    } else {
      ans = 1;
      for(int l = 0; l < K; l++) {
         ans = mul(ans, v[l].first * v[l].second);
      }
    }
  }
  cout << ans << '\n';
    return;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:108:4: error: expected '}' at end of input
  108 |   }
      |    ^
a.cc:98:15: note: to match this '{'
   98 | signed main() {
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll mod=1e9+7;
ll INF=1e18;
ll mul(ll a, ll b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}
void solve(){
    int n, k, ans = 1, K; cin >> n >> k;
     K = k;
    vector <int> p, neg, z;
    vector<pair<ll,ll>>v;
    for(ll i=0;i<n;i++){
        ll x, s; cin >> x;
    if(x > 0) {
      p.push_back(x);
      s = 1;
    }
    if(x < 0) {
      neg.push_back(abs(x));
      s = -1;
    }
    if(x == 0) {
      z.push_back(x);
      s = 1;
    }
    v.push_back({abs(x), s});
    }
    sort(p.begin(),p.end());
    sort(neg.begin(),neg.end());
    sort(v.begin(),v.end());
    int i=pos.size()-1,j=neg.size()-1;
    if(k%2){
        if(!pos.empty()){
            ans=mul(ans,pos[i]);
            i--;
            k--;
        }
    }
    while(k && (i>0 || j>0)){
        int a = -INF, b = -INF;
     if(i >= 1) {
       a = pos[i] * pos[i-1];
     }
     if(j >= 1) {
       b = neg[j] * neg[j-1];
     }
     if(a > b) {
       ans = mul(ans, a);
       k-=2; i-=2;
     }
     else {
       ans = mul(ans, b);
       k-=2; j-=2;
     }
    }
    if(k) {
    if(!zero.empty()) {
      ans = 0;
    } else {
      ans = 1;
      for(int l = 0; l < K; l++) {
         ans = mul(ans, v[l].first * v[l].second);
      }
    }
  }
  cout << ans << '\n';
    return;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:35:11: error: 'pos' was not declared in this scope; did you mean 'pow'?
   35 |     int i=pos.size()-1,j=neg.size()-1;
      |           ^~~
      |           pow
a.cc:43:24: error: 'j' was not declared in this scope
   43 |     while(k && (i>0 || j>0)){
      |                        ^
a.cc:61:9: error: 'zero' was not declared in this scope; did you mean 'bzero'?
   61 |     if(!zero.empty()) {
      |         ^~~~
      |         bzero
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll MOD=(ll)1e9+7;

int main(){
  ll ans=1;
  for(int i=0;i<99;i++){
    ans*=7;ans%=MOD;
  }
  cout<<ans<<endl;
  ll n,k,a;
  cin>>n>>k;
  vector<ll> p,z,m;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a>=0)p.push_back(a);
    if(a<0)m.push_back(a);
  }
  ll ps=p.size(),ms=m.size();
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(m.begin(),m.end());
  ll pmax=0,mmax=0,pmin=ps-1,mmin=ms-1;
  while(k>1){
    k-=2;
    if(pmax+1<ps && mmax+1<ms && p[pmax]*p[pmax+1]>=m[mmax]*m[mmax+1])pmax+=2;
    else if(pmax+1<ps && mmax+1<ms && p[pmax]*p[pmax+1]<m[mmax]*m[mmax+1])mmax+=2;
    else if(pmax+1>=ps && mmax+1<ms)mmax+=2;
    else if(pmax+1<ps && mmax+1>=ms)pmax+=2;
    else{mmax++;pmax++;}
    if(pmin-1>=0 && mmin-1>=0 && p[pmin]*p[pmin-1]>=m[mmin]*m[mmin-1])pmin-=2;
    else if(pmin-1>=0 && mmin-1>=0 && p[pmin]*p[pmin-1]<m[mmin]*m[mmin-1])mmin-=2;
    else if(pmin-1<0 && mmin-1>=0)mmin-=2;
    else if(pmin-1>=0 && mmin-1<0)pmin-=2;
    else{mmin--;pmin--;}
  }
  ll ans=1;
  if(k==0 || (k==1 && pmax<ps)){
    if(k==1 && pmax<ps)pmax++;
    for(int i=0;i<pmax;i++){
      ans*=p[i];ans%=MOD;
    }
    for(int i=0;i<mmax;i++){
      ans*=m[i];ans%=MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
  }
  else if(k==1 && pmax==ps){
    mmin--;
    for(int i=ps-1;i>pmin;i--){
      ans*=p[i];ans%=MOD;
    }
    for(int i=ms-1;i>mmin;i--){
      ans*=m[i];ans%=MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:6: error: redeclaration of 'll ans'
   38 |   ll ans=1;
      |      ^~~
a.cc:7:6: note: 'll ans' previously declared here
    7 |   ll ans=1;
      |      ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll mod=1e9+7;
ll INF=1e18;
ll mul(ll a, ll b) {
  a += mod; b += mod;
  a %= mod; b %= mod; return ((a * b) % mod);
}
void solve(){
    ll n,k;
    cin>>n>>k;
    ll K=k;
    vector<ll>pos,neg,zero;
    vector<pair<ll,ll>>v(n);
    for(ll i=0;i<n;i++){
        ll d;
        cin>>d;
        if(d>0)pos.push_back(d);
        else if(d<0)neg.push_back(abs(d));
        else zero.push_back(d);
        ll s;
        if(d>=0)s=1;
        else s=-1;
        v[i]=make_pair(abs(d),s);
    }
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());
    sort(v.begin(),v.end());
    ll ans=1;
    ll i=pos.size()-1,j=neg.size()-1;
    if(k%2){
        if(!pos.empty()){
            ans=mul(ans,pos[i]);
            i--;
            k--;
        }
    }
    while(k && (pcur>0 || ncur>0)){
        int a = -INF, b = -INF;
     if(i >= 1) {
       a = p[i] * p[i-1];
     }
     if(j >= 1) {
       b = neg[j] * neg[j-1];
     }
     if(a > b) {
       ans = mul(ans, a);
       k-=2; i-=2;
     }
     else {
       ans = mul(ans, b);
       k-=2; j-=2;
     }
    }
    if(k){
        if(!zero.empty()){
            ans=0;
        }
        else{
            for(ll l=0;l<K;l++){
               ans=mul(ans,v[l].first * v[l].second);
            }
        }
    }
    cout<<ans<<endl;
    return;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:40:17: error: 'pcur' was not declared in this scope
   40 |     while(k && (pcur>0 || ncur>0)){
      |                 ^~~~
a.cc:40:27: error: 'ncur' was not declared in this scope
   40 |     while(k && (pcur>0 || ncur>0)){
      |                           ^~~~
a.cc:43:12: error: 'p' was not declared in this scope
   43 |        a = p[i] * p[i-1];
      |            ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int main(){
	int n, k;
	cin >> n >> k;
	int neg = 0, pos = 0, zero = 0;
	vector<ll> posis, negs;
	for(int i = 0; i < n; i++){
		ll cur;
		cin >> cur;
		if(cur == 0){
			zero++;
		}else if(cur < 0){
			neg++;
			negs.push_back(-cur);
		}else{
			pos++;
			posis.push_back(cur);
		}
	}
	sort(posis.begin(), posis.end());
	sort(negs.begin(), negs.end());
	ll sol = 1, count = 0;
	if(pos >= k - neg + (neg % 2) && pos > 0){
		int pos_pointer = posis.size() - 1, negs_pointer = negs.size() - 1;
		while(count < k){
			if(pos_pointer < 0 || (pos_pointer == 0 && count == k - 2)){
				sol = (sol * negs[negs_pointer]) % MOD;
				sol = (sol * negs[negs_pointer - 1]) % MOD;
				negs_pointer--;
				negs_pointer--;
				count++;
				count++;
				continue;
			}
			if(negs_pointer <= 0 || count == k - 1){
				sol = (sol * posis[pos_pointer]) % MOD;
				pos_pointer--;
				count++;
				continue;
			}
			ll cur_pos = posis[pos_pointer] * posis[pos_pointer - 1];
			ll neg_pos = negs[negs_pointer] * negs[negs_pointer - 1];
			if(cur_pos >= neg_pos){
				sol = (sol * posis[pos_pointer]) %  MOD;
				sol = (sol * posis[pos_pointer - 1]) %  MOD;
				pos_pointer -= 2;
				count += 2;
			}else{
				sol = (sol * negs[negs_pointer]) %  MOD;
				sol = (sol * negs[negs_pointer - 1]) %  MOD;
				negs_pointer -= 2;
				count += 2;
			}
		}
		cout << sol << '\n';
	}else if (pos + neg + zero >= k && zero > 0){
		cout << 0 << '\n';
	}else{
		int posi_i = 0, neg_i = 0;
		bool is = false;
		while(count < k){
			if(count == k - 1 && !is){
				sol = (sol * negs[neg_i]) % MOD;
				count++;
				neg_i++;
				is = true
				continue;
			}
			if(neg_i == negs.size() - 1){
				sol = (sol * posis[pos_i]) % MOD;
				count++;
				posi_i++;
				continue;
			}
			if(pos_i == posis.size() - 1){
				sol = (sol * negs[neg_i]) % MOD;
				count++;
				if(is) is = false;
				else is = true;
				neg_i++;
				continue;
			}
			if(negs[neg_i] < posis[posi_i]){
				sol = (sol * negs[neg_i]) % MOD;
				count++;
				neg_i++;
				if(is) is = false;
				else is = true;
				continue;
			}else{
				sol = (sol * posis[posi_i]) % MOD;
				count++;
				posi_i++;
				continue;
			}
		}
		cout << (-sol + MOD) % MOD << '\n';
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:73:42: error: expected ';' before 'continue'
   73 |                                 is = true
      |                                          ^
      |                                          ;
   74 |                                 continue;
      |                                 ~~~~~~~~  
a.cc:77:52: error: 'pos_i' was not declared in this scope; did you mean 'posi_i'?
   77 |                                 sol = (sol * posis[pos_i]) % MOD;
      |                                                    ^~~~~
      |                                                    posi_i
a.cc:82:28: error: 'pos_i' was not declared in this scope; did you mean 'posi_i'?
   82 |                         if(pos_i == posis.size() - 1){
      |                            ^~~~~
      |                            posi_i
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int main(){
	int n, k;
	cin >> n >> k;
	int neg = 0, pos = 0, zero = 0;
	vector<ll> posis, negs;
	for(int i = 0; i < n; i++){
		ll cur;
		cin >> cur;
		if(cur == 0){
			zero++;
		}else if(cur < 0){
			neg++;
			negs.push_back(-cur);
		}else{
			pos++;
			posis.push_back(cur);
		}
	}
	sort(a.begin(), a.end());
	sort(posis.begin(), posis.end());
	sort(negs.begin(), negs.end());
	ll sol = 1, count = 0;
	if(pos >= k - neg + (neg % 2) && pos > 0){
		int pos_pointer = posis.size() - 1, negs_pointer = negs.size() - 1;
		while(count < k){
			if(pos_pointer < 0 || (pos_pointer == 0 && count == k - 2)){
				sol = (sol * negs[negs_pointer]) % MOD;
				sol = (sol * negs[negs_pointer - 1]) % MOD;
				negs_pointer--;
				negs_pointer--;
				count++;
				count++;
				continue;
			}
			if(negs_pointer <= 0 || count == k - 1){
				sol = (sol * posis[pos_pointer]) % MOD;
				pos_pointer--;
				count++;
				continue;
			}
			ll cur_pos = posis[pos_pointer] * posis[pos_pointer - 1];
			ll neg_pos = negs[negs_pointer] * negs[negs_pointer - 1];
			if(cur_pos >= neg_pos){
				sol = (sol * posis[pos_pointer]) %  MOD;
				sol = (sol * posis[pos_pointer - 1]) %  MOD;
				pos_pointer -= 2;
				count += 2;
			}else{
				sol = (sol * negs[negs_pointer]) %  MOD;
				sol = (sol * negs[negs_pointer - 1]) %  MOD;
				negs_pointer -= 2;
				count += 2;
			}
		}
		cout << sol << '\n';
	}else if (pos + neg + zero >= k && zero > 0){
		cout << 0 << '\n';
	}else{
		for(int i = 0; i < negs.size(); i++){
			if(count == k) break;
			sol = ((sol * negs[i])) % MOD;
			count++;
		}
		if(count < k){
			for(int i = 0; i < posis.size(); i++){
				sol = (sol * posis[i]) % MOD;
			}
		}
		cout << (-sol + MOD) % MOD << '\n';
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:14: error: 'a' was not declared in this scope
   27 |         sort(a.begin(), a.end());
      |              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
const long long int mod=1000000000+7;

long long int mul(long long int x,long long int y)
{
	
   long long int ans=(x%m * 1ll * y%m) % mod;
   while(ans<0)
   	ans+=mod;
   	return ans;
}

long long int check(long long int A[],long long int n,long long int k) 
{ 
    sort(A, A + n); 
   long long int 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=mul(product,A[i]);
        while(product<0)
        	product+=mod;
        return (product%mod); 
    } 
    long long int i = 0; 
   long long int j = n - 1; 
    if (k & 1) { 
        product=mul(product,A[i]);
        j--; 
        k--; 
    } 
    k >>= 1; 
    for (int itr = 0; itr < k; itr++) { 
       long long int left_product =mul(A[i+1],A[i]);
       long long int right_product =mul(A[j-1],A[j]); 
        if (left_product > right_product) { 
           product=mul(product,left_product);
            i += 2; 
        } 
        else { 
          product=mul(product,right_product);
            j -= 2; 
        } 
    } 
    while(product<0)
    	product+=mod;
    return (product%mod); 
} 

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a,k;
	cin>>a>>k;
	long long int b[a];
	forr(i,0,a)
		cin>>b[i];
	long long int x=check(b,a,k);
	while(x<0)
		x+=mod;
	cout<<x;
	
	return 0; 	
}

Compiler output:
a.cc: In function 'long long int mul(long long int, long long int)':
a.cc:10:25: error: 'm' was not declared in this scope
   10 |    long long int ans=(x%m * 1ll * y%m) % mod;
      |                         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define vpii vector<pair<int,int>>

ll MOD = 1e9+7;

ll bpow(ll n,ll m)
{
  if(m==0) return 1;
  ll ans = bpow(n,m/2);
  ans = (ans*ans)%MOD;
  if(m%2 == 1) ans = (ans*n)%MOD;
  return ans;
}

ll inverse(ll n)
{
  return bpow(n,MOD-2);
}

void solve()
{
  int n,k;
  cin>>n>>k;
  vpii a(n);
  int totneg = 0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i].first;
    if(a[i].first<0)
    {
      a[i].second = 1;
      a[i].first *=-1;
      totneg++;
    }
    else
    {
      a[i].second = 0;
    }
  }
  sort(a.begin(),a.end());
  ll prod = 1,nneg=0,firstneg=-1;
  if(totneg == n)
  {
    for(int i=0;i<k;i++)
    {
      prod = (prod*a[iffirst)%MOD;
    }
    if(k%2) prod = (prod*-1 + MOD)%MOD;
    cout<<prod<<"\n";
    return;
  }
  
  for(int i=n-k;i<n;i++)
  {
      if(a[i].second == 1 && firstneg == -1)
      {
        firstneg = i;
      }
      if(a[i].second == 1)
      {
        nneg++;
      }
      prod = (prod*a[i].first)%MOD;
  }
  if(nneg%2 == 0)
  {
    cout<<prod<<'\n';
    return;
  }
  ll maxpos = -1,lneg=-1;
  for(int i=n-k-1;i>=0;i--)
  {
    if(a[i].second == 0)
    {
      maxpos = a[i].first;
      break;
    }
  }
  if(maxpos != -1){ 
    prod = ((prod*inverse(a[firstneg].first))%MOD*maxpos)%MOD;
    cout<<prod<<'\n';
    return;
  }
  for(int i=0;i<n-k;i++)
  {
    if(a[i].second == 1)
    {
      lneg = a[i].first;
    }
  }
  lneg *=-1;
  prod = ((prod*inverse(a[firstneg].first))%MOD*lneg + MOD)%MOD;
  cout<<prod<<endl;
}

int main()
{
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:53:22: error: 'iffirst' was not declared in this scope
   53 |       prod = (prod*a[iffirst)%MOD;
      |                      ^~~~~~~
a.cc:53:29: error: expected ']' before ')' token
   53 |       prod = (prod*a[iffirst)%MOD;
      |                             ^
      |                             ]
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}



int main() {
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for (ll i=0;i<n;i++)cin >> a[i];
    vector<ll> p;
    vector<ll> m;
    for (ll i=0;i<n;i++){
        if (a[i]>0)p.push_back(a[i]);
        else m.push_back(a[i]);
    }
    if (p.size())sort(ALL(p));
    if (m.size())sort(ALL(m),greater<ll>());
    vector<ll> ansvec;
    ll ans=1;
    ll x=p.size()-1,y=m.size()-1;
    ll c=0;
    for (ll i=0;i<k;i++){
        if (x>=0 and y>=0){
            if (p[x]>abs(m[y])){¥
                ansvec.push_back(p[x]);
                x--;
            }else{
                ansvec.push_back(m[y]);
                y--;
                c++;
            }
        }else if(x>=0){
            ansvec.push_back(p[x]);
            x--;
        }else if (y>=0){
            ansvec.push_back(m[y]);
            y--;
            c++;
        }
    }
    if(c%2==1 and x>=0){
        sort(ALL(ansvec));
        ll f=-INF;
        for (ll i=0;i<n;i++){
            if (ansvec[i]<0){
                f=max(ansvec[i],f);
            }
        }
        ansvec.push_back(p[x]);
        for (ll i=0;i<ansvec.size();i++){
            if (ansvec[i]==f)continue;
            ans*=ansvec[i];
            ans%=MOD;
        }
        cout << ans << endl;
    }else{
        for (ll i=0;i<ansvec.size();i++){
            ans*=ansvec[i];
            ans%=MOD;
        }
        cout << ans << endl;
    }
    return 0;
}


Compiler output:
a.cc:51:33: error: extended character ¥ is not valid in an identifier
   51 |             if (p[x]>abs(m[y])){¥
      |                                 ^
a.cc: In function 'int main()':
a.cc:51:33: error: '\U000000a5' was not declared in this scope
   51 |             if (p[x]>abs(m[y])){¥
      |                                 ^
Language: C++

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
long M=1e9+7;
int main(){
ll n,k;
  cin>>n>>k;
ll a[n];
ll   r=n-1;
ll ans=1;
ll b;
  for(ll i=0;i<n;i++)
cin>>a[i];
  sort(a,a+n);
  if(k%2)
{ans=a[r];
r--;
k--;
b=(ans<0?-1:1);
}
  while(k){
   ll  x=a[l]*a[l+1];
ll y=a[r]*a[r-1];
    if(x*b>y*b)ans*=x%M,ans%=M,l+=2;
    else ans*=y%M,ans%=M,r-=2;
    k-=2;
  }
  cout<<(ans+M)%M<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: 'l' was not declared in this scope
   22 |    ll  x=a[l]*a[l+1];
      |            ^