Problem:
Score : 500 points

Problem Statement

There is a building with n rooms, numbered 1 to n.

We can move from any room to any other room in the building.

Let us call the following event a move: a person in some room i goes to another room j~ (i \neq j).

Initially, there was one person in each room in the building.

After that, we know that there were exactly k moves happened up to now.

We are interested in the number of people in each of the n rooms now. How many combinations of numbers of people in the n rooms are possible?

Find the count modulo (10^9 + 7).

Constraints

All values in input are integers.

3 \leq n \leq 2 \times 10^5

2 \leq k \leq 10^9

Input

Input is given from Standard Input in the following format:

n k

Output

Print the number of possible combinations of numbers of people in the n rooms now, modulo (10^9 + 7).

Sample Input 1

3 2

Sample Output 1

10

Let c_1, c_2, and c_3 be the number of people in Room 1, 2, and 3 now, respectively. There are 10 possible combination of (c_1, c_2, c_3):

(0, 0, 3)

(0, 1, 2)

(0, 2, 1)

(0, 3, 0)

(1, 0, 2)

(1, 1, 1)

(1, 2, 0)

(2, 0, 1)

(2, 1, 0)

(3, 0, 0)

For example, (c_1, c_2, c_3) will be (0, 1, 2) if the person in Room 1 goes to Room 2 and then one of the persons in Room 2 goes to Room 3.

Sample Input 2

200000 1000000000

Sample Output 2

607923868

Print the count modulo (10^9 + 7).

Sample Input 3

15 6

Sample Output 3

22583772

Solution in C (GCC 5.4.1) (judge verdict: Runtime Error)

/*************************************************/
/*abc157E*/
long long gya(long long a);
long long com(long long b, long long d); //bCd
long long mem[100000];
int main(void) {
  int n, k, i, mod=1000000007;
  long long ans, g=1, t1, t2;
  scanf(" %d %d", &n, &k);

  if(n <= k + 1){
    ans=1;
    for(i=0; i < n - 1; i++)
      ans=ans * (n + i + 1) % mod, g=g * (i + 1) % mod;
    ans=ans * gya(g) % mod;
  }else{
    for(i=0; i < n; i++)
      mem[i]=0;

    ans=1;
    for(i=1; i <= k; i++){
      t1=com(n, i), t2=com(n - 1, n - i - 1);
      ans=(ans + t1 * t2) % mod;
      //printf("ans+= %dC%d * %dC%d =%lld*%lld=%lld\n", n, i, n - 1, n - i - 1, t1, t2, t1 * t2%mod);
    }
  }
  printf("%lld", ans);
  return 0;
}
long long gya(long long a) { //逆元を求める
  long long m=1000000007, b=m, u=1, v=0, c, t;
  while(b){
    t=a / b; //何これ
    a-=t * b, u-=t * v; //何これ
    c=a, a=b, b=c, c=u, u=v, v=c; //swap
  }
  return (u + m) % m;
}
long long com(long long b, long long d) { //bCd
  int i, mod=1000000007;
  long long ret=1, ret2=1, tmp=1;

  if(mem[b - 1] == 0){
    for(i=1; i <= b; i++)
      ret=ret * i % mod;
    mem[b - 1]=ret;
  }else ret=mem[b - 1];

  if(mem[b - d - 1] == 0){
    for(i=1; i <= b - d; i++)
      ret2=ret2 * i % mod;
    mem[b - d - 1]=ret2;
  }else ret2=mem[b - d - 1];

  if(mem[d - 1] == 0){
    for(i=1; i <= d; i++)
      tmp=tmp * i % mod;
    mem[d - 1]=tmp;
  }else tmp=mem[d - 1];

  //printf("ret=%10lld \t ret2=%10lld \t tmp=%10lld\n", ret,ret2, tmp);
  return ret * gya(tmp * ret2 % mod) % mod;
}