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

#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = cpp_int;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n, k;
	cin >> n >> k;
	priority_queue<int> plus, minus;
	priority_queue<ll> m2, ms;
	priority_queue<ll, vector<ll>, greater<ll>> mn;
	rep(i, n)
	{
		int a;
		cin >> a;
		if (a < 0)
		{
			ms.push(-a);
			mn.push(-a);
			minus.push(-a);
		}
		else
		{
			plus.push(a);
			mn.push(a);
		}
	}
	rep(i, size(minus) / 2)
	{
		ll a = minus.top();
		minus.pop();
		ll b = minus.top();
		a *= b;
		minus.pop();
		m2.push(a);
	}
	int rest = k;
	ll ans = 1;
	bool debug = false;
	if ((int)size(plus) + (int)size(m2) * 2 < k 
		or (size(plus)==0 and k%2==1))
	{
		rep(i, k)
		{
			ans *=(ll) mn.top();
			ans %= M;
			mn.pop();
		}
		ans=-ans;
		ans%=M;
		while (ans < 0)
		{
			ans += M;
		}
		ans%=M;
	}
	else
	{
		while (rest > 0)
		{
			if (debug)
				cout << ans << endl;
			ans %= M;
			if (rest > 1)
			{
				if (debug)
					cout << "c1" << endl;
				ll ttp = 0;
				ll tp = -1;
				if (size(plus) > 1)
				{
					tp = plus.top();
					plus.pop();//tp used
					ll tp2 = plus.top();
					ttp = tp * tp2;
				}

				if (size(m2) == 0)
				{
					ttp %= M;
					ans *= ttp;
					ans%=M;
					plus.pop(); //tp2 used
				}
				else if (ttp > m2.top())
				{
					ttp %= M;
					ans *= ttp;
					ans %= M;
					plus.pop();// tp2 used
				}
				else
				{
					if (tp != -1)
						plus.push(tp);//tp back
				
					ll tm2 = m2.top();
					tm2 %= M;
					ans *= tm2;
					ans %= M;
					m2.pop();//m2 used
				}
				rest -= 2;
			}
			else
			{
				if (debug)
					cout << "c2" << endl;
				ans *= plus.top();
				ans %= M;
				rest--;
			}
		}
	}
	cout << ans << endl;
}

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


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

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

static ll mod = 1000000007;

int main()
{
	vector<ll> Positive;
	vector<ll> Negative;
	vector<ll> Select;
	int N, K;
	cin >> N >> K;
	static ll A[200200];
	int zeroCount = 0;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		if(A[i] >= 0){
			Positive.push_back(A[i]);
		}else if(A[i] < 0){
			Negative.push_back(A[i]);
		}
		if(A[i] == 0){
			zeroCount++;
		}
	}
	
	sort(Positive.begin(), Positive.end(), std::greater<ll>());
	sort(Negative.begin(), Negative.end() );
	
	int pos = 0;
	int posCount = Positive.size();
	int neg = 0;
	int negCount = Negative.size();
	for(int i = 0; i < K; i++){
		if(i < K-1 && posCount - pos >= 2 && negCount-neg >= 2 && Negative[neg] * Negative[neg+1] >= Positive[pos] * Positive[pos+1]){
			if(Negative[neg] * Negative[neg+1] >= Positive[pos] * Positive[pos+1]){
				Select.push_back(Negative[neg]);
				Select.push_back(Negative[neg+1]);
				neg += 2;
				i++;
		}else if(posCount-pos >= 1 && Positive[pos] > 0){
			Select.push_back(Positive[pos]);
			pos++;
		}else if(negCount-neg>=1){
			Select.push_back(Negative[neg]);
			neg++;
		}else{
			Select.push_back(Positive[pos]);
			pos++;
		}
	}
	
	if(neg % 2 == 1 && zeroCount > 0){
		cout << "0" << endl;
		return 0;
	}else if(neg % 2 == 1){
		sort(Positive.begin(), Positive.end());
		sort(Negative.begin(), Negative.end(), std::greater<ll>());
		Select.clear();
		pos = 0;
		posCount = Positive.size();
		neg = 0;
		negCount = Negative.size();
		for(int i = 0; i < K; i++){
			if(posCount-pos >= 1 && negCount-neg >=1){
				if(Positive[pos] < (ll)(-1) * Negative[neg]){
					Select.push_back(Positive[pos]);
					pos++;
				}else{
					Select.push_back(Negative[neg]);
					neg++;
				}
			}else if(negCount-neg >= 1){
				Select.push_back(Negative[neg]);
				neg++;
			}else{
				Select.push_back(Positive[pos]);
				pos++;
			}
		}
	}
	
	for(int i = 0; i < K; i++){
		//cout << Select[i] << endl;
	}
	
	ll ans = Select[0];
	if(ans < 0) { ans += mod;}
	for(int i = 1; i < K; i++){
		ll a = Select[i];
		if(a < 0){ a += mod;}
		ans *= a;
		if(ans < 0) { ans += mod;}
		ans %= mod;
	}
	
	cout << ans <<endl;
	
	return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll n,k;cin>>n>>k;
	vector<ll> po;
	vector<ll> ne;
	ll cnt_zero = 0;
	for(ll i = 0; i < n; i++) {
		ll x;cin>>x;
		if (x > 0){
			po.pb(x);
		}
		else if(x != 0){
			ne.pb(x);
		}
		else{
			cnt_zero++;
		}
	}
	ll po_len = po.size();
	ll ne_len = ne.size();

	

	k -= cnt_zero;
	sort(ALL(po),greater<ll>());
	sort(ALL(ne));

	// for(int i = 0; i < po_len; i++) {
	// 	cout << ne[i] << endl;
	// }
	vector<ll> sum_po(po_len+1,1LL);
	vector<ll> sum_ne(ne_len+1,1LL);

	for(ll i = 0; i < po_len; i++) {
		sum_po[i+1] = sum_po[i] * po[i];
		sum_po[i+1] %= mod;
	}
	for(ll i = 0; i < ne_len; i++) {
		sum_ne[i+1] = sum_ne[i] * ne[i];
		sum_ne[i+1] %= mod;
		if(sum_ne[i+1] < 0){
			sum_ne[i+1] += mod;
		}
	}


	if (k == po_len + ne_len){
		if (cnt_zero != 0){
			cout << 0 << endl;
		}
		else{
			if (po_len == 0){
				cout << sum_ne[ne_len] << endl;
			}
			else if (ne_len == 0){
				cout << sum_po[po_len] << endl;
			}
			else{
				cout << sum_po[po_len] * sum_ne[ne_len] % mod << endl;
			}
		}
		return 0;
	}
	
	else if (k % 2 == 1 && po_len == 0){
		ll res;
		sort(ALL(ne),greater<ll>());
		vector<ll> sum_ne(ne_len+1,1LL);
		for(ll i = 0; i < ne_len; i++) {
			sum_ne[i+1] = sum_ne[i] * ne[i];
			sum_ne[i+1] %= mod;
			if(sum_ne[i+1] < 0){
			sum_ne[i+1] += mod;
		}
		}
		if (cnt_zero != 0){
			res = max(0LL,sum_ne[k]);
		}
		else{
			res = sum_ne[k];
		}
		if(res < 0){
			res += mod;
		}
		cout << res << endl;
		return 0;
	}
	else{
		ll res;
		if (cnt_zero != 0){
			res = 0;
		}
		else {
			res = -1;
		}
		ll border = min(k,ne_len);
		if (ne_len % 2 ==1){
			border = min(k,ne_len-1)
		}
		for(ll i = 0; i <= border; i+= 2) {
			ll ans = 1;
			ans *= sum_ne[i];
			// cout << ans << endl;
			ans %= mod;
			ans *= sum_po[k - i];
			ans %= mod;
			// cout << "ans" << i << endl;
			if(cnt_zero != 0){
				ans = max(0LL,ans);
			}
			res = max(res,ans);
		}
		cout << res << endl;
	}




	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:114:49: error: expected ';' before '}' token
  114 |                         border = min(k,ne_len-1)
      |                                                 ^
      |                                                 ;
  115 |                 }
      |                 ~
