Language: C++

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

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

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

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

   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:40:17: error: 'll' was not declared in this scope; did you mean 'all'?
   40 |     vector<pair<ll,ll>>v;
      |                 ^~
      |                 all
a.cc:40:20: error: template argument 1 is invalid
   40 |     vector<pair<ll,ll>>v;
      |                    ^~
a.cc:40:22: error: template argument 1 is invalid
   40 |     vector<pair<ll,ll>>v;
      |                      ^~
a.cc:40:22: error: template argument 2 is invalid
a.cc:41:11: error: expected ';' before 'i'
   41 |     for(ll i=0;i<n;i++){
      |           ^~
      |           ;
a.cc:41:16: error: 'i' was not declared in this scope
   41 |     for(ll i=0;i<n;i++){
      |                ^
a.cc:42:11: error: expected ';' before 'x'
   42 |         ll x, s; cin >> x;
      |           ^~
      |           ;
a.cc:42:25: error: 'x' was not declared in this scope
   42 |         ll x, s; cin >> x;
      |                         ^
a.cc:45:7: error: 's' was not declared in this scope
   45 |       s = 1;
      |       ^
a.cc:49:7: error: 's' was not declared in this scope
   49 |       s = -1;
      |       ^
a.cc:53:7: error: 's' was not declared in this scope
   53 |       s = 1;
      |       ^
a.cc:55:7: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   55 |     v.push_back({abs(x), s});
      |       ^~~~~~~~~
a.cc:55:26: error: 's' was not declared in this scope
   55 |     v.push_back({abs(x), s});
      |                          ^
a.cc:59:12: error: request for member 'begin' in 'v', which is of non-class type 'int'
   59 |     sort(v.begin(),v.end());
      |            ^~~~~
a.cc:59:22: error: request for member 'end' in 'v', which is of non-class type 'int'
   59 |     sort(v.begin(),v.end());
      |                      ^~~
a.cc:91:26: error: invalid types 'int[long long int]' for array subscript
   91 |          ans = mul(ans, v[l].first * v[l].second);
      |                          ^
a.cc:91:39: error: invalid types 'int[long long int]' for array subscript
   91 |          ans = mul(ans, v[l].first * v[l].second);
      |                                       ^