Language: C++

#include <bits/stdc++.h>

#include <functional>

#include <iostream>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素



void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *),ll,ll> f) {
    int indexes[k];
    recursive_comb(indexes, n - 1, k, f);
}


signed main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    // vector<bool> Minus(N);
    REP(i,N){
        cin >> A.at(i);
        
    }
    
    ll ans = -1000000000000;
    
    foreach_comb(N, K,
        [](int *indexes,ll K,ll ans) {
            long long thisAns = 1;
            REP(i, K){
                thisAns *= indexes[i];
                thisAns = (MOD + thisAns * -1) % MOD;
            }
            if(ans < thisAns){
                ans = thisAns;
            }
            // cout << indexes[0] << ',' << indexes[1] << ',' << indexes[2] << endl;
        }
    );
    ans = (MOD + ans * -1) % MOD;
    cout << ans;
}


Compiler output:
a.cc:48:64: error: wrong number of template arguments (3, should be 1)
   48 | void foreach_comb(int n, int k, std::function<void(int *),ll,ll> f) {
      |                                                                ^
In file included from /usr/include/c++/14/functional:59,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/std_function.h:111:11: note: provided for 'template<class _Signature> class std::function'
  111 |     class function;
      |           ^~~~~~~~
a.cc: In function 'void foreach_comb(int, int, int)':
a.cc:50:39: error: could not convert 'f' from 'int' to 'std::function<void(int*)>'
   50 |     recursive_comb(indexes, n - 1, k, f);
      |                                       ^
      |                                       |
      |                                       int
a.cc: In function 'int main()':
a.cc:68:9: error: invalid user-defined conversion from 'main()::<lambda(int*, ll, ll)>' to 'int' [-fpermissive]
   68 |         [](int *indexes,ll K,ll ans) {
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |             long long thisAns = 1;
      |             ~~~~~~~~~~~~~~~~~~~~~~
   70 |             REP(i, K){
      |             ~~~~~~~~~~
   71 |                 thisAns *= indexes[i];
      |                 ~~~~~~~~~~~~~~~~~~~~~~
   72 |                 thisAns = (MOD + thisAns * -1) % MOD;
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   73 |             }
      |             ~
   74 |             if(ans < thisAns){
      |             ~~~~~~~~~~~~~~~~~~
   75 |                 ans = thisAns;
      |                 ~~~~~~~~~~~~~~
   76 |             }
      |             ~
   77 |             // cout << indexes[0] << ',' << indexes[1] << ',' << indexes[2] << endl;
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   78 |         }
      |         ~
a.cc:68:9: note: candidate is: 'constexpr main()::<lambda(int*, ll, ll)>::operator void (*)(int*, ll, ll)() const' (near match)
   68 |         [](int *indexes,ll K,ll ans) {
      |         ^
a.cc:68:9: note:   no known conversion from 'void (*)(int*, ll, ll)' {aka 'void (*)(int*, long long int, long long int)'} to 'int'
a.cc:48:66: note:   initializing argument 3 of 'void foreach_comb(int, int, int)'
   48 | void foreach_comb(int n, int k, std::function<void(int *),ll,ll> f) {
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^