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

#include <algorithm>
#include <chrono>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

ll inv(ll x) {
  ll e = MOD - 2;
  ll res = 1;
  while (e) {
    if (e & 1) res = res * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return res;
}

int main() {
  int n, k;
  cin >> n >> k;
  ll a;
  vector<ll> minus;
  vector<pair<ll, ll>> item;
  rep(i, 0, n) {
    cin >> a;
    item.emplace_back(abs(a), a);
    if (a < 0) minus.push_back(a);
  }

  ll ans = 1;
  if ((int)minus.size() == n) {
    if (k & 1)
      sort(minus.rbegin(), minus.rend());
    else
      sort(minus.begin(), minus.end());
    rep(i, 0, k) ans = (MOD + ans * minus[i] % MOD) % MOD;
  } else {
    sort(item.rbegin(), item.rend());
    int used_minus = 0;
    ll p = INFL, m = INFL;
    rep(i, 0, k) {
      ll x = item[i].second;
      if (x < 0) {
        used_minus++;
        m = item[i].second;
      } else
        p = item[i].second;

      ans = (MOD + ans * x % MOD) % MOD;
    }

    if (used_minus & 1) {
      ll mx = -1;
      rep(i, k, n) if (item[i].second >= 0) mx = max(mx, item[i].second);
      // m nozoku, mx tuika

      ll mn = INFL;
      rep(i, k, n) if (item[i].second < 0) mn = min(mn, item[i].second);
      // p nozoku, mn tuika
      // ans / m * mx < ans / p * mn
      // p * mx < m * mn
      if (mx != -1 && mn != INFL) {
        if (p != INFL && mn != INFL && abs(p * mx) <= abs(m * mn))
          ans = (MOD + ans * inv(p) % MOD * (MOD + mn)) % MOD;
        else
          ans = (MOD + ans * inv(MOD + m) % MOD * mx) % MOD;
      }
    }
    cout << ans << '\n';
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
  }

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

#include<iostream>
#include<cmath>
using namespace std;
const int BUF = 200005;
const int MOD = 1000000007;
const int INF = 1<<30;


int nVal, nPick;
int val[BUF];

void read() {
    cin >> nVal >> nPick;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
    }
}


void work() {
    int nNeg = 0, nZero = 0, nPos = 0;
    int neg[BUF], pos[BUF];

    for (int i = 0; i < nVal; ++i) {
        if (val[i] < 0) {
            neg[nNeg++] = val[i];
        } else if (val[i] > 0) {
            pos[nPos++] = val[i];
        } else {
            ++nZero;
        }
    }

    sort(neg, neg + nNeg);
    sort(pos, pos + nPos);

    double posLogSum[BUF];
    posLogSum[0] = log(pos[0]);
    for (int i = 1; i < nPos; ++i) {
        posLogSum[i] = posLogSum[i - 1] + log(pos[i]);
    }
    
    double maxV = -INF;
    int nNegPickMax;
    double cur = 0;
    for (int nNegPick = 0; nNegPick <= min(nNeg, nPick); nNegPick += 2) {
        if (nNegPick) {
            cur += log(fabs(neg[nNegPick - 1]));
            cur += log(fabs(neg[nNegPick - 2]));
        }
        
        int nRemainPick = nPick - nNegPick;
        if (nRemainPick > nPos) {
            if (nZero) maxV = max(maxV, -INF + 1.0);
            continue;
        }
        
        double sum = posLogSum[nPos - 1] - (nRemainPick == nPos ? 0 : posLogSum[nPos - 1 - nRemainPick]);
        if (maxV < cur + sum) {
            maxV = cur + sum;
            nNegPickMax = nNegPick;
        }
    }

    if (maxV > -INF) {
        if (maxV == -INF + 1) {
            cout << 0 << endl;
            return;
        }
        int ans = 1;
        for (int i = 0; i < nNegPickMax; ++i) {
            ans = 1LL * ans * (MOD + neg[i]) % MOD;
        }
        for (int i = 0; i < nPos - nNegPickMax; ++i) {
            ans = 1LL * ans * pos[nPos - 1 - i] % MOD;
        }
        cout << ans << endl;
        return;
    }

    
    reverse(neg, neg + nNeg);

    double minV = INF;
    
    cur = log(fabs(neg[0]));
    for (int nNegPick = 1; nNegPick <= min(nNeg, nPick); nNegPick += 2) {
        if (nNegPick > 1) {
            cur += log(fabs(neg[nNegPick - 1]));
            cur += log(fabs(neg[nNegPick - 2]));
        }
        
        int nRemainPick = nPick - nNegPick;

        if (nRemainPick > nPos) {
            continue;
        }
        
        double sum = nRemainPick == 0 ? 0 : posLogSum[nRemainPick - 1];
        if (minV > cur + sum) {
            minV = cur + sum;
            nNegPickMax = nNegPick;
        }
    }

    int ans = 1;
    for (int i = 0; i < nNegPickMax; ++i) {
        ans = 1LL * ans * (MOD + neg[i]) % MOD;
    }
    for (int i = 0; i < nPos - nNegPickMax; ++i) {
        ans = 1LL * ans * pos[i] % MOD;
    }
    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


Compiler output:
a.cc: In function 'void work()':
a.cc:34:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   34 |     sort(neg, neg + nNeg);
      |     ^~~~
      |     sqrt
a.cc:82:5: error: 'reverse' was not declared in this scope
   82 |     reverse(neg, neg + nNeg);
      |     ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long mood = 1e9 + 7;
long long arr[maxn];
bool cmp(long long i, long long j)
{
	return abs(i) > abs(j);
}
inline posit(long long x)
{
	return (x + mood) % mood;
}
long long cl()
{
	int n, kk, tot = 0;
	long long ans = 1LL;
	scanf("%d%d", &n, &kk);
	for(int i = 1; i <= n; i ++)
	{
		scanf("%lld", &arr[i]);
	}
	
	sort(arr + 1, arr + 1 + n, cmp);
	int cnt = 0; 
	for(int i = 1; i <= kk; i ++){
		if(arr[i] < 0){
			cnt ++;
		}
	}
	
	if(cnt % 2 == 0)
	{
		for(int i = 1; i <= kk; i ++)
		{
			ans *= (arr[i] + mood);
			ans %= mood;
		}
		return ans;
	}
	else
	{
		long long negbef, negaft, posbef, posaft;
		int wzngbef=-1, wzngaft=-1, wzpsbef=-1, wzpsaft=-1;
		for(int i = kk; i >= 1; i --){
			if(arr[i] < 0){
				negbef = arr[i]; wzngbef = i; break;
			}
		} 
		for(int i = kk; i >= 1; i --){
			if(arr[i] > 0){
				posbef = arr[i]; wzpsbef = i; break;
			}
		} 
		for(int i = kk+ 1; i <= n; i ++){
			if(arr[i] < 0){
				negaft = arr[i]; wzngaft = i; break;
			}
		}
		for(int i = kk+ 1; i <= n; i ++){
			if(arr[i] > 0){
				posaft = arr[i]; wzpsaft = i; break;
			}
		}
		if(wzngbef !=-1 && wzngaft !=-1 && wzpsbef !=-1 && wzpsaft!=-1)
		{
			if(negbef * negaft > posbef * posaft){
				ans *= (negbef * negaft % mood);
				ans %= mood;
			}
			else{
				ans *= (posbef * posaft % mood);
				ans %= mood;
			}
			return ans;
		}
		if((wzngbef != -1 && wzpsaft != -1) || (wzpsbef != -1 && wzngaft != -1)){
			for(int i = 1; i <= kk; i ++){
				if(i != wzngbef && i != wzpsbef){
					ans *= (arr[i] + mood);
					ans %= mood;
				}
			}
			
			if((wzpsbef != -1 && wzngaft != -1)){
				//cout << posbef <<" "<<posit(negaft)<<"\n";
				ans *= posit(negaft) % mood;
				ans %= mood;
				if(wzngbef != -1){
					ans *= posit(negbef); ans %= mood;
				}
//		cout <<ans<<" "<< wzngbef<<" "<<wzngaft<<" "<<wzpsbef<<" "<<wzpsaft<<endl;
			}
			else{
				ans *= posaft % mood;
				ans %= mood;
				if(wzpsbef != -1){
					ans *= posbef; ans %= mood;
				}
			}
			return ans;
		}
		for(int i = n - kk + 1; i <= n; i ++){
			ans *= (arr[i] + mood);
			ans %= mood;
		}
		return ans;
	}
	
	
}
int main()
{
	printf("%lld\n", cl());
	return 0;
} 

/*5 3
9 -4 8 -2 -5

5 3
9 8 -5 -4 -2
*/

Compiler output:
a.cc:10:8: error: ISO C++ forbids declaration of 'posit' with no type [-fpermissive]
   10 | inline posit(long long x)
      |        ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
long long n,k,a[200005],pos[200005],neg[200005],sp[200005],sn[200005],ans,cnt,flag,top1,top2;
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)cin>>a[i];
top1=top2=0;flag=0;
for(int i=1;i<=n;i++)
	{
	if(a[i]==0)flag=1;
	if(a[i]>0)pos[++top1]=a[i];
	if(a[i]<0)neg[++top2]=a[i];
	}
sort(neg+1,neg+top2+1);
sort(pos+1,pos+top1+1);
sp[0]=1;sn[0]=1;
for(int i=1;i<=top1;i++)sp[i]=sp[i-1]*pos[top1-i+1]%mod;
for(int i=1;i<=top2;i++)sn[i]=sn[i-1]*neg[i]%mod;
if((top1==0)&&(k%2>0))
	{
	if(flag==1)cout<<0;
	else{
		ans=1;
		for(int i=top2;i>=top2-k+1;i--)ans=ans*neg[i]%mod;
		while(ans<0)ans+=mod;
		cout<<ans;
		}
	}
else{
ans=1;cnt=1;
	for(int i=0;i<=min(k,top1);i++)
	{
	if(i+top<k)continue;
	cnt=sp[i]*sn[k-i]%mod;
	if(cnt>ans)ans=cnt;
	}
cout<<ans;
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:14: error: 'top' was not declared in this scope; did you mean 'top2'?
   35 |         if(i+top<k)continue;
      |              ^~~
      |              top2
Language: C++

/*
ID: alec3
LANG: C++14
PROG:
*/

#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int pct(int x) { return __builtin_popcount(x); }
bool absComp (int i, int j) { return (abs(i) < abs(j)); }


const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}
int main()
{
    io;
    int n, k;
    cin >> n >> k;

    vector<ll> a, apos, aneg;
    FOR(i, 0, n){
        int it;
        cin >> it;
        a.pb(abs(it));
        if (it > 0)
            apos.pb(it);
        if(it < 0)
            aneg.pb(it);
    }
    int szp = apos.size(), szn = aneg.size();

    ll ans = 1;
    if (szp + szn/2 * 2 >= k && (k % 2 == 0 || szp > 0)){
        sort(apos.rbegin(), apos.rend());
        sort(aneg.rbegin(), aneg.rend());

        if (k % 2)
            ans = apos[0];
        vector<ll> v;
        for (int i = k %2; i + 1 < szn; i+= 2)
            v.pb(apos[i] * apos[i+1]);
        for (int i = 0;  i + 1 < szn; i+=2)
            v.pb(aneg[i] * aneg[i+1]);
        sort(v.rbegin(), v.rend());

        for (int i = 0; i < k/2; i++)
            mul(ans, v[i] % MOD);
    }
    else {
        sort(a.begin(), a.end());
        FOR (i, 0, k)
            mul(ans, a[i]);
        ans = (MOD - ans) % MOD;
    }
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:17: error: cannot bind non-const lvalue reference of type 'int64_t&' {aka 'long int&'} to a value of type 'll' {aka 'long long int'}
   69 |             mul(ans, v[i] % MOD);
      |                 ^~~
a.cc:33:19: note:   initializing argument 1 of 'void mul(int64_t&, int64_t)'
   33 | void mul(int64_t& a, int64_t b){
      |          ~~~~~~~~~^
a.cc:74:17: error: cannot bind non-const lvalue reference of type 'int64_t&' {aka 'long int&'} to a value of type 'll' {aka 'long long int'}
   74 |             mul(ans, a[i]);
      |                 ^~~
a.cc:33:19: note:   initializing argument 1 of 'void mul(int64_t&, int64_t)'
   33 | void mul(int64_t& a, int64_t b){
      |          ~~~~~~~~~^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

bool comp(int a,int b){
  return a>b;
}

int main(){
  long long N,K;
  cin>>N>>K;
  vector<long long> pos;
  vector<long long> neg;
  for(int i=0;i<N;i++){
    long long x;
    cin>>x;
    if(x<0){
      neg.push_back(x);
    }else{
      pos.push_back(x);
    }
  }
  sort(pos.begin(),pos.end(),comp);
  sort(neg.begin(),neg.end());
  long long final=1;
  int negindex=0;
  int posindex=0;
  int negnum=0;
  vector<long long> v;
  if(pos.size()==0 && K%2==1){
    sort(neg.begin(),neg.end(),comp);
    for(int i=0;i<K;i++){
      final=(final*(1000000007+neg[i]))%1000000007;
    }
    cout<<final<<endl;
    return 0;
  }
  for(int i=0;i<K;i++){
    if(posindex==pos.size() ||(negindex<neg.size() &&neg[negindex]*-1>pos[posindex])){
      final=(final*(1000000007+neg[negindex]))%1000000007;
      v.push_back(neg[negindex]);
      negindex++;
      negnum++;
    }else{
      final=(final*pos[posindex])%1000000007;
      v.push_back(pos[posindex]);
      posindex++;
    }
  //  cout<<final<<endl;
  }
//  for(int i=0;i<K;i++){
  //  cout<<v[i]<<" ";
  //}
//  cout<<endl<<final<<endl;
  int counter;
  if(K!=N){
    if(negnum%2==1){
      if(v[K-1]<0){
        if(posindex==pos.size()){
          counter=K-1;
          while(v[counter]<0){
            counter--;
          }``
          final=final*neg[negindex]/v[counter];
        }else{//still positive left
          final=final*pos[posindex]/v[K-1];
        }
      }else{
        if(negindex==neg.size()){
          counter=K-1;
          while(v[counter]>=0){
            counter--;
          }
          final=final*pos[posindex]/v[counter];
        }else{
          final=final*neg[negindex]/v[K-1];
        }
      }
    }
  }
  cout<<final<<endl;
}


Compiler output:
a.cc:64:12: error: stray '`' in program
   64 |           }``
      |            ^
a.cc:64:13: error: stray '`' in program
   64 |           }``
      |             ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  int n, k;
  cin >> n >> k;
  
  int zero = 0;
  vector<int> pos, neg;
  pos.resize(n);
  neg.resize(n);
  
  for (int i = 0, x; i < n; i++)
  {
	cin >> x;
	if (x < 0) neg.push_back(x);
	else if (x > 0) pos.push_back(-x);
	else zero++;
  }
  
  if (zero >= k)
  {
	cout << "0";
	return 0;
  }
  
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end());
  
  long long int prod = 1;
  while (k >= 2)
  {
	int n, p;
    n = neg.size() >= 2 ? 0 : (*(neg.end() - 1) * *(neg.end() - 2));
	p = pos.size() >= 2 ? 0 : (*(pos.end() - 1) * *(pos.end() - 2));
	
	if (p >= n)
	{
	  prod *= p;
	  pos.pop_back();
	  pos.pop_back();
	}
	else
	{
	  prod *= n;
	  neg.pop_back();
	  neg.pop_back();
	}
	k -= 2;
	if (prod > (1 << 42)) prod %= 10e9 + 7;
  }
  
  if (k != 0 && !pos.empty())
  {
	prod *= *(pos.end() - 1);
  }
  prod %= 10e9 + 7;
  cout << prod;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:23: warning: left shift count >= width of type [-Wshift-count-overflow]
   58 |         if (prod > (1 << 42)) prod %= 10e9 + 7;
      |                     ~~^~~~~
a.cc:58:36: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   58 |         if (prod > (1 << 42)) prod %= 10e9 + 7;
      |                               ~~~~~^~~~~~~~~~~
a.cc:58:36: note:   in evaluation of 'operator%=(long long int, double)'
a.cc:65:8: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   65 |   prod %= 10e9 + 7;
      |   ~~~~~^~~~~~~~~~~
a.cc:65:8: note:   in evaluation of 'operator%=(long long int, double)'
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  int n, k;
  cin >> n >> k;
  
  int zero = 0;
  vector<int> pos, neg;
  pos.resize(n);
  neg.resize(n);
  
  for (int i = 0, x; i < n; i++)
  {
	cin >> x;
	if (x < 0) neg.push_back(x);
	else if (x > 0) pos.push_back(-x);
	else zero++;
  }
  
  if (zero >= k)
  {
	cout << "0";
	return 0;
  }
  
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end());
  
  long long int prod = 1;
  while (k >= 2)
  {
	n = neg.size() >= 2 ? 0 : neg.end() - 1 * neg.end() - 2;
	p = pos.size() >= 2 ? 0 : pos.end() - 1 * pos.end() - 2;
	
	if (p >= n)
	{
	  prod *= p;
	  pos.pop_back();
	  pos.pop_back();
	}
	else
	{
	  prod *= n;
	  neg.pop_back();
	  neg.pop_back();
	}
	k -= 2;
	if (prod > (1 << 42)) prod %= 10e9 + 7;
  }
  
  if (k != 0 && !pos.empty())
  {
	prod *= pos.end();
  }
  prod %= 10e9 + 7;
  cout << prod;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:49: error: no match for 'operator*' (operand types are 'int' and 'std::vector<int>::iterator')
   41 |         n = neg.size() >= 2 ? 0 : neg.end() - 1 * neg.end() - 2;
      |                                               ~ ^ ~~~~~~~~~
      |                                               |          |
      |                                               int        std::vector<int>::iterator
