Language: C++

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

ll MOD = 1000000007;

struct data{
    double raw;
    ll ans;
    data(ll a){
        raw = (double)a;
        ans = a;
    }
    void mult(ll a){
        raw *= (double)a;
        ans = (((ans*a)%MOD)+MOD)%MOD;
    }
};

vector<data> candidate;
int main() { 
    int N, K;
    ll a;
    cin >> N >> K;
    vector<ll> P, M;
    bool hasZero = false;
    for(int i=0; i<N; i++){
        cin >> a;
        if(a>0) P.emplace_back(a);
        else if(a==0) hasZero  = true;
        else M.emplace_back(a);
    }
    sort(P.begin(), P.end(), std::greater<ll>());
    sort(M.begin(), M.end());
    if(hasZero) candidate.emplace_back(data(0));

    //try1
    data t1(1);
    int cntP=0, cntM = 0;
    while(cntP+cntM<K){
        if(cntP==P.size()){
            t1.mult(M[cntM]);
            cntM++;
        }
        else if(cntM == M.size()){
            t1.mult(P[cntP]);
            cntP++;
        }
        else if(cntP + cntM < K-1 && cntM<M.size()-1){
            if(P[cntP] < M[cntM]*M[cntM+1]){
                t1.mult(M[cntM]);
                t1.mult(M[cntM+1]);
                cntM+=2;
            }
            else{
                t1.mult(P[cntP]);
                cntP++;
            }
        }
        else{
            t1.mult(P[cntP]);
            cntP++;
        }
    }
    candidate.emplace_back(t1);

    //try2
    if(M.size() > 1){
        sort(P.begin(), P.end());
        sort(M.begin(), M.end(),std::greater<ll>());
        data t2(M[0]);
        cntP=0, cntM = 1;
        while(cntP+cntM<K){
            if(cntP==P.size()){
                t2.mult(M[cntM]);
                cntM++;
            }
            else if(cntM == M.size()){
                t2.mult(P[cntP]);
                cntP++;
            }
            else if(cntP + cntM < K-1 && cntM<M.size()-1){
                if(P[cntP] > M[cntM]*M[cntM+1]){
                    t2.mult(M[cntM]);
                    t2.mult(M[cntM+1]);
                    cntM+=2;
                }
                else{
                    t2.mult(P[cntP]);
                    cntP++;
                }
            }
            else{
                t2.mult(P[cntP]);
                cntP++;
            }
        }
         candidate.emplace_back(t2);
    }

    sort(candidate.begin(), candidate.end(), [](const data& l, const data& r)->int {return l.raw > r.raw;});    
    cout << candidate[0].ans << endl; 
}

Compiler output:
a.cc:20:12: error: template argument 1 is invalid
   20 | vector<data> candidate;
      |            ^
a.cc:20:12: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:35:27: error: request for member 'emplace_back' in 'candidate', which is of non-class type 'int'
   35 |     if(hasZero) candidate.emplace_back(data(0));
      |                           ^~~~~~~~~~~~
a.cc:35:40: error: reference to 'data' is ambiguous
   35 |     if(hasZero) candidate.emplace_back(data(0));
      |                                        ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:8: note:                 'struct data'
    7 | struct data{
      |        ^~~~
a.cc:38:5: error: reference to 'data' is ambiguous
   38 |     data t1(1);
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:8: note:                 'struct data'
    7 | struct data{
      |        ^~~~
a.cc:42:13: error: 't1' was not declared in this scope; did you mean 'y1'?
   42 |             t1.mult(M[cntM]);
      |             ^~
      |             y1
a.cc:46:13: error: 't1' was not declared in this scope; did you mean 'y1'?
   46 |             t1.mult(P[cntP]);
      |             ^~
      |             y1
a.cc:51:17: error: 't1' was not declared in this scope; did you mean 'y1'?
   51 |                 t1.mult(M[cntM]);
      |                 ^~
      |                 y1
a.cc:56:17: error: 't1' was not declared in this scope; did you mean 'y1'?
   56 |                 t1.mult(P[cntP]);
      |                 ^~
      |                 y1
a.cc:61:13: error: 't1' was not declared in this scope; did you mean 'y1'?
   61 |             t1.mult(P[cntP]);
      |             ^~
      |             y1
a.cc:65:15: error: request for member 'emplace_back' in 'candidate', which is of non-class type 'int'
   65 |     candidate.emplace_back(t1);
      |               ^~~~~~~~~~~~
a.cc:65:28: error: 't1' was not declared in this scope; did you mean 'y1'?
   65 |     candidate.emplace_back(t1);
      |                            ^~
      |                            y1
a.cc:71:9: error: reference to 'data' is ambiguous
   71 |         data t2(M[0]);
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:8: note:                 'struct data'
    7 | struct data{
      |        ^~~~
a.cc:75:17: error: 't2' was not declared in this scope; did you mean 'tm'?
   75 |                 t2.mult(M[cntM]);
      |                 ^~
      |                 tm
a.cc:79:17: error: 't2' was not declared in this scope; did you mean 'tm'?
   79 |                 t2.mult(P[cntP]);
      |                 ^~
      |                 tm
a.cc:84:21: error: 't2' was not declared in this scope; did you mean 'tm'?
   84 |                     t2.mult(M[cntM]);
      |                     ^~
      |                     tm
a.cc:89:21: error: 't2' was not declared in this scope; did you mean 'tm'?
   89 |                     t2.mult(P[cntP]);
      |                     ^~
      |                     tm
a.cc:94:17: error: 't2' was not declared in this scope; did you mean 'tm'?
   94 |                 t2.mult(P[cntP]);
      |                 ^~
      |                 tm
a.cc:98:20: error: request for member 'emplace_back' in 'candidate', which is of non-class type 'int'
   98 |          candidate.emplace_back(t2);
      |                    ^~~~~~~~~~~~
a.cc:98:33: error: 't2' was not declared in this scope; did you mean 'tm'?
   98 |          candidate.emplace_back(t2);
      |                                 ^~
      |                                 tm
a.cc:101:20: error: request for member 'begin' in 'candidate', which is of non-class type 'int'
  101 |     sort(candidate.begin(), candidate.end(), [](const data& l, const data& r)->int {return l.raw > r.raw;});
      |                    ^~~~~
a.cc:101:39: error: request for member 'end' in 'candidate', which is of non-class type 'int'
  101 |     sort(candidate.begin(), candidate.end(), [](const data& l, const data& r)->int {return l.raw > r.raw;});
      |                                       ^~~
a.cc:101:55: error: reference to 'data' is ambiguous
  101 |     sort(candidate.begin(), candidate.end(), [](const data& l, const data& r)->int {return l.raw > r.raw;});
      |                                                       ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:8: note:                 'struct data'
    7 | struct data{
      |        ^~~~
a.cc: In lambda function:
a.cc:101:108: error: expected '{' before ';' token
  101 |     sort(candidate.begin(), candidate.end(), [](const data& l, const data& r)->int {return l.raw > r.raw;});
      |                                                                                                            ^
a.cc: In function 'int main()':
a.cc:101:108: error: expected ')' before ';' token
  101 |     sort(candidate.begin(), candidate.end(), [](const data& l, const data& r)->int {return l.raw > r.raw;});
      |         ~                                                                                                  ^
      |                                                                                                            )
a.cc:102:22: error: invalid types 'int[int]' for array subscript
  102 |     cout << candidate[0].ans << endl;
      |                      ^