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

#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
const double esp = 1e-7;
const int ff = 0x3f3f3f3f;
map<int,int>::iterator it;

struct node
{
	ll x;
	int f;
}a[maxn];

int n,k;

bool cmp(node x,node y)
{
	return x.x> y.x;
}

ll solve(int o)
{
	ll ans = 1;
	int cnt = 0;
	if(o == 0)//从前往后乘
	{
		for(int i = 1;i<= k;i++)
		{
			ans = (ans*a[i].x)%mod;
			if(a[i].f == 1)
				cnt++;
		}
	}
	else//从后往前乘
	{
		for(int i = n;i> n-k;i--)
		{
			ans = (ans*a[i].x)%mod;
			if(a[i].f == 1)
				cnt++;
		}
	}

	if(cnt&1)
		return ans*(-1);
	return ans;
}

int main()
{
	cin>>n>>k;

	int flag = 0;
	int cnt = 0;
	for(int i = 1;i<= n;i++)
	{
		scanf("%lld",&a[i].x);
		if(a[i].x< 0)
		{
			a[i].f = 1;
			a[i].x = -a[i].x;
			cnt++;
		}
		else if(a[i].x> 0)
			a[i].f = 0;
		else
		{
			i--;n--;//我们不记录0，0只做迫不得已的选择
			flag = 1;
		}
	}

	sort(a+1,a+n+1,cmp);

	ll ans = 0;

	if(n< k)//如果必须选0
		ans = 0;
	else if(cnt == n)//如果都为负数
	{
		if(k&1)
			ans = solve(1);
		else
			ans = solve(0);
	}
	else if(cnt == 0)//如果都为正数
		ans = solve(0);
	else
	{
		int tmp = 0;
		for(int i = 1;i<= k;i++)
			if(a[i].f == 1)
				tmp++;

		if(tmp%2 == 0)//如果前k大的数有偶数个负数
			ans = solve(0);
		else
		{
			ans = -1;//将其设置为负数
			//尝试将前k个里面一个绝对值最小负数和后面最大正数交换
			int p = -1,q = -1;
			for(int i = k+1;i<= n;i++)
				if(a[i].f == 0)
				{
					q = i;
					break;
				}
			for(int i = k;i>= 1;i--)
				if(a[i].f == 1)
				{
					p = i;
					break;
				}

			if(p!= -1&&q!= -1)
			{
				swap(a[p],a[q]);
				ans = solve(0);
				swap(a[p],a[q]);
			}

			//尝试将前k个里面一个最小正数和后面绝对值最大正数交换
			p = -1,q = -1;
			for(int i = k+1;i<= n;i++)
				if(a[i].f == 1)
				{
					q = i;
					break;
				}
			for(int i = k;i>= 1;i--)
				if(a[i].f == 0)
				{
					p = i;
					break;
				}

			if(p!= -1&&q!= -1)
			{
				swap(a[p],a[q]);
				ans = max(ans,solve(0));
				swap(a[p],a[q]);
			}

			//假如结果仍然小于0，我们只能尝试从最后往前乘了
			if(ans< 0)
				ans = solve(1);
		}
	}


ans=(mod+ans)mod;
	cout<<ans<<endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:154:14: error: expected ';' before numeric constant
  154 | ans=(mod+ans)mod;
      |              ^
      |              ;
Language: Java



import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public final class E {

    private static final int MOD = (int) (1e9 + 7);

    static int solve(long[] nums, int k) {
        final int n = nums.length;
        Arrays.sort(nums);
        long product = 1;
        int i = 0;
        int j = n - 1;
        if (k % 2 != 0) {
            product = (product * nums[j]) % MOD;
            j--;
            k--;
        }
        k >>= 1;
        for (int itr = 0; itr < k; itr++) {
            final long left = nums[i] * nums[i + 1];
            final long right = nums[j] * nums[j - 1];
            if (left > right) {
                product = (product * (left % MOD)) % MOD;
                i += 2;
            } else {
                product = (product * (right % MOD)) % MOD;
                j -= 2;
            }
        }
        return Math.floorMod(product, MOD);
    }

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        final int k = in.nextInt();
        in.nextLine();
        final long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLong();
        }
        in.nextLine();
        System.out.println(solve(arr, k));
    }
}


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

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

#define pb push_back
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define sz(s) (ll) s.size()
#define deb(i) cout << "Aqui " << (ld) i << "\n";


bool fun(int i,int j)
{
   return abs(i)>abs(j);
}