Language: C++

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

int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  rep(i,n)cin >> a[i];

  sort(a,a+n);
  ll max=1;
  int cnt1=0,cnt2=n-1;
  ll tmp1=1,tmp2=1;

  if(k%2==0){
    rep(i,k-1){
      tmp1=(a[cnt1]%1000000007)*(a[cnt1+1]%1000000007);
      tmp2=(a[cnt2]%1000000007)*(a[cnt2-1]%1000000007);
      
      if(tmp1>tmp2){
	max*=tmp1;
      cnt1+=2;
      }else if(tmp1<tmp2){
	max*=tmp2;
	cnt2-=2;
      }else{
	if(a[cnt1+1]>a[cnt2-2]){
	  max*=tmp1;
	  cnt1+=2;
	}else{
	  max*=tmp2;
	  cnt2-=2;
      }
      }
    }
  }else{
    rep(i,k){
      max=max*(a[k-i]%1000000007);
    }
    if(ans<0)ans=1000000007+ans;
  }

  cout << max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |     if(ans<0)ans=1000000007+ans;
      |        ^~~
      |        abs
Language: C++

#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
ll dx[4]={0,1,-1,0};
ll dy[4]={1,0,0,-1};
long long double eps = 1e-6;
long long double pi = acos(-1);

ll mod = 1e9+7;
//mod mでの a の逆元を求める
ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,k;
    cin>>n>>k;
    array<ll,2> a[n];
    int z = 0;
    for(int i=0;i<n;i++){
        ll t;
        cin>>t;
        if(t<0){
            a[i]={-t,0};
            z++;
        }
        else a[i] = {t,1};
    }
    if(z == n){
        sort(a,a+n);
        ll ans = 1;
        for(int i=0;i<k;i++)ans = (ans * a[i][0]) % mod;
        if(k%2)ans = mod-ans;
        cout << ans << endl;
        return 0;
    }
    if(z == 0){
        sort(a,a+n,greater<array<ll,2>>());
        ll ans = 1;
        for(int i=0;i<k;i++)ans = (ans * a[i][0]) % mod;
        cout << ans << endl;
        return 0;
    }
    sort(a,a+n,greater<array<ll,2>>());
    ll cnt = 0;
    ll ans = 1;
    ll pmi = 1e18;
    ll mmi = 1e18;
    for(int i=0;i<k;i++){
        ans *= a[i][0];
        if(a[i][0] == 0){
            cout << 0 << endl;
            return 0;
        }
        ans %= mod;
        if(a[i][1] == 0){
            cnt++;
            mmi = a[i][0];
        }
        else pmi = a[i][0];
    }
    if(cnt % 2 == 0){
        cout << ans << endl;
        return 0;
    }
    ll pma = 0;
    ll mma = 0; 
    for(int i=k;i<n;i++){
        if(a[i][1] == 1){
            chmax(pma,a[i][0]);
        }
        else chmax(mma,a[i][0]);
    }
    // in pma, out mmi
    long double p = (long double)((long double)pma/(long double)mmi);
    long double m = (long double)((long double)mma/(long double)pmi);
    if(p>m){
        ans = (ans * modinv(mmi)) % mod;
        ans = (ans * pma) % mod;
    }
    else{
        ans = (ans * modinv(pmi)) % mod;
        ans = (ans * mma) % mod;
    }
    // in mma, out pmi
    cout << ans << endl;
}