a.cc:42:9: error: 'p' was not declared in this scope
   42 |         p = pos.size() >= 2 ? 0 : pos.end() - 1 * pos.end() - 2;
      |         ^
a.cc:42:49: error: no match for 'operator*' (operand types are 'int' and 'std::vector<int>::iterator')
   42 |         p = pos.size() >= 2 ? 0 : pos.end() - 1 * pos.end() - 2;
      |                                               ~ ^ ~~~~~~~~~
      |                                               |          |
      |                                               int        std::vector<int>::iterator
a.cc:57:23: warning: left shift count >= width of type [-Wshift-count-overflow]
   57 |         if (prod > (1 << 42)) prod %= 10e9 + 7;
      |                     ~~^~~~~
a.cc:57:36: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   57 |         if (prod > (1 << 42)) prod %= 10e9 + 7;
      |                               ~~~~~^~~~~~~~~~~
a.cc:57:36: note:   in evaluation of 'operator%=(long long int, double)'
a.cc:62:14: error: no match for 'operator*=' (operand types are 'long long int' and 'std::vector<int>::iterator')
   62 |         prod *= pos.end();
      |         ~~~~~^~~~~~~~~~~~
a.cc:64:8: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   64 |   prod %= 10e9 + 7;
      |   ~~~~~^~~~~~~~~~~