int main(){
		
	ll N, k, mod = (ll) (1e9+7);
	cin >> N >> k;
	vll n,p, both;
	for (int i = 0; i < N; i++)
	{
		ll a;
		cin >> a;
		both.pb(a);
		if(a<0)
			n.pb(a);
		else
			p.pb(a);
	}
	
	sort(all(n));
	sort(all(p), greater<ll>());
	sort(all(both), fun);
	long double lp = 1.0, ln = 1.0;
	ll neg = 0;
	for (int i = 0; i < k; i++)
	{
		if(both[i]<0){
			neg++;
			ln = (long double)both[i];
		}else{
			lp = (long double)both[i];
		}
	}
	
	if(neg%2){
		long double np = 0.0, nn = 0.0;
		ll ans = 1ll;
		
		for (int i = k; i < N; i++)
		{
			if(both[i]<0){
				nn = (long double)both[i];
				break;
			}
		}
		
		for (int i = k; i < N; i++)
		{
			if(both[i]>=0){
				np = (long double)both[i];
				break;
			}
		}
		
		if((abs(np/lp)>abs(nn/ln))){
			bool helper = true;
			int j = 0;
			int cnt = 0;
			
			for (int i = 0; i < k; i++)
			{
				if(both[i]==ln && helper){
					helper = false;
					continue;
				}
				ans = (ans*abs(both[i]))%mod;
			}
			ans = (ans*(ll)np)%mod;
		}else{
			bool helper = true;
			int j = 0;
			int cnt = 0;
			
			for (int i = 0; i < k; i++)
			{
				if(both[i]==lp && helper){
					helper = false;
					continue;
				}
				ans = (ans*abs(both[i]))%mod;
			}
			ans = (*ans*abs((ll)nn))%mod;
		}
		
		cout << ans << "\n";
	}else{
		ll ans = 1ll;
		for (int i = 0; i < k; i++)
			ans = (ans*abs(both[i]))%mod;
			
		cout << ans << "\n";
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:99:32: error: invalid type argument of unary '*' (have 'll' {aka 'long long int'})
   99 |                         ans = (*ans*abs((ll)nn))%mod;
      |                                ^~~~
Language: C++

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N, K;
	cin >> N >> K;
	ll mod = 1000000000 + 7;
	vector<ll> pos;
	vector<ll> neg;
	for (int i = 0; i < N; i++)
	{
		ll temp;
		cin >> temp;
		if (temp >= 0)
		{
			pos.push_back(temp);
		}
		else
		{
			neg.push_back(-1 * temp);
		}
	}
	if (pos.size() == 0)
	{
		ll val = 1;
		if (K % 2 == 0)
			sort(neg.rbegin(), neg.rend());
		else
		{
			sort(neg.begin(), neg.end());
		}

		for (int i = 0; i < K; i++)
		{
			val *= mod - neg[i];
			val %= mod;
		}
		cout << val << endl;
		return 0;
	}
	sort(pos.rbegin(), pos.rend());
	sort(neg.rbegin(), neg.rend());
	int ans = 0;
	ll val = 1;
	int pt1 = 0;
	int pt2 = 0;
	while (ans < K - 1 && pt2 < pos.size() && pt1 < neg.size())
	{
		if (neg[pt1] > pos[pt2])
		{
			val *= neg[pt1++];
			val %= mod;
			ans++;
		}
		else
		{
			val *= pos[pt2++];
			val %= mod;
			ans++;
		}
	}
	while (ans < K - 1 && pt2 < pos.size())
	{
		val *= pos[pt2++];
		val %= mod;
		ans++;
	}
	while (ans < K - 1 && pt1 < neg.size())
	{
		val *= neg[pt1++];
		val %= mod;
		ans++;
	}
	if (pt1 % 2 == 0)
	{
		ll t1 = 0;
		ll t2 = 0;
		if (pt2 < pos.size())
		{
			val *= pos[pt2];
			val %= mod;
		}
		else
		{
			ll temp = 1;
			for (int i = 0; i < pt2 - 1; i++)
			{
				temp *= pos[i];
				temp %= mod;
			}
			for (int i = 0; i <= pt1; i++)
			{
				temp *= neg[i];
				temp %= mod;
			}
			val = temp;
		}
	}
	else
	{
		if (p1 >= (pos.size() - 1))
		{
			val *= neg[p2];
			val %= mod;
		}
		else
		{
			ll t1 = 0;
			ll t2 = 0;
			t1 = neg[p1 - 1] * neg[p1];
			t2 = pos[p2] * pos[p2 + 1];
			if (t1 >= t2)
			{
				val *= neg[p1];
				val %= mod;
			}
			else
			{
				ll temp = 1;
				for (int i = 0; i < pt1 - 1; i++)
				{
					temp *= neg[i];
					temp %= mod;
				}
				for (int i = 0; i <=pt2; i++)
				{
					temp *= pos[i];
					temp %= mod;
				}
				val = temp;
			}
		}
	}
	cout << val;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:106:21: error: 'p1' was not declared in this scope; did you mean 'pt1'?
  106 |                 if (p1 >= (pos.size() - 1))
      |                     ^~
      |                     pt1
a.cc:108:36: error: 'p2' was not declared in this scope; did you mean 'pt2'?
  108 |                         val *= neg[p2];
      |                                    ^~
      |                                    pt2
a.cc:116:34: error: 'p2' was not declared in this scope; did you mean 't2'?
  116 |                         t2 = pos[p2] * pos[p2 + 1];
      |                                  ^~
      |                                  t2
Language: C++

#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
  int64_t N,K;cin>>N;cin>>K;
  vector<pair<int64_t ,char>>A(N);
  for(int i=0;i<N;i++){
  int64_t a;cin>>a;
    if(0<=a){
    pair<int64_t,int64_t>p(a,'+');A.at(i)=p;
    }else{
     pair<int64_t,int64_t>p(-a,'-');A.at(i)=p;
    }
  }sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  int64_t sum=0;
  for(int i=0;i<N;i++)
    if(A.at(i).second=='-')sum++;
  if(sum==N){
  if(K%2==0){
  int64_t ans=1;
    for(int i=0;i<K;i++)
      ans=(ans*A.at(i).first)%mod;
    cout<<ans<<endl;
  
  }else{
  int64_t ans=1;
    for(int i=0;i<K;i++)
      ans=(ans*A.at(N-1-i).first)%mod;
    cout<<(mod-ans)%mod<<endl;
  }
  
  }else{
    int64_t sum1=0;
    int64_t ans=1;
    for(int i=0;i<K;i++)
      if(A.at(i).second=='+'){
      ans=(ans*A.at(i).first)%mod;
      }else{
       ans=(ans*A.at(i).first))%mod;sum1++;
      }
       if(sum1%2==0)cout<<ans<<endl;
    else{
      int64_t a=0;int64_t b=0;int64_t c=0;int64_t d=0;
      for(int i=0;i<K;i++)
        if(A.at(i).second=='+')
          a=A.at(i).first;
      else
        b=A.at(i).first;
       for(int i=K;i<N;i++)
        if(A.at(i).second=='+' && c==0)
          c=A.at(i).first;
      else{if(A.at(i).second=='-' && d==0)
        d=A.at(i).first;
          }
           if(a*c<=b*d){ans=(ans*d)%mod;ans=(ans*f(a,mod-2))%mod;cout<<ans<<endl;}
           else{ans=(ans*c)%mod;ans=(ans*f(b,mod-2))%mod;cout<<ans<<endl;
      }
    }
  
  }
  
  
  
 return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:31: error: expected ';' before ')' token
   48 |        ans=(ans*A.at(i).first))%mod;sum1++;
      |                               ^
      |                               ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
 ll n,k;
 cin>>n>>k;
 ll arr[n];
 ll po=0,ne=0;
 for(ll i=0;i<n;i++){
     cin>>arr[i];
     if(arr[i]>=0){
        po++;
     }else{
      ne++;
     }
 } ll prod = 1;
 if(k <= po){
   sort(arr,arr+n,greater<int());
    for(int i=1;i<=k;i++){
      prod = ((prod * arr[i])%100000009);
    }
  }else{
    sort(arr,arr+n);
    for(int i=1;i<=k;i++){
      prod = ((prod * arr[i])%100000009);
    }
  }
  cout<<prod%100000009<<"\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:31: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp> struct std::greater'
   20 |    sort(arr,arr+n,greater<int());
      |                               ^
