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

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

int main() {
  int N, K;
  int64_t ans=0;
  cin >> N;
  vector<int64_t> A(N);
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
  }
  if (N%2=0) {
    K = (N-2)/2;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: lvalue required as left operand of assignment
   12 |   if (N%2=0) {
      |       ~^~
a.cc:15:2: error: expected '}' at end of input
   15 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C

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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
    ll n
    // ll a[200000];
    ll a_min=1e10;
    ll a;
    ll sum=0;
    int i;

  scanf("%lld", &n);

  for (i = 0; i < n; i++)
  {
      scanf("%lld", &a);
      sum += a;
      a_min = (a < a_min) ? a : a_min;
  }

  printf("%d\n", sum - a_min);

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:39:9: error: expected ';' before 'long'
   39 |     ll n
      |         ^
      |         ;
main.c:46:18: error: 'n' undeclared (first use in this function)
   46 |   scanf("%lld", &n);
      |                  ^
main.c:46:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int N = 200000 + 10;
int a[N], b[N];

int main() {
    int n;  cin >> n;
    for (int i = 1; i <= n; i++)    cin >> a[i];
    sort(a + 1, a + 1 + n, [&](int a, int b) {
        return a > b;
    })
    long long ans = 0;
    for (int i = 2; i <= n; i++) {
        ans += a[i];
    }
    cout << ans;
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:7: error: expected ';' before 'long'
   13 |     })
      |       ^
      |       ;
   14 |     long long ans = 0;
      |     ~~~~
a.cc:16:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |         ans += a[i];
      |         ^~~
      |         abs
a.cc:18:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |     cout << ans;
      |             ^~~
      |             abs
Language: C++

#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
using namespace std;
int main(){
	int n, ans=0;
	cin>>n;
	vector<int>A(n);
	for(int&a:A){
		cin>>a;
		ans+=a;
	}
	cout<<a<<"\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: 'a' was not declared in this scope
   14 |         cout<<a<<"\n";
      |               ^
Language: Java

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Min {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        long min = 99999999999999L;
        for (int i=1;i<=n;i++) {
            long a = sc.nextLong();
            ans += a;
            if (min > a) {
                min = a;
            }
        }
        ans -= min;
        System.out.println(ans);
    }
}


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

#include <iostream>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  long long s = 0;
  int m = INT_MAX;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);

    s += a;
    if (a < m) m = a;
  }

  printf("%lld\n", s - m);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:11: error: 'INT_MAX' was not declared in this scope
    9 |   int m = INT_MAX;
      |           ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C++

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
     int n;
     cin>>n;
     ll*arr=new ll[n];
     for(int i=0;i<n;i++)
     {
     	cin>>arr[i];
	 }
	 sort(arr,arr+n);
	 long long ans=0;
	 for(int i=1;i<n;i++)
	 {
	 	ans+=arr[i];
	 }
	 cout<<ans;
		
		   

Compiler output:
a.cc: In function 'int main()':
a.cc:21:20: error: expected '}' at end of input
   21 |          cout<<ans;
      |                    ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll> 
#define pii pair<int, int> 
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

using namespace std;

ll MOD = 1e9+7;

ll pwr(ll x, ll y) {
	ll res = 1;
	x = x%MOD;
	while (y > 0) {
		if (y&1) res = (res*x)%MOD;

		y = y>>1;
		x = (x*x)%MOD;
	}
	return res;
}

inline ll addmod(ll a, ll b){
	return ((a+b)%MOD);
}

inline ll mulmod(ll a, ll b){
	return ((a*b)%MOD);
}

class BIT {
	int *bit;
	int N;

public:
	void update(int x, int val) {
		int ind = x;
		while (ind <= N) {
			bit[ind] += val;
			ind += (ind & (-ind));
		}
	}

	BIT(int ar[], int n) {
		bit = new int[n+1];
		N = n+1;
		for (int i = 1; i < N; i++) bit[i] = 0;
		for (int i = 1; i < N; i++) update(i, ar[i-1]);
	}

	int getSum(int x) {
		if (x < 0) return 0;

		int ind = x+1;
		int sum = 0;
		while (ind > 0) {
			sum += bit[ind];
			ind = (ind & (ind-1));
		}
		return sum;
	}

	int getValue(int x) {
		return getSum(x) - getSum(x-1);
	}

	void changeElem(int x, int val) {
		update(x+1, val-getValue(x));
	}
};

int bsh(int val, int ar[], int n) {		// return ind such that val >= ar[ind] and val < ar[ind+1]
	int a = 0, b = n - 1, c = (a+b)/2;
	if (val < ar[0]) return -1;
	if (val >= ar[b]) return b;

	while (!(val >= ar[c] && val < ar[c+1])) {
		if (val < ar[c]) b = c;
		else {
			if (b-a == 1 && c == a) a = b;
			else a = c;
		}
		c = (a+b)/2;
	}
	return c;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);

	int n; cin >> n;
	ll mn = 1e10;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll x; cin >> x;
		mn = min(mn, x);
		sum += x;
	}
	cout << sum -x << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:102:22: error: 'x' was not declared in this scope
  102 |         cout << sum -x << endl;
      |                      ^
Language: C++

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

