Language: C++

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;



template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< 1000000007 >;


const int mod = 1000000007;

modint dp[2019][2019];

modint combination(int n, int r)
{
    if (n<r) return 0;
    if (r == 0 or r == n) return 1;
    else if (r == 1) return n;
    
    if (dp[n][r] != 0) return dp[n][r];
    
    return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
}

modint f2(int n, int k){
    return combination(n+k+1,k-1);
}
modint f(int n, int k){
    if (n<k or k<1) return 0;
    if (n == 0 and k == 0) return 1;
    return f2(n-k,k);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    int red = N-K;
    int blue = K;

    
    FOR(i,1, K+1){
        //cout << red+1 << ":" << i+1 << ":" << blue-1 << endl;
        //cout << (combination(red+1,i+1)%mod) * (combination(blue-1,i))%mod << endl;
        modint b = f(K,i);
        modint r;
        r += f(red,i-1);
        r += f(red,i);
        r += f(red,i);
        r += f(red,i+1);

        cout << r*b << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'modint combination(int, int)':
a.cc:121:50: error: no match for 'operator%' (operand types are 'modint' {aka 'ModInt<1000000007>'} and 'const int')
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
      |                                    |              |
      |                                    |              const int
      |                                    modint {aka ModInt<1000000007>}
In file included from /usr/include/c++/14/valarray:605,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note:   template argument deduction/substitution failed:
a.cc:121:51: note:   'modint' {aka 'ModInt<1000000007>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                   ^~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note:   template argument deduction/substitution failed:
a.cc:121:51: note:   'modint' {aka 'ModInt<1000000007>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                   ^~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note:   template argument deduction/substitution failed:
a.cc:121:51: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'const int'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                   ^~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note:   template argument deduction/substitution failed:
a.cc:121:51: note:   'modint' {aka 'ModInt<1000000007>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                   ^~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note:   template argument deduction/substitution failed:
a.cc:121:51: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'const int'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                   ^~~
/usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const valarray<_Tp>&, const valarray<_Tp>&)'
 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1200:1: note:   template argument deduction/substitution failed:
a.cc:121:51: note:   'modint' {aka 'ModInt<1000000007>'} is not derived from 'const std::valarray<_Tp>'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                   ^~~
/usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1200:1: note:   template argument deduction/substitution failed:
a.cc:121:51: note:   'modint' {aka 'ModInt<1000000007>'} is not derived from 'const std::valarray<_Tp>'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                   ^~~
/usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1200:1: note:   template argument deduction/substitution failed:
a.cc:121:51: note:   mismatched types 'const std::valarray<_Tp>' and 'const int'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                   ^~~
a.cc:121:80: error: no match for 'operator%' (operand types are 'modint' {aka 'ModInt<1000000007>'} and 'const int')
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                           ~~~~~~~~~~~~~~~~~~~~~^~~~
      |                                                                      |          |
      |                                                                      |          const int
      |                                                                      modint {aka ModInt<1000000007>}
/usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note:   template argument deduction/substitution failed:
a.cc:121:81: note:   'modint' {aka 'ModInt<1000000007>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                                                 ^~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note:   template argument deduction/substitution failed:
a.cc:121:81: note:   'modint' {aka 'ModInt<1000000007>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
  121 |     return dp[n][r] = ((combination(n - 1, r - 1)%mod) + (combination(n - 1, r)%mod))%mod;
      |                                                                                 ^~~
/usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
  409 |     _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after