a.cc:20:31: note:   expected a type, got '0'
Language: C++

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

int main() {
  int N, K,r=0;
  cin >> N >> K;
  vector<pair<long long int, int>> A(N);

  for(int i=0; i<N; i++){
    long long int tmp;
    cin >> tmp;
    pair<long long int,int>p = make_pair(abs(tmp),tmp/abs(tmp));

    A.at(i)=p;
    //cout  << "i " << i;
    if(tmp/abs(tmp)==-1){
      r++;
    }
  }

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

  if(r>N-K&&(r+K-N)%2==1){
    long long int ok=1;
    int ii =0;
    for(int i=0;i<K;i++){
      for(int j=0;j+i<N;j++){
        if(A.at(i+j).first!=0){
          ok*=A.at(i+j).first*A.at(i+j).second;
          ok %=((long long int)pow(10,9)+7);
          break;
        }

      }
      cout << ok << endl;
    }


  //cout << "sort comp";
  long long int ans=1,tmp2,ans2=1;
  int count=1, num=0,at3;


  for(int i=N-1; i>N-K-1; i--){
    long long int tmp;
    tmp = A.at(i).first;
    tmp%=((long long int)pow(10,9)+7);

    if(A.at(i).second==-1){
      if(num=0){
        ans2 = ans;
      }
      else{ans2 *= A.at(num).first;}
      ans2 %=((long long int)pow(10,9)+7);

      count *= -1;
      num =i;

      ans *= tmp;
      ans%=((long long int)pow(10,9)+7);

    }else{
      ans *= tmp;
      ans2 *= tmp;
      ans%=((long long int)pow(10,9)+7);
      ans2 %=((long long int)pow(10,9)+7);
    }
    if(i==N-K+1){

      at3 = ans;
    }



  }




  if(count == 1){
    cout << ans << endl;
  }
  else{
    bool frag =false;
    int ll = N-K-1;

    long long int at1,at2;
    at1 = A.at(num).first;
    while(ll>-1){
      if(A.at(ll).second==-1){
        at1 *= A.at(ll).first;
        frag=true;
        break;
      }
      frag=false;
      ll--;
    }
    at1 %= ((long long int)pow(10,9)+7);
    at1 *= ans2;
    at1 %= ((long long int)pow(10,9)+7);
    at2 = A.at(N-K).first*A.at(N-K-1).first;
    at2 %= ((long long int)pow(10,9)+7);
    at2 *= at3;
    at2 %= ((long long int)pow(10,9)+7);

    if(at1>=at2&&frag){
      cout << at1 << endl;
    }
    else if(at1<at2){
      cout << at2 << endl;
    }else{
      //(long long int)pow(10,9)+7
      cout << -1*ans <<endl;
    }




  }

}


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

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

int main(){
        int n,k,i,idx,cnt_m=0,cnt_p=0;
        long long ans;
        cing >> n >> k;
        vector<long long> a(n);
        vector<long long> b(n);
        for(i=0;i<n;++i){
                cin >> tmp;
                a.at(i) = tmp;
                b.at(i) = abs(tmp);
                if(tmp<0) ++cnt_m;
                if(tmp>0) ++cnt_p;
                if(tmp==0&&flg==0) flg = 1;
        }
        sort(a.begin(),a.end(),greater<long long>());
        sort(b.begin(),b.end(),greater<long long>());
        if(k<cnt_p){
                int idx = 0;
                while(1){
                        if(ans*a.at(idx)>1000000000+7) ans = (ans*a.at(idx))%(1000000000 + 7);
                        else ans = ans*a.at(idx);
                        if(idx+1==k) break;
                        ++idx;
                }
        }else if((k-cnt_p)%2==0){
                while(1){
                        if(a.at(idx)==0) continue;
                        ans*b.at(idx)>1000000000+7) ans = (ans*b.at(idx))%(1000000000 + 7);
                        else ans = ans*b.at(idx);
                        if(idx+1==k) break;
                        ++idx;
                }
        }else{
                sort(a.begin(),a.end());
                while(1){
                        if(a.at(idx)==0) continue;
                        ans*b.at(idx)>1000000000+7) ans = (ans*b.at(idx))%(1000000000 + 7);
                        else ans = ans*b.at(idx);
                        if(idx+1==k) break;
                        ++idx;
                }
        }
        cout << ans << endl;
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cing' was not declared in this scope
    8 |         cing >> n >> k;
      |         ^~~~
a.cc:12:24: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   12 |                 cin >> tmp;
      |                        ^~~
      |                        tm
a.cc:17:28: error: 'flg' was not declared in this scope
   17 |                 if(tmp==0&&flg==0) flg = 1;
      |                            ^~~
a.cc:19:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |         sort(a.begin(),a.end(),greater<long long>());
      |         ^~~~
      |         short
a.cc:32:51: error: expected ';' before ')' token
   32 |                         ans*b.at(idx)>1000000000+7) ans = (ans*b.at(idx))%(1000000000 + 7);
      |                                                   ^
      |                                                   ;
a.cc:33:25: error: 'else' without a previous 'if'
   33 |                         else ans = ans*b.at(idx);
      |                         ^~~~
a.cc:41:51: error: expected ';' before ')' token
   41 |                         ans*b.at(idx)>1000000000+7) ans = (ans*b.at(idx))%(1000000000 + 7);
      |                                                   ^
      |                                                   ;
a.cc:42:25: error: 'else' without a previous 'if'
   42 |                         else ans = ans*b.at(idx);
      |                         ^~~~
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;

const int m =1000000007;

