Language: C++

lude <bits/stdc++.h>

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

// O(log(p))
ll mpow(ll x, ll p) {
    if (p == 1) { return x % MOD; }
    if (p % 2) { return (x * mpow(x, p - 1)) % MOD; }
    ll sub = mpow(x, p / 2);
    return (sub * sub) % MOD;
}

// O(1)
ll f(const vll& fac, const vll& inv, int i, int j) {
    if (i == 0 || j == 0) { return 1; }
    if (i == 1 || j == 1) { return (i + j) % MOD; }
    return (((fac[i + j] * inv[i]) % MOD) * inv[j]) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    int n = r2 + c2;
    vll fac(n + 2, 0), inv(n + 2, 0);

    // O(n)
    fac[0] = 1;
    rep(i, 1, n + 2) { fac[i] = (i * fac[i - 1]) % MOD; }

    // O(nlog(MOD))
    inv.back() = mpow(fac.back(), MOD - 2);
    rrep(i, 0, n + 1) { inv[i] = (inv[i + 1] * (i + 1)) % MOD; }

    // O(n)
    ll sum = 0;
    rep(i, r1, r2 + 1) {
        ll tmp = (f(fac, inv, i + 1, c2) - f(fac, inv, i + 1, c1 - 1)) % MOD;
        if (tmp < 0) { tmp += MOD; }
        sum = (sum + tmp) % MOD;
    }
    cout << sum << endl;
    return 0;
}

Compiler output:
a.cc:1:1: error: 'lude' does not name a type
    1 | lude <bits/stdc++.h>
      | ^~~~
a.cc:9:12: error: 'vector' does not name a type
    9 | using vi = vector<int>;
      |            ^~~~~~
a.cc:10:13: error: 'vector' does not name a type
   10 | using vvi = vector<vi>;
      |             ^~~~~~
a.cc:11:13: error: 'vector' does not name a type
   11 | using vll = vector<ll>;
      |             ^~~~~~
a.cc:24:12: error: 'vll' does not name a type; did you mean 'll'?
   24 | ll f(const vll& fac, const vll& inv, int i, int j) {
      |            ^~~
      |            ll
a.cc:24:28: error: 'vll' does not name a type; did you mean 'll'?
   24 | ll f(const vll& fac, const vll& inv, int i, int j) {
      |                            ^~~
      |                            ll
a.cc: In function 'll f(const int&, const int&, int, int)':
a.cc:27:18: error: invalid types 'const int[int]' for array subscript
   27 |     return (((fac[i + j] * inv[i]) % MOD) * inv[j]) % MOD;
      |                  ^
a.cc:27:31: error: invalid types 'const int[int]' for array subscript
   27 |     return (((fac[i + j] * inv[i]) % MOD) * inv[j]) % MOD;
      |                               ^
a.cc:27:48: error: invalid types 'const int[int]' for array subscript
   27 |     return (((fac[i + j] * inv[i]) % MOD) * inv[j]) % MOD;
      |                                                ^
a.cc: In function 'int main()':
a.cc:31:5: error: 'cin' was not declared in this scope
   31 |     cin.tie(0);
      |     ^~~
a.cc:32:5: error: 'ios' has not been declared
   32 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:38:5: error: 'vll' was not declared in this scope; did you mean 'll'?
   38 |     vll fac(n + 2, 0), inv(n + 2, 0);
      |     ^~~
      |     ll
a.cc:41:5: error: 'fac' was not declared in this scope
   41 |     fac[0] = 1;
      |     ^~~
a.cc:45:5: error: 'inv' was not declared in this scope; did you mean 'int'?
   45 |     inv.back() = mpow(fac.back(), MOD - 2);
      |     ^~~
      |     int
a.cc:55:5: error: 'cout' was not declared in this scope
   55 |     cout << sum << endl;
      |     ^~~~
a.cc:55:20: error: 'endl' was not declared in this scope
   55 |     cout << sum << endl;
      |                    ^~~~