Buggy python submission (verdict: Time Limit Exceeded):
#from scipy.special import comb
r1, c1, r2, c2 = map(int, input().split())
#mod = 1000000007
#hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
#rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
#rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod
#duplicate = (comb(r1 + c1, r1, exact=True) - 1) % mod
#ans = (hole - rect1 - rect2 + duplicate) % mod

p = 10 ** 9 + 7
N = 1010000*2  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p

hole = (cmb(r2 + c2 + 2, r2 + 1, p) - 1)
rect1 = (cmb(r2 + c1 - 1 + 2, r2 + 1, p) - 1)
rect2 = (cmb(r1 - 1 + c2 + 2, r1, p) - 1)
duplicate = (cmb(r1 + c1, r1, p) - 1)
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())

p = 10 ** 9 + 7
size = 1010000 * 2
f_list = [1] * size
for i in range(1, size):
    f_list[i] = (f_list[i - 1] * i) % p

def cmb(n, r):
    return f_list[n + r] * pow(f_list[n], p-2, p) * pow(f_list[r], p-2, p) % p

hole = cmb(r2 + 1, c2 + 1) - 1
rect1 = cmb(r2 + 1, c1) - 1
rect2 = cmb(r1, c2 + 1) - 1
duplicate = cmb(r1, c1) - 1
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#from scipy.special import comb
r1, c1, r2, c2 = map(int, input().split())
#mod = 1000000007
#hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
#rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
#rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod
#duplicate = (comb(r1 + c1, r1, exact=True) - 1) % mod
#ans = (hole - rect1 - rect2 + duplicate) % mod

p = 10 ** 9 + 7
N = 10 ** 6  * 2 + 100# N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p

hole = (cmb(r2 + c2 + 2, r2 + 1, p) - 1)
rect1 = (cmb(r2 + c1 - 1 + 2, r2 + 1, p) - 1)
rect2 = (cmb(r1 - 1 + c2 + 2, r1, p) - 1)
duplicate = (cmb(r1 + c1, r1, p) - 1)
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())

p = 10 ** 9 + 7
size = 1010000 * 2
f_list = [1] * size
for i in range(1, size):
    f_list[i] = (f_list[i - 1] * i) % p

def cmb(n, r):
    return f_list[n + r] * pow(f_list[n], p-2, p) * pow(f_list[r], p-2, p) % p

hole = cmb(r2 + 1, c2 + 1) - 1
rect1 = cmb(r2 + 1, c1) - 1
rect2 = cmb(r1, c2 + 1) - 1
duplicate = cmb(r1, c1) - 1
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Buggy python submission (verdict: Runtime Error):
#from scipy.special import comb
r1, c1, r2, c2 = map(int, input().split())
#mod = 1000000007
#hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
#rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
#rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod
#duplicate = (comb(r1 + c1, r1, exact=True) - 1) % mod
#ans = (hole - rect1 - rect2 + duplicate) % mod

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p

hole = (cmb(r2 + c2 + 2, r2 + 1, p) - 1)
rect1 = (cmb(r2 + c1 - 1 + 2, r2 + 1, p) - 1)
rect2 = (cmb(r1 - 1 + c2 + 2, r1, p) - 1)
duplicate = (cmb(r1 + c1, r1, p) - 1)
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())

p = 10 ** 9 + 7
size = 1010000 * 2
f_list = [1] * size
for i in range(1, size):
    f_list[i] = (f_list[i - 1] * i) % p

def cmb(n, r):
    return f_list[n + r] * pow(f_list[n], p-2, p) * pow(f_list[r], p-2, p) % p

hole = cmb(r2 + 1, c2 + 1) - 1
rect1 = cmb(r2 + 1, c1) - 1
rect2 = cmb(r1, c2 + 1) - 1
duplicate = cmb(r1, c1) - 1
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb
r1, c1, r2, c2 = map(int, input().split())
mod = 1000000007
hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod
duplicate = (comb(r1 + c1, r1, exact=True) - 1) % mod
ans = (hole - rect1 - rect2 + duplicate) % mod
print(ans)

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())

p = 10 ** 9 + 7
size = 1010000 * 2
f_list = [1] * size
for i in range(1, size):
    f_list[i] = (f_list[i - 1] * i) % p

def cmb(n, r):
    return f_list[n + r] * pow(f_list[n], p-2, p) * pow(f_list[r], p-2, p) % p

hole = cmb(r2 + 1, c2 + 1) - 1
rect1 = cmb(r2 + 1, c1) - 1
rect2 = cmb(r1, c2 + 1) - 1
duplicate = cmb(r1, c1) - 1
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb
r1, c1, r2, c2 = map(int, input().split())
mod = 1000000007
hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod
duplicate = (comb(r1 + c1, r1, exact=True) - 1) % mod
ans = (hole - rect1 - rect2 + duplicate) % mod
print(ans)

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())

p = 10 ** 9 + 7
size = 1010000 * 2
f_list = [1] * size
for i in range(1, size):
    f_list[i] = (f_list[i - 1] * i) % p

def cmb(n, r):
    return f_list[n + r] * pow(f_list[n], p-2, p) * pow(f_list[r], p-2, p) % p

hole = cmb(r2 + 1, c2 + 1) - 1
rect1 = cmb(r2 + 1, c1) - 1
rect2 = cmb(r1, c2 + 1) - 1
duplicate = cmb(r1, c1) - 1
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
r1, c1, r2, c2 = map(int, input().split())
mod = 1000000007
hole = (comb(r2 + c2 + 2, r2 + 1, exact=True) - 1) % mod
rect1 = (comb(r2 + c1 - 1 + 2, r2 + 1, exact=True) - 1) % mod
rect2 = (comb(r1 - 1 + c2 + 2, r1, exact=True) - 1) % mod
duplicate = (comb(r1 + c1, r1, exact=True) - 1) % mod
ans = (hole - rect1 - rect2 + duplicate) % mod
print(ans)

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())

p = 10 ** 9 + 7
size = 1010000 * 2
f_list = [1] * size
for i in range(1, size):
    f_list[i] = (f_list[i - 1] * i) % p

def cmb(n, r):
    return f_list[n + r] * pow(f_list[n], p-2, p) * pow(f_list[r], p-2, p) % p

hole = cmb(r2 + 1, c2 + 1) - 1
rect1 = cmb(r2 + 1, c1) - 1
rect2 = cmb(r1, c2 + 1) - 1
duplicate = cmb(r1, c1) - 1
ans = (hole - rect1 - rect2 + duplicate) % p
print(ans)