int main(){
 long long int n;
  cin>>n;
  long long int a[n],res=0;
  for(int i=0;i<n;i++) cin>>a[i};
  sort(a,a+n);
  for(int i=1;i<n;i++) res+=a[i];
  cout<<res;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:32: error: expected ']' before '}' token
    8 |   for(int i=0;i<n;i++) cin>>a[i};
      |                                ^
      |                                ]
a.cc:8:32: error: expected ';' before '}' token
    8 |   for(int i=0;i<n;i++) cin>>a[i};
      |                                ^
      |                                ;
a.cc: At global scope:
a.cc:9:7: error: expected constructor, destructor, or type conversion before '(' token
    9 |   sort(a,a+n);
      |       ^
a.cc:10:3: error: expected unqualified-id before 'for'
   10 |   for(int i=1;i<n;i++) res+=a[i];
      |   ^~~
a.cc:10:15: error: 'i' does not name a type
   10 |   for(int i=1;i<n;i++) res+=a[i];
      |               ^
a.cc:10:19: error: 'i' does not name a type
   10 |   for(int i=1;i<n;i++) res+=a[i];
      |                   ^
a.cc:11:3: error: 'cout' does not name a type
   11 |   cout<<res;
      |   ^~~~
a.cc:12:1: error: expected declaration before '}' token
   12 | }
      | ^
Language: C++

#include <iostream>

typedef long long ll;

using namespace std;

ll n, a[200005], ans, cnt;

int main() {
    cin >> n;
    for (ll i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    ans += a[n];
    cnt = n - 2;
    for (ll i = n - 1; i >= 1; i--) {
        if (cnt < 1) break;
        if (cnt == 1) ans -= a[i];
        ans += 2 * a[i];
        cnt -= 2;
    }
    cout << ans << endl;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll
int main(){
 ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++) cin>>a[i};
  sort(a,a+n);
  ll res=0;
  for(ll i=1;i<n;i++) res+=a[i];
  cout<<res;
}

Compiler output:
a.cc:4:1: error: expected initializer before 'int'
    4 | int main(){
      | ^~~
a.cc:9:7: error: expected constructor, destructor, or type conversion before '(' token
    9 |   sort(a,a+n);
      |       ^
a.cc:10:3: error: 'll' does not name a type
   10 |   ll res=0;
      |   ^~
a.cc:11:3: error: expected unqualified-id before 'for'
   11 |   for(ll i=1;i<n;i++) res+=a[i];
      |   ^~~
a.cc:11:14: error: 'i' does not name a type
   11 |   for(ll i=1;i<n;i++) res+=a[i];
      |              ^
a.cc:11:18: error: 'i' does not name a type
   11 |   for(ll i=1;i<n;i++) res+=a[i];
      |                  ^
a.cc:12:3: error: 'cout' does not name a type
   12 |   cout<<res;
      |   ^~~~
a.cc:13:1: error: expected declaration before '}' token
   13 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int a[200005];
 
int32_t main()
{
    fast;
    int n, sum = 0; cin >> n;
    Rep(i, 1, n) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n, greater<int>());
    Rep(i, 1, n-1) sum += a[i];
    cout << sum;


    
    
    
    return 0;
}#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 

int a[200005];
 
int32_t main()
{
    fast;
    int n, sum = 0; cin >> n;
    Rep(i, 1, n) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n, greater<int>());
    Rep(i, 1, n-1) sum += a[i];
    cout << sum;


    
    
    
    return 0;
}

Compiler output:
a.cc:33:2: error: stray '#' in program
   33 | }#include<bits/stdc++.h>
      |  ^
a.cc:33:3: error: 'include' does not name a type
   33 | }#include<bits/stdc++.h>
      |   ^~~~~~~
a.cc:47:5: error: redefinition of 'long long int a [200005]'
   47 | int a[200005];
      |     ^
a.cc:15:5: note: 'long long int a [200005]' previously declared here
   15 | int a[200005];
      |     ^
a.cc:49:9: error: redefinition of 'int32_t main()'
   49 | int32_t main()
      |         ^~~~
a.cc:17:9: note: 'int32_t main()' previously defined here
   17 | int32_t main()
      |         ^~~~
Language: C++

int main(){
  int N;
  cin >> N;
  int M = N - 1; 
  int sum = 0;
	int num[200100];
	int tmp,i,p,q;
for(int i = 0;i < N;i++){
     sum += num[i];
}
	for(i = 0; i < N; i++){
	scanf("%d",&num[i]);
	}
	
	for(p = 0; p < 4; p++){
		for(q = p + 1; q < 5; q++){
			if(num[p] < num[q]){
				tmp = num[p];
				num[p] = num[q];
				num[q] = tmp;
			}
		}
	}
  cout << sum - num[M] << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> N;
      |   ^~~
a.cc:12:9: error: 'scanf' was not declared in this scope
   12 |         scanf("%d",&num[i]);
      |         ^~~~~
a.cc:24:3: error: 'cout' was not declared in this scope
   24 |   cout << sum - num[M] << endl;
      |   ^~~~
a.cc:24:27: error: 'endl' was not declared in this scope
   24 |   cout << sum - num[M] << endl;
      |                           ^~~~
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class AC_173_D {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int A[]=new int[N];
        for(int i=0;i<A.length;++i)
            A[i]=sc.nextInt();
        Arrays.sort(A);
        long sum=0;
        for(int i=A.length-1;i>0;--i) {
            sum+=A[i];
        }
        System.out.println(sum);
    }
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  
  sort(all(a), grater<ll>());
  ll ans=0;
  rep(i, n-1) ans += a[i];
  cout << ans << newl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:16: error: 'grater' was not declared in this scope
   37 |   sort(all(a), grater<ll>());
      |                ^~~~~~
a.cc:37:25: error: expected primary-expression before '>' token
   37 |   sort(all(a), grater<ll>());
      |                         ^
a.cc:37:27: error: expected primary-expression before ')' token
   37 |   sort(all(a), grater<ll>());
      |                           ^
Language: Java

import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 05 Jul 2020.
 * Problem:
 * Round:
 */

public class D {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine(), " ");
        int[] a = new int[n];
        int j = 0;
        long ans = 0;
        while (st.hasMoreTokens()) {
            a[j] = Integer.parseInt(st.nextToken());
            ans += a[j];
            j++;
        }
        br.close();
        Arrays.sort(a);
        ans -= a[0];

        System.out.println(ans);
    }
}


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

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