a.cc:64:8: note:   in evaluation of 'operator%=(long long int, double)'
Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

long gyaku(long a, long mod){
  long s = 1, tmp = a, t = mod - 2;
  while(t > 0){
    if(t % 2 == 1){
      s *= tmp;
      s %= mod;
    }
    t /= 2;
    tmp *= tmp;
    tmp %= mod;
  }
  return s;
}

int main(){
  long ans = 1, mod = 1000000007; int n, l = 0, la = 0, lb = 0; cin >> n;
  vector<long> v(n), a = {}, b = {}; rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  while(l < n){
    if(l < n-1 && v[l] < 0 && v[l+1] < 0){
      b.push_back(v[l] * v[l+1]);
      l += 2;
    }
    else{
      a.push_back(v[l]);
      ++l;
    }
  }
  reverse(a.begin(), a.end());
  while(k > 0){
    if(k > 1){
      if(la < (int)a.size() && lb <(int) b.size()){
        if(a[la] * a[la + 1] > b[lb]){
          ans *= a[la];
          ans %= mod;
          ++la;
          --k;
        }
        else{
          ans *= b[lb] % mod;
          ans %= mod;
          ++lb;
          k -= 2;
        }
      }
      else if(la < (int)a.size()){
        ans *= a[la];
        ans %= mod;
        ++la;
        --k;
      }
      else{
        ans *= b[lb] % mod;
        ans %= mod;
        ++lb;
        k -= 2;
      }
    }
    else{
      if(lb < (int)b.size() && b[lb] > a[la-1] * a[la]){
        ans *= gyaku(a[la-1], mod);
        ans %= mod;
        ans *= b[lb] % mod;
        ans %= mod;
        --k;
      }
      else{
        ans *= a[la];
        ans %= mod;
        --k;
      }
    }
  }
  cout << ans << "\n;
  return 0;
}

