Language: C++

//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 998244353LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807

template <ull N, class T, class... Args, std::enable_if_t<N == 0, int> = 0>
auto make_multiple_vector(Args... args) {
    return T(args...);
}

template <ull N, class T, class... Args, std::enable_if_t<N != 0, int> = 0>
auto make_multiple_vector(ull size, Args... args) {
    using value_type = std::decay_t<decltype(make_multiple_vector<N - 1, T>(args...))>;
    return vector<value_type>(size, make_multiple_vector<N - 1, T>(args...));
}

ll getModValue(const ll& n, ll mod)
{
	return (n % mod + mod) % mod;
}

// computational complexity: o(log(max(a, b))) 
inline pair<ll, ll> getBezoutsIdentitySolution(ll a, ll b)
{
	if (b == 0)
	{
		return { 1, 0 };
	}
	auto sol = getBezoutsIdentitySolution(b, a % b);
	return { sol.second, sol.first - (a / b) * sol.second };
}

// computational complexity: o(log(max(n, mod))) 
inline ll getModInverse(const ll& n, ll mod)
{
	auto sol = getBezoutsIdentitySolution(n, mod);
	if (n * sol.first + mod * sol.second != 1)
	{
		return -1;
	}
	return getModValue(sol.first, mod);
}

class ResidueInteger
{
private:
	ll mod_;
	ll n_;
public:
	ResidueInteger() : mod_(MOD), n_(getModValue(0, mod_)) {}
	ResidueInteger(ll n) : mod_(MOD), n_(getModValue(n, mod_)) {}
	ResidueInteger(ll n, ll mod) : mod_(mod), n_(getModValue(n, mod_)) {}

	friend ResidueInteger operator+(const ResidueInteger& lhs, const ResidueInteger& rhs);
	friend ResidueInteger operator+(const ResidueInteger& lhs, const ll& rhs);
	friend ResidueInteger operator+(const ll& lhs, const ResidueInteger& rhs);
	friend ResidueInteger& operator+=(ResidueInteger& lhs, const ResidueInteger& rhs);
	friend ResidueInteger& operator+=(ResidueInteger& lhs, const ll& rhs);

	friend ResidueInteger operator-(const ResidueInteger& lhs, const ResidueInteger& rhs);
	friend ResidueInteger operator-(const ResidueInteger& lhs, const ll& rhs);
	friend ResidueInteger operator-(const ll& lhs, const ResidueInteger& rhs);
	friend ResidueInteger& operator-=(ResidueInteger& lhs, const ResidueInteger& rhs);
	friend ResidueInteger& operator-=(ResidueInteger& lhs, const ll& rhs);

	friend ResidueInteger operator*(const ResidueInteger& lhs, const ResidueInteger& rhs);
	friend ResidueInteger operator*(const ResidueInteger& lhs, const ll& rhs);
	friend ResidueInteger operator*(const ll& lhs, const ResidueInteger& rhs);
	friend ResidueInteger& operator*=(ResidueInteger& lhs, const ResidueInteger& rhs);
	friend ResidueInteger& operator*=(ResidueInteger& lhs, const ll& rhs);

	friend ResidueInteger operator/(const ResidueInteger& lhs, const ResidueInteger& rhs);
	friend ResidueInteger operator/(const ResidueInteger& lhs, const ll& rhs);
	friend ResidueInteger operator/(const ll& lhs, const ResidueInteger& rhs);
	friend ResidueInteger& operator/=(ResidueInteger& lhs, const ResidueInteger& rhs);
	friend ResidueInteger& operator/=(ResidueInteger& lhs, const ll& rhs);

	friend bool operator==(const ResidueInteger& lhs, const ResidueInteger& rhs);
	friend bool operator==(const ResidueInteger& lhs, const ll& rhs);
	friend bool operator==(const ll& lhs, const ResidueInteger& rhs);

	ll n() const { return n_; }

	friend std::ostream& operator<<(std::ostream& lhs, const ResidueInteger& rhs);
	friend std::istream& operator>>(std::istream& lhs, ResidueInteger& rhs);
};

