Language: C++

#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
constexpr long long int MOD = 998244353;
static int sum;
std::vector<std::vector<std::vector<long long int>>> memo;
long long int pattern(const std::vector<int>& run_length, const int current_pos, const int current_use, const int k) {
	if (k < 0) return 0LL;
	if (run_length.size() <= current_pos) return current_use == sum ? 1LL : 0LL;
	if (current_use == sum) return 1LL;
	if (memo[current_pos][current_use][k] >= 0) return memo[current_pos][current_use][k];
	long long int result{ 0 };
	for (auto use = 0; current_use + use <= sum; ++use) {
		result += pattern(run_length, current_pos + 1, current_use + use, k - std::max(0, use - run_length[current_pos]));
	}
	return memo[current_pos][current_use][k] = result % MOD;
}
int main() {
	std::string str; int k; std::cin >> str >> k;
	std::vector<int> run_length{ 0 };
	for (const auto c: str) {
		if (c == '1') {
			run_length.back()++;
		}
		else {
			run_length.push_back(0);
		}
	}
	const auto all_one = std::count(str.begin(), str.end(), '1');
	sum = all_one;
	memo = std::vector<std::vector<std::vector<long long int>>>(run_length.size(), std::vector<std::vector<long long int>>(all_one + 1, std::vector<long long int>(std::min(k, all_one) + 1, -1)));
	int prev{ 0 };
	for (auto i = 0; i < run_length.size(); ++i) {
		for (auto j = 0; j < prev; ++j) {
			std::fill(memo[i][j].begin(), memo[i][j].end(), 0);
		}
		prev += run_length[i];
	}
	std::cout << pattern(run_length, 0, 0, std::min(k, all_one));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:176: error: no matching function for call to 'min(int&, const long int&)'
   50 |         memo = std::vector<std::vector<std::vector<long long int>>>(run_length.size(), std::vector<std::vector<long long int>>(all_one + 1, std::vector<long long int>(std::min(k, all_one) + 1, -1)));
      |                                                                                                                                                                        ~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:50:176: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   50 |         memo = std::vector<std::vector<std::vector<long long int>>>(run_length.size(), std::vector<std::vector<long long int>>(all_one + 1, std::vector<long long int>(std::min(k, all_one) + 1, -1)));
      |                                                                                                                                                                        ~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:10:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:50:176: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   50 |         memo = std::vector<std::vector<std::vector<long long int>>>(run_length.size(), std::vector<std::vector<long long int>>(all_one + 1, std::vector<long long int>(std::min(k, all_one) + 1, -1)));
      |                                                                                                                                                                        ~~~~~~~~^~~~~~~~~~~~
a.cc:58:56: error: no matching function for call to 'min(int&, const long int&)'
   58 |         std::cout << pattern(run_length, 0, 0, std::min(k, all_one));
      |                                                ~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:58:56: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   58 |         std::cout << pattern(run_length, 0, 0, std::min(k, all_one));
      |                                                ~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:58:56: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |         std::cout << pattern(run_length, 0, 0, std::min(k, all_one));
      |                                                ~~~~~~~~^~~~~~~~~~~~