long long n;
vector<long long> a;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for (auto &p : a) cin >> p;
  sort(a.begin(), a.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long id = n - 1, x = n, res = 0;
  while (x) {
    res += a[id] * min(2LL, x);
    x -= min(2LL, x)
  }
  return res;
}

Compiler output:
a.cc: In function 'long long int solve()':
a.cc:22:21: error: expected ';' before '}' token
   22 |     x -= min(2LL, x)
      |                     ^
      |                     ;
   23 |   }
      |   ~
Language: C++

// C++ program to find the maximum product of a subarray 
// of size k. 
#include <bits/stdc++.h> 
#define M 1000000007 
#define int long long
using namespace std; 

// This function returns maximum product of a subarray 
// of size k in given arrar, arr[0..n-1]. This function 
// assumes that k is smaller than or equal to n. 
int findMaxProduct(int arr[], int n, int k) 
{ 
	// Initialize the MaxProduct to 1, as all elements 
	// in the array are positive 
	int MaxProduct = 1; 
	for (int i=0; i<k; i++){
		MaxProduct *= arr[i]; 
		MaxProduct %= M;
	}
		

	int prev_product = MaxProduct; 

	// Consider every product beginning with arr[i] 
	// where i varies from 1 to n-k-1 
	for (int i=1; i<=n-k; i++) 
	{ 
		int curr_product = (prev_product/arr[i-1]) * 
							arr[i+k-1]; 
		curr_product %= M;
		MaxProduct = max(MaxProduct, curr_product); 
		prev_product = curr_product; 
	} 

	// Return the maximum product found 
	return MaxProduct; 
} 

// Driver code 
int main() 
{ 	
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int n,k;cin >> n >> k;
	int arr1[n];
	for(int i=0; i<n; ++i) cin >> arr1[i];

	cout << findMaxProduct(arr1, n, k) %M<< endl; 

	

	return 0; 
} 


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

// https://atcoder.jp/contests/abc173/tasks/abc173_e

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

using namespace std;
using namespace atcoder;

using ll = int64_t;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define FORR(i,b,e) for(int i=(b); i>=(int)(e); i--)
#define ALL(v)     (v.begin()), (v.end())

#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2*1e5;
const int A_I_MAX = 1e9;
const int MOD = 1e9+7;

int N, K;
vector<int> A;

vector<double> pacc;
vector<double> nacc;

int main() {
  cin >> N >> K;
  A = vector<int>(N);
  REP(i, N) cin >> A[i];

  sort(ALL(A));

  int ni = lower_bound(ALL(A), 0) - A.begin();
  int nc = ni;
  nacc = vector<double>(nc + 1);
  nacc[0] = 0;
  for (int i = 0, j = 0; i < ni; i++, j++) {
    nacc[j + 1] = nacc[j] + log10(abs(A[i]));
  }

  int pi = upper_bound(ALL(A), 0) - A.begin();
  int pc = N - pi;
  pacc = vector<double>(pc + 1);
  pacc[0] = 0;
  for (int i = N - 1, j = 0; i >= pi; i--, j++) {
    pacc[j + 1] = pacc[j] + log10(abs(A[i]));
  }

  double xlog = 0;
  int xnk = -1;
  int xpk = -1;
  for (int nk = 0; nk <= K; nk += 2) {
    int pk = K - nk;
    if (pk > pc || nk > nc) continue;
    double tmp = pacc[pk] + nacc[nk];
    if (tmp > xlog) {
      xlog = tmp;
      xnk = nk;
      xpk = pk;
    }
  }

  static_modint<MOD> ans = 1;
  if (xlog > 0) {
    for (int i = 0; i < xnk; i++) {
      ans *= A[i];
    }
    for (int i = N - 1; i >= N - xpk; i--) {
      ans *= A[i];
    }
  } else {
    sort(ALL(A), [](auto const& lhs, auto const& rhs) { return abs(lhs) < abs(rhs); });
    REP(i, K) ans *= A[i];
  }
  cout << ans.val() << endl;
}


Compiler output:
a.cc:7:17: error: 'atcoder' is not a namespace-name
    7 | using namespace atcoder;
      |                 ^~~~~~~
a.cc: In function 'int main()':
a.cc:73:3: error: 'static_modint' was not declared in this scope
   73 |   static_modint<MOD> ans = 1;
      |   ^~~~~~~~~~~~~
