Buggy python submission (verdict: Time Limit Exceeded):
# a^n mod p
def beki_mod(a, n, p):
    ans = 1
    n = format(n, "b")
    for i in range(len(n)):
        ans = ans * ans % p
        if n[i] == "1":
            ans = ans * a % p
    return ans

# a! mod p
def kaijo_mod(a, p):
    ans = 1
    while a > 0:
        ans = ans * a % p
        a -= 1
    return ans    

# nCr = n * (n -1) * ... * (n - r + 1) / r!
# a^(-1) mod p = a^(p -2) mod p
def combi_mod(n, r, p):
    bunshi = 1
    r = min(r, n - r)

    bumbo = kaijo_mod(r, p)
    bumbo_gyakugen = beki_mod(bumbo, p - 2, p)

    while r > 0:
        bunshi = bunshi * n % p
        n -= 1
        r -= 1
    
    ans = bunshi * bumbo_gyakugen % p
    return ans


H, W, A, B = map(int, input().split())
mod = 10 ** 9 + 7

if B < W / 2:
    not_ans = 0
    total = combi_mod((H - 1) + (W - 1), H-1, mod)
    for i in range(B):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h -1) + (sq1w - 1), (sq1h -1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod) % mod
        not_ans += n
    ans = (total - not_ans) % mod
    print(ans)
        
else:
    ans = 0
    for i in range(B, W):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h - 1) + (sq1w - 1), (sq1h - 1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod)
        ans += n
    ans %= mod
    print(ans)


Fixed submission:
mod = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

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

def combi_mod(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


H, W, A, B = map(int, input().split())

if B < W / 2:
    not_ans = 0
    total = combi_mod((H - 1) + (W - 1), H-1, mod)
    for i in range(B):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h -1) + (sq1w - 1), (sq1h -1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod) % mod
        not_ans = (not_ans + n) % mod
    ans = (total - not_ans) % mod
    print(ans)
        
else:
    ans = 0
    for i in range(B, W):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h - 1) + (sq1w - 1), (sq1h - 1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod)
        ans = (ans + n) % mod
    ans %= mod
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# a^n mod p
def beki_mod(a, n, p):
    ans = 1
    n = format(n, "b")
    for i in range(len(n)):
        ans = ans * ans % p
        if n[i] == "1":
            ans = ans * a % p
    return ans

# nCr = n * (n -1) * ... * (n - r + 1) / r!
# a^(-1) mod p = a^(p -2) mod p
def combi_mod(n, r, p):
    bunshi = 1
    bumbo_gyakugen = 1
    r = min(r, n - r)

    while r > 0:
        bunshi = bunshi * n % p
        bumbo_gyakugen = bumbo_gyakugen * beki_mod(r, p - 2, p) % p
        n -= 1
        r -= 1
    
    ans = bunshi * bumbo_gyakugen % p
    return ans


H, W, A, B = map(int, input().split())
mod = 10 ** 9 + 7

if B < W / 2:
    not_ans = 0
    total = combi_mod((H - 1) + (W - 1), H-1, mod)
    for i in range(B):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h -1) + (sq1w - 1), (sq1h -1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod) % mod
        not_ans += n
    ans = (total - not_ans) % mod
    print(ans)
        
else:
    ans = 0
    for i in range(B, W):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h - 1) + (sq1w - 1), (sq1h - 1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod)
        ans += n
    ans %= mod
    print(ans)


Fixed submission:
mod = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

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

def combi_mod(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


H, W, A, B = map(int, input().split())

if B < W / 2:
    not_ans = 0
    total = combi_mod((H - 1) + (W - 1), H-1, mod)
    for i in range(B):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h -1) + (sq1w - 1), (sq1h -1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod) % mod
        not_ans = (not_ans + n) % mod
    ans = (total - not_ans) % mod
    print(ans)
        
