Language: C

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int mod = 1000000007;

#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

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

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

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

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(ll size) {
        prime.resize(size, 1);
        prime[0] = 0;
        prime[1] = 0;
        for (size_t i = 2; i * i <= size; ++i)
            if (prime[i]) {
                for (size_t j = 2; i * j <= size; ++j)prime[i * j] = false;
            }
    }
};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % mod;
            ifac[i + 1] = ifac[i] * mpow(i + 1, mod - 2) % mod;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % mod;
            x = x * x % mod;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % mod;
        return tmp * fac[a] % mod;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}


struct SegmentTree {
private:
    int n;
    vector<ll> node;

public:
    SegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2 * n - 1, 0);
        for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) node[i] = (node[2 * i + 1] | node[2 * i + 2]);
    }

    void update(int x, ll val) {
        x += (n - 1);
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2 * x + 1] | node[2 * x + 2];
        }
    }

    ll getLR(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;

        if (r <= a || b <= l) return 0;

        if (a <= l && r <= b) return node[k];

        ll vl = getLR(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = getLR(a, b, 2 * k + 2, (l + r) / 2, r);
        return (vl | vr);
    }
};

ll n, k;

int main() {
    cin >> n >> k;
    ll mi = 0, ma = 0;
    REP(i, k) {
        mi += i;
        ma += n - i;
    }
    ll ans = 0;
    FOR(i, k, n) {
        ans = (ans + (ma - mi + 1) % mod) % mod;
        ans %= mod;
        mi += i;
        ma += n - i;
    }
    ans = (ans + 1) % mod;
    cout << ans << endl;
    return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.