Problem p03432 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int, int>
#define pll pair<ll, ll>
#define PB push_back
#define fi first
#define se second
#define For(i, j, k) for (int i = (int)(j); i <= (int)(k); i++)
#define Rep(i, j, k) for (int i = (int)(j); i >= (int)(k); i--)
#define CLR(a, v) memset(a, v, sizeof(a));
#define CPY(a, b) memcpy(a, b, sizeof(a));
using namespace std;
const int mo = 998244353;
const int FFTN = (1 << 14);
const int N = FFTN + 5;
int power(int x, int y) {
  int s = 1;
  for (; y; y /= 2, x = 1ll * x * x % mo)
    if (y & 1)
      s = 1ll * s * x % mo;
  return s;
}
int fac[N], inv[N];
int W[N], w[N], R[N];
int n, m, f[105][N];
int A[N], B[N];
ull p[N];
void init() {
  fac[0] = inv[0] = inv[1] = 1;
  For(i, 2, N - 1) inv[i] = 1ll * inv[mo % i] * (mo - mo / i) % mo;
  For(i, 1, N - 1) inv[i] = 1ll * inv[i - 1] * inv[i] % mo;
  For(i, 1, N - 1) fac[i] = 1ll * fac[i - 1] * i % mo;
}
void FFTinit() {
  W[0] = 1;
  W[1] = power(3, (mo - 1) / FFTN);
  For(i, 2, N - 1) W[i] = 1ll * W[i - 1] * W[1] % mo;
}
int FFTinit(int n) {
  int L = 1;
  for (; L <= n; L <<= 1)
    ;
  For(i, 0, L - 1) R[i] = (R[i >> 1] >> 1) | ((i & 1) ? (L >> 1) : 0);
  return L;
}
void DFT(int *a, int n) {
  For(i, 0, n - 1) p[R[i]] = a[i];
  for (int d = 1; d < n; d <<= 1) {
    int len = FFTN / (d << 1);
    for (int i = 0, j = 0; i < d; i++, j += len)
      w[i] = W[j];
    for (int i = 0; i < n; i += (d << 1))
      for (int j = 0; j < d; j++) {
        int y = p[i + j + d] * w[j] % mo;
        p[i + j + d] = p[i + j] + mo - y;
        p[i + j] += y;
      }
  }
  For(i, 0, n - 1) a[i] = p[i] % mo;
}
void IDFT(int *a, int n) {
  For(i, 0, n - 1) p[R[i]] = a[i];
  for (int d = 1; d < n; d <<= 1) {
    int len = FFTN / (d << 1);
    for (int i = 0, j = FFTN; i < d; i++, j -= len)
      w[i] = W[j];
    for (int i = 0; i < n; i += (d << 1))
      for (int j = 0; j < d; j++) {
        int y = p[i + j + d] * w[j] % mo;
        p[i + j + d] = p[i + j] + mo - y;
        p[i + j] += y;
      }
  }
  int val = power(n, mo - 2);
  For(i, 0, n - 1) a[i] = p[i] * val % mo;
}
int C(int x, int y) { return 1ll * fac[x] * inv[y] % mo * inv[x - y] % mo; }
int main() {
  init();
  FFTinit();
  scanf("%d%d", &n, &m);
  f[0][0] = 1;
  int L = FFTinit(2 * n);
  For(i, 1, n) B[i] = inv[i + 2];
  DFT(B, L);
  For(i, 1, m) {
    For(j, 0, n) f[i][j] = 1ll * (j * (j + 1) / 2 + 1) * f[i - 1][j] % mo;
    int L = FFTinit(2 * n);
    For(j, 0, L - 1) A[j] = 0;
    For(j, 0, n) A[j] = 1ll * f[i - 1][j] * inv[j] % mo;
    DFT(A, L);
    For(j, 0, L - 1) A[j] = 1ll * A[j] * B[j] % mo;
    IDFT(A, L);
    For(j, 0, n) f[i][j] = (f[i][j] + 1ll * A[j] * fac[j + 2]) % mo;
  }
  int ans = 0;
  For(i, 0, n) ans = (ans + 1ll * f[m][i] * C(n, i)) % mo;
  printf("%d\n", ans);
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int, int>
#define pll pair<ll, ll>
#define PB push_back
#define fi first
#define se second
#define For(i, j, k) for (int i = (int)(j); i <= (int)(k); i++)
#define Rep(i, j, k) for (int i = (int)(j); i >= (int)(k); i--)
#define CLR(a, v) memset(a, v, sizeof(a));
#define CPY(a, b) memcpy(a, b, sizeof(a));
using namespace std;
const int mo = 998244353;
const int FFTN = (1 << 14);
const int N = FFTN + 5;
int power(int x, int y) {
  int s = 1;
  for (; y; y /= 2, x = 1ll * x * x % mo)
    if (y & 1)
      s = 1ll * s * x % mo;
  return s;
}
int fac[N], inv[N];
int W[N], w[N], R[N];
int n, m, f[205][N];
int A[N], B[N];
ull p[N];
void init() {
  fac[0] = inv[0] = inv[1] = 1;
  For(i, 2, N - 1) inv[i] = 1ll * inv[mo % i] * (mo - mo / i) % mo;
  For(i, 1, N - 1) inv[i] = 1ll * inv[i - 1] * inv[i] % mo;
  For(i, 1, N - 1) fac[i] = 1ll * fac[i - 1] * i % mo;
}
void FFTinit() {
  W[0] = 1;
  W[1] = power(3, (mo - 1) / FFTN);
  For(i, 2, N - 1) W[i] = 1ll * W[i - 1] * W[1] % mo;
}
int FFTinit(int n) {
  int L = 1;
  for (; L <= n; L <<= 1)
    ;
  For(i, 0, L - 1) R[i] = (R[i >> 1] >> 1) | ((i & 1) ? (L >> 1) : 0);
  return L;
}
void DFT(int *a, int n) {
  For(i, 0, n - 1) p[R[i]] = a[i];
  for (int d = 1; d < n; d <<= 1) {
    int len = FFTN / (d << 1);
    for (int i = 0, j = 0; i < d; i++, j += len)
      w[i] = W[j];
    for (int i = 0; i < n; i += (d << 1))
      for (int j = 0; j < d; j++) {
        int y = p[i + j + d] * w[j] % mo;
        p[i + j + d] = p[i + j] + mo - y;
        p[i + j] += y;
      }
  }
  For(i, 0, n - 1) a[i] = p[i] % mo;
}
void IDFT(int *a, int n) {
  For(i, 0, n - 1) p[R[i]] = a[i];
  for (int d = 1; d < n; d <<= 1) {
    int len = FFTN / (d << 1);
    for (int i = 0, j = FFTN; i < d; i++, j -= len)
      w[i] = W[j];
    for (int i = 0; i < n; i += (d << 1))
      for (int j = 0; j < d; j++) {
        int y = p[i + j + d] * w[j] % mo;
        p[i + j + d] = p[i + j] + mo - y;
        p[i + j] += y;
      }
  }
  int val = power(n, mo - 2);
  For(i, 0, n - 1) a[i] = p[i] * val % mo;
}
int C(int x, int y) { return 1ll * fac[x] * inv[y] % mo * inv[x - y] % mo; }
int main() {
  init();
  FFTinit();
  scanf("%d%d", &n, &m);
  f[0][0] = 1;
  int L = FFTinit(2 * n);
  For(i, 1, n) B[i] = inv[i + 2];
  DFT(B, L);
  For(i, 1, m) {
    For(j, 0, n) f[i][j] = 1ll * (j * (j + 1) / 2 + 1) * f[i - 1][j] % mo;
    int L = FFTinit(2 * n);
    For(j, 0, L - 1) A[j] = 0;
    For(j, 0, n) A[j] = 1ll * f[i - 1][j] * inv[j] % mo;
    DFT(A, L);
    For(j, 0, L - 1) A[j] = 1ll * A[j] * B[j] % mo;
    IDFT(A, L);
    For(j, 0, n) f[i][j] = (f[i][j] + 1ll * A[j] * fac[j + 2]) % mo;
  }
  int ans = 0;
  For(i, 0, n) ans = (ans + 1ll * f[m][i] * C(n, i)) % mo;
  printf("%d\n", ans);
}