//
// main.cpp
// Modular Combinatorics
//
// Created by Himanshu on 18/02/22.
//
#include <iostream>
#define p 1000000007
using namespace std;
typedef long long ll;
void precompute (int n, ll fact[], ll inv[], ll invFact[]) {
fact[0] = 1;
for (int i=1; i<= n; i++) {
fact[i] = (fact[i-1]*i)%p;
}
inv[1] = 1;
for (int i=2; i<= n; i++) {
inv[i] = ((p - (p/i))*inv[p%i])%p;
}
invFact[0] = invFact[1] = 1;
for (int i=2; i<= n; i++) {
invFact[i] = (invFact[i-1]*inv[i])%p;
}
}
ll computeCombinatorics (int n, int r, ll fact[], ll inv[], ll invFact[]) {
ll ans = (((fact[n]*invFact[r])%p)*(invFact[n-r]%p))%p;
return ans;
}
int main (int argc, const char * argv[]) {
int n = 100000;
int r = 500;
ll *fact = new ll[n]();
ll *inv = new ll[n]();
ll *invFact = new ll[n]();
precompute(n, fact, inv, invFact);
cout<<computeCombinatorics(n, r, fact, inv, invFact)<<endl;
return 0;
}
Ly8KLy8gIG1haW4uY3BwCi8vICBNb2R1bGFyIENvbWJpbmF0b3JpY3MKLy8KLy8gIENyZWF0ZWQgYnkgSGltYW5zaHUgb24gMTgvMDIvMjIuCi8vCgojaW5jbHVkZSA8aW9zdHJlYW0+CiNkZWZpbmUgcCAxMDAwMDAwMDA3CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnR5cGVkZWYgbG9uZyBsb25nIGxsOwoKdm9pZCBwcmVjb21wdXRlIChpbnQgbiwgbGwgZmFjdFtdLCBsbCBpbnZbXSwgbGwgaW52RmFjdFtdKSB7CiAgICBmYWN0WzBdID0gMTsKICAgIAogICAgZm9yIChpbnQgaT0xOyBpPD0gbjsgaSsrKSB7CiAgICAgICAgZmFjdFtpXSA9IChmYWN0W2ktMV0qaSklcDsKICAgIH0KICAgIAogICAgaW52WzFdID0gMTsKICAgIGZvciAoaW50IGk9MjsgaTw9IG47IGkrKykgewogICAgICAgIGludltpXSA9ICgocCAtIChwL2kpKSppbnZbcCVpXSklcDsKICAgIH0KICAgIAogICAgaW52RmFjdFswXSA9IGludkZhY3RbMV0gPSAxOwogICAgICAgCiAgICBmb3IgKGludCBpPTI7IGk8PSBuOyBpKyspIHsKICAgICAgICBpbnZGYWN0W2ldID0gKGludkZhY3RbaS0xXSppbnZbaV0pJXA7CiAgICB9Cn0KCmxsIGNvbXB1dGVDb21iaW5hdG9yaWNzIChpbnQgbiwgaW50IHIsIGxsIGZhY3RbXSwgbGwgaW52W10sIGxsIGludkZhY3RbXSkgewogICAgbGwgYW5zID0gKCgoZmFjdFtuXSppbnZGYWN0W3JdKSVwKSooaW52RmFjdFtuLXJdJXApKSVwOwogICAgcmV0dXJuIGFuczsKfQoKCmludCBtYWluIChpbnQgYXJnYywgY29uc3QgY2hhciAqIGFyZ3ZbXSkgewogICAgaW50IG4gPSAxMDAwMDA7CiAgICBpbnQgciA9IDUwMDsKICAgIAogICAgbGwgKmZhY3QgPSBuZXcgbGxbbl0oKTsKICAgIGxsICppbnYgPSBuZXcgbGxbbl0oKTsKICAgIGxsICppbnZGYWN0ID0gbmV3IGxsW25dKCk7CiAgICAKICAgIHByZWNvbXB1dGUobiwgZmFjdCwgaW52LCBpbnZGYWN0KTsKICAgIGNvdXQ8PGNvbXB1dGVDb21iaW5hdG9yaWNzKG4sIHIsIGZhY3QsIGludiwgaW52RmFjdCk8PGVuZGw7CiAgICAKICAgIHJldHVybiAwOwp9Cg==