inline ResidueInteger operator+(const ResidueInteger& lhs, const ResidueInteger& rhs)
{
	if (lhs.mod_ != rhs.mod_)
	{
		throw invalid_argument("The mods of both operands should be equal.");
	}
	return { lhs.n_ + rhs.n_, lhs.mod_ };
}

inline ResidueInteger operator+(const ResidueInteger& lhs, const ll& rhs)
{
	return { lhs.n_ + getModValue(rhs, lhs.mod_), lhs.mod_ };
}

inline ResidueInteger operator+(const ll& lhs, const ResidueInteger& rhs)
{
	return { getModValue(lhs, rhs.mod_) + rhs.n_, rhs.mod_ };
}

inline ResidueInteger& operator+=(ResidueInteger& lhs, const ResidueInteger& rhs)
{
	if (lhs.mod_ != rhs.mod_)
	{
		throw invalid_argument("The mods of both operands should be equal.");
	}
	lhs.n_ = getModValue(lhs.n_ + rhs.n_, lhs.mod_);
	return lhs;
}

inline ResidueInteger& operator+=(ResidueInteger& lhs, const ll& rhs)
{
	lhs.n_ = getModValue(lhs.n_ + getModValue(rhs, lhs.mod_), lhs.mod_);
	return lhs;
}

inline ResidueInteger operator-(const ResidueInteger& lhs, const ResidueInteger& rhs)
{
	if (lhs.mod_ != rhs.mod_)
	{
		throw invalid_argument("The mods of both operands should be equal.");
	}
	return { lhs.n_ - rhs.n_, lhs.mod_ };
}

inline ResidueInteger operator-(const ResidueInteger& lhs, const ll& rhs)
{
	return { lhs.n_ - getModValue(rhs, lhs.mod_), lhs.mod_ };
}

inline ResidueInteger operator-(const ll& lhs, const ResidueInteger& rhs)
{
	return { getModValue(lhs, rhs.mod_) - rhs.n_, rhs.mod_ };
}

inline ResidueInteger& operator-=(ResidueInteger& lhs, const ResidueInteger& rhs)
{
	if (lhs.mod_ != rhs.mod_)
	{
		throw invalid_argument("The mods of both operands should be equal.");
	}
	lhs.n_ = getModValue(lhs.n_ - rhs.n_, lhs.mod_);
	return lhs;
}

inline ResidueInteger& operator-=(ResidueInteger& lhs, const ll& rhs)
{
	lhs.n_ = getModValue(lhs.n_ - getModValue(rhs, lhs.mod_), lhs.mod_);
	return lhs;
}

inline ResidueInteger operator*(const ResidueInteger& lhs, const ResidueInteger& rhs)
{
	if (lhs.mod_ != rhs.mod_)
	{
		throw invalid_argument("The mods of both operands should be equal.");
	}
	return { lhs.n_ * rhs.n_, lhs.mod_ };
}

inline ResidueInteger operator*(const ResidueInteger& lhs, const ll& rhs)
{
	return { lhs.n_ * getModValue(rhs, lhs.mod_), lhs.mod_ };
}

inline ResidueInteger operator*(const ll& lhs, const ResidueInteger& rhs)
{
	return { getModValue(lhs, rhs.mod_) * rhs.n_, rhs.mod_ };
}

inline ResidueInteger& operator*=(ResidueInteger& lhs, const ResidueInteger& rhs)
{
	if (lhs.mod_ != rhs.mod_)
	{
		throw invalid_argument("The mods of both operands should be equal.");
	}
	lhs.n_ = getModValue(lhs.n_ * rhs.n_, lhs.mod_);
	return lhs;
}

inline ResidueInteger& operator*=(ResidueInteger& lhs, const ll& rhs)
{
	lhs.n_ = getModValue(lhs.n_ * getModValue(rhs, lhs.mod_), lhs.mod_);
	return lhs;
}

