Problem p03991 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 200003, mod = 924844033, G = 5, Gi = 554906420;
int fac[N], invfac[N];
inline int kasumi(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1)
      res = (LL)res * a % mod;
    a = (LL)a * a % mod;
    b >>= 1;
  }
  return res;
}
inline void init(int m) {
  fac[0] = 1;
  for (Rint i = 1; i <= m; i++)
    fac[i] = (LL)i * fac[i - 1] % mod;
  invfac[m] = kasumi(fac[m], mod - 2);
  for (Rint i = m; i; i--)
    invfac[i - 1] = (LL)invfac[i] * i % mod;
}
int n, siz[N], A[N], B[N], head[N], to[N << 1], nxt[N << 1];
inline void add(int a, int b) {
  static int cnt = 0;
  to[++cnt] = b;
  nxt[cnt] = head[a];
  head[a] = cnt;
}
inline void dfs(int x, int f = 0) {
  siz[x] = 1;
  for (Rint i = head[x]; i; i = nxt[i])
    if (to[i] != f) {
      dfs(to[i], x);
      siz[x] += siz[to[i]];
    }
}
int rev[N];
inline int calrev(int len) {
  int limit = 1, L = -1;
  while (limit <= len) {
    limit <<= 1;
    L++;
  }
  for (Rint i = 0; i < limit; i++)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << L);
  return limit;
}
inline void NTT(int *A, int limit, int type) {
  for (Rint i = 0; i < limit; i++)
    if (i < rev[i])
      swap(A[i], A[rev[i]]);
  for (Rint mid = 1; mid < limit; mid <<= 1) {
    int Wn = kasumi(type == 1 ? G : Gi, (mod - 1) / (mid << 1));
    for (Rint j = 0; j < limit; j += mid << 1) {
      int w = 1;
      for (Rint k = 0; k < mid; k++, w = (LL)w * Wn % mod) {
        int x = A[j + k], y = (LL)w * A[j + k + mid] % mod;
        A[j + k] = (x + y) % mod;
        A[j + k + mid] = (x - y + mod) % mod;
      }
    }
  }
  if (type == -1) {
    int inv = kasumi(limit, mod - 2);
    for (Rint i = 0; i < limit; i++)
      A[i] = (LL)A[i] * inv % mod;
  }
}
int main() {
  scanf("%d", &n);
  init(n << 1);
  for (Rint i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1);
  for (Rint i = 2; i <= n; i++)
    ++A[siz[i]], ++A[n - siz[i]];
  for (Rint i = 0; i <= n; i++) {
    A[i] = (LL)A[i] * fac[i] % mod;
    B[i] = invfac[n - i];
  }
  int limit = calrev(n << 1);
  NTT(A, limit, 1);
  NTT(B, limit, 1);
  for (Rint i = 0; i < limit; i++)
    A[i] = (LL)A[i] * B[i] % mod;
  NTT(A, limit, -1);
  for (Rint i = n + 1; i <= (n << 1); i++)
    printf("%d\n", ((LL)n * fac[n] % mod * invfac[i - n] % mod *
                        invfac[(n << 1) - i] % mod -
                    (LL)A[i] * invfac[i - n] % mod + mod) %
                       mod);
}

Fixed submission:
#include <bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 1 << 19, mod = 924844033, G = 5, Gi = 554906420;
int fac[N], invfac[N];
inline int kasumi(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1)
      res = (LL)res * a % mod;
    a = (LL)a * a % mod;
    b >>= 1;
  }
  return res;
}
inline void init(int m) {
  fac[0] = 1;
  for (Rint i = 1; i <= m; i++)
    fac[i] = (LL)i * fac[i - 1] % mod;
  invfac[m] = kasumi(fac[m], mod - 2);
  for (Rint i = m; i; i--)
    invfac[i - 1] = (LL)invfac[i] * i % mod;
}
int n, siz[N], A[N], B[N], head[N], to[N << 1], nxt[N << 1];
inline void add(int a, int b) {
  static int cnt = 0;
  to[++cnt] = b;
  nxt[cnt] = head[a];
  head[a] = cnt;
}
inline void dfs(int x, int f = 0) {
  siz[x] = 1;
  for (Rint i = head[x]; i; i = nxt[i])
    if (to[i] != f) {
      dfs(to[i], x);
      siz[x] += siz[to[i]];
    }
}
int rev[N];
inline int calrev(int len) {
  int limit = 1, L = -1;
  while (limit <= len) {
    limit <<= 1;
    L++;
  }
  for (Rint i = 0; i < limit; i++)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << L);
  return limit;
}
inline void NTT(int *A, int limit, int type) {
  for (Rint i = 0; i < limit; i++)
    if (i < rev[i])
      swap(A[i], A[rev[i]]);
  for (Rint mid = 1; mid < limit; mid <<= 1) {
    int Wn = kasumi(type == 1 ? G : Gi, (mod - 1) / (mid << 1));
    for (Rint j = 0; j < limit; j += mid << 1) {
      int w = 1;
      for (Rint k = 0; k < mid; k++, w = (LL)w * Wn % mod) {
        int x = A[j + k], y = (LL)w * A[j + k + mid] % mod;
        A[j + k] = (x + y) % mod;
        A[j + k + mid] = (x - y + mod) % mod;
      }
    }
  }
  if (type == -1) {
    int inv = kasumi(limit, mod - 2);
    for (Rint i = 0; i < limit; i++)
      A[i] = (LL)A[i] * inv % mod;
  }
}
int main() {
  scanf("%d", &n);
  init(n << 1);
  for (Rint i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1);
  for (Rint i = 2; i <= n; i++)
    ++A[siz[i]], ++A[n - siz[i]];
  for (Rint i = 0; i <= n; i++) {
    A[i] = (LL)A[i] * fac[i] % mod;
    B[i] = invfac[n - i];
  }
  int limit = calrev(n << 1);
  NTT(A, limit, 1);
  NTT(B, limit, 1);
  for (Rint i = 0; i < limit; i++)
    A[i] = (LL)A[i] * B[i] % mod;
  NTT(A, limit, -1);
  for (Rint i = n + 1; i <= (n << 1); i++)
    printf("%d\n", ((LL)n * fac[n] % mod * invfac[i - n] % mod *
                        invfac[(n << 1) - i] % mod -
                    (LL)A[i] * invfac[i - n] % mod + mod) %
                       mod);
}