else:
    ans = 0
    for i in range(B, W):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h - 1) + (sq1w - 1), (sq1h - 1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod)
        ans = (ans + n) % mod
    ans %= mod
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# a^n mod p
def beki_mod(a, n, p):
    ans = 1
    n = format(n, "b")
    for i in range(len(n)):
        ans = ans * ans % p
        if n[i] == "1":
            ans = ans * a % p
    return ans

# nCr = n * (n -1) * ... * (n - r + 1) / r!
# a^(-1) mod p = a^(p -2) mod p
def combi_mod(n, r, p):
    bunshi = 1
    bumbo_gyakugen = 1
    r = min(r, n - r)

    while r > 0:
        bunshi = bunshi * n % p
        bumbo_gyakugen = bumbo_gyakugen * beki_mod(r, p - 2, p) % p
        n -= 1
        r -= 1
    
    ans = bunshi * bumbo_gyakugen % p
    return ans


H, W, A, B = map(int, input().split())
mod = 10 ** 9 + 7

if B < W / 2:
    not_ans = 0
    total = combi_mod((H - 1) + (W - 1), H-1, mod)
    for i in range(B):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h -1) + (sq1w - 1), (sq1h -1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod) % mod
        not_ans += n
    ans = (total - not_ans) % mod
    print(ans)
        
else:
    ans = 0
    for i in range(B, W):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h - 1) + (sq1w - 1), (sq1h - 1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod)
        ans += n
    ans %= mod
    print(ans)


Fixed submission:
mod = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

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

def combi_mod(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


H, W, A, B = map(int, input().split())

if B < W / 2:
    not_ans = 0
    total = combi_mod((H - 1) + (W - 1), H-1, mod)
    for i in range(B):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h -1) + (sq1w - 1), (sq1h -1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod) % mod
        not_ans = (not_ans + n) % mod
    ans = (total - not_ans) % mod
    print(ans)
        
else:
    ans = 0
    for i in range(B, W):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h - 1) + (sq1w - 1), (sq1h - 1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod)
        ans = (ans + n) % mod
    ans %= mod
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def conbi(n, r):
    bunbo = 1
    bunshi = 1
    if n / 2 < r:
        r = n - r
    while r > 0:
        bunbo *= r
        bunshi *= n
        r -= 1
        n -= 1
    return bunshi // bunbo

def conbi_mod(n, r):
    return conbi(n, r) % (10 ** 9 + 7)
    


H, W, A, B = map(int, input().split())

if B < W / 2:
    not_ans = 0
    total = conbi_mod((H - 1) + (W - 1), H-1)
    for i in range(B):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = conbi((sq1h -1) + (sq1w - 1), (sq1h -1)) * conbi((sq2h - 1) + (sq2w - 1), (sq2h - 1)) % (10 ** 9 + 7)
        not_ans += n
    ans = (total - not_ans) % (10 ** 9 + 7)
    print(ans)
        
else:
    ans = 0
    for i in range(B, W):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = conbi((sq1h - 1) + (sq1w - 1), (sq1h - 1)) * conbi((sq2h - 1) + (sq2w - 1), (sq2h - 1)) % (10 ** 9 + 7)
        ans += n
    ans = ans % (10 ** 9 + 7)
    print(ans)

Fixed submission:
mod = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

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

def combi_mod(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


H, W, A, B = map(int, input().split())

if B < W / 2:
    not_ans = 0
    total = combi_mod((H - 1) + (W - 1), H-1, mod)
    for i in range(B):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h -1) + (sq1w - 1), (sq1h -1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod) % mod
        not_ans = (not_ans + n) % mod
    ans = (total - not_ans) % mod
    print(ans)
        
else:
    ans = 0
    for i in range(B, W):
        sq1h = H - A
        sq1w = i + 1
        sq2h = A
        sq2w = W - i
        n = combi_mod((sq1h - 1) + (sq1w - 1), (sq1h - 1), mod) * combi_mod((sq2h - 1) + (sq2w - 1), (sq2h - 1), mod)
        ans = (ans + n) % mod
    ans %= mod
    print(ans)