Compiler output:
a.cc:8:6: error: 'long long' specified with 'double'
    8 | long long double eps = 1e-6;
      |      ^~~~
a.cc:9:6: error: 'long long' specified with 'double'
    9 | long long double pi = acos(-1);
      |      ^~~~
Language: C++

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int n,k;
   cin >> n >> k;

   multiset<int> neg , pos;
   int temp  = 1;
   f(i,0,n){
      int a;
      cin >> a;
      temp = ((temp*(a % MOD + MOD)%MOD)%MOD + MOD)%MOD;
      if(a >= 0) pos.insert(a);
      else neg.insert(a);
   }

   int ans = 1;
   if(k == n){
      cout << temp << "\n";
      return 0;
   }

   if(k % 2 == 1){
      if(sz(pos)){
         ans = *pos.rbegin();
         pos.erase(--pos.end());
         k--;
      }
      else{
         f(i,0,k){
            int x = *neg.rbegin();
            x = (x%MOD + MOD)%MOD;
            ans = ((ans * x) % MOD + MOD ) % MOD;
            neg.erase(--neg.end());
         }
         cout << ans << "\n";
         return 0;
      }
   }

   if(ans == 0 || k == 0){
      cout << ans << "\n";
      return 0;
   }

   set<int> s;

   while(sz(neg) >= 2){
      int x1 = *neg.begin();
      neg.erase(neg.begin());
      int x2 = *neg.begin();
      neg.erase(neg.begin());
      s.insert(x1*x2);
   }

   while(sz(pos) >= 2){
      int x1 = *pos.rbegin();
      pos.erase(--pos.end());
      int x2 = *pos.rbegin();
      pos.erase(--pos.end());
      s.insert(x1*x2);
   }

   int x = k/2;
   while(x-- && sz(s)){
      int x1 = *s.rbegin();
      x1 = (x1%MOD + MOD)%MOD;
      ans = ((ans * x1) % MOD + MOD)%MOD;
      s.erase(--s.end());
   }

   if(sz(s) == 0 && x){
      int x1 = 0 , x2 = 0;
      if(sz(pos)) x1 = *pos.begin();
      if(sz(neg)) x12 = *neg.begin();
      x1 = (x1%MOD + MOD)%MOD;
      x2 = (x2%MOD + MOD)%MOD;
      ans = (ans * x1) % MOD;
      ans = (ans * x2) % MOD;
   }
   cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:99:19: error: 'x12' was not declared in this scope; did you mean 'x2'?
   99 |       if(sz(neg)) x12 = *neg.begin();
      |                   ^~~
      |                   x2
Language: C++