a.cc:73:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   73 |   static_modint<MOD> ans = 1;
      |                      ^~~
      |                      abs
Language: C++

// https://atcoder.jp/contests/abc173/tasks/abc173_e

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

using namespace std;
using namespace atcoder;

using ll = int64_t;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define FORR(i,b,e) for(int i=(b); i>=(int)(e); i--)
#define ALL(v)     (v.begin()), (v.end())

#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2*1e5;
const int A_I_MAX = 1e9;
const int MOD = 1e9+7;

int N, K;
vector<int> A;

vector<double> pacc;
vector<double> nacc;

int main() {
  cin >> N >> K;
  A = vector<int>(N);
  REP(i, N) cin >> A[i];

  sort(ALL(A));

  int ni = lower_bound(ALL(A), 0) - A.begin();
  int nc = ni;
  nacc = vector<double>(nc + 1);
  nacc[0] = 0;
  for (int i = 0, j = 0; i < ni; i++, j++) {
    nacc[j + 1] = nacc[j] + log10(abs(A[i]));
  }

  int pi = upper_bound(ALL(A), 0) - A.begin();
  int pc = N - pi;
  pacc = vector<double>(pc + 1);
  pacc[0] = 0;
  for (int i = N - 1, j = 0; i >= pi; i--, j++) {
    pacc[j + 1] = pacc[j] + log10(abs(A[i]));
  }

  double xlog = 0;
  int xnk = -1;
  int xpk = -1;
  for (int nk = 0; nk <= K; nk += 2) {
    int pk = K - nk;
    if (pk > pc || nk > nc) continue;
    double tmp = pacc[pk] + nacc[nk];
    if (tmp > xlog) {
      xlog = tmp;
      xnk = nk;
      xpk = pk;
    }
  }

  static_modint<MOD> ans = 1;
  if (xlog > 0) {
    for (int i = 0; i < xnk; i++) {
      ans *= A[i];
    }
    for (int i = N - 1; i >= N - xpk; i--) {
      ans *= A[i];
    }
  } else {
    sort(ALL(A), [](auto const& lhs, auto const& rhs) { return abs(lhs) < abs(rhs); });
    REP(i, K) ans *= A[i];
  }
  cout << ans.val() << endl;
}


Compiler output:
a.cc:4:10: fatal error: atcoder/modint: No such file or directory
    4 | #include <atcoder/modint>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
#include <atcoder/modint>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;

using mint = atcoder::modint1000000007;

