Language: C++

#include <bits/stdc++.h>
using namespace std;
//const long long MOD = 1e9+7;
const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
long long power(ll x,long long n,long long MOD){
    long long a = 1;
    long long b = x;
    while(n>0){
        if(n%2==1){
            a*=b;
            a%=MOD;
        }
        n/=2;
        b = b*b;
        b%=MOD;
    }
    return a;
}
int main(){
    string s;
    cin >> s;
    ll kk;
    cin >> kk;
    vector<ll> a;
    int cnt = 0;
    rep(i,s.size()){
        if(s[i]=='0'){
            a.push_back(cnt);
            cnt  = 0;
        }
        else cnt++;
    }
    a.push_back(cnt);
    kk = min(300LL,kk);
    ll dp[a.size()+1][a.size()+1][kk+1];
    rep(i,a.size()+1) rep(j,a.size()+1) rep(k,kk+1) dp[i][j][k]=0;
    dp[0][0][0]=1LL;
    vector<ll> dp_acc[a.size()+1][a.size()+1];
    dp_acc[0][0].push_back(0);
    for(int i = 0;i<kk+1;i++){
        ll tmp = dp_acc[0][0][i];
        tmp*=(1); // *(j+1)
        tmp%=MOD;
        tmp+=dp[0][0][i]; // (dp[i][j][k-1]
        tmp%=MOD;
        dp_acc[0][0].push_back(tmp);
    }

    //cout << a.size() << endl;
    for(ll i = 1;i<a.size();i++){
        lrep(j,i){
            lrep(k,kk+1){
                if(j==i-1 && k<=a[i]){
                    ll tmp=dp[i-1][j][0];
                    tmp*=power(j+1,k,MOD);
                }
                else if(j==i-1){
                    ll tmp = 0;
                }
                else{}
                    ll tmp = dp_acc[i-1][j][max(0LL,k)]-dp_acc[i-1][j][max(0LL,k-a[i])];
                    tmp*=(j+1);
                    tmp%=MOD;
                }
                dp[i][j][k]+=tmp;
                dp[i][j][k]%=MOD;

                if(j!=0) dp[i][j][k]+=dp[i-1][j-1][k];
                dp[i][j][k]%=MOD;
                cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
            }
        }
        lrep(j,i){
            dp_acc[i][j].push_back(0);
            for(int k = 0;k<kk+1;k++){
                ll tmp = dp_acc[i][j][k];
                tmp*=(j+1); // *(j+1)
                tmp%=MOD;
                tmp+=dp[i][j][k]; // (dp[i][j][k-1]
                tmp%=MOD;
                dp_acc[i][j].push_back(tmp);
            }            
        }
    }
    ll ans = 0;
    rep(i,a.size()+1) rep(j,kk+1){
        ans+=dp[a.size()-1][i][j];
        ans%=MOD;
    }
    cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:72:26: error: 'k' was not declared in this scope
   72 |                 dp[i][j][k]+=tmp;
      |                          ^
a.cc:72:30: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   72 |                 dp[i][j][k]+=tmp;
      |                              ^~~
      |                              tm
a.cc:80:16: error: 'i' was not declared in this scope
   80 |         lrep(j,i){
      |                ^
a.cc:9:41: note: in definition of macro 'lrep'
    9 | #define lrep(i,n) for(long long i = 0;i<n;i++)
      |                                         ^
a.cc: At global scope:
a.cc:8:18: error: expected unqualified-id before 'for'
    8 | #define rep(i,n) for(int i = 0;i<n;i++)
      |                  ^~~
a.cc:93:5: note: in expansion of macro 'rep'
   93 |     rep(i,a.size()+1) rep(j,kk+1){
      |     ^~~
a.cc:93:9: error: 'i' does not name a type
   93 |     rep(i,a.size()+1) rep(j,kk+1){
      |         ^
a.cc:8:32: note: in definition of macro 'rep'
    8 | #define rep(i,n) for(int i = 0;i<n;i++)
      |                                ^
a.cc:93:9: error: 'i' does not name a type
   93 |     rep(i,a.size()+1) rep(j,kk+1){
      |         ^
a.cc:8:36: note: in definition of macro 'rep'
    8 | #define rep(i,n) for(int i = 0;i<n;i++)
      |                                    ^
a.cc:93:27: error: 'j' does not name a type
   93 |     rep(i,a.size()+1) rep(j,kk+1){
      |                           ^
a.cc:8:32: note: in definition of macro 'rep'
    8 | #define rep(i,n) for(int i = 0;i<n;i++)
      |                                ^
a.cc:93:27: error: 'j' does not name a type
   93 |     rep(i,a.size()+1) rep(j,kk+1){
      |                           ^
a.cc:8:36: note: in definition of macro 'rep'
    8 | #define rep(i,n) for(int i = 0;i<n;i++)
      |                                    ^
a.cc:97:5: error: 'cout' does not name a type
   97 |     cout << ans << endl;
      |     ^~~~
a.cc:99:1: error: expected declaration before '}' token
   99 | }
      | ^