#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;
int mod=1e9+7;
//                                          mdsaqib
signed main(){
    fast;
    int n,k;
    cin >> n >> k;
    //vector <int> P,N;
    vector <pair<int,bool>> A(n);
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        A[i]={abs(a),a<0?true:false};
        // if(a<0)N.push_back(-a);
        // else P.push_back(a);
    }
    sort(all(A));
    reverse (all(A));
    int sum=1;
    int pos=0,prev,duck=0,dog=-1;
    vector <int> V;
    for(int i=0;i<k;i++){
        V.push_back(A[i].first);
        if(A[i].second){
            pos++;
            prev=i;
        }
        else{
            duck++;
            dog=i;
        }
    }
    int pp=0,pprev=-1;
    for(int i=k;i<n;i++){
        if(A[i].second==false){pp++;pprev=i;break;}
    }
    if(pos%2==1 && pp==0 && pos<k && k<n){
        V[dog]=1;
        V.push_back(A[k].first)
        for(int i=0;i<V.size();i++){
            sum*=V[i];
            sum%=mod;
        }
        cout << sum;
    }
    else if(pos%2==1 && pp==0 && pos==k ){
        reverse(all(A));
        for(int i=0;i<k;i++){
            sum*=A[i].first;
            sum%=mod;
        }
        sum=-sum;
        sum+=mod;
        sum%=mod;
        cout << sum;
    }
    else if(pos%2==1 && pp>0){
        V[prev]=A[pprev].first;
        for(int i=0;i<V.size();i++){
            sum*=V[i];
            sum%=mod;
        }
        cout << sum;
    }
    else{
        for(int i=0;i<V.size();i++){
            sum*=V[i];
            sum%=mod;
        }
        cout << sum;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:32: error: expected ';' before 'for'
   44 |         V.push_back(A[k].first)
      |                                ^
      |                                ;
   45 |         for(int i=0;i<V.size();i++){
      |         ~~~                     
a.cc:45:21: error: 'i' was not declared in this scope
   45 |         for(int i=0;i<V.size();i++){
      |                     ^
Language: C++

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}




int main() {
    int n,k;
    cin >> n >> k;
    vector<pair<ll,int>> a(n);
    int cnt=0;
    rep(i,n){
        ll c;
        cin >> c;
        if(c<0) a[i] = make_pair(-c,-1);
        else if(c>0) a[i] = make_pair(c,1);
        else cnt++;
    }

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

    sort(ALL(a));
    reverse(ALL(a));
    mint ans = 1;
    ll p,m;
    int flag = 0; 
    rep(i,k){
        ans *= a[i].first;
        if(a[i].second==1){
            p = i;
        }
        else {
            m = i;
            flag++;
        }
    }

    if(flag%2==0){
        cout << ans << endl;
        return 0;
    }
    int np=p,nm=m;
    for(int i = p+1;i<n;i++){
        if(a[i].second==1){
            np = i;
            break;
        }
    }
    for(int i = m+1;i<n;i++){
        if(a[i].second==-1){
            nm = i;
            break;
        }
    }
    if(p==np&&m==mp) ans *= -1;
    else if(p==np) {
        ans /= a[p].first;
        ans *= a[nm].first;
    }
    else if(m==nm){
        ans /= a[m].first;
        ans *= a[np].first;
    }
    else {
        if(a[p].first*a[nm].first>=a[np].first*a[m].first){
            ans /= a[p].first;
            ans *= a[nm].first;
        }
        else {
            ans /= a[m].first;
            ans *= a[np].first;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:97:18: error: 'mp' was not declared in this scope; did you mean 'np'?
   97 |     if(p==np&&m==mp) ans *= -1;
      |                  ^~
      |                  np
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
ll mod=1000000007;
ll f(ll X){
  ll res=1,n=mod-2;
  while(n>0){
    if(n&1)res=res*X%mod;
    X=X*X%mod;
    n/=2;
  } 
  return res;
}
signed main(){
  ll N,K,i,j,p,ans=1,x,y;
  cin>>N>>K;vector<ll>A(N);
  REP(i,N)cin>>A.at(i);sort(ALL(A));
  x=upper_bound(ALL(A),0)-A.begin();
  y=lower_bound(ALL(A),0)-A.begin();
  if((y==N&&K%2==1)||(K==N))REP(i,K){
    ans*=A.at(N-1-i);ans%=mod;
  }
  else if(x-y>N-K||(x-y==N-K&&y%2==1))ans=0;
  else{
    i=0;j=N-1;
    REP(p,K){
      if(abs(A.at(i))>abs(A.at(j))){
        ans*=abs(A.at(i));ans%=mod;i++;
      }
      else{
        ans*=abs(A.at(j));ans%=mod;j--;
      }
    }
    if(i%2==1){
      if(j<N-1&&A.at(i)*A.at(j)>A.at(i-1)*A.at(j+1)ans*=abs(A.at(i))%mod*f(abs(A.at(j+1))%mod;
      else ans*=abs(A.at(j))%mod*f(abs(A.at(i-1))%mod;
    }
  }
  ans%=mod;ans+=mod;ans%=mod;
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:52: error: expected ')' before 'ans'
   41 |       if(j<N-1&&A.at(i)*A.at(j)>A.at(i-1)*A.at(j+1)ans*=abs(A.at(i))%mod*f(abs(A.at(j+1))%mod;
      |         ~                                          ^~~
      |                                                    )
a.cc:42:54: error: expected ')' before ';' token
   42 |       else ans*=abs(A.at(j))%mod*f(abs(A.at(i-1))%mod;
      |                                   ~                  ^
      |                                                      )
Language: C++

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    long long int N,K;
    cin>>N>>K;
    long long int lis[200003];
    for(int i=0;i<N;i++)cin>>lis[i];
    sort(lis,lis+N);
    long long int mai=0;
    long long int plu=0;
    long long int now=1;
    for(int i=0;i<K;i++){
        if(0<=lis[mai]&&lis[N-1-plu]<=0){
            continue;
        }
        else if(0<=lis[mai]){
            now*=lis[N-1-plu];
            now%=1000000007;
            plu++;
        }
        else if(lis[N-1-plu]<=0){
            now*=lis[mai]*-1;
            now%=1000000007;
            mai++;
        }
        else{
            if(lis[mai]*-1ll<=lis[N-1-plu]){
                now*=lis[N-1-plu];
                now%=1000000007;
                plu++;
            }
            else{
                now*=lis[mai]*-1;
                now%=1000000007;
                mai++;
            }
        }
    }
    if(mai+plu<K){
        cout<<0<<endl;
        return 0;
    }
    if(mai%2==0){
        cout<<now<<endl;
        return 0;
    }
    if(plu==0){
        if(lis[N-1]==0){
            cout<<0<<endl;
            return 0;
        }
        else{
            long long int papapa=1;
            for(int i=0;i<K;i++){
                papapa*=lis[N-i-1];
                papapa%=1000000007;
            }
            cout<<(papapa+1000000007)%1000000007<<endl;
            return 0;
        }
    }






    if(0<=lis[mai]&&lis[N-1-plu]<=0){
        cout<<0<<endl;
        return 0;
    }
    else if((0<=lis[mai]||plu==0)&&(lis[N-1-plu]<=0||mai==0)){
        long long int papapa=1;
        for(int i=0;i<K;i++){
            papapa*=lis[N-i-1];
            papapa%=1000000007;
        }
        cout<<(papapa+1000000007)%1000000007<<endl;
        return 0;
    }
    else if(0<=lis[mai]||plu==0){
        mai--;
        plu++;
    }
    else if(lis[N-1-plu]<=0||mai==0){
        mai++;
        plu--;
    }
    else{
        if((float)lis[N-1-plu+1]/((float)lis[mai]*-1f)<(float)lis[N-1-plu]/((float)lis[mai-1]*-1f)){
            mai--;
            plu++;
        }
        else{
            mai++;
            plu--;
        }
    }

    long long int papapa=1;
    for(int i=0;i<mai;i++){
        papapa*=lis[i]*-1ll;
        papapa%=1000000007ll;
    }
    for(int i=0;i<plu;i++){
        papapa*=lis[N-i-1];
        papapa%=1000000007ll;
    }
    cout<<papapa<<endl;







    //ここで再度掛け合わせる









    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:94:52: error: unable to find numeric literal operator 'operator""f'
   94 |         if((float)lis[N-1-plu+1]/((float)lis[mai]*-1f)<(float)lis[N-1-plu]/((float)lis[mai-1]*-1f)){
      |                                                    ^~
a.cc:94:96: error: unable to find numeric literal operator 'operator""f'
   94 |         if((float)lis[N-1-plu+1]/((float)lis[mai]*-1f)<(float)lis[N-1-plu]/((float)lis[mai-1]*-1f)){
      |                                                                                                ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
ll mod=1000000007;
ll f(ll X){
  ll res=1,n=mod-2;
  while(n>0){
    if(n&1)res=res*X%mod;
    X=X*X%mod;
    n/=2;
  } 
  return res;
}
signed main(){
  ll N,K,i,j,p,ans=1,x,y;
  cin>>N>>K;vector<ll>A(N);
  REP(i,N)cin>>A.at(i);sort(ALL(A));
  x=upper_bound(ALL(A),0)-A.begin();
  y=lower_bound(ALL(A),0)-A.begin();
  if((y==N&&K%2==1)||(K==N))REP(i,K){
    ans*=A.at(N-1-i);ans%=mod;
  }
  else if(x-y>N-K||(x-y==N-K&&y%2==1))ans=0;
  else{
    i=0;j=N-1;
    REP(p,K){
      if(abs(A.at(i))>abs(A.at(j))){
        ans*=abs(A.at(i));ans%=mod;i++;
      }
      else{
        ans*=abs(A.at(j));ans%=mod;j--;
      }
    }
    if(i%2==1){
      if(j<N-1&&A.at(i)*A.at(j)>A.at(i-1)*A.at(j+1)ans*=abs(A.at(i))%mod*f(abs(A.at(j+1))%mod;
      else ans*=abs(A.at(j))%mod*f(abs(A.at(i-1)))%mod;
    }
  }
  ans%=mod;ans+=mod;ans%=mod;
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:52: error: expected ')' before 'ans'
   41 |       if(j<N-1&&A.at(i)*A.at(j)>A.at(i-1)*A.at(j+1)ans*=abs(A.at(i))%mod*f(abs(A.at(j+1))%mod;
      |         ~                                          ^~~
      |                                                    )
Language: C++

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

const int mod = 1e9 + 7;
signed main(void)
{
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	ll ans;
	rep(i, n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	if (k == 1)
	{
		ans = a[0];
		if (ans < 0) ans += mod;
		ans %= mod;
	}
	else
	{
		rep(i, n)
		{
			if (a[i] == 0) continue
			a[i] += mod;
			a[i] %= mod;
		}
		sort(a.rbegin(), a.rend());
		ans = 1;
		rep(i, k)
		{
			ans *= a[i];
			if (ans < 0) ans += mod;
			ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:48: error: expected ';' before 'a'
   26 |                         if (a[i] == 0) continue
      |                                                ^
      |                                                ;
   27 |                         a[i] += mod;
      |                         ~
Language: C++

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

#define pb push_back
#define rb  pop_back
#define rf  pop_front
#define ins insert
#define f   first
#define s   second
#define um  unordered_map
#define us  unordered_set
#define pq  priority_queue

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef vector<double> vd;
typedef pair<double,double> pd;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef us<int> si;
typedef us<double> sd;
typedef us<ll> sll;
typedef vector<vd> md;


const int MAX = 1e6;
const int N = 200043;
const int MOD = 1000000007;

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define EE endl
#define PI 3.14159265
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
#define SOT(A) sort(A.begin(),A.end())
#define SOTR(A) sort(A.rbegin(),A.rend())
#define REV(a) reverse(ALL(a))

// LOOP Control Statements
#define forn(i,j,n) for ( auto i=j ; i<n ; i++ )
#define fornd(i,j,n) for ( auto i=j ; i>n ; i-- )
#define FORE(i, b) for(auto &i:b)


#define SQ(i) (i*i)
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define tcase(term) int tc;cin>>tc;for(int term=0; cout<<"CASE "<<term+1<<EE,term<tc;term++)





int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	// tcase(terms)
	{
		ll n,k;
		cin>>n>>k;
		vl pos,neg;
		for(int i=0;i<n;++i){
			ll x;
			cin>>x;
			if(x>0) pos.pb(x);
			if(x<0) neg.pb(x);
		}
		// cout<<pos.size()<<endl;
		if(pos.size()==0){
			if(k()%2) SOTR(neg);
			else SOT(neg);
			neg.insert(neg.begin(), 1);
			for(int i=1;i<neg.size();++i){
				neg[i]=(neg[i]*neg[i-1])%MOD;
			}
			if (neg.size()-1<k) cout<<0;
			else cout<<(neg[k]+MOD)%MOD;
			// cout<<"HERE";
			return 0;
		}
		SOT(neg);
		SOT(pos);
		neg.insert(neg.begin(), 1);
		for(int i=1;i<neg.size();++i){
			neg[i]=(neg[i]*neg[i-1])%MOD;
		}
		pos.insert(pos.begin(), 1);
		for(int i=1;i<pos.size();++i){
			pos[i]=(pos[i]*pos[i-1])%MOD;
		}
		ll mx=neg[l(k,(neg.size()-1))];

		for(int i=0;i<neg.size();i+=2){
			if(k-i>=0 and k-i<pos.size()){
				ll curr=(neg[i]*pos[k-i])%MOD;
				mx=g(mx,curr);
			}
		}
		// if(mx<0) mx+=MOD;
		cout<<mx%MOD;


	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:90:29: error: 'k' cannot be used as a function
   90 |                         if(k()%2) SOTR(neg);
      |                            ~^~
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){
      |     ^~~
a.cc:28:9: error: 'i' was not declared in this scope
   28 |     rep(i,k){
      |         ^
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>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
ll mod=1000000007;
ll f(ll X){
  ll res=1,n=mod-2;
  while(n>0){
    if(n&1)res=res*X%mod;
    X=X*X%mod;
    n/=2;
  } 
  return res;
}
signed main(){
  ll N,K,i,j,p,ans=1,x,y;
  cin>>N>>K;vector<ll>A(N);
  REP(i,N)cin>>A.at(i);sort(ALL(A));
  x=upper_bound(ALL(A),0)-A.begin();
  y=lower_bound(ALL(A),0)-A.begin();
  if((y==N&&K%2==1)||(K==N))REP(i,K){
    ans*=A.at(N-1-i);ans%=mod;
  }
  else if(x-y>N-K||(x-y==N-K&&y%2==1))ans=0;
  else{
    i=0;j=N-1;
    REP(p,K){
      if(abs(A.at(i))>abs(A.at(j))){
        ans*=abs(A.at(i));ans%=mod;i++;
      }
      else{
        ans*=abs(A.at(j));ans%=mod;j--;
      }
    }
    if(i%2==1){
      if(j<N-1&&A.at(i)*A.at(j)>A.at(i-1)*A.at(j+1)ans*=abs(A.at(i))%mod*f(abs(A.at(j+1)))%mod;
      else ans*=abs(A.at(j))%mod*f(abs(A.at(i-1)))%mod;
    }
  }
  ans%=mod;ans+=mod;ans%=mod;
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:52: error: expected ';' before 'ans'
   41 |       if(j<N-1&&A.at(i)*A.at(j)>A.at(i-1)*A.at(j+1)ans*=abs(A.at(i))%mod*f(abs(A.at(j+1)))%mod;
      |                                                    ^~~
      |                                                    ;
a.cc:42:7: error: expected primary-expression before 'else'
   42 |       else ans*=abs(A.at(j))%mod*f(abs(A.at(i-1)))%mod;
      |       ^~~~
a.cc:41:96: error: expected ')' before 'else'
   41 |       if(j<N-1&&A.at(i)*A.at(j)>A.at(i-1)*A.at(j+1)ans*=abs(A.at(i))%mod*f(abs(A.at(j+1)))%mod;
      |         ~                                                                                      ^
      |                                                                                                )
   42 |       else ans*=abs(A.at(j))%mod*f(abs(A.at(i-1)))%mod;
      |       ~~~~
Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,k;
  cin >> n >> k;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin >> a[i];
  sort(a,a+n);
  ll sum=1,sum1=1;
  for(int i=0;i<k;i++)
    sum*=a[i];
  for(int i=(n-k);i<n;i++)
    sum1*=a[i];
  ll p=max(sum,sum1);
  
  if(p<0)
    cout << (1000000007-m) << endl;
  else{
    ll m=p%1000000007;
  	cout << m << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:25: error: 'm' was not declared in this scope
   21 |     cout << (1000000007-m) << endl;
      |                         ^
Language: C++

#include <iostream>
#include <vector>
#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--]; break;}
            else if(abs(a[l]) > abs(a[r])) { ans1 *= a[l++]; break;}
            else {ans1 *= a[r--]; 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])) { ans2 *= a[r--]; break;}
            else if(abs(a[l]) > abs(a[r])) { ans2 *= a[l++]; break;}
            else {ans2 *= a[l--]; 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:21:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   21 |     sort(a.begin(), a.end());
      |     ^~~~
      |     sqrt
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define mod 1000000007 //998244353
#define mii map<int, int>
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>

//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word



const long long N = 200005, INF = 2000000000000000000;
//lld pi = 3.1415926535897932;
int lcm(int a, int b)
{
  int g = __gcd(a, b);
  return a / g * b;
}
int power(int a, int b, int p)
{
  if (a == 0)
    return 0;
  int res = 1;
  a %= p;
  while (b > 0)
  { if (b & 1)
      res = (res * a) % p;
    b >>= 1;
    a = (a * a) % p;
  }
  return res;
}

int testcaseva;

int sq(int x) { return 1ll * x * x; }
int findMaxProduct(int arr[], int n, int k)
{

    int MaxProduct = 1;
    for (int i=0; i<k; i++)
        MaxProduct *= arr[i];

    int prev_product = MaxProduct;

    for (int i=1; i<=n-k; i++)
    {
        int curr_product = (prev_product/arr[i-1]) *
                            arr[i+k-1];
        MaxProduct = max(MaxProduct, curr_product);
        prev_product = curr_product;
    }
    return MaxProduct;
}
int32_t main() {
    int n,k;
    cin >> n>>k;
    int ar[n];
    for(int i=0;i<n;i++)
        cin >> ar[i];
        int ans=findMaxProduct(ar,n,k);
        if(ans<0){
            cout << ans+1000000007;
            return;
        }
        while(ans>10000000007){
            ans=ans%1000000007;
        }
    cout <<ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:81:13: error: return-statement with no value, in function returning 'int32_t' {aka 'int'} [-fpermissive]
   81 |             return;
      |             ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using double = long double;

const ll MOD = (ll)1e9 + 7;

// グローバル変数（入力）
ll n, k;
bool zero = false;
vll ap, am;

void input() {
  cin >> n >> k;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a == 0) {
      zero = true;
    } else if (a > 0) {
      ap.push_back(a);
    } else {
      am.push_back(a);
    }
  }
}

ll zyoyo(double a, double b) { return (ll)(a - floor(a / b) * b); }

ll solve() {
  ll np = ap.size(), nm = am.size();
  sort(ap.begin(), ap.end(), greater<ll>());
  sort(am.begin(), am.end());
  if (np == 0) {
    if (zero == true) {
      cout << 0 << endl;
      return 0;
    } else {
      ll ans = 1;
      for (ll i = nm - 1; i >= nm - k; i--) {
        ans = zyoyo(ans * am[i], MOD);
      }
      cout << ans << endl;
      return 0;
    }
  }
  ll mmax = min(2 * (ll)floor(k / 2.0), 2 * (ll)floor(nm / 2.0));
  ll pmax = min(k, np);
  rep(i, nm) { am[i] *= (-1); }
  vll rp(pmax + 1), rm(mmax + 1);
  rp[0] = 1, rm[0] = 1;
  rep1(i, pmax) { rp[i] = zyoyo(rp[i - 1] * ap[i - 1], MOD); }
  rep1(i, mmax) { rm[i] = zyoyo(rm[i - 1] * am[i - 1], MOD); }
  vector<double> logap(np), logam(nm);
  rep(i, np) { logap[i] = log(ap[i]); }
  rep(i, nm) { logam[i] = log(am[i]); }
  vector<double> logrp(pmax + 1), logrm(mmax + 1);
  logrp[0] = 0, logrm[0] = 0;
  rep1(i, pmax) { logrp[i] = logrp[i - 1] + logap[i - 1]; }
  rep1(i, mmax) { logrm[i] = logrm[i - 1] + logam[i - 1]; }
  ll ans=-1;
  ll bi=0,bj=k-bi;
  for (ll i = 0; i <= mmax; i += 2) {
    ll j = k - i;
    if (j < 0 || pmax < j) { continue; }
    double koho=logrp[j]+logrm[i];
    if (koho>ans){
      ans=koho;
      bi=i,bj=j;
    }
  }
  cout << zyoyo(rp[bj]*rm[bi],MOD) << endl;
  return 0;
}

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


Compiler output:
a.cc:10:7: error: expected nested-name-specifier before 'double'
   10 | using double = long double;
      |       ^~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <sstream>

using namespace std;
typedef long long ll;
vector<ll> v, v2;

ll mod = 1e9 + 7;

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		ll x; cin >> x; 
		if (x >= 0)v.push_back(x);
		else v2.push_back(x);
	}
	sort(v.begin(), v.end());
	sort(v2.begin(), v2.end());

	if (k - v.size() > 0 && (k - v.size() & 1)) {
		// 최소값을 구해야함.
		ll ans = 1;
		int l = 0;
		int r = v2.size() - 1;
		while (k > 0) {
			k -= 1;
			if (l == v.size()) {
				ans *= v2[r]; r -= 1;
				continue;
			}
			if (r == -1) {
				ans *= v[l]; l += 1;
				continue;
			}
			if (abs(v[l] < abs(v[r]))) {
				ans *= v[l]; l += 1;
			}
			else {
				ans *= v[r]; r -= 1;
			}
		}
		while (ans <= 0)ans += mod;
		cout << ans << '\n';
	}
	else {
		// 무조건 양수.
		ll ans = 1;
		int l = v.size() - 1;
		int r = 0;
		while (k > 1) {
			k -= 2;
			if (l - 1 < 0) {
				ll cnt2 = v2[r] * v2[r + 1]; cnt %= mod;
				ans *= cnt2; ans %= mod; 
				r += 2;
				continue;
			}
			if (r + 1 >= v2.size()) {
				ll cnt = v[l] * v[l - 1]; cnt %= mod;
				ans *= cnt; ans %= mod;
				l -= 2;
				continue;
			}

			ll cnt = v[l] * v[l - 1]; cnt %= mod;
			ll cnt2 = v2[r] * v2[r + 1]; cnt2 %= mod;
			if (cnt > cnt2) {
				ans *= cnt; ans %= mod;
				l -= 2;
			}
			else {
				ans *= cnt2; ans %= mod;
				r += 2;
			}
		}
		if (k > 0)
			ans *= v[l];
		ans %= mod;
		cout << ans << '\n';
	}


}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:62: error: 'cnt' was not declared in this scope; did you mean 'cnt2'?
   61 |                                 ll cnt2 = v2[r] * v2[r + 1]; cnt %= mod;
      |                                                              ^~~
      |                                                              cnt2
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll val=1e9+7;
int main(void){
  int n,k;
  cin>>n>>k;
  vector<ll> a;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll mul1=1;
  ll mul2=1;
  sort(a.rbegin(),a.rend());
  for(int i=0;i<k;i++){
    mul1*=a[i];
  }
  boost::sort(a);
  for(int i=0;i<k;i++){
    mul2*=a[i];
  }
  cout<<max(mul1,mul2)<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'boost' has not been declared
   18 |   boost::sort(a);
      |   ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll val=1e9+7;
int main(void){
  int n,k;
  cin>>n>>k;
  vector<ll> a;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll mul1=1;
  ll mul2=1;
  sort(a.rbegin(),a.rend());
  for(int i=0;i<k;i++){
    mul1*=a[i];
  }
  boost::sort(a);
  for(int i=0;i<k;i++){
    mul2*=a[i];
  }
  cout<<mul<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: 'boost' has not been declared
   18 |   boost::sort(a);
      |   ^~~~~
a.cc:22:9: error: 'mul' was not declared in this scope; did you mean 'mul2'?
   22 |   cout<<mul<<endl;
      |         ^~~
      |         mul2
Language: C

#include<bits/stdc++.h>

using namespace std;

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

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

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

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

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

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

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

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

/*input
5 3
-1 2 3 4 -5 
*/
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll pwr(ll a, ll pw) {
	ll ret = 1;
	if (a < 0) {
		a += mod;
	}
	while (pw > 0) {
		if (pw & 1) {
			ret = ret * a % mod;
		}
		a = a * a % mod;
		pw >>= 1;
	}
	if (ret < 0) {
		ret += mod;
	}
	return ret;
}
ll modinv(ll a) {
	return pwr(a, mod - 2);
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll>v;
	int zeros = 0, positives = 0;
	ll mn_neg = mod, mn_pos = mod;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		v.pb(a);
		zeros += a == 0;
		positives += a > 0;
	}

	sort(all(v), [&](ll a, ll b) {
		return abs(a) > abs(b);
	});

	for (int i = 0; i < k; i++) {
		if (v[i] < 0) {
			mn_neg = min(mn_neg, -v[i]);
		}
		if (v[i] > 0) {
			mn_pos = min(mn_pos, v[i]);
		}
	}

	if (zeros > n - k) {
		cout << "0\n";
		return 0;
	}

	if (positives == 0 && k % 2 == 1) {
		ll mul = 1;
		for (int i = n - 1; i >= n - k; i--) {
			mul = mul * v[i] % mod;
		}
		if (mul < 0) {
			mul += mod;	
		}
		cout << mul << "\n";
		return 0;
	}

	int neg = 0;
	ll mul = 1;
	for (int i = 0; i < k; i++) {
		if (v[i] < 0) {
			neg++;
		}
		mul = ((mul * v[i] % mod) + mod) % mod;
	}

	if (neg % 2 == 0 || k == n) {
		cout << mul << "\n";
	} else {
		if (v[k] == 0) {
			cout << "0\n";
			return 0;
		}
		// remove 1 negative, add 1 positive
		// remove 1 positive, add 1 negative

		ll mx_neg = 0, mx_pos = 0;
		for (int i = k; i < n; i++) {
			if (v[i] < 0) {
				mx_neg = max(mx_neg, -v[i]);
			}
			if (v[i] > 0) {
				mx_pos = max(mx_pos, v[i]);
			}
		}


		// if (mx_neg / mn_pos > mx_pos / mn_neg)
		ll ans;
		if (!mx_neg) {
			ans = mul * modinv(-mn_eng) % mod * mx_pos % mod;
			goto done;
		}
		if (!mx_pos) {
			ans = mul * modinv(mn_pos) % mod * -mx_neg % mod;
			goto done;
		}

		if (-mn_neg * -mx_neg > mx_pos * mn_pos) {
			ans = (mul * modinv(mn_pos) % mod * -mx_neg % mod + mod) % mod;
		} else {
			ans = (mul * modinv(-mn_neg) % mod * mx_pos % mod + mod) % mod;
		}

		done: ;

		ans = (ans + mod) % mod;
		cout << ans << "\n";
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:118:45: error: 'mn_eng' was not declared in this scope; did you mean 'mn_neg'?
  118 |                         ans = mul * modinv(-mn_eng) % mod * mx_pos % mod;
      |                                             ^~~~~~
      |                                             mn_neg