inline ResidueInteger operator/(const ResidueInteger& lhs, const ResidueInteger& rhs)
{
	if (lhs.mod_ != rhs.mod_)
	{
		throw invalid_argument("The mods of both operands should be equal.");
	}
	return { lhs.n_ * getModInverse(rhs.n_, lhs.mod_), lhs.mod_ };
}

inline ResidueInteger operator/(const ResidueInteger& lhs, const ll& rhs)
{
	return { lhs.n_ * getModInverse(getModValue(rhs, lhs.mod_), lhs.mod_), lhs.mod_ };
}

inline ResidueInteger operator/(const ll& lhs, const ResidueInteger& rhs)
{
	return { getModValue(lhs, rhs.mod_) * getModInverse(rhs.n_, rhs.mod_), rhs.mod_ };
}

inline ResidueInteger& operator/=(ResidueInteger& lhs, const ResidueInteger& rhs)
{
	if (lhs.mod_ != rhs.mod_)
	{
		throw invalid_argument("The mods of both operands should be equal.");
	}
	lhs.n_ = getModValue(lhs.n_ * getModInverse(rhs.n_, lhs.mod_), lhs.mod_);
	return lhs;
}

inline ResidueInteger& operator/=(ResidueInteger& lhs, const ll& rhs)
{
	lhs.n_ = getModValue(lhs.n_ * getModInverse(getModValue(rhs, lhs.mod_), lhs.mod_), lhs.mod_);
	return lhs;
}

inline bool operator==(const ResidueInteger& lhs, const ResidueInteger& rhs)
{
	return (lhs.n_ == rhs.n_) && (lhs.mod_ == rhs.mod_);
}

inline bool operator==(const ResidueInteger& lhs, const ll& rhs)
{
	return lhs.n_ == getModValue(rhs, lhs.mod_);
}

bool operator==(const ll& lhs, const ResidueInteger& rhs)
{
	return getModValue(lhs, rhs.mod_) == rhs.n_;
}

std::ostream& operator<<(std::ostream& lhs, const ResidueInteger& rhs)
{
	return lhs << rhs.n_;
}

std::istream& operator>>(std::istream& lhs, ResidueInteger& rhs)
{
	lhs >> rhs.n_;
	return lhs;
}

using rll = ResidueInteger;

vector<rll> get_exclamations(ull n) {
	vector<rll> exclamations(n + 1ULL);
	exclamations[0] = 1LL;
	for (ll i = 1; i <= n; ++i) exclamations[i] = exclamations[i - 1] * i;

	return exclamations;
}

int solve() {
	std::string s; ll K;
	std::cin >> s >> K;

	K = min(K, s.size());
	vector<ll> a;
	REPD (i, 0, s.length()) if (s[i] == '0') a.emplace_back(i);
	a.emplace_back(s.length());

	ll n = a.size() - 1;
	auto dp = make_multiple_vector<2, rll>(K + 1, K + 1);
	dp[0][0] = 1;
	for (ll i = n-1; i >= 0; i--) {
		auto swp = make_multiple_vector<2, rll>(K + 1, K + 1);
		for (ll j = 0; j <= K; j++) for (ll k=0; k<=K; k++) {
			for (ll nj = 0; nj <= j + a[i+1] - a[i] - 1; nj++) {
				ll nk = k + std::max(ll{0}, nj - j);
				if (nj<=K && nk<=K) swp.at(nj).at(nk) += dp.at(j).at(k);
			}
		}
		swp.swap(dp);
	}

	rll ans = 0;
	for (auto&& v: dp) for (rll& x: v) ans += x;
	RET(ans);

	return 0;
}

//main function
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:327:16: error: no matching function for call to 'min(ll&, std::__cxx11::basic_string<char>::size_type)'
  327 |         K = min(K, s.size());
      |             ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from a.cc:3:
/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:327:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
  327 |         K = min(K, s.size());
      |             ~~~^~~~~~~~~~~~~
/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:12:
/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:327:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  327 |         K = min(K, s.size());
      |             ~~~^~~~~~~~~~~~~