Problem:
 Score : 400 points    Problem Statement We have a large square grid with H rows and W columns.
Iroha is now standing in the top-left cell.
She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell.  However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells.  Find the number of ways she can travel to the bottom-right cell.  Since this number can be extremely large, print the number modulo 10^9+7 .      Constraints  1 ≦ H, W ≦ 100,000  1 ≦ A < H  1 ≦ B < W         Input The input is given from Standard Input in the following format:  H  W  A  B       Output Print the number of ways she can travel to the bottom-right cell, modulo 10^9+7 .        Sample Input 1 2 3 1 1      Sample Output 1 2  We have a 2×3 grid, but entering the bottom-left cell is forbidden. The number of ways to travel is two: "Right, Right, Down" and "Right, Down, Right".       Sample Input 2 10 7 3 4      Sample Output 2 3570  There are 12 forbidden cells.       Sample Input 3 100000 100000 99999 99999      Sample Output 3 1       Sample Input 4 100000 100000 44444 55555      Sample Output 4 738162020

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def inv(x):
    return pow(x, mod - 2, mod)

def nCb(n, b):
    if b > n - b:
        b = n - b
    r = 1
    for k in range(n, n-b, -1):
        r = r * k % mod
    d = 1
    for k in range(1, b+1):
        d = d * k % mod
    return r * inv(d) % mod

def main():
    h,w,a,b = LI()
    c1 = nCb(h-a-1+b, b)
    c2 = nCb(w-b-1+a, a)
    r = 0
    for i in range(1, min(h-a, w-b)+1):
        r += c1 * c2
        r %= mod
        c1 = c1 * (h-a-i) * inv(b+i) % mod
        c2 = c2 * (w-b-i) * inv(a+i) % mod

    return r

print(main())

Solution (Python):
import scipy.misc as scm

H, W, A, B = [int(i) for i in input().split()]
MOD = 10**9 + 7
f = [1]
a = [1]
for i in range(1, H+W-1):
    f.append((f[i-1] * i) % MOD)
    a.append(pow(f[i], MOD-2, MOD))
ans = 0
for i in range(B, W, 1):
    ans += (((f[(H-A-1)+i] * a[H-A-1] * a[i]) % MOD) * ((f[(A-1)+(W-1-i)] * a[A-1] * a[W-1-i]) % MOD))
    ans %= MOD
print(ans)

Solution (Python):
from sys import stdin, stdout, stderr

mod = 10**9 + 7

def solve():
    def binom(n, k):
        res = (modfact[n] * factinv[k]) % mod
        res = (res * factinv[n - k]) % mod
        return res

    h, w, a, b = map(int, input().split())
    ans = 0
    modfact = [1] * (h + w)
    factinv = [1] * (h + w)
    inv = [1] * (h + w)

    for i in range(2, h + w):
        modfact[i] = (i * modfact[i - 1]) % mod

    factinv[h + w - 1] = pow(modfact[h + w - 1], mod - 2, mod)

    for i in range(h + w - 2, 0, -1):
        factinv[i] = (factinv[i + 1] * (i + 1)) % mod

    for i in range(h - a):
        ans += (binom(b + i - 1, i) * binom(w + h - b - i - 2, h - i - 1)) % mod
        ans %= mod

    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
from sys import stdin, stdout, stderr

mod = 10**9 + 7