void solve() {
    int n, k;
    cin >> n >> k;
    V<int> A(n);
    rep(i, n) cin >> A[i];

    mint ans = 1;

    if (n == k) {
        for (auto&& a : A) {
            ans *= a;
        }
        cout << ans.val() << "\n";
        return;
    }

    bool all_nagative = true;
    for (auto&& a : A) {
        if (a >= 0) all_nagative = false;
    }
    if (all_nagative) {
        sort(A.begin(), A.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
        rep(i, k) { ans *= A[i]; }
        cout << ans.val() << "\n";
        return;
    }

    sort(A.begin(), A.end(), [](int i, int j) -> bool { return abs(i) > abs(j); });
    int minus_cnt = 0;
    rep(i, k) {
        ans *= A[i];
        if (A[i] < 0) minus_cnt++;
    }
    if (minus_cnt % 2 == 0) {
        cout << ans.val() << "\n";
        return;
    }

    bool flag1 = false;  // true : element >= 0 in A[k:]
    bool flag2 = false;  // true: element > 0 in A[:k]
    bool flag3 = false;  // true: element <= 0 in A[k:]
    int v1, v2, v3, v4;
    rep(i, k) {
        if (A[i] < 0) v4 = A[i];
        if (A[i] > 0) {
            flag2 = true;
            v2 = A[i];
        }
    }
    reps(i, k, n) {
        if (!flag3 and A[i] < 0) {
            flag3 = true;
            v3 = A[i];
        }
        if (!flag1 and A[i] >= 0) {
            flag1 = true;
            v1 = A[i];
        }
    }
    mint ans1 = ans;
    if (flag1) {
        ans1 /= v4;
        ans1 *= v1;
    } else {
        ans1 = 0;
    }
    mint ans2 = ans;
    if (flag2 and flag3) {
        ans2 /= v2;
        ans2 *= v3;
    } else {
        ans2 = 0;
    }
    ans = max(ans1.val(), ans2.val());
    cout << ans.val() << "\n";
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Compiler output:
a.cc:5:10: fatal error: atcoder/modint: No such file or directory
    5 | #include <atcoder/modint>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
// Template END
int ans = 1 ;
signed main(){
	int n, k ; cin >> n >> k ;
	vector<int> a(n) ;
	for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;
	if( a[n-1] <= 0 && (k & 1) ){
		sort( all(a), [](int a, int b){
			return a > b ;
		} ) ;
		for( int i = 0 ; i < k ; i++ ){
			ans = ( ans * (a[i] % mod) ) % mod ;
			if( ans < 0 ) ans += mod ;
		}
		cout << ( ans + mod ) % mod 
		return 0 ;
	}
	sort( all( a ) ) ;
	int left = 0, right = n - 1 ;
	if( k & 1 ){
		ans = a[right] ;
		right--, k-- ;
	}
	while( k > 0 ) {
		int f = a[left] * a[left+1], s = a[right] * a[right-1] ;
		if( f > s ){
			f %= mod ;
			ans *= f ;
			ans %= mod ;
			left += 2 ;
		}
		else{
			s %= mod ;
			ans *= s ;
			ans %= mod ;
			right -= 2 ;
		}
		if( ans < 0 ) ans += mod ;
		if( ans < 0 ) ans += mod ;
		k -= 2 ;
	}
	cout << ans ;
	return 0 ;
}













Compiler output:
a.cc: In function 'int main()':
a.cc:40:44: error: expected ';' before 'return'
   40 |                 cout << ( ans + mod ) % mod
      |                                            ^
      |                                            ;
   41 |                 return 0 ;
      |                 ~~~~~~
Language: C++

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
// Template END
int ans = 1 ;
signed main(){
	int n, k ; cin >> n >> k ;
	vector<int> a(n) ;
	for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;
	if( a[n-1] <= 0 && (k & 1) ){
		sort( all(a), [](int a, int b){
			return a > b ;
		} ) ;
		for( int i = 0 ; i < k ; i++ ){
			ans = ( ans * (a[i] % mod) ) % mod ;
			if( ans < 0 ) ans += mod ;
		}
		cout << ( ans + mod ) % mod 
		return 0 ;
	}
	sort( all( a ) ) ;
	int left = 0, right = n - 1 ;
	if( k & 1 ){
		ans = a[right] ;
		right--, k-- ;
	}
	while( k > 0 ) {
		int f = a[left] * a[left+1], s = a[right] * a[right-1] ;
		if( f >= s ){
			f %= mod ;
			ans *= f ;
			ans %= mod ;
			left += 2 ;
		}
		else{
			s %= mod ;
			ans *= s ;
			ans %= mod ;
			right -= 2 ;
		}
		if( ans < 0 ) ans += mod ;
		if( ans < 0 ) ans += mod ;
		k -= 2 ;
	}
	cout << ans ;
	return 0 ;
}













Compiler output:
a.cc: In function 'int main()':
a.cc:40:44: error: expected ';' before 'return'
   40 |                 cout << ( ans + mod ) % mod
      |                                            ^
      |                                            ;
   41 |                 return 0 ;
      |                 ~~~~~~
Language: C++

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
void absorb( int &product, int &x ){
    product = ( product * (x % mod) ) % mod ;
    if( produce < 0 ) product += mod ;
}


signed main(){
    int n, k ; cin >> n >> k ;
    vector<int> a(n) ;
    for( int i = 0 ; i < n ; i++ ){
        cin >> a[i] ;
    }
    sort( all(a) ) ; int ans = 1 ;
    if( a[n-1] <= 0 && (k & 1) ) {
        reverse( all(a) ) ;
        for( int i = 0 ; i < k ; i++ ){
            absorb( ans, a[i] ) ;
        }
        cout << ans ;
        return 0 ;
    }
    n-- ;
    // cout << k << " " << n << endl ;
    if( k & 1 ){
        absorb( ans, a[n] ) ;
        k-- ;
        n-- ;
    }
    int i = 0 ;
    while( k > 0 ){
        int f = a[i] * a[i+1], s = a[n] * a[n-1] ;
        if( f > s ){
            f %= mod ;
            absorb( ans, f ) ;
            i += 2 ;
        }
        else{
            s %= mod ;
            absorb( ans, s ) ;
            n -= 2 ;
        }
        k -= 2 ;
    }
    cout << ans ;
    return 0 ;   
}


Compiler output:
a.cc: In function 'void absorb(long long int&, long long int&)':
a.cc:30:9: error: 'produce' was not declared in this scope; did you mean 'product'?
   30 |     if( produce < 0 ) product += mod ;
      |         ^~~~~~~
      |         product
Language: C++

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
void absorb( int &product, int &x ){
    product = ( product * x ) % mod ;
}


signed main(){
    int neg = 0 ;
    int n, k ; cin >> n >> k ;
    vector<int> a(n) ;
    for( int i = 0 ; i < n ; i++ ){
        cin >> a[i] ;
        if( a[i] < 0 ) neg++ ;
    }
    sort( all(a) ) ; int ans = 1 ;
    if( v[n-1] == 0 && (k & 1) ) {
        for( int i = 0 ; i < k ; i++ ){
            absorb( ans, a[i] ) ;
        }
        cout << (ans + mod) % mod ;
        return 0 ;
    }
    n-- ;
    // cout << k << " " << n << endl ;
    if( k & 1 ){
        absorb( ans, a[n--] ) ;
        k-- ;
    }
    int i = 0 ;
    while( k > 0 ){
        int f = a[i] * a[i+1], s = a[n] * a[n-1] ;
        if( f >= s ){
            f %= mod ;
            absorb( ans, f ) ;
            i += 2 ;
        }
        else{
            s %= mod ;
            absorb( ans, s ) ;
            n -= 2 ;
        }
        k -= 2 ;
    }
    cout << ans ;
    return 0 ;   
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:9: error: 'v' was not declared in this scope
   42 |     if( v[n-1] == 0 && (k & 1) ) {
      |         ^
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
long long int mod = 1e9 + 7;
long long int  n,m;
long long int a[200005];
bool cmp(int x, int y)
{
	return abs(x) < abs(y);
}
int main()
{
	int pn=0 ,nn = 0;
	//pn正数，nn负数；
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] >= 0)
			pn++;
		else
			nn++;
	}
	int l=1, r=n;//左右逼近
	long long ans = 1;
	if (!pn && m % 2 == 1)//结果必定为负数
	{
		sort(a + 1, a + 1 + n, cmp);
		for (int i = 1; i <= m; i++) 
			ans = a[i] * ans % mod;
	}
	else
	{
		sort(a + 1, a + 1 + n, greater< int >());
			内置类型的由大到小排序
		while (m)
		{
			if (m % 2 == 1)//为奇数就乘大的正数
			{
				ans = ans * a[l] % mod;
				l++, m--;
			}
			else
			{
				if (a[l] * a[l + 1] >= a[r] * a[r - 1])
					//两正数乘起来比负数大
				{
					ans = ans * a[l] % mod * a[l + 1] % mod;
					l += 2,m -= 2;
				}
				else
				{
					ans = ans * a[r - 1] % mod * a[r] % mod;
					r -= 2,m -= 2;
				}
			}

		}
	}
	//防止出现负数，故再加mod再取余数
	cout << (ans % mod + mod) % mod << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:25: error: '\U00005185\U00007f6e\U00007c7b\U0000578b\U00007684\U00007531\U00005927\U00005230\U00005c0f\U00006392\U00005e8f' was not declared in this scope
   37 |                         内置类型的由大到小排序
      |                         ^~~~~~~~~~~~~~~~~~~~~~
Language: C++

//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
//unordered_map
typedef long long ll;
ll a[MAXN];
int cmp(int f,int s)
{
	return abs(f)>abs(s);
}
int main()
{
	int n,k,vis=0,zheng=0,fu=0;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) 
	{
	    scanf("%lld",&a[i]);
	    if(a[i]<0)	fu++;
		else ,zheng++;
	}
	ll ans=1;
	//判断答案是正负  觉得先判负 wa了8个数据 可能wa在负数取模上 
	if(n==k)
	{
		for(int i=1;i<=n;i++)
		{
			ans=(ans%mod*a[i]%mod)%mod;
		}
		printf("%lld\n",(ans%mod+mod)%mod);
	}
	else
	{
    	if(k%2&&zheng==0)//负 
    	{
    		sort(a+1,a+1+n,cmp);
    		for(int i=n;i>=n-k+1;i--)
    		{
    			ans=(ans%mod*a[i]%mod)%mod;
			}
			printf("%lld\n",(ans%mod+mod)%mod);
    	} 
    	else
    	{
    		sort(a+1,a+1+n);
    		int r=n,l=1;
    		if(k%2) ans=(ans%mod*a[r]%mod)%mod,r--,k--;
    		while(k>0)
    		{
    			ll sum1=a[l]*a[l+1],sum2=a[r]*a[r-1];
    			if(sum1>=sum2)
    			{
    				ans=(ans%mod*sum1%mod)%mod;
    				l+=2;
    				k-=2;
				}
				else
				{
					ans=(ans%mod*sum2%mod)%mod;
    				r-=2;
    				k-=2;
				}
			}
			printf("%lld\n",(ans%mod+mod)%mod);
    	}
	} 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:22: error: expected primary-expression before ',' token
   43 |                 else ,zheng++;
      |                      ^
Language: C++

#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long

#define md 1000000007
#define mx 200005
int arr[mx];

int main(){
    int n,k;
    scanf("%d %d",&n,&k);

    for(int i=0;i<n;i++){
        scanf("%d",arr+i);
    }

    sort(arr,arr+n,[](int a, int b){return abs(a)>abs(b);});

    bool solved=false;

    int fks=1;
    for(int i=0;i<k;i++){
        if(arr[i]<0) fks*=-1;
        if(arr[i]==0) fks*=0;
    }

    if(fks==1){
        solved=true;
        ll prod=1;
        for(int i=0;i<k;i++) prod=(prod*arr[i])%md;
        printf("%lld\n", prod);
    }
    else if(fks==0){
        solved=true;
        printf("0\n");
    }
    else{
        assert(false);
        int last_neg=1,last_pos=-1,fst_neg=1,fst_pos=-1;
        int lpidx,lnidx;

        for(int i=0;i<k;i++){
            if(arr[i]>0) {last_pos=arr[i]; lpidx=i;}
            if(arr[i]<0) {last_neg=arr[i]; lnidx=i;}
        }
        for(int i=n-1;i>=k;i--){
            if(arr[i]>0) fst_pos=arr[i];
            if(arr[i]<0) fst_neg=arr[i];
        }

        ll prod1=-1,prod2=-1;
        if(last_neg<0 && fst_pos>0){
            solved=true;
            prod1=fst_pos;
            for(int i=0;i<k;i++) if(i!=lnidx) prod1=(prod1*arr[i])%md;
        }
        else if(fst_neg<0 && last_pos>0){
            solved=true;
            prod2=fst_neg;
            for(int i=0;i<k;i++) if(i!=lpidx) prod2=(prod2*arr[i])%md;
        }
        if(prod1>=0 and prod2>=0){
            if(fst_pos*(ll)last_pos > fst_neg*(ll)last_neg){
                printf("%lld\n",prod1);
            }
            else{
                printf("%lld\n",prod2);
            }
        }
        else if(solved){
            printf("%lld\n",max(prod1,prod2));
        }
    }

    if(!solved){
        if(arr[n-1]==0){
            solved=true;
            printf("0\n");
        }
        else{
            solved=true;
            ll prod=1;
            for(int i=0;i<k;i++) prod=(prod*arr[n-1-i])%md;
            if(prod<0) prod=prod+md;
            printf("%lld\n",prod);
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'assert' was not declared in this scope
   39 |         assert(false);
      |         ^~~~~~
a.cc:3:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    2 | #include <algorithm>
  +++ |+#include <cassert>
    3 | using namespace std;
Language: C++

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

#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 INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N,K; cin>>N>>K;
    vector<ll> A(N); rep(i,N)cin>>A.at(i);
    vector<ll> P,M,Z;
    rep(i,N){
        if(A.at(i)>0)P.push_back(A.at(i));
        if(A.at(i)<0)M.push_back(A.at(i));
        if(A.at(i)==0)Z.push_back(A.at(i));
    }
    sort(P.begin(),P.end());
    reverse(P.begin(),P.end());
    sort(M.begin(),M.end());

    int cK = K;
    ll res = 1;
    int p = 0, m = 0;
    int sp = P.size(), sm = M.size();
    while(K){
        if(m>=sm-1){
            res*=P.at(p);
            p++;
            K--;
        }
        else if(p>=sp){
            res*=M.at(m);
            m++;
            K--;
        }
        else{
            if(P.at(p)*P.at(p+1)<M.at(m)*M.at(m+1)){
                res*=M.at(m)*M.at(m+1);
                m+=2;
                K-=2;
            }else
                res*=P.at(p);
                p++;
                K--;
            }
        }
        if(res>0)res%=MOD;
        
    }
    if(res<0){
        reverse(M.begin(),M.end());
        ll tmpres = 1;
        rep(i,cK)tmpres*=M.at(i);
        cout<<(max(res,tmpres)+MOD)%MOD<<endl;
    }else cout<<(res+MOD)%MOD<<endl;
}

Compiler output:
a.cc:53:5: error: expected unqualified-id before 'if'
   53 |     if(res<0){
      |     ^~
a.cc:58:6: error: expected unqualified-id before 'else'
   58 |     }else cout<<(res+MOD)%MOD<<endl;
      |      ^~~~
a.cc:59:1: error: expected declaration before '}' token
   59 | }
      | ^
Language: C++

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

ll MOD = 1000000007;

int main(void){
    int n,k;
    cin>>n>>k;
    vector<ll> a(n);
    int pm=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0)pm++;
    }
    sort(a.begin(),a.end());
    vector<ll> p(n,0),m(n,0);
    rep(i,pm)m[i]=a[i];
    rep(i,n-pm)p[i]=a[n-1-i];
    ll ans=1,prep,prem;
    // 例外
    if(pm==n && k%2==1){
        for(int i=n-1;i>=n-k;i--)ans=(ans*a[i])%MOD;
        ans+=MOD;
    }
    else if(n==k){
        rep(i,k)ans=(ans*a[i])%MOD;
    }
    else{
        int i=0,j=0;
        while(i+j<k){
            if(p[i]>=m[j]*(-1)){
                prep=ans*p[i];
                ans=prep%MOD;
                i++;
            }
            else{
                prem=ans*m[j];
                ans=prem%MOD;
                j++;
            }
        }
        if(j%2==1){
            if(i==0)ans=(prem/m[j-1]*p[i]%MOD;
            else if(j==0)ans=(prep/p[i-1]*m[j])%MOD;
            else if(p[i-1]*p[i]>=m[j-1]*m[j])ans=(prem/m[j-1]*p[i])%MOD;
            else ans=(prep/p[i-1]*m[j])%MOD;
        }
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:46: error: expected ')' before ';' token
   46 |             if(i==0)ans=(prem/m[j-1]*p[i]%MOD;
      |                         ~                    ^
      |                                              )
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const ll ll_mod=1e9+7;
int n,k;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    cin >> n >> k;
    vector< pair<ll,ll> > a(n);
    bool all_negative=true;
    for(int i=0; i<n; i++){
        cin >> a[i].first;
        a[i].second = abs(a[i].first);
        if(a[i].first>0) all_negative=false;
    }
    ll ans=1;
    //k=nのとき
    if(k==n){
        for(int i=0; i<n; i++){ans *= a[i].first; ans %= ll_mod;}
        if(ans<0){ans += ll_mod; ans%=ll_mod;}
        cout << ans << "\n";
        return 0;
    }
    //sort
    sort(a.begin(), a.end(), compare_by_b);
    //全てのaが負でかつkが奇数のとき
    if(all_negative && k%2==1){
        for(int i=n-1; i>=n-k; i--){ans *= a[i].first; ans %= ll_mod;}
        if(ans<0) ans += ll_mod;
        else if(a[n-1].first==0) ans=0;
        cout << ans << "\n";
        return 0;
    }
    //それ以外
    for(int i=0; i<k; i++){
        ans *= a[i].first; ans %= ll_mod;
        if(a[i].first>0) all_negative=false;
    }
    if(ans<0){
        ll rm_negative, rm_positive, add_negative, add_positive;
        rm_negative = -1e10;
        rm_positive = 1e10;
        add_negative = add_positive = 0;
        for(int i=0; i<k; i++){
            if(a[i].first<0) rm_negative = max(rm_negative, a[i].first);
            else if(a[i].first>0) rm_positive = min(rm_positive, a[i].first);
        }
        for(int i=k; i<n; i++){
            if(a[i].first<0) add_negative = min(add_negative, a[i].first);
            else if(a[i].first>0) add_positive = max(add_positive, a[i].first);
        }
        ans=1;
        if(rm_negative == -1e10){
                for(int i=0; i<k; i++){
                    if(a[i].first==rm_positive) ans*= add_negative;
                    else ans *= a[i].first; 
                    ans %= ll_mod;
                }
        }else if(rm_positive == 1e10;){
                for(int i=0; i<k; i++){
                    if(a[i].first==rm_negative) ans*= add_positive;
                    else ans *= a[i].first; 
                    ans %= ll_mod;
                }
        }else{
            if(rm_negative*add_negative<=rm_positive*add_positive){
                for(int i=0; i<k; i++){
                    if(a[i].first==rm_negative) ans*= add_positive;
                    else ans *= a[i].first; 
                    ans %= ll_mod;
                }
            }else{
                for(int i=0; i<k; i++){
                    if(a[i].first==rm_positive) ans*= add_negative;
                    else ans *= a[i].first; 
                    ans %= ll_mod;
                }
            }
        }
    }
    cout << ans << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:38: error: expected primary-expression before ')' token
   70 |         }else if(rm_positive == 1e10;){
      |                                      ^
Language: C++

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

int modX(long n){
  int R=n%1000000007;
  return R;
}

int main(){
  int N;cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  bool plus=true;
  int F=0;//0の数も数えようか考えたが、関係なさそう
  while(plus){
    if(A.at(F)>0) break;
    F++;
    if(F==N) plus=false;
  }
  int ans=1;
  if(plus){//A.at(F-1)までのF個は負か0、A.at(F)以降のN-F個は正
    if(N-F>=K){
      for(int i=0;i<K;i++){
        long G=ans*A.at(N-1-i);
        ans=modX(G);
      }
      cout<<ans<<endl;
    }
    else{
      for(int i=0;i<N-F;i++){
        long G=ans*A.at(N-1-i);
        ans=modX(G);
      }
      for(int j=0;j<K-N+F;j++){
        long G=ans*A.at(j);
        ans=modX(G);
      }
      cout<<ans<<endl;
    }
  }
  else{
    for(int j=0;j<K;j++){
        long G=ans*A.at(j);
        ans=modX(G);
      }
    cout<<ans<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:13: error: 'K' was not declared in this scope
   23 |     if(N-F>=K){
      |             ^
a.cc:43:19: error: 'K' was not declared in this scope
   43 |     for(int j=0;j<K;j++){
      |                   ^
Language: C++

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

#define ll long long
const int MOD = 1e9+7;
ll mod(ll x) {
	return (x%MOD + MOD) %MOD;
}
ll mul(ll a,ll b) {
	return mod(mod(a) * mod(b));
}
ll cond1(vector<ll> &v,int k)
{
	ll result = 1;
	if(k%2 == 0) 
	{
		for(int i = 0;i<k;i++)
			result = mul(result,v[i]);
		return result;
	}
	
	int n = v.size();
	for(int i = n-1; i >= n-k;i--)
		result = mul(result,v[i]);
	return result;
}
ll cond2(vector<ll> &a,vector<ll> &b)
{
	ll result = 1;
	for(int i = 0;i<a.size();i++)
		result = mul(result,a[i]);
	for(int i = 0;i<b.size();i++)
		result = mul(result,b[i]);
	return result;
}
int main() {
	int n,k;
	cin >> n >> k;
	vector<ll> pos_v;
	vector<ll> neg_v;
	for(int i = 0;i<n;i++)
	{
		ll tmp;
		cin >> tmp;
		if(tmp >= 0)
			pos_v.push_back(tmp);
		else
			neg_v.push_back(tmp);
	}
	sort(pos_v.begin(),pos_v.end(),greater<ll>());
	sort(neg_v.begin(),neg_v.end());

	if(pos_v.size() == 0) {
		cout  << cond1(neg_v,k) << endl;
		return 0;
	}
	
	if( k == n) 
	{
		cout << cond2(pos_v,neg_v) << endl;
		return 0;
	}
	
	ll result = 1;int i = 0,j = 0;
	

	while(k > 0) {
		ll first = 1;
        if(i+1 < pos_v.size()) {
        	first = mul(pos_v[i],pos_v[i+1]);
        }
        ll second = 1;
        if(j+1 < neg_v.size()) {
        	second = mul(neg_v[i],neg_v[i+1]);
        }
        if(first > second){
        	result = mul(result,first);
        	i += 2;
        }
        else {
        	result = mul(result,second);
        	j += 2;
        }
        if(k == 1)
        { 
        	if(i < pos_v.size())
        	result = mod(result,pos_v[i]);
        }
		k -= 2;
	}
	cout << result << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:29: error: too many arguments to function 'long long int mod(long long int)'
   87 |                 result = mod(result,pos_v[i]);
      |                          ~~~^~~~~~~~~~~~~~~~~
a.cc:6:4: note: declared here
    6 | ll mod(ll x) {
      |    ^~~