Problem:
Score : 400 points

Problem Statement

We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.

We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Constraints

1 \leq N \leq 2\times 10^5

1 \leq K \leq N+1

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible values of the sum, modulo (10^9+7).

Sample Input 1

3 2

Sample Output 1

10

The sum can take 10 values, as follows:

(10^{100})+(10^{100}+1)=2\times 10^{100}+1

(10^{100})+(10^{100}+2)=2\times 10^{100}+2

(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\times 10^{100}+3

(10^{100}+1)+(10^{100}+3)=2\times 10^{100}+4

(10^{100}+2)+(10^{100}+3)=2\times 10^{100}+5

(10^{100})+(10^{100}+1)+(10^{100}+2)=3\times 10^{100}+3

(10^{100})+(10^{100}+1)+(10^{100}+3)=3\times 10^{100}+4

(10^{100})+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+5

(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+6

(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\times 10^{100}+6

Sample Input 2

200000 200001

Sample Output 2

1

We must choose all of the integers, so the sum can take just 1 value.

Sample Input 3

141421 35623

Sample Output 3

220280457

Solution in C# (.NET Core 3.1.201) (judge verdict: Wrong Answer)

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        const long mod = 1000000007;

        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        long[] nk = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];

        long ans = 0;
        for (long i = k; i <= n + 1; i++)
        {
            if (n - 1 >= i)
            {
                ans += Ncr(n + 1, i, mod) - Ncr(n - 1, i, mod);
            }
            else
            {
                ans += Ncr(n + 1, i, mod);
            }

            ans %= mod;
        }

        // 出力
        Console.WriteLine(ans);
    }

    public static long Mpow(long x, long n, long m)
    {
        long ans = 1;
        while (n > 0)
        {
            if (n % 2 == 1)
            {
                ans = ans * x % m;
                n -= 1;
            }
            x = x * x % m;
            n /= 2;
        }
        return ans;
    }
    public static long Ncr(long n, long r, long m)
    {
        long ans = 1;
        for (var i = n - r + 1; i <= n; i++)
        {
            ans = ans * i % m;
        }
        for (var i = 2; i <= r; i++)
        {
            ans = ans * Mpow(i, m - 2, m) % m;
        }
        return ans;
    }

}