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 JavaScript (node.js v5.12) (judge verdict: Runtime Error)

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
class ModInt {
    constructor(value, mod) {
        this.value = value;
        this.mod = mod;
        this.value %= mod;
        if (this.value < 0)
            this.value += mod;
    }
    add(value) {
        if (typeof value === "number") {
            return new ModInt(this.value + (value % this.mod), this.mod);
        }
        else {
            if (value.mod !== this.mod)
                throw new Error("the mods are not same");
            return new ModInt(this.value + value.value, this.mod);
        }
    }
    sub(value) {
        if (typeof value === "number") {
            return this.add(-value);
        }
        else {
            if (value.mod !== this.mod)
                throw new Error("the mods are not same");
            return this.add(new ModInt(-value.value, this.mod));
        }
    }
    mul(value) {
        if (typeof value === "number") {
            return new ModInt(ModInt.multiplyMod(this.value, value, this.mod), this.mod);
        }
        else {
            if (value.mod !== this.mod)
                throw new Error("the mods are not same");
            return this.mul(value.value);
        }
    }
    div(value) {
        if (typeof value === "number") {
            return new ModInt(value, this.mod).inverse().mul(this.value);
        }
        else {
            if (value.mod !== this.mod)
                throw new Error("the mods are not same");
            return value.inverse().mul(this);
        }
    }
    inverse() {
        if (ModInt.gcd(this.value, this.mod) !== 1)
            throw new Error(`${this.value} is not coprime to ${this.mod}`);
        return new ModInt(ModInt.gcdEx(this.value, this.mod)[0], this.mod);
    }
    pow(n) {
        const rem = (x, y) => x === Infinity ? Infinity : x % y;
        const powMod = (x, n) => {
            if (n <= 0)
                return 1;
            if (n % 2 === 0)
                return powMod(rem(ModInt.multiplyMod(x, x, this.mod), this.mod), n / 2);
            else
                return rem(ModInt.multiplyMod(x, powMod(x, n - 1), this.mod), this.mod);
        };
        return new ModInt(powMod(this.value, n), this.mod);
    }
    static combination(n, k, mod) {
        if (typeof n === "number" && typeof k === "number" && typeof mod === "number") {
            n = new ModInt(n, mod);
            k = new ModInt(k, mod);
        }
        if (typeof n === "number" || typeof k === "number")
            throw new Error("argument type mismatched");
        if (n.mod !== k.mod)
            throw new Error("the mods are not same");
        const m = n.mod;
        const modint = (x) => new ModInt(x, m);
        if (n.value <= 0 || k.value <= 0)
            return modint(1);
        if (this.factorial_cache[m] === undefined)
            this.factorial_cache[m] = [modint(1)];
        if (this.factorial_cache[m].length <= n.value) {
            for (let i = this.factorial_cache[m].length; i <= n.value; i++) {
                this.factorial_cache[m][i] = this.factorial_cache[m][i - 1].mul(i);
            }
        }
        let result = modint(1);
        result = result.mul(this.factorial_cache[m][n.value]);
        result = result.div(this.factorial_cache[m][k.value]);
        result = result.div(this.factorial_cache[m][n.value - k.value]);
        return result;
    }
    /**
     * avoid overflow and calc x*y%mod
     * @param x non-negative int
     * @param y non-negative int
     * @param mod
     */
    static multiplyMod(x, y, mod) {
        if (x * y < Number.MAX_SAFE_INTEGER)
            return x * y % mod;
        // avoid overflow
        const multiplymod = (x, y) => {
            if (y <= 0)
                return 0;
            if (y % 2 === 0)
                return ModInt.multiplyMod(x, y / 2, mod) * 2 % mod;
            else
                return ModInt.multiplyMod(x, y - 1, mod) + x % mod;
        };
        return multiplymod(x, y);
    }
    ;
    /**
     * get a maximum number z s.t. x%z==0 && x%y==0
     */
    static gcd(x, y) {
        if (y === 0)
            return x;
        return ModInt.gcd(y, x % y);
    }
    /**
     * get one (a,b) pair that satisfies ax+by=gcd(a,b)
     * @returns [a, b]
     */
    static gcdEx(x, y) {
        let [a0, a1, b0, b1] = [1, 0, 0, 1];
        while (y > 0) {
            const r = Math.floor(x / y);
            [x, y] = [y, x % y];
            [a0, a1] = [a1, a0 - r * a1];
            [b0, b1] = [b1, b0 - r * b1];
        }
        return [a0, b0];
    }
}
ModInt.factorial_cache = [];
const MOD = Math.pow(10, 9) + 7;
const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");
const [n, k] = input[0].split(" ").map((x) => +x);
let result = new ModInt(0, MOD);
for (let i = 0; i <= Math.min(n - 1, k); i++) {
    result = result.add(ModInt.combination(n, i, MOD).mul(ModInt.combination(n - 1, i, MOD)));
}
console.log(result.value);