Problem p02990 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout << "\n";
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define tr(c, i) for (auto i : c)
#define pii pair<int, int>
#define fast_io()                                                              \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr)
#define pq                                                                     \
  priority_queue<pair<ll, pii>, vector<pair<ll, pii>>, greater<pair<ll, pii>>> \
      p; // container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x, y) cout << x << " " << y
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 10000;
using namespace std;
clock_t time_p = clock();
void dem() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
ll fac[N];
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll fastExp(ll base, ll pow) {
  ll res = 1;
  while (pow > 0) {

    if (pow & 1)
      res = mul(res, base);
    base = mul(base, base);
    pow >>= 1;
  }
  return res;
}
ll Inv(ll base) { return fastExp(base, MOD - 2); }
void fact() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i)
    fac[i] = mul(fac[i - 1], i);
}
ll nCr(ll n, ll r) {
  ll C = fac[n];
  C = mul(C, Inv(fac[r]));
  C = mul(C, Inv(fac[n - r]));
  return C;
}
int main() {
  fast_io();
  fact();
  int n, blue;
  cin >> n >> blue;
  int red = n - blue;
  ll res = 0;
  for (int i = 1; i <= blue; ++i) {
    res = mul(nCr(red + 1, i), nCr(blue - 1, i - 1));
    cout << res;
    br
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout << "\n";
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define tr(c, i) for (auto i : c)
#define pii pair<int, int>
#define fast_io()                                                              \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(nullptr)
#define pq                                                                     \
  priority_queue<pair<ll, pii>, vector<pair<ll, pii>>, greater<pair<ll, pii>>> \
      p; // container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x, y) cout << x << " " << y
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 10000;
using namespace std;
clock_t time_p = clock();
void dem() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
ll fac[N];
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll fastExp(ll base, ll pow) {
  ll res = 1;
  while (pow > 0) {

    if (pow & 1)
      res = mul(res, base);
    base = mul(base, base);
    pow >>= 1;
  }
  return res;
}
ll Inv(ll base) { return fastExp(base, MOD - 2); }
void fact() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i)
    fac[i] = mul(fac[i - 1], i);
}
ll nCr(ll n, ll r) {
  ll C = fac[n];
  C = mul(C, Inv(fac[r]));
  C = mul(C, Inv(fac[n - r]));
  return C;
}
int main() {
  fast_io();
  fact();
  int n, blue;
  cin >> n >> blue;
  int red = n - blue;
  ll res = 0;
  for (int i = 1; i <= blue; ++i) {
    if (n - blue - i + 1 < 0) {
      cout << "0";
      br continue;
    }
    res = mul(nCr(red + 1, i), nCr(blue - 1, i - 1));
    cout << res;
    br
  }

  return 0;
}