int main(){
  int t,k;
  cin >> t >> k;
  vi p,n,pp,np,pair;
  int rp=0,rn=0;
  int zero=0;
  rep(i,t){
    int x;
    cin >> x;
    if(x>0) p.push_back(x);
    if(x==0) zero++;
    if(x<0) n.push_back(x);
  }
  if(k>t-zero){cout << 0;return 0;}
  int pn=p.size();
  int nn=n.size();
  sort(p.rbegin(),p.rend());
  sort(n.begin(),n.end());
  ll tmp=1;
  rep(i,pn){
    tmp*=p[i];
    if(i%2==1){
      pp.push_back(tmp);
      tmp=1;
    }
  }
  if(pn%2==1) rp=n[pn-1];
  tmp=1;
  rep(i,nn){
    tmp*=n[i];
    if(i%2==1){
      np.push_back(tmp);
      tmp=1;
    }
  }
  if(nn%2==1) rn=n[nn-1];
  rep(i,pn/2) pair.push_back(pp[i]);
  rep(i,nn/2) pair.push_back(np[i]);
  sort(pair.rbegin(),pair.rend());
  int z=pair.size();
  ll ans=1;
  if(nn+zero==t){
    if(zero>0){cout << 0;return 0;}
    rep(i,k){
        ans*=n[i];
        ans%=m;
      }
    cout << ans;
    return 0;
  }
  if(t==k){
    rep(i,nn){
      ans*=n[i];
      ans%=m;
    }
    rep(i,zero){
      ans*=0;
    }
    rep(i,pn){
      ans*=p[i];
      ans%=m;
    }
    cout << ans;
    return 0;
  }
  
  rep(i,k/2){
    if(i>=z){
      if(rp!=0 and rn!=0){
        ans*=rp;ans%=m;
        ans*=np;ans%=m;
        cout << ans;return 0;
      }else{cout << 0;return 0;}}
    ans*=pair[i];
    ans%=m;
  }
  if(k%2==1){
    ans*=rp;
    ans%=m
      cout << ans;return 0;
  }
  
  
  
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:80:12: error: no match for 'operator*=' (operand types are 'll' {aka 'long long int'} and 'vi' {aka 'std::vector<int>'})
   80 |         ans*=np;ans%=m;
      |         ~~~^~~~
a.cc:88:11: error: expected ';' before 'cout'
   88 |     ans%=m
      |           ^
      |           ;
   89 |       cout << ans;return 0;
      |       ~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int MOD = 1000000007;
int main(){
	long long int N,K,A,M,pI,mI,ans=1;
	long long int ans=1;
	vector<long long int> p,m;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>A;
		if(A<0)m.push_back(-A);
		else p.push_back(A);
	}
	sort(p.begin(),p.end());
	sort(m.begin(),m.end());
	if(p.size()==0 && K%2){
		for(int i=0;i<K;i++)ans=((-ans*m[i])%MOD+MOD)%MOD;
	}else{
		pI=p.size()-1;
		mI=m.size()-1;
		if(K%2){
			ans=p[pI]%MOD;
			pI--;K--;
		}
		for(int i=0;i<K/2;i++){
			if(mI-1<0 && pI-1<0){M=-p[0]*m[0]%MOD;break;}
			else if(mI-1<0){M=p[pI]*p[pI-1]%MOD;pI-=2;}
			else if(pI-1<0){M=m[mI]*m[mI-1]%MOD;mI-=2;}
			else if(p[pI]*p[pI-1]>=m[mI]*m[mI-1]){M=p[pI]*p[pI-1]%MOD;pI-=2;}
			else {M=m[mI]*m[mI-1]%MOD;mI-=2;}
			ans=(ans*M%MOD+MOD)%MOD;
		}
	}
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:23: error: redeclaration of 'long long int ans'
    8 |         long long int ans=1;
      |                       ^~~
a.cc:7:37: note: 'long long int ans' previously declared here
    7 |         long long int N,K,A,M,pI,mI,ans=1;
      |                                     ^~~
Language: C++

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

int main(){
  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()-1,ms=m.size()-1;
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(m.begin(),m.end());
  ll pmax=0,mmax=0,pmin=ps,mmin=ms;
  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])mmin-=2;
    else if(pmin-1>=0 && mmin-1>=0 && p[pmin]*p[pmin-1]<m[mmin]*m[mmin-1])mmmax-=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){
    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<<endl;
  }
  else 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<<endl;
  }
  else if(k==1 && pmax==ps && ps+1%2!=0){
    mmin--;
    for(int i=ps;i>pmin;i--){
      ans*=p[i];ans%=MOD;
    }
    for(int i=0;i>mmin;i--){
      ans*=m[i];ans%=MOD;
    }
    cout<<ans<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:75: error: 'mmmax' was not declared in this scope; did you mean 'mmax'?
   28 |     else if(pmin-1>=0 && mmin-1>=0 && p[pmin]*p[pmin-1]<m[mmin]*m[mmin-1])mmmax-=2;
      |                                                                           ^~~~~
      |                                                                           mmax
Language: C

#include <stdio.h>
#define swap(type, x, y) do{ type t = x; x = y; y = t; }while(0)

void quick(long a[], long left, long right){
  long pl = left, pr = right, x = a[(left+right)/2];
  do{
    while(a[pl] > x)  pl++;
    while(a[pr] < x)  pr--;
    if(pl <= pr){
      swap(long, a[pl], a[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(a, pl, right);
  if(pr > left)   quick(a, left, pr);
}

int main(){
  long ans = 0, idx, mod = 1e9+7;
  int n, k;  scanf("%d %d", &n, &k);
  long zeros = 0, plus[200005] = {0}, minus[200005] = {0};
  long twos[100005] = {0}, ones[100005] = {0};
  for(int i=1; i<=n; i++){
    long a;  scanf("%ld", &a);
    if(a > 0)  plus[++plus[0]] = a;
    else if(a < 0)  minus[++minus[0]] = -a;
    else  zeros++;
  }
  quick(plus, 1, plus[0]);
  quick(minus, 1, minus[0]);
  int pidx = 1, midx = 1;
  while(idx<k){  // && pidx<plus[0] && midx<minus[0]){
    if(pidx>=pinus[0] || plus[pidx]*plus[pidx+1] <= minus[midx]*minus[midx+1]){
      ans = (ans * (minus[midx]*minus[midx+1])%mod) % mod;
      midx += 2;
    }else if(midx>=minus[0] || plus[pidx]*plus[pidx+1] > minus[midx]*minus[midx+1]){
      ans = (ans * (plus[pidx]*plus[pidx+1])%mod) % mod;
      pidx += 2;
    }
    idx += 2;
  }
  if(idx != k){
    while(idx < k && pidx <= plus[0]){
      ans = (ans * plus[pidx++]) % mod;
      idx++;
    }
    if(idx < k){
      ans = 0;
      if(idx+zeros < k)
	while(idx+zeros<k){
	  ans = (ans * -minus[midx++])%mod;
	  idx++;
	}
    }
  }
  ans = (ans + mod) % mod;  
  printf("%ld\n", ans);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:33:14: error: 'pinus' undeclared (first use in this function); did you mean 'minus'?
   33 |     if(pidx>=pinus[0] || plus[pidx]*plus[pidx+1] <= minus[midx]*minus[midx+1]){
      |              ^~~~~
      |              minus
main.c:33:14: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int mod=1e9+7;
const int MAX=2e5+5;
const int inf=1e18+9;
int tab[MAX];
int ans=1;
multiset<int>dodatnie,ujemne;

int fastpow(int a,int b)
{
	int wynik=1;
	while (b)
	{
		if (b&1)wynik=(wynik*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return wynik;
}

int inv(int a)
{
	return fastpow(a,mod-2);
}

int dziel(int a,int b)
{
	return (a*inv(b))%mod;
}

bool cmp(pii a,pii b)
{
	if (a.st!=b.st)return a.st>b.st;
	return a.nd<b.nd;
}

vector<pii>nums;

int32_t main()
{
  BOOST;
  int n,k;
  cin>>n>>k;
  int last=0;
  for (int i=1;i<=n;i++)
  {
    cin>>tab[i];
    if (tab[i]>=0)nums.pb(mp(tab[i],1));
    else nums.pb(mp(-tab[i],-1));
  }
  
  sort(nums.begin(),nums.end(),cmp);
  
  for (int i=1;i<=n;i++)
  	if (tab[i]>0)dodatnie.insert(tab[i]);
  	else if (tab[i]==0)dodatnie.insert(tab[i]),ujemne.insert(tab[i]);
  	else ujemne.insert(-tab[i]);
  
  if (n==k)
  {
  	for (int i=1;i<=n;i++)
  	{
  		ans*=tab[i];
  		if (ans<0)ans+=mod*mod;
  		ans%=mod;
  	}
  	cout<<ans;
  	return 0;
  }
  else if (k==1)
  {
  	sort(tab+1,tab+n+1);
  	cout<<tab[n];
  	return 0;
  }
  
  int dod=-1,ujem=-1;
  int ile=0;
  for (int i=0;i<sz(nums);i++)
  {
  	if (nums[i].nd==-1)ujem=nums[i].st,ile++,ujemne.erase(ujemne.find(nums[i].st));
  	else dod=nums[i].st,dodatnie.erase(dodatnie.find(nums[i].st));
  	ans=(ans*num[i].st)%mod;
  }
  
  if (ile%2==0)
  {
  	cout<<ans;
  	return 0;
  }
  else
  {
  	int x,y;
  	if (!ujemne.empty())
  	x=ujem*(*ujemne.begin());
  	else x=-inf;
  	if (!dodatnie.empty())
  	y=dod*(*dodatnie.begin());
  	else y=-inf;
  	if (x>y)
  	{
  		ans=dziel(ans,dod);
  		ans=(ans*ujem)%mod;
  		ans=(ans*(*ujemne.begin()));
  	}
  	else
  	{
  		ans=dziel(ans,ujem);
  		ans=(ans*dod)%mod;
  		ans=(ans*(*dodatnie.begin()));
  	
  	}
  	
  }
  
  
  
  cout<<ans;
  return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:110:18: error: 'num' was not declared in this scope; did you mean 'nums'?
  110 |         ans=(ans*num[i].st)%mod;
      |                  ^~~
      |                  nums
Language: C++

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

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;



ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

int main()
{
//ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vi p,nn;
    rep(i,0,n)
    {
        ll x;
        cin>>x;
        if(x>0)p.pb(x);
        else nn.pb(x);
    }
    sort(p.begin(),p.end(),greater<ll>())'
    sort(nn.begin(),nn.end());
    n=p.size();
    ll m=nn.size();
    ll ans=1;
    int f=0;
    if(k%2!=0)k--,f=1;
     ll i=0,j=0;
        ll c=0;
    if(p.size()!=0)
    {
       if(f==1)n--;
        while(i+1<n&&j+1<m&&c<k)
        {
            if(p[i]*p[i+1]>nn[j]*nn[j+1])
            {
                ans*=(p[i]*p[i+1])%mod;
                i+=2;
            }
            else 
            {
                ans*=(nn[j]*nn[j+1])%mod;
                j+=2;
            }
            ans%=mod;
            c+=2;
        }
        while(i+1<n&&c<k)
        {
            ans*=(p[i]*p[i+1])%mod;
                i+=2;
                c+=2;
                ans%=mod;
        }
        while(j+1<m&&c<k)
        {
            ans*=(nn[j]*nn[j+1])%mod;
                j+=2;
                c+=2;
                ans%=mod;
        }
        
        
    }
    else
    {
        ll cc=0;
        
            repr(j,m-1,-1)
            {
                if(cc==k)break;
                cc++;
                ans*=nn[j];
                ans%=mod;
            }
        
        
    
    }
    if(f==1&&p.size()!=0)ans*=p[i];
    cout<<ans%mod;
}


Compiler output:
a.cc:51:42: warning: missing terminating ' character
   51 |     sort(p.begin(),p.end(),greater<ll>())'
      |                                          ^
a.cc:51:42: error: missing terminating ' character
a.cc: In function 'int main()':
a.cc:51:42: error: expected ';' before 'sort'
   51 |     sort(p.begin(),p.end(),greater<ll>())'
      |                                          ^
      |                                          ;
   52 |     sort(nn.begin(),nn.end());
      |     ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
const int N=2e5;
const int MOD = 1e9+7;

vector<int> v(N);
vector<bool> neg(N);

bool fun(int i, int j){
    return abs(i) > abs(j)
}

int main(){
    int n, k; cin >> n >> k;
    for (int i=0; i!=n; i++){
        cin >> v[i];
    }

    sort(v.begin(), v.begin()+n, fun);
    int lastneg = 0;
    int numneg=0;
    for (int i=0; i<k; i++){
        if (v[i] < 0){
            lastneg = i;
            numneg++;
        }
    }

    long long ans = 1;
    if (numneg%2==0){
        for(int i=0; i<k; i++){
            ans = (ans*v[i]) % MOD;
        }
    }
    else{
        for (int i=0; i<k; i++){
            if (i==lastneg) continue;
            ans = (ans*v[i]) % MOD;
        }
        sort(v.begin()+k, v.begin()+n, greater<int>());
        ans = (ans*v[k]) % MOD;
    }

    if (ans < 0) ans = (MOD+ans) % MOD;
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'bool fun(int, int)':
a.cc:11:27: error: expected ';' before '}' token
   11 |     return abs(i) > abs(j)
      |                           ^
      |                           ;
   12 | }
      | ~
Language: C++

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

int main() {
    ll MOD = 10000007;
    int n,k;cin>>n>>k;
    pair<ll,int>a[n];
    
    int cc = 0;
    rep(i,n){
        ll tmp;cin>>tmp;
        a[i].first = abs(tmp);
        if(tmp>=0)a[i].second = 1;
        else {
            a[i].second = -1;
            ++cc;
        }
    }
    sort(a,a+n,greater<pair<ll,int>>());

    ll ans=1;
    ll tmp2,tmp3;
    
    int c1=0
    rep(i,k) if(a[i].second == -1)++c1;

    if(cc==n && k%2==1)rep(i,k)ans=ans*a[n-1-i].first%MOD;
    else{
    rep(i,k)ans=ans*a[i].first%MOD;

    if(c1%2==1){
        for(int i=k;i>=0;--i)if(a[i].second==1){
            tmp2=a[i].first;
            break;
        }
        for(int j=k+1;j<n;++j)if(a[j].second==-1){
            tmp3=a[j].first;
            break;
        }
        ans=(ans/tmp2*tmp3)%MOD;
    }
    }
    cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:19: error: expected ',' or ';' before 'for'
    5 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                   ^~~
a.cc:28:5: note: in expansion of macro 'rep'
   28 |     rep(i,k) if(a[i].second == -1)++c1;
      |     ^~~
a.cc:28:9: error: 'i' was not declared in this scope
   28 |     rep(i,k) if(a[i].second == -1)++c1;
      |         ^
a.cc:5:35: note: in definition of macro 'rep'
    5 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                   ^
Language: C++

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

int main(){
    ll n,k;
    cin >> n >> k;
    vector <ll> p,m,all;
    ll a;
    rep(i,n){
        cin >> a;
        all.push_back(a);
        if(a>=0){
            p.push_back(a);
            //all.push_back(a);
        }
        else{
            m.push_back(-1*a);
            //all.push_back(-1*a);
        }
    }

    sort(p.begin(),p.end());
    sort(m.begin(),m.end());

    ll pk=0;
    ll mod=1000000007;
    ll ans=1;
    ll lp,lm;
    lp=p.size();
    lm=m.size();
    vector <ll> rp(lp),rm(lm);
    
    ll kk=0;
    ll k3;
    k3=k;
    if(k==1){
        ans=p[lp-1];
    }
    else if(lm==0){
        rep(i,k){
            ans*=p[lp-i-1];
            ans=ans%mod;
        }
    }
    else if(k==n){
        rep(i,k){
            ans*=all[i];
            ans=ans%mod;
        }
        if(ans<0){
            ans+=mod;
        }
    }
    else if(lp==0){
        if((k%2)==0){
            rep(i,k){
            ans*=m[lm-1-i];
            ans=ans%mod;
        }
        }
        else{
            rep(i,k){
            ans*=m[i];
            ans=ans%mod;
        }
        ans*=-1;
        ans+=mod;
        }
    }
    else if(lp<k){
        while(lp<k3){
            k3-=2;
            kk+=2;
        }

        while(m[lm-kk-1]*m[lm-kk-2]>p[lp-(kk-1)]*p[lp-kk]){
            kk+=2;
            if(kk>lm){
                break;
            }
        }

         rep(i,kk){
            ans*=m[lm-i-1];
            ans=ans%mod;
        }
        rep(i,k-kk){
            ans*=p[lp-i-1];
            ans=ans%mod;
        }

    }
    else{
        ans=1;
        //cout << lm << endl;
        //cout << (m[lm-kk-1]*m[lm-kk-2]) << endl;
        //cout << (p[lp-(kk-1)]*p[lp-kk]) << endl;
        if(lm>=2 and lp>=2){
        while((m[lm-kk-1]*m[lm-kk-2])>(p[lp-k+kk]*p[lp-k+1+kk])){
            kk+=2;
            if(kk>lm){
                break;
            }
            if(kk>pm)
            break;
        }
        }
        
        rep(i,kk){
            ans*=m[lm-i-1];
            ans=ans%mod;
            //cout << ans << endl;
        }
        rep(i,k-kk){
            ans*=p[lp-i-1];
            ans=ans%mod;
        }
    }

    cout << ans << endl;

















    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:107:19: error: 'pm' was not declared in this scope; did you mean 'rm'?
  107 |             if(kk>pm)
      |                   ^~
      |                   rm
Language: C

#include <stdio.h>
#include <stdlib.h>

void arr_sort(int *a, int i)
{
  int tmp;
  int k;
  
  k = i;
  while (k > 0)
  {
    if (a[k] > a[k - 1])
    {
      tmp = a[k];
      a[k] = a[k - 1];
      a[k - 1] = a[k];
    }
    k--;
  }
}

int main(void)
{
  int n;
  int k;
  int i;
  int a*;
  long times;
  long res;
  
  if (!(scanf("%d %d", &n, &k)))
    return (0);
  a = (int *)malloc(n * sizeof(int));
  i = 0;
  while (i < n)
  {
    if (!(scanf("%d", &a[i])))
        return (0);
    arr_sort(a, i++);
  };
  i = 0;
  times = 1;
  while (i < k)
    times *= a[i++];
  printf("%d", times % (100000000 + 7));
  return (0);
}

Compiler output:
main.c: In function 'main':
main.c:27:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
   27 |   int a*;
      |        ^
main.c:27:9: error: expected expression before ';' token
   27 |   int a*;
      |         ^
main.c:33:3: error: 'a' undeclared (first use in this function)
   33 |   a = (int *)malloc(n * sizeof(int));
      |   ^
main.c:33:3: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

using ll = long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n) for(ll i=0;i<(n);i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

static const ll MOD = 1000000007;
//static const ll INF = 1000000000;
//#define PI 3.14159265359

int main() {
    // input
    ll N, K;
    cin >> N >> K;
    Vec A_minus, A_plus;
    rep(i, N) {
        ll a;
        cin >> a;
        if (a < 0) {
            A_minus.emplace_back(a);
        } else if (a > 0) {
            A_plus.emplace_back(a);
        }
    }

    // process
    ll ans = 0;
    ll p_max = A_plus.size(), m_max = A_minus.size();
    if ((K % 2 == 0) || ((K % 2 == 1) && (K < A_minus.size() / 2 + A_plus.size()))) {
        sort(A_plus.begin(), A_plus.end(), greater<ll>());
        sort(A_minus.begin(), A_minus.end());

        ll p_i = 0,  m_i = 0,;
        A_plus.emplace_back(0);
        A_plus.emplace_back(0);
        rep(i, K) {
            if (m_i + 1 < m_max && A_minus[m_i] * A_minus[m_i + 1] > A_plus[p_i] * A_plus[p_i + 1]) {
                ans = (ans * (A_minus[m_i] % MOD)) % MOD;
                m_i++;
                i++;
                ans = (ans * (A_minus[m_i] % MOD)) % MOD;
                m_i++;
            } else if (p_i < p_max) {
                ans = (ans * (A_plus[p_i] % MOD)) % MOD;
                p_i++;
            }
        }
    } else if (N == A_minus.size() - A_plus.size()) {
        sort(A_plus.begin(), A_plus.end());
        sort(A_minus.begin(), A_minus.end(), greater<ll>());

        ll p_i = 0, m_i = 0;
        A_plus.emplace_back(0);
        A_plus.emplace_back(0);
        rep(i, K) {
            if (m_i + 1 < m_max && A_minus[m_i] < A_plus[p_i]) {
                ans = (ans * (A_minus[m_i] % MOD)) % MOD;
                m_i++;
            } else if (p_i < p_max) {
                ans = (ans * (A_plus[p_i] % MOD)) % MOD;
                p_i++;
            }
        }
    }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:49:30: error: expected unqualified-id before ';' token
   49 |         ll p_i = 0,  m_i = 0,;
      |                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double  
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((ll)x.size())
ll powm(ll a,ll n,ll x=MOD){a%=x;ll r=1;while(n>0){if(n&1)r=(r*a)%x;a=(a*a)%x;n>>=1;}return r;}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  ll _=1; //cin>>_;
  while(_--)
  {
    ll n,k; cin>>n>>k;
    vector<ll> pv,nv;
    for(ll i=0,a ; i<n ; i++){
      cin>>a;
      if(a<0 && a<MOD) nv.pb(a);
      else if(a<MOD) pv.pb(a);
    }
    sort(all(nv)); sort(all(pv));
    reverse(all(nv)); reverse(all(pv));
    ll ans1=1,ans2=1;
    for(ll i=0 ; i<k ; i++) ans1=((ans*nv[i])%MOD+MOD)%MOD;
    for(ll i=0 ; i<k ; i++) ans2*=((ans*pv[i])%MOD+MOD)%MOD;
    if(ans1>ans2) cout<<ans1;
    else cout<<ans2;LOL
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:36: error: 'ans' was not declared in this scope; did you mean 'ans2'?
   31 |     for(ll i=0 ; i<k ; i++) ans1=((ans*nv[i])%MOD+MOD)%MOD;
      |                                    ^~~
      |                                    ans2
a.cc:32:37: error: 'ans' was not declared in this scope; did you mean 'ans2'?
   32 |     for(ll i=0 ; i<k ; i++) ans2*=((ans*pv[i])%MOD+MOD)%MOD;
      |                                     ^~~
      |                                     ans2
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
 ll n,k;
 cin>>n>>k;
 ll arr[n];
 ll po=0,ne=0;
 for(ll i=0;i<n;i++){
     cin>>arr[i];
     if(arr[i]>=0){
        po++;
     }else{
      ne++;
     }
 } ll prod = 1;
 if(k <= po){
   sort(arr,arr+n,greater<int());
    for(int i=1;i<=k;i++){
      prod *= arr[i];
    }
  }else{
    sort(arr,arr+n);
    for(int i=1;i<=k;i++){
      prod *= arr[i];
    }
  }
  cout<<prod%100000009<<"\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:31: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp> struct std::greater'
   20 |    sort(arr,arr+n,greater<int());
      |                               ^
a.cc:20:31: note:   expected a type, got '0'
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include<queue>

using namespace std;

int main(void) {
	int n,k;
	cin >> n>>k;
	long long int ans = 0;
	priority_queue<long long int> min,plus;
	for (int i = 0; i < n; i++) {
		long long int temp;
		cin >> temp;
		if (temp > 0) {
			plus.push(temp);
		}
		else if (temp < 0) {
			min.push(temp);
		}
	}//入力おわ

	if (plus.empty() && min.empty()) {
		//全部０とかわろ
		cout << 0;
		return 0;
	}

	priority_queue<int, vector<int>, greater<int>> plus_r, min_r;

	int now = k,mi_count = 0;
	while (now != 0) {

		if(min.empty()){
			plus_r.push(plus.top());
			plus.pop();
			now--;
			continue;
		}
		else if (plus.empty()) {
			min_r.push(min.top());
			min.pop();
			mi_count++;
			now--;
			continue;
		}


		long long int pl = plus.top(), mi = min.top();
		if (abs(pl) >= abs(mi)) {//プラスからとる
			plus.pop();
			plus_r.push(pl);
		}
		else {
			min.pop();
			min_r.push(mi);
			mi_count++;
		}
		now--;
	}


	if (!(mi_count % 2)) {//奇数

		if (min.empty()) {
			plus_r.push(plus.top());
			min_r.pop();
		}
		else if (plus.empty()) {
			min_r.push(min.top());
			plus_r.pop();
		}

		if (min_r.top()*min.top()>plus.top()*plus_r.top()) {
			min_r.push(min.top());
			plus_r.pop();
		}
		else {
			plus_r.push(plus.top());
			min_r.pop();
		}
	}
  
	long long ans = 1;


	while (!plus_r.empty()) {
		ans*=plus_r.top();
		plus_r.pop();
		ans %= 1000000000 + 7;
	}

	while (!min_r.empty()) {
		ans *= min_r.top();
		min_r.pop();
		ans %= 1000000000 + 7;
	}

	cout << ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:85:19: error: redeclaration of 'long long int ans'
   85 |         long long ans = 1;
      |                   ^~~
a.cc:11:23: note: 'long long int ans' previously declared here
   11 |         long long int ans = 0;
      |                       ^~~
Language: C++

//
#include<bits/stdc++.h>

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const ll MOD = 1000000007;
const int N = 200005;
int n, k;

vector<ll> a[2];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for(int i=0; i<n; i++)
    {
        ll x;
        cin >> x;
        a[x<0].PB(x);
    }
    if(a[0].size())
        sort(a[0].begin(), a[0].end());
    if(a[1].size())
        sort(a[1].begin(), a[1].end());
    int siz0 = a[0].size();
    int siz1 = a[1].size();
    //what_is(siz0);
    //what_is(siz1);
    int ind0 = siz0-k, ind1 = 0;
    //take all positive
    if(siz0 + siz1 == k)
    {
        ind0 = 0, ind1 = siz1;
    }
    else if((siz1 == 0) || (siz1 > 0 && siz0 >= k && abs(a[1][0]) < a[0][siz0-k]))
    {
        ind0 = siz0-k;
        ind1 = 0;
    }
    else
    {
        for(int i=2; i<=min(k, (int)siz1); i+=2)
        {
            if(k - i > siz0)
                continue;
            int ind = siz0-k+i;
            //what_is(i);
            //what_is(ind);
            if(ind <= 1)
            {
                ind1 = i;
                ind0 = ind;
            }

            if(ind >= 2 && (a[0][ind-1] * a[0][ind-2]) <= (a[1][smallest] * a[1][smallest-1]))
            {
                ind1 = i;
                ind0 = ind;
            }
        }
        //all negative

    }
    ll ans = 1LL;
    //what_is(ind0);
    //what_is(ind1);
    if(ind0 < 0)
    {
        if(k%2 == 1)
        {
            for(int i=siz1-k; i<siz1; i++)
            {
                ans = (ans * (MOD + a[1][i]) % MOD) % MOD;
            }
        }
        else
        {
            for(int i=0; i<k; i++)
            {
                ans = (ans * (MOD + a[1][i]) % MOD) % MOD;
            }
        }
    }
    else
    {
        if(ind0 < siz0)
        {
            for(int i=ind0; i<siz0; i++)
            {
                ans = (ans * a[0][i]) % MOD;
            }
        }
        if(ind1 > 0)
        {
            for(int i=0; i<ind1; i++)
            {
                ans = (ans * (MOD + a[1][i]) % MOD) % MOD;
            }
        }
    }
    cout << ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:65: error: 'smallest' was not declared in this scope
   66 |             if(ind >= 2 && (a[0][ind-1] * a[0][ind-2]) <= (a[1][smallest] * a[1][smallest-1]))
      |                                                                 ^~~~~~~~
Language: C++

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	while (t--) {
		int n, k;
		cin >> n >> k;
		int arr[n], brr[n], crr[n];
		int a = 0, b = 0;
		for (int i = 0; i < n; i++)
			cin >> arr[i];
		vector<int> v1, v2, v3;
		for (int i = 0; i < n; i++) {
			if (arr[i] >= 0) {
				brr[a] = arr[i];
				a++;
			}
			else if (arr[i] < 0) {
				crr[b] = arr[i];
				b++;
			}
		}
		int ans = 0;
		sort(brr, brr + a);
		sort(crr, crr + b);
		if (k % 2 == 1) {
			ans = brr[a - 1];
			a--;
			k--;
		}
		while (k > 0) {
			int x = 0, y = 0, flag = 0, flag1 = 0;
			if (a == 0) {
				x = brr[a];
				a--;
				flag = 1;
			}
			if (b == 0) {
				y = brr[b];
				b--;
				flag1 = 1;
			}
			if (a >= 0 && a - 1 >= 0) {
				x = brr[a] * brr[a - 1];
				a = a - 2;
			}
			if (b >= 0 && b - 1 >= 0) {
				y = crr[b] * crr[b - 1];
				b = b - 2;
			}
			if (x > y) {
				ans = (ans * x)1000000007;
				if (flag == 1) k = k - 1;
				else k = k - 2;
			}
			else {
				ans = (ans * y)1000000007;
				if (flag1 == 1) k = k - 1;
				else k = k - 2;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:48: error: expected ';' before numeric constant
   61 |                                 ans = (ans * x)1000000007;
      |                                                ^~~~~~~~~~
      |                                                ;
a.cc:66:48: error: expected ';' before numeric constant
   66 |                                 ans = (ans * y)1000000007;
      |                                                ^~~~~~~~~~
      |                                                ;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main()
{
    int n, k; 
    cin >> n >> k;
    vector<ll> a(n);
    ll ans = 1;
    
    int pos = 0, neg = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] < 0) neg++;
        else if(a[i] > 0) pos++;
    }

    sort(a.begin(), a.end());
    int neg_min_index = -1;
    for(int i=0; i<n; i++){
        if(a[i] >= 0) {neg_min_index = i-1; break;}
    }

    if(k%2 && pos == 0){
        int index = n-1;
        int count = 0;
        while(count < k){
            if(a[index] != 0)
                { ans *= a[index]; count++;}
            index--;
        }
    }
    else{
        if(neg%2) a.erase(a.begin() + neg_min_index);
        int l = 0, r = n-1;
        int count = 0;
        ll ans1 = 1;
        while(count++ < k-1){
            if(abs(a[l]) < abs(a[r])) { ans1 *= a[r--]; ans1 %= mod; break;}
            else if(abs(a[l]) > abs(a[r])) { ans1 *= a[l++]; ans1 %= mod; break;}
            else {ans1 *= a[r--]; ans1 %= mod; break;}
        }
        if(ans1 < 0) ans1 *= a[l];
        else ans1 *= a[r];

        l = 0;
        r = n-1;
        count = 0;
        ll ans2 = 1;
        while(count++ < k-1){
            if(abs(a[l]) < abs(a[r])) { ansa2 *= a[r--]; ans2 %= mod; break;}
            else if(abs(a[l]) > abs(a[r])) { ans2 *= a[l++]; ans2 %= mod; break;}
            else {ans2 *= a[l--];ans2 %= mod; break;}

            ans2 %= mod;
        }
        if(ans2 < 0) ans2 *= a[l];
        else ans2 *= a[r];

        ans = max(ans1, ans2);
    }
    if(ans < 0) ans += mod;
    cout << ans % mod << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:41: error: 'ansa2' was not declared in this scope; did you mean 'ans2'?
   55 |             if(abs(a[l]) < abs(a[r])) { ansa2 *= a[r--]; ans2 %= mod; break;}
      |                                         ^~~~~
      |                                         ans2