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 in Rust (1.15.1) (judge verdict: Accepted)

#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());

    let (h,w,a,b):(i64,i64,i64,i64) = (io.read(),io.read(),io.read(),io.read());
    let mut md = ModComb::new(3234421,MOD);

    let mut ans:i64 = 0;
    for i in 0..h-a{
        ans += md.nCk(i+b-1, i) * md.nCk(h+w-i-1-b-1, w-b-1);
        ans %= MOD;
    }
    io.writeln(ans);



}
struct ModComb {
  fact: Vec<i64>,
  fact_inv: Vec<i64>,
  n: usize,
  p: i64,
}
fn modpow(x: i64, n: i64, m: i64) -> i64 {
  let mut res = 1;
  let mut x = x % m;
  let mut n = n;
  while n > 0 {
    if n & 1 == 1 {
      res = (res * x) % m;
    }
    x = (x * x) % m;
    n >>= 1;
  }
  res
}
impl ModComb {
  fn initialize(&mut self) {
    let n = self.n;

    self.fact[0] = 1;
    for i in 1..n {
      self.fact[i] = (self.fact[i - 1] * i as i64) % self.p;
    }
    self.fact_inv[n - 1] = modpow(self.fact[n - 1], self.p - 2, self.p);
    for i in (0..n - 1).rev() {
      self.fact_inv[i] = (self.fact_inv[i + 1] * (i + 1) as i64) % self.p;
    }
  }
  fn new(max_n: usize, p: i64) -> ModComb {
    let mut ft = ModComb {
      fact: vec![0; max_n + 1],
      fact_inv: vec![0; max_n + 1],
      n: max_n + 1,
      p: p,
    };
    ModComb::initialize(&mut ft);
    ft
  }
  fn fact(&self, n: usize) -> i64 {
    self.fact[n]
  }
  fn nCk(&self, n: i64, k: i64) -> i64 {
    if n < k {
      return 0;
    }
    (self.nPk(n, k) * self.fact_inv[k as usize]) % self.p
  }
  fn nPk(&self, n: i64, k: i64) -> i64 {
    if n < k {
      return 0;
    }
    self.fact[n as usize] * self.fact_inv[(n - k) as usize] % self.p
  }
  fn nHk(&self, n: i64, k: i64) -> i64 {
    if n == 0 && k == 0 {
      return 1;
    }
    self.nCk(n + k - 1, k)
  }
  fn nSk(&self, n: i64, k: i64) -> i64 {
    if n < k {
      return 0;
    }
    let mut res = 0;
    for i in 0..k + 1 {
      let v = self.nCk(k, i) * modpow(i, n, self.p) % self.p;
      if (k - i) % 2 == 1 {
        // odd
        res = (res + self.p - v) % self.p;
      } else {
        //
        res = (res + v) % self.p;
      }
    }
    return res * self.fact_inv[k as usize] % self.p;
  }
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}