def solve():
    def binom(n, k):
        res = (modfact[n] * factinv[k]) % mod
        res = (res * factinv[n - k]) % mod
        return res

    h, w, a, b = map(int, input().split())
    ans = 0
    modfact = [1] * (h + w)
    factinv = [1] * (h + w)
    inv = [1] * (h + w)

    for i in range(2, h + w):
        modfact[i] = (i * modfact[i - 1]) % mod
        inv[i] = (-(mod // i) * inv[mod % i]) % mod
        factinv[i] = (inv[i] * factinv[i - 1]) % mod

    for i in range(h - a):
        ans += (binom(b + i - 1, i) * binom(w + h - b - i - 2, h - i - 1)) % mod
        ans %= mod

    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
from sys import stdin, stdout, stderr, setrecursionlimit
from functools import lru_cache

setrecursionlimit(10**7)

mod = 10**9 + 7

def solve():
    def binom(n, k):
        res = (modfact[n] * factinv[k]) % mod
        res = (res * factinv[n - k]) % mod
        return res

    h, w, a, b = map(int, input().split())
    ans = 0
    modfact = [1] * (h + w)
    factinv = [1] * (h + w)

    for i in range(1, h + w):
        modfact[i] = (i * modfact[i - 1]) % mod
        factinv[i] = (pow(i, mod - 2, mod) * factinv[i - 1]) % mod

    for i in range(h - a):
        ans += (binom(b + i - 1, i) * binom(w + h - b - i - 2, h - i - 1)) % mod
        ans %= mod

    print(ans)

'''
@lru_cache(maxsize=None)
def binom(n, k):
    res = (modfact(n) * factinv(k)) % mod
    res = (res * factinv(n - k)) % mod
    return res

@lru_cache(maxsize=None)
def modfact(n):
    if n == 0:
        return 1

    return (n * modfact(n - 1)) % mod

@lru_cache(maxsize=None)
def factinv(n):
    if n == 0:
        return 1

    return (pow(n, mod - 2, mod) * factinv(n - 1)) % mod
'''

if __name__ == '__main__':
    solve()

Solution (Python):
h, w, a, b = map(int, raw_input().split())

MOD = 10**9+7

M = 2*10**5
fact = [1]*(M+1)
rev = [1]*(M+1)
for i in xrange(1, M+1):
    fact[i] = (fact[i-1]*i) % MOD
    rev[i] = pow(fact[i], MOD-2, MOD)

def comb(a, b):
    a -= 1; b -= 1
    return (fact[a+b] * rev[a] * rev[b]) % MOD

ans = 0
for y in xrange(1, h-a+1):
    ans += comb(y, b) * comb(h-y+1, w-b)
    ans %= MOD
print ans

Solution (Python):
p = 10**9+7; M=10**5;
F = [1]; FI=[0]*(M+1)
for i in xrange(1,M*2+1):F+=[i*F[i-1]%p]
FI[M]=pow(F[M],p-2,p)
for i in xrange(M,0,-1):FI[i-1]=i*FI[i]%p
H,W,A,B = map(int,raw_input().split())
hx,hy = B+1,H-A
ans = 0
while hx <= W and hy > 0:
	tmp = F[hx+hy-2]*FI[hx-1]*FI[hy-1]%p * F[W-hx+H-hy]*FI[W-hx]*FI[H-hy]%p
	ans = (ans + tmp) % p
	hx += 1; hy -= 1
print ans

Solution (Python):
import functools

MOD = 1000000007

fact = [None] * 300000
fact[0] = 1
for i in range(1, 300000):
    fact[i] = (i * fact[i - 1]) % MOD

def comb(h, w):
    numer = fact[h - 1 + w - 1]
    denom = (fact[h - 1] * fact[w - 1]) % MOD
    

    return (numer * pow(denom, MOD - 2, MOD)) % MOD

H, W, A, B = map(int, input().split())
ans = 0
for h in range(H - A):
    x = comb(h + 1, B)
    y = comb(H - h, W - B)
    
    ans += x * y
    ans %= MOD
print(ans)

Solution (Python):
from sys import exit
from itertools import count

def read():
  return [int(x) for x in input().split()]

P = 10**9 + 7

def inv(x):
  return pow(x, P-2, P)

def comb(n, r):
  res = 1
  for i in range(r):
    res = (res * (n-i) * inv(i+1)) % P
  return res

(H, W, A, B) = read()

result = 0

c1 = comb(H-A-1+B, B)
c2 = comb(W-B-1+A, A)

for i in range(1, min(H-A+1, W-B+1)):
  
  result = (result + c1 * c2) % P
  c1 = (c1 * (H-A-i) * inv(B+i)) % P
  c2 = (c2 * (W-B-i) * inv(A+i)) % P

print(result)

Solution (Python):
if __file__.startswith('/tmp/'):
	import sys; sys.stdin = open('input.txt')

MOD = 10**9 + 7

h, w, a, b = map(int, raw_input().split())

def inv(x):
	return pow(x, MOD-2, MOD)

x = [1]
y = [1]

for k in xrange(1, h - a):
	x.append(((x[-1] * (b - 1 + k)) % MOD) * inv(k) % MOD)

for k in xrange(1, h):
	y.append(((y[-1] * (w - b - 1 + k)) % MOD) * inv(k) % MOD)

ans = 0
for k in xrange(h - a):
	ans = (ans + x[k] * y[h - k - 1]) % MOD

print ans

Solution (Python):
mod = 10 ** 9 + 7
h, w, a, b = map(int, raw_input().split())

fm = [1]
for i in xrange(1, 300000):
    fm.append(fm[-1] * i % mod)

def f(x):
    return fm[x]

def inv(x):
    return pow(x, mod - 2, mod)

def c(x, y):
    return f(x + y) * inv(f(x)) % mod * inv(f(y)) % mod

x, y = b - 1, h - a
ans = c(w-1, h-1)
while h - a <= y < h and 0 <= x < b:
    ans = (ans + mod - c(x, y) * c(w - 1-x, h-1 - y) % mod) % mod
    x -= 1
    y += 1

print ans