Problem p03991 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 5e5, mod = 924844033;
int b[N], n, rev[N], w[N], limn, a[N], siz[N], fst[N], nxt[N], to[N], fac[N],
    ifac[N], mm;
void ade(int u, int v) { to[++mm] = v, nxt[mm] = fst[u], fst[u] = mm; }
void dfs(int u, int fa) {
  siz[u] = 1;
  ++a[n];
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa)
      continue;
    dfs(v, u), siz[u] += siz[v];
  }
  if (u != 1)
    --a[siz[u]];
  --a[n - siz[u]];
}
int qpower(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1)
      ans = 1ll * ans * a % mod;
  return ans;
}
void prework(int n) {
  limn = 1;
  while (limn <= (n << 1))
    limn <<= 1;
  for (int i = 1; i < limn; i++)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) ? (limn >> 1) : 0);
  for (int i = 1; i < limn; i <<= 1) {
    int omg = qpower(5, (mod - 1) / (i << 1));
    w[i] = 1;
    for (int j = 1; j < i; j++)
      w[i + j] = 1ll * w[i + j - 1] * omg % mod;
  }
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = 1ll * fac[i - 1] * i % mod;
  ifac[n] = qpower(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
    ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
}
void DFT(int a[]) {
  for (int i = 0; i < limn; i++)
    if (i < rev[i])
      swap(a[i], a[rev[i]]);
  for (int i = 1; i < limn; i <<= 1)
    for (int j = 0; j < limn; j += i << 1)
      for (int k = 0; k < i; k++) {
        int x = 1ll * w[i + k] * a[i + j + k] % mod;
        a[i + j + k] = (a[j + k] - x) % mod, a[j + k] = (a[j + k] + x) % mod;
      }
}
void IDFT(int a[]) {
  reverse(a + 1, a + limn);
  DFT(a);
  int iv = mod - (mod - 1) / limn;
  for (int i = 0; i < limn; i++)
    a[i] = 1ll * iv * a[i] % mod;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), ade(u, v), ade(v, u);
  dfs(1, 0);
  prework(n);
  for (int i = 0; i <= n; i++)
    a[i] = 1ll * a[i] * fac[i] % mod, b[i] = ifac[i];
  reverse(a, a + n + 1);
  DFT(a), DFT(b);
  for (int i = 0; i < limn; i++)
    a[i] = 1ll * a[i] * b[i] % mod;
  IDFT(a);
  reverse(a, a + n + 1);
  for (int i = 1; i <= n; i++)
    printf("%d\n", (1ll * a[i] * ifac[i] % mod + mod) % mod);
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 6e5, mod = 924844033;
int b[N], n, rev[N], w[N], limn, a[N], siz[N], fst[N], nxt[N], to[N], fac[N],
    ifac[N], mm;
void ade(int u, int v) { to[++mm] = v, nxt[mm] = fst[u], fst[u] = mm; }
void dfs(int u, int fa) {
  siz[u] = 1;
  ++a[n];
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa)
      continue;
    dfs(v, u), siz[u] += siz[v];
  }
  if (u != 1)
    --a[siz[u]];
  --a[n - siz[u]];
}
int qpower(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1)
      ans = 1ll * ans * a % mod;
  return ans;
}
void prework(int n) {
  limn = 1;
  while (limn <= (n << 1))
    limn <<= 1;
  for (int i = 1; i < limn; i++)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) ? (limn >> 1) : 0);
  for (int i = 1; i < limn; i <<= 1) {
    int omg = qpower(5, (mod - 1) / (i << 1));
    w[i] = 1;
    for (int j = 1; j < i; j++)
      w[i + j] = 1ll * w[i + j - 1] * omg % mod;
  }
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    fac[i] = 1ll * fac[i - 1] * i % mod;
  ifac[n] = qpower(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
    ifac[i] = 1ll * ifac[i + 1] * (i + 1) % mod;
}
void DFT(int a[]) {
  for (int i = 0; i < limn; i++)
    if (i < rev[i])
      swap(a[i], a[rev[i]]);
  for (int i = 1; i < limn; i <<= 1)
    for (int j = 0; j < limn; j += i << 1)
      for (int k = 0; k < i; k++) {
        int x = 1ll * w[i + k] * a[i + j + k] % mod;
        a[i + j + k] = (a[j + k] - x) % mod, a[j + k] = (a[j + k] + x) % mod;
      }
}
void IDFT(int a[]) {
  reverse(a + 1, a + limn);
  DFT(a);
  int iv = mod - (mod - 1) / limn;
  for (int i = 0; i < limn; i++)
    a[i] = 1ll * iv * a[i] % mod;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), ade(u, v), ade(v, u);
  dfs(1, 0);
  prework(n);
  for (int i = 0; i <= n; i++)
    a[i] = 1ll * a[i] * fac[i] % mod, b[i] = ifac[i];
  reverse(a, a + n + 1);
  DFT(a), DFT(b);
  for (int i = 0; i < limn; i++)
    a[i] = 1ll * a[i] * b[i] % mod;
  IDFT(a);
  reverse(a, a + n + 1);
  for (int i = 1; i <= n; i++)
    printf("%d\n", (1ll * a[i] * ifac[i] % mod + mod) % mod);
}