Compiler output:
a.cc:78:18: warning: missing terminating " character
   78 |   cout << ans << "\n;
      |                  ^
a.cc:78:18: error: missing terminating " character
   78 |   cout << ans << "\n;
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:34:9: error: 'k' was not declared in this scope
   34 |   while(k > 0){
      |         ^
a.cc:79:3: error: expected primary-expression before 'return'
   79 |   return 0;
      |   ^~~~~~
Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

long gyaku(long a, long mod){
  long s = 1, tmp = a, t = mod - 2;
  while(t > 0){
    if(t % 2 == 1){
      s *= tmp;
      s %= mod;
    }
    t /= 2;
    tmp *= tmp;
    tmp %= mod;
  }
  return s;
}

int main(){
  long ans = 1, mod = 1000000007; int n, l = 0, la = 0, lb = 0; cin >> n;
  vector<long> v(n), a = {}, b = {}; rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  while(l < n){
    if(l < n-1 && v[l] < 0 && v[l+1] < 0){
      b.push_back(v[l] * v[l+1]);
      l += 2;
    }
    else{
      a.push_back(v[l]);
      ++l;
    }
  }
  reverse(a.begin(), a.end());
  while(k > 0){
    if(k > 1){
      if(la < a.size() && lb < b.size()){
        if(a[la] * a[la + 1] > b[lb]){
          ans *= a[la];
          ans %= mod;
          ++la;
          --k;
        }
        else{
          ans *= b[lb] % mod;
          ans %= mod;
          ++lb;
          k -= 2;
        }
      }
      else if(la < a.size()){
        ans *= a[la];
        ans %= mod;
        ++la;
        --k;
      }
      else{
        ans *= b[lb] % mod;
        ans %= mod;
        ++lb;
        k -= 2;
      }
    }
    else{
      if(lb < b.size() && b[lb] > a[la-1] * a[la]){
        ans *= gyaku(a[la-1], mod);
        ans %= mod;
        ans *= b[lb] % mod;
        ans %= mod;
        --k;
      }
      else{
        ans *= a[la];
        ans %= mod;
        --k;
      }
    }
  }
  cout << ans << "\n;
  return 0;
}

Compiler output:
a.cc:78:18: warning: missing terminating " character
   78 |   cout << ans << "\n;
      |                  ^
a.cc:78:18: error: missing terminating " character
   78 |   cout << ans << "\n;
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:34:9: error: 'k' was not declared in this scope
   34 |   while(k > 0){
      |         ^
a.cc:79:3: error: expected primary-expression before 'return'
   79 |   return 0;
      |   ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define ff first
#define ss second
#define N 1000000007
#define INF (1ll<<60) - 1
#define M 998244353
#define rep(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define nrep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,x,y,q,n,z,l,k,r,ans=0,m;
    cin>>n>>k;
    vector<ll> v,vv;
    rep(i,1,n){
    	cin>>x;
    	if(x>0) v.pb(x);
    	else if(x<0) vv.pb(x);
	}
	if(v.size() + vv.size() < k){
		cout<<0;
		return 0;
	}
	sort(v.begin(),v.end());
	sort(vv.begin(),vv.end());
	if(v.size() == 0){
		if(k%2){
			ans = 1ll;
			i=vv.size()-1;
			while(k--){
				ans= (ans*vv[i])%N;
				if(ans<0) ans+=N;
				ans%=N;
				i--;
			}
			cout<<ans;
			return 0;
		}else{
			ans=1ll;
			for(i=0;i<k;i++){
				ans = (ans*vv[i])%N;
				if(ans<0) ans+=N;
				ans%=N;
			}
			cout<<ans;
		}
		return 0;
	}
	if(k==n){
		ans=1ll;
		for(i=0;i<v.size();i++){
			ans = (ans*v[i])%N;
			if(ans<0) ans+=N;
			ans%=N;
		} 
		for(i=0;i<vv.size();i++){
			ans = (ans*vv[i])%N;
			if(ans<0) ans+=N;
			ans%=N;
		} 
		cout<<ans;
		return 0;
	}
	i=v.size()-1;
	j=0;
	m = vv.size();
	ans=1ll;
	while(k>0){
		if(k!=1){
			ll neg=0,pos=0;
			if(j+1<m) neg = vv[j]*vv[j+1];
			if(i>0) pos = v[i]*v[i-1];
			if(pos>neg){
				ans = (ans*pos)%N;
				i-=2;
			}else{
				ans = (ans*neg)%N;
				j+=2;
			}
			k-=2;
		}else{
			ans = (ans*v[i])%N;
			k--;
		
	}
	cout<<ans;
	
}

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

#include<iostream>
#include<algorithm>

using namespace std;

#define MOD 1000000007
typedef unsigned long long ULL;
typedef long long LL;
bool checker(LL a, LL b){
    if( abs(a) < abs(b)){
        return true;
    }else{
        return false;
    }
}
bool rchecker(LL a, LL b){
    return !checker(a,b);
}
bool MinusCheck(int mem_of_plus, int mem_of_minus, int K){
    if( mem_of_plus + mem_of_minus - mem_of_minus % 1 < K){
        return true;
    }
    
    if( mem_of_plus == 0 && K % 2 == 1){
        return true;
    }
    return false;
}
int main(){
    LL *A;
    LL *minus;
    LL *plus;
    LL *calc;
    int mem_of_plus,mem_of_minus,mem_of_calc;
    int K,N;
    int i,j,pos;
    LL ans;
    LL a;
    int count;
    LL bef;
    cin >> N >> K;
    A = new LL[N];
    plus = new LL[N];
    minus = new LL[N];
    calc = new LL[N];

    mem_of_plus = mem_of_minus = 0;
    for(i=0;i<N;i++){
        cin >> a;
        if( a >= 0 ){
            plus[mem_of_plus++] = a;
        }else{
            minus[mem_of_minus++] = a;
        }
        A[i] = a;
    }

    //どうあがいてもマイナス
    if( 
        MinusCheck(mem_of_plus, mem_of_minus, K) == true ){
        ans = 1;
        sort(A,A+N,checker);
        for(i=0;i<K;i++){
            ans = ans * A[i];
            ans %= MOD;
            if( ans < 0 ){
                ans += MOD;
            }
        }
    }else{
        sort(minus,minus+mem_of_minus);
        sort(plus,plus + mem_of_plus,std::greater<LL>());
        if(K % 2 == 1){
            i=2;
        }else{
            i=1;
        }
        mem_of_calc = 0;
        for(;i<mem_of_plus;i+=2){
            calc[mem_of_calc++] = plus[i-1] * plus[i];
        }
        for(i=1;i<mem_of_minus;i+=2){
            calc[mem_of_calc++] = minus[i-1] * minus[i];
        }
        sort(calc,calc + mem_of_calc,std::greater<LL>());
        if(K % 2 == 1){
            ans = plus[0];
        }else{
            ans = 1;
        }
        for(i=0;i<K/2;i++){
            ans = ans * (calc[i] % MOD);
            ans %= MOD;
            if( ans < 0 ){
                ans += MOD;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

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

#define ll long long
#define mod1 1000000007

int main()
{
    ll i, n, k, x, y, sign, ans, p, q, r, s, p1, q1, r1, s1;

    cin >> n >> k;

    ll a[n];
    for(i=0; i<n; i+=1)
        cin >> a[i];

    vector <pair<int, int> > v;

    for(i=0; i<n; i+=1)
    {
        x=abs(a[i]);
        y=1;
        if(a[i]<0)
            y*=-1;
        v.push_back(make_pair(x, y));
    }

    sort(v.begin(), v.end());

    sign=0;
    for(i=n-1; i>=n-k; i-=1)
    {
        if(v[i].second==-1)
            sign=(sign+1)%2;
        i-=1;
        k-=1;
    }

    if(sign==0)
    {
        ans=1;
        for(i=n-1; i>=n-k; i-=1)
        {
            ans*=v[i].first;
            ans%=mod1;
        }

        cout << ans << endl;
    }
    else
    {
        p=q=r=s=-1;
        i=n-k;
        while(i<n && p==-1 && q==-1)
        {
            if(a[i].second==1)
                p=i;
            else
                q=i;
        }
        i=n-k-1;
        while(i>=0 && r==-1 && s==-1)
        {
            if(a[i].second==1)
                r=i;
            else
                s=i;
        }

        if(p!=-1 && s!=-1 && q!=-1 && r!=-1)
        {
            p1=v[p].first;
            s1=v[s].first;
            q1=v[q].first;
            r1=v[r].first;

            if(((1.0*p1)/s1)>((1.0*q1)/r1))
            {
                x=q;
                y=r;
            }
            else
            {
                x=p;
                y=s;
            }
        }
        else if(p!=-1 && s!=-1)
        {
            x=p;
            y=s;
        }
        else if(q!=-1 && r!=-1)
        {
            x=q;
            y=r;
        }
        else
        {
            ans=1;
            for(i=n-1; i>=n-k; i-=1)
            {
                ans*=v[i].first;
                ans%=mod1;
            }
            ans*=-1;
            ans%=mod1;
            cout << ans << endl;
            return 0;
        }

        ans=1;
        for(i=n-1; i>=n-k; i-=1)
        {
            if(i!=x)
            {
                ans*=v[i].first;
                ans%=mod1;
            }
        }
        ans*=v[y].first;
        ans%=mod1;

        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:21: error: request for member 'second' in 'a[i]', which is of non-class type 'long long int'
   56 |             if(a[i].second==1)
      |                     ^~~~~~
a.cc:64:21: error: request for member 'second' in 'a[i]', which is of non-class type 'long long int'
   64 |             if(a[i].second==1)
      |                     ^~~~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i = 0; i<n; ++i){
    cin>>arr[i];
  }
  sort(arr, arr+n);
  int maxprod = arr[0], minprod = arr[0],x,y;
  int dp[n+1] = {0}; /* max till i elements */
  for(int i = 1; i<k; ++i){
    dp[i] = maxprod;
    maxprod *= arr[i];
  }
  minprod = maxprod;
  dp[k] = maxprod;
  for(int i = k+1; i<=n; ++i){
  	x = max(dp[i-1], max((dp[i-1]/dp[i-k])*arr[i-1], (dp[i-1]/dp[i-2])*arr[i-1]))%(1000000007);
    y = min(dp[i-1], min((dp[i-1]/dp[i-k])*arr[i-1], (dp[i-1]/dp[i-2])*arr[i-1]))%(1000000007);
    dp[i] = max(x,y);
  }
  cout<<dp[n]%(1000000007)
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:27: error: expected ';' before '}' token
   26 |   cout<<dp[n]%(1000000007)
      |                           ^
      |                           ;
   27 | }
      | ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000000 + 7;

long long modplus(long long a, long long b){
	long long ans = a + b;
	ans %= mod;
	return ans;
}
long long modminus(long long a, long long b){
	long long ans = a - b;
	ans %= mod;
	if(ans < 0) ans += mod;
	return ans;
}
long long modmul(long long a, long long b){
	long long ans = a * b;
	ans = (ans + mod) % mod;
	return ans;
}

long long modpow(long long A, long long P){
	long long a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	long long adash = modmul(a,a);
	if(p % 2) return modmul(modpow(adash, p / 2), a);
	else return modpow(adash, p / 2);
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<long long> A;
	int mis = 0;
	for(int i=0;i<N;i++){
		long long X;
		cin >> X;
		A.push_back(X);
		if(X < 0)mis++;
	}
	sort(A.begin(), A.end());
	for(int i=0;i<N;i++){
		cout << i << ":" << A[i] << endl;
	}
	long long ans = 1;
	if(N == K){
		for(int i=0;i<N;i++){
			ans = modmul(ans, A[i]);
		}
	}
	else if(K % 2 == 1 && mis == N){
		for(int i=0;i<K;i++){
			ans = modmul(ans, A[N - i - 1]);
		}
	}
	else{
		int cnt = 0;
		vector<long long> M, P;
		for(int i=0;i<N;i++){
			if(A[i] < 0)M.push_back(A[i]);
			else P.push_back(A[i]);
		}
		reverse(P.begin(), P.end());
		int Mi = 0, Pi = 0;
		int MN = M.size(), P.size();
		while(cnt < K){
			long long tmpP = -1, tmpM = -1;
			if(Pi + 1 < PN)tmpP = P[Pi] * P[Pi + 1];
			if(Mi + 1 < MN)tmpM = M[Mi] * M[Mi + 1];
			if(tmpP > tmpM || cnt >= K - 1){
				ans = modmul(ans, P[Pi]);
				Pi++;
				cnt++;
			}
			else{
				ans = modmul(ans , tmpM);
				Mi += 2;
				cnt += 2;
			}
		}
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:37: error: expected initializer before '.' token
   66 |                 int MN = M.size(), P.size();
      |                                     ^
a.cc:69:37: error: 'PN' was not declared in this scope; did you mean 'MN'?
   69 |                         if(Pi + 1 < PN)tmpP = P[Pi] * P[Pi + 1];
      |                                     ^~
      |                                     MN
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  
  priority_queue<ll> pos, neg;
  rep(i, N){
    if(i + 1 < N) if(A[i] < 0 and A[i + 1] < 0) neg.push(A[i] * A[i+1]);
    if(A[i] >= 0) pos.push(A[i]);
  }
  
  ll ans = 1;
  ll ct = 0;
  while(!pos.empty() or !neg.empty()){
    ans %= mod;
    if(ct == K) break;
    if(pos.empty()){
      if(ct + 2 > K) break;
      ct += 2;
      ans *= neg.top() % mod;
      neg.pop();
    }else if(neg.empty()){
      ++ct;
      ans *= pos.top() % mod;
      pos.pop();
    }else{
      if(ct == K - 1){
        ans *= pos.top() % mod;
        ++ct;
        break;
      }
      if(ct == K - 2 and pos.size() ==1){
        ct += 2;
        ans *= neg.top() % mod;
        break;
      }
      ll t1 = pos.top(), pos.pop();
      ll t2 = pos.top(), pos.push(t1);
      ll sum = t1 * t2;
      if(sum >= neg.top()){
        ++ct;
        ans *= pos.top();
        pos.pop();
      }else{
        ct += 2;
        ans *= neg.top() % mod;
        neg.pop();
      }
    }
  }
  if(ct == K){
    cout << ans % mod << endl;
    return 0;
  }
  
  sort(A.rbegin(), A.rend());
  ans = 1;
  rep(i, K) ans *= A[i], ans %= mod;
  cout << ans << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:29: error: expected initializer before '.' token
   44 |       ll t1 = pos.top(), pos.pop();
      |                             ^
a.cc:45:29: error: expected initializer before '.' token
   45 |       ll t2 = pos.top(), pos.push(t1);
      |                             ^
Language: C++

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10 ** 9+ 7
    ans = 1

    def answer(a):
        ans =1
        for i in range(k):
            ans *= a[i]
            ans %= mod
        print(ans)

    if n == k:
        answer(a)
        return

    if all([True if x < 0 else False for x in a]):
        a.sort(reverse=True)
        answer(a)
        return

    a.sort(reverse=True, key=lambda x: abs(x))
    flag = 1
    for i in range(k):
        if a[i] < 0:
            flag ^= 1
    if flag or a[k-1] == 0:
        answer(a)
        return
    
    x1, x2, y1, y2 = k-1, k-1, k, k
    while a[x1]*a[x2] > 0 and x2 >= 0:
        x2 -= 1

    while a[x1]*a[y1] > 0 and y1 < n:
        y1 += 1

    if x2 == -1:
        a[x1], a[y1] = a[y1], a[x1]
    else:
        while a[x2]*a[y2] > 0 and y2 < n:
            y2 += 1
        if y1 == n:
            a[x2], a[y2] = a[y2], a[x2]
        else:
            if a[x1]*a[y2] < a[x2]*a[y1]:
                a[x1], a[y1] = a[y1], a[x1]
            else:
                a[x2], a[y2] = a[y2], a[x2]
    answer(a)
 

if __name__ == '__main__':
    main()

Compiler output:
a.cc:56:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   56 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
const int mod = 1000000007;
typedef long long ll;
 
int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> s(2e5,0), f(2e5,0);
    vector<ll> A;
    ll cntz = 0, cntpl = 0, cntmi = 0;
    rep(i,N){
        ll a;
        cin >> a;
        A.push_back(abs(a));
        if(a == 0)cntz++;
        if(a > 0){
            s.push_back(a);
            cntpl++;
        }
        if(a < 0){
            f.push_back(abs(a));
            cntmi++;
        }
    }
    sort(all(A));
    sort(all(s), greater<>());
    sort(all(f), greater<>());
    ll ans = 1;
    if(N == K){
        rep(i,K) {
          ans *= A[i];
          ans %= mod;
        }
        if(cntmi & 1)ans = (-ans%mod+mod)%mod;
        cout << (ans % MOD) << endl;
        return 0;
    }
    // K < N;
    ll idx[] = {0,0};
    if(K&1){
        if(cntpl > 0) {
          ans *= s[idx[0]++];
          ans %= mod;
        }
        else{
            rep(i,K) {
              ans *= A[i];
              ans %= mod;
            }
            ans = (-ans%mod+mod)%mod;
            cout << (ans % MOD) << endl;
            return 0;
        }
    }
    // 残りの偶数個を決めていく
    ll len = K / 2;
    while(len--){
        ll tmp[2];
        tmp[0] = s[idx[0]] * s[idx[0]+1];
        tmp[1] = f[idx[1]] * f[idx[1]+1];
        if(tmp[0] < tmp[1]){
            ans *= tmp[1];
            ans %= mod;
            idx[1] += 2;
        }
        else{
            ans *= tmp[0];
            ans %= mod;
            idx[0] += 2;
        }
    }
    cout << (ans % MOD) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:24: error: 'MOD' was not declared in this scope
   38 |         cout << (ans % MOD) << endl;
      |                        ^~~
a.cc:54:28: error: 'MOD' was not declared in this scope
   54 |             cout << (ans % MOD) << endl;
      |                            ^~~
a.cc:75:20: error: 'MOD' was not declared in this scope
   75 |     cout << (ans % MOD) << endl;
      |                    ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
const int mod = 1000000007;
typedef long long ll;
 
int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> s(2e5,0), f(2e5,0);
    vector<ll> A;
    ll cntz = 0, cntpl = 0, cntmi = 0;
    rep(i,N){
        ll a;
        cin >> a;
        A.push_back(abs(a));
        if(a == 0)cntz++;
        if(a > 0){
            s.push_back(a);
            cntpl++;
        }
        if(a < 0){
            f.push_back(abs(a));
            cntmi++;
        }
    }
    sort(all(A));
    sort(all(s), greater<>());
    sort(all(f), greater<>());
    ll ans = 1;
    if(N == K){
        rep(i,K) {
          ans *= A[i];
          ans %= mod;
        }
        if(cntmi & 1)ans = (-ans%mod+mod)%mod;
        cout << ans % MOD << endl;
        return 0;
    }
    // K < N;
    ll idx[] = {0,0};
    if(K&1){
        if(cntpl > 0) {
          ans *= s[idx[0]++];
          ans %= mod;
        }
        else{
            rep(i,K) {
              ans *= A[i];
              ans %= mod;
            }
            ans = (-ans%mod+mod)%mod;
            cout << ans % MOD << endl;
            return 0;
        }
    }
    // 残りの偶数個を決めていく
    ll len = K / 2;
    while(len--){
        ll tmp[2];
        tmp[0] = s[idx[0]] * s[idx[0]+1];
        tmp[1] = f[idx[1]] * f[idx[1]+1];
        if(tmp[0] < tmp[1]){
            ans *= tmp[1];
            ans %= mod;
            idx[1] += 2;
        }
        else{
            ans *= tmp[0];
            ans %= mod;
            idx[0] += 2;
        }
    }
    cout << ans % MOD << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:23: error: 'MOD' was not declared in this scope
   38 |         cout << ans % MOD << endl;
      |                       ^~~
a.cc:54:27: error: 'MOD' was not declared in this scope
   54 |             cout << ans % MOD << endl;
      |                           ^~~
a.cc:75:19: error: 'MOD' was not declared in this scope
   75 |     cout << ans % MOD << endl;
      |                   ^~~
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll; 

const ll MOD = 1000000007;
int N, K;
ll A[200001];

bool comp(const ll& l, const ll& r) {
  return abs(l) > abs(r);
}

void solve() {
  ll ans = 1;

  // Aiが全て負かつKが奇数のとき
  bool is_all_neg = true;
  if (K % 2 == 0) is_all_neg = false;
  else {
    for (int i = 0; i < N; i++) {
      if (A[i] >= 0) is_all_neg = false;
    }  
  }
  if (is_all_neg) {
    // 降順
    sort(A, A + N, greater<int>()); 
    for (int i = 0; i < K; i++) {
      ans *= A[i];
    }
    printf("%lld\n", (ans + MOD) % MOD);
    return;
  }

  // 絶対値の降順
  sort(A, A + N, comp);

  ll last_neg = -1; // 選んだ中での絶対値最小の負数
  ll last_pos = 0; // 選んだ中での絶対値最小の正数
  for (int i = 0; i < K; i++) {
    if (A[i] < 0) last_neg = A[i];
    else last_pos = A[i];
    ans =  (ans * A[i]) % MOD;
  }
  
  // 負数の場合
  if (ans < 0) {
    ll new_pos = -1, new_neg = 0;
    for (int i = K; i < N; i++) {
      if (A[i] < 0 && new_neg == 0) new_neg = A[i];
      else if (A[i] >= 0 && new_pos == -1) new_pos = A[i];
    }
    
    ll ans_a = ans;
    ll ans_b = ans;

    // 絶対値最小の負数を正数と入れ替える
    if (new_pos >= 0 && last_neg < 0) {
      ans_a /= last_neg;
      ans_a *= new_pos;
    }
    // 絶対値最小の正数を負数と入れ替える
    if (new_neg < 0 && last_pos >= 0) {
      ans_b /= last_pos;
      ans_b *= new_neg;
    }
    
    
    ans_c = max(ans_a, ans_b);
    ans = max(ans, ans_c);
  }
  
  printf("%lld\n", (ans + MOD) % MOD);

}

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

Compiler output:
a.cc: In function 'void solve()':
a.cc:70:5: error: 'ans_c' was not declared in this scope; did you mean 'ans_b'?
   70 |     ans_c = max(ans_a, ans_b);
      |     ^~~~~
      |     ans_b
Language: C++

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
ll a[200005];
vector<ll> b[2];

int main(void){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(a[i]>=0){
			b[0].push_back(a[i]);
		}else{
			b[1].push_back(-a[i]);
		}
	}
	sort(b[0].begin(),b[0].end());
	sort(b[1].begin(),b[1].end());
	ll ans=1;
	if(n==k){
		for(int i=0;i<b[0].size();i++){
			ans=ans*b[0][i]%MOD;
		}
		for(int i=0;i<b[1].size();i++){
			ans=ans*b[1][i]%MOD;
		}
		if(b[1].size()%2==1){
			ans=MOD-ans;
		}
	}else if(b[0].size()==0){
		if(k%2==1){
			for(int i=0;i<k;i++){
				ans=ans*b[1][i]%MOD;
			}
			ans=MOD-ans;
		}else{
			for(int i=b[1][i].size()-k;i<b[1][i].size();i++){
				ans=ans*b[1][i]%MOD;
			}
		}
	}else{
		int pos0=(int)b[0].size()-1;
		int pos1=(int)b[1].size()-1;
		if(k%2==1){
			ans=ans*b[0][pos0--]%MOD;
			k--;
		}
		for(int i=0;i<k/2;i++){
			bool flag=false;
			if(pos0-1>=0 && pos1-1>=0){
				ll v0=b[0][pos0]*b[0][pos0-1]%MOD;
				ll v1=b[1][pos1]*b[1][pos1-1]%MOD;
				if(v0<v1){
					flag=true;
				}
			}else if(pos0-1<0){
				flag=true;
			}
			if(!flag){
				ll val=b[0][pos0]*b[0][pos0-1]%MOD;
				ans=ans*val%MOD;
				pos0-=2;
			}else{
				ll val=b[1][pos1]*b[1][pos1-1]%MOD;
				ans=ans*val%MOD;
				pos1-=2;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:43: error: request for member 'size' in 'b[1].std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   41 |                         for(int i=b[1][i].size()-k;i<b[1][i].size();i++){
      |                                           ^~~~
a.cc:41:62: error: request for member 'size' in 'b[1].std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   41 |                         for(int i=b[1][i].size()-k;i<b[1][i].size();i++){
      |                                                              ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main() {
    
   int n, k, a;
   ll ans = 1;
   cin >> n >> k;
   vector<int> pos;
   vector<int> neg;
   for(int i = 0; i < n; ++i)
   {
        cin >> a;
        if(a >= 0)
            pos.push_back(a);
        else
            neg.push_back(a);
   }
   sort(pos.begin(), pos.end());
   sort(neg.begin(), neg.end());
   int ps = pos.size();
   int ns = neg.size();
   if(ns == 0)  // All elements are +ve
   {
       for(int i = ps-1; i >= ps-k ; --i)
       {
           ans = (ans*pos[i]%mod);
       }
   }
   else if(ps == 0) // All element are -ve
   {
       if((k&1) == 0) // K is even
       {
           for(int i = 0; i < k; ++i)
                ans = (ans*neg[i]%mod);
       }
       else  // k is odd
       {
           for(auto i : neg)
            cout << i << " ";
            cout << endl;
           for(int i = ns - 1; i >= ns-k ; --i)
                ans = (ans*neg[i]);
                ans = (ans%mod + mod)%mod;
       }
   }
   else  // Mixture of both +ve and -ve number
   {
       
        int l = 1;
        vector<int> arr;
        for(int i = ps - 1; i >= 0; --i)
            arr.push_back(pos[i]);
        
        for(int i = ns - 1; i >= 0; --i)
            arr.push_back(neg[i]);
       if(k >= n)
       {
           for(int i = 0; i < n; ++i)
            ans = ans*arr[i]%mod;
            ans = (ans%mod + mod)%mod;
            
       }
       else{
           
        if(k&1)
        {
            ans = arr[0];
            --k;
        }
        ll xx, yy;
        int r = n-1;
        while(k)
        {
            xx = (LL)arr[r]*arr[r-1];
            yy = (LL)arr[l]*arr[l+1];
            if(xx > yy)
                xx %= mod, ans = (ans*xx%mod), r -= 2;
            else
                yy %= mod, ans = (ans*yy%mod), l += 2;
            
            k -= 2;
        }
       }
   }
   cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:78:19: error: 'LL' was not declared in this scope; did you mean 'll'?
   78 |             xx = (LL)arr[r]*arr[r-1];
      |                   ^~
      |                   ll
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);
    int n,m;
    cin>>n>>m;
    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;
}
————————————————
版权声明：本文为CSDN博主「憨厚的小马」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
原文链接：https://blog.csdn.net/acmzhou/article/details/107154462

Compiler output:
a.cc:51:1: error: extended character — is not valid in an identifier
   51 | ————————————————
      | ^
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:51:1: error: extended character — is not valid in an identifier
a.cc:52:1: error: extended character 「 is not valid in an identifier
   52 | 版权声明：本文为CSDN博主「憨厚的小马」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
      | ^
a.cc:52:1: error: extended character 」 is not valid in an identifier
a.cc:52:65: error: extended character 。 is not valid in an identifier
   52 | 版权声明：本文为CSDN博主「憨厚的小马」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
      |                                                                 ^
a.cc:51:1: error: '\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014\U00002014' does not name a type
   51 | ————————————————
      | ^~~~~~~~~~~~~~~~