Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    ll n, k, zc=0;    cin >> n >> k;
    vector<ll> pos, neg;
  
    REP(i, n){
        ll x;   cin >> x;
        if(0<x) pos.push_back(x);
        else if(x<0) neg.push_back(x);
        else zc = 1;
    }
    sort(ALL(pos), greater<ll>());
    sort(ALL(neg));
    ll res=1;
    if(neg.size()+pos.size()<k) res=0;
    else{
        priority_queue<ll> pv, nv;
        REP(i, pos.size()/2) pv.push(pos[2*i]*pos[2*i+1]); 
        REP(i, neg.size()/2) nv.push(neg[2*i]*neg[2*i+1]);
        ll obj = max(k-2*pos.size(), 0LL);
        if(obj%2){
            if(zc) res = 0;
            priority_queue<ll, vector<ll>, greater<ll>> v;
            REP(i, pos.size()) v.push(pos[i]);
            REP(i, neg.size()) v.push(-neg[i]);
            REP(i, k){
                res *= v.top(); v.pop();
                res = (res+MOD)%MOD;
            }
            
        }else{
            ll bef=pv.size();
            while(1<k && !pv.empty() || !nv.empty()){
                if(!pv.empty() && !nv.empty()){
                    if(pv.top()<=nv.top()){
                        res = (res*nv.top())%MOD;
                        nv.pop();
                    }else{
                        res = (res*pv.top())%MOD;
                        pv.pop();
                    }
                }else if(!pv.empty()){
                    res = (res*pv.top())%MOD;
                    pv.pop();
                }else{
                    res = (res*nv.top())%MOD;
                    nv.pop();
                }
                k -= 2;
            }
            if(k) res = (res*pos[2*(bef-pv.size())]) % MOD;
        }
    }
    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:21: error: no matching function for call to 'max(long long unsigned int, long long int)'
   39 |         ll obj = max(k-2*pos.size(), 0LL);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:39:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   39 |         ll obj = max(k-2*pos.size(), 0LL);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:39:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   39 |         ll obj = max(k-2*pos.size(), 0LL);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~