stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>

#include <cstdio>

#include <cstring>

typedef long long ll;

#define rep(i,s,t) for (ll i = s ; i < t ; ++ i)

#define mod 1000000007

#define maxn 200005



using namespace std;



ll fac[maxn],inv[maxn];



int f(ll a,ll b)

{

    ll ans = 1;

    while (b)

    {

        if (b%2)

           ans = ans * a % mod;

        a = a * a % mod;

        b /= 2;

    }

    return ans;

}



void init()

{

    fac[0] = 1;

    rep(i,1,maxn)

       fac[i] = fac[i-1] * i % mod;

    inv[maxn-1] = f(fac[maxn-1],mod-2);

    for (ll i = maxn-2 ; i >=0 ; -- i)

        inv[i] = inv[i+1] * (i+1) % mod;

}

int main()

{

    init();

    int h,w,a,b;

    cin>> h >> w >> a >> b;

    ll ans = 0;

    for (int i = b + 1 ; i <= w ; i++)

    {

        int sum = h - a + i - 2 ;

        ll cmp1 = fac[sum] * inv[i - 1] % mod;

        cmp1 = cmp1 * inv[h-a-1] % mod;



        sum = a + w - i - 1;

        ll cmp2 = fac[sum] * inv[a - 1] % mod;

        cmp2 = cmp2 * inv[w-i] % mod;



        cmp1 = cmp1 * cmp2 % mod;

        ans = (ans + cmp1) % mod;

    }

    cout<< ans <<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2380249373272458x):
#include<cstdio>

#include<algorithm>

#define MOD 1000000007

#define MAXN 200006

using namespace std;

long long fac[MAXN],inv[MAXN],ans;

int n,m,a,b;

long long ksm(long long a,long long m)

{

	if(m==0) return 1;

	long long nex=ksm(a,m/2);

	nex=(nex*nex)%MOD;

	if(m%2==0) return nex;

	else return (nex*a)%MOD;

}

void waiting()

{

	fac[0]=1;

	for(long long i=1;i<MAXN;i++)

		fac[i]=(fac[i-1]*i)%MOD;

	inv[MAXN-1]=ksm(fac[MAXN-1],MOD-2);

	for(long long i=MAXN-2;i>=0;i--)

		inv[i]=(inv[i+1]*(i+1))%MOD;

}

long long C(int n,int m)

{

	return (((fac[m]*inv[n])%MOD)*inv[m-n])%MOD;

}

int main()

{

	waiting();

	scanf("%d%d%d%d",&n,&m,&a,&b);

	for(int i=1;i<=n-a;i++)

	{

		long long p1=C(b-1,b+i-2);

		long long p2=C(m-b-1,m-b+n-i-1);

		long long p=(p1*p2)%MOD;

		ans=(ans+p)%MOD;

	}

	printf("%lld",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <cstdio>

#include <algorithm>

#include <cmath>

using namespace std;

#define ll long long

#define maxn 210000

#define mod 1000000007

const int m=1e9+7;

ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}

ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}

int n,k,t,h,w,a,b;

ll fac[maxn],inv[maxn];

void init()

{

    fac[0]=1;

    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;

    inv[maxn-10]=qpow(fac[maxn-10],mod-2);

    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

}

ll C(int x,int y)

{

    return fac[x]*inv[y]%mod*inv[x-y]%mod;

}

int main()

{

    //freopen("de.txt","r",stdin);

    init();

    while (~scanf("%d%d%d%d",&h,&w,&a,&b)){

        ll ans=C(h+w-2,h-1);

        for (int i=0;i<b;++i){

            ll temp1=C(i+h-1-a,i);

            ll temp2=C(w-i+a-2,a-1);

            ll temp3=(temp1*temp2)%mod;

            ans=(ans-temp3+mod)%mod;

        }

        printf("%I64d\n",ans);

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.2838976810896565x):
#include<cstdio>

#include<algorithm>

#define MOD 1000000007

#define MAXN 200006

using namespace std;

long long fac[MAXN],inv[MAXN],ans;

int n,m,a,b;

long long ksm(long long a,long long m)

{

	if(m==0) return 1;

	long long nex=ksm(a,m/2);

	nex=(nex*nex)%MOD;

	if(m%2==0) return nex;

	else return (nex*a)%MOD;

}

void waiting()

{

	fac[0]=1;

	for(long long i=1;i<MAXN;i++)

		fac[i]=(fac[i-1]*i)%MOD;

	inv[MAXN-1]=ksm(fac[MAXN-1],MOD-2);

	for(long long i=MAXN-2;i>=0;i--)

		inv[i]=(inv[i+1]*(i+1))%MOD;

}

long long C(int n,int m)

{

	return (((fac[m]*inv[n])%MOD)*inv[m-n])%MOD;

}

int main()

{

	waiting();

	scanf("%d%d%d%d",&n,&m,&a,&b);

	for(int i=1;i<=n-a;i++)

	{

		long long p1=C(b-1,b+i-2);

		long long p2=C(m-b-1,m-b+n-i-1);

		long long p=(p1*p2)%MOD;

		ans=(ans+p)%MOD;

	}

	printf("%lld",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <climits>

#include <cstring>

#include <string>

#include <set>

#include <bitset>

#include <map>

#include <queue>

#include <stack>

#include <vector>

#define rep(i,m,n) for(i=m;i<=n;i++)

#define mod 1000000007

#define inf 0x3f3f3f3f

#define vi vector<int>

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define ll long long

#define pi acos(-1.0)

#define pii pair<int,int>

#define sys system("pause")

const int maxn=2e5+10;

const int N=1e3+10;

using namespace std;

ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}

ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}

int n,m,k,t,h,w,a,b;

ll fac[maxn],inv[maxn];

void init()

{

    fac[0]=1;

    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;

    inv[maxn-10]=qpow(fac[maxn-10],mod-2);

    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

}

ll C(int x,int y)

{

    return fac[x]*inv[y]%mod*inv[x-y]%mod;

}

int main()

{

    int i,j;

    init();

    scanf("%d%d%d%d",&h,&w,&a,&b);

    ll ret=C(h+w-2,h-1);

    for(i=0;i<=b-1;i++)ret=(ret-C(i+h-a-1,h-a-1)*C(w-i+a-2,a-1)%mod+mod)%mod;

    printf("%lld\n",ret);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 21.96823213084715x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MO 1000000007

#define MAXN 200005

#define LL long long

LL inv[MAXN],s[MAXN];

int n;

LL PowMod(LL a,int b)

{

	LL ret=1;

	while(b)

	{

		if(b&1) ret=ret*a%MO;

		a=a*a%MO;

		b>>=1;

	}

	return ret;

}

void Pre()

{

	s[0]=1;

	for(int i=1;i<=n;i++)

		s[i]=s[i-1]*i%MO;

	inv[0]=1;

	inv[n]=PowMod(s[n],MO-2);

	for(int i=n-1;i>0;i--)

		inv[i]=inv[i+1]*(i+1)%MO;

}

LL C(int a,int b)

{

	if(a<0||b<0) return 1;

	return s[a]*inv[b]%MO*inv[a-b]%MO;

}

int main()

{

	int h,w,A,B;

	scanf("%d%d%d%d",&h,&w,&A,&B);

	n=h+w-2;

	Pre();

	LL ans=C(h+w-2,h-1);

	for(int i=1;i<=B;i++)

	{

		ans-=C(h-A+i-2,h-A-1)*C(A-1+w-i,A-1)%MO;

		ans=(ans%MO+MO)%MO;

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>

#include <cstdio>

#include <cstring>

typedef long long ll;

#define rep(i,s,t) for (ll i = s ; i < t ; ++ i)

#define mod 1000000007

#define maxn 200005



using namespace std;



ll fac[maxn],inv[maxn];



int f(ll a,ll b)

{

    ll ans = 1;

    while (b)

    {

        if (b%2)

           ans = ans * a % mod;

        a = a * a % mod;

        b /= 2;

    }

    return ans;

}



void init()

{

    fac[0] = 1;

    rep(i,1,maxn)

       fac[i] = fac[i-1] * i % mod;

    inv[maxn-1] = f(fac[maxn-1],mod-2);

    for (ll i = maxn-2 ; i >=0 ; -- i)

        inv[i] = inv[i+1] * (i+1) % mod;

}

int main()

{

    init();

    int h,w,a,b;

    cin>> h >> w >> a >> b;

    ll ans = 0;

    for (int i = b + 1 ; i <= w ; i++)

    {

        int sum = h - a + i - 2 ;

        ll cmp1 = fac[sum] * inv[i - 1] % mod;

        cmp1 = cmp1 * inv[h-a-1] % mod;



        sum = a + w - i - 1;

        ll cmp2 = fac[sum] * inv[a - 1] % mod;

        cmp2 = cmp2 * inv[w-i] % mod;



        cmp1 = cmp1 * cmp2 % mod;

        ans = (ans + cmp1) % mod;

    }

    cout<< ans <<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 22.04013328645354x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MO 1000000007

#define MAXN 200005

#define LL long long

LL inv[MAXN],s[MAXN];

int n;

LL PowMod(LL a,int b)

{

	LL ret=1;

	while(b)

	{

		if(b&1) ret=ret*a%MO;

		a=a*a%MO;

		b>>=1;

	}

	return ret;

}

void Pre()

{

	s[0]=1;

	for(int i=1;i<=n;i++)

		s[i]=s[i-1]*i%MO;

	inv[0]=1;

	inv[n]=PowMod(s[n],MO-2);

	for(int i=n-1;i>0;i--)

		inv[i]=inv[i+1]*(i+1)%MO;

}

LL C(int a,int b)

{

	if(a<0||b<0) return 1;

	return s[a]*inv[b]%MO*inv[a-b]%MO;

}

int main()

{

	int h,w,A,B;

	scanf("%d%d%d%d",&h,&w,&A,&B);

	n=h+w-2;

	Pre();

	LL ans=C(h+w-2,h-1);

	for(int i=1;i<=B;i++)

	{

		ans-=C(h-A+i-2,h-A-1)*C(A-1+w-i,A-1)%MO;

		ans=(ans%MO+MO)%MO;

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <cstdio>

#include <algorithm>

#include <cmath>

using namespace std;

#define ll long long

#define maxn 210000

#define mod 1000000007

const int m=1e9+7;

ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}

ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}

int n,k,t,h,w,a,b;

ll fac[maxn],inv[maxn];

void init()

{

    fac[0]=1;

    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;

    inv[maxn-10]=qpow(fac[maxn-10],mod-2);

    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

}

ll C(int x,int y)

{

    return fac[x]*inv[y]%mod*inv[x-y]%mod;

}

int main()

{

    //freopen("de.txt","r",stdin);

    init();

    while (~scanf("%d%d%d%d",&h,&w,&a,&b)){

        ll ans=C(h+w-2,h-1);

        for (int i=0;i<b;++i){

            ll temp1=C(i+h-1-a,i);

            ll temp2=C(w-i+a-2,a-1);

            ll temp3=(temp1*temp2)%mod;

            ans=(ans-temp3+mod)%mod;

        }

        printf("%I64d\n",ans);

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 22.85679000818451x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MO 1000000007

#define MAXN 200005

#define LL long long

LL inv[MAXN],s[MAXN];

int n;

LL PowMod(LL a,int b)

{

	LL ret=1;

	while(b)

	{

		if(b&1) ret=ret*a%MO;

		a=a*a%MO;

		b>>=1;

	}

	return ret;

}

void Pre()

{

	s[0]=1;

	for(int i=1;i<=n;i++)

		s[i]=s[i-1]*i%MO;

	inv[0]=1;

	inv[n]=PowMod(s[n],MO-2);

	for(int i=n-1;i>0;i--)

		inv[i]=inv[i+1]*(i+1)%MO;

}

LL C(int a,int b)

{

	if(a<0||b<0) return 1;

	return s[a]*inv[b]%MO*inv[a-b]%MO;

}

int main()

{

	int h,w,A,B;

	scanf("%d%d%d%d",&h,&w,&A,&B);

	n=h+w-2;

	Pre();

	LL ans=C(h+w-2,h-1);

	for(int i=1;i<=B;i++)

	{

		ans-=C(h-A+i-2,h-A-1)*C(A-1+w-i,A-1)%MO;

		ans=(ans%MO+MO)%MO;

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

#define MOD 1000000007

#define MAXN 200006

using namespace std;

long long fac[MAXN],inv[MAXN],ans;

int n,m,a,b;

long long ksm(long long a,long long m)

{

	if(m==0) return 1;

	long long nex=ksm(a,m/2);

	nex=(nex*nex)%MOD;

	if(m%2==0) return nex;

	else return (nex*a)%MOD;

}

void waiting()

{

	fac[0]=1;

	for(long long i=1;i<MAXN;i++)

		fac[i]=(fac[i-1]*i)%MOD;

	inv[MAXN-1]=ksm(fac[MAXN-1],MOD-2);

	for(long long i=MAXN-2;i>=0;i--)

		inv[i]=(inv[i+1]*(i+1))%MOD;

}

long long C(int n,int m)

{

	return (((fac[m]*inv[n])%MOD)*inv[m-n])%MOD;

}

int main()

{

	waiting();

	scanf("%d%d%d%d",&n,&m,&a,&b);

	for(int i=1;i<=n-a;i++)

	{

		long long p1=C(b-1,b+i-2);

		long long p2=C(m-b-1,m-b+n-i-1);

		long long p=(p1*p2)%MOD;

		ans=(ans+p)%MOD;

	}

	printf("%lld",ans);

}

// Faster C++ solution for the same problem (measured speedup: 17.802656975582142x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MO 1000000007

#define MAXN 200005

#define LL long long

LL inv[MAXN],s[MAXN];

int n;

LL PowMod(LL a,int b)

{

	LL ret=1;

	while(b)

	{

		if(b&1) ret=ret*a%MO;

		a=a*a%MO;

		b>>=1;

	}

	return ret;

}

void Pre()

{

	s[0]=1;

	for(int i=1;i<=n;i++)

		s[i]=s[i-1]*i%MO;

	inv[0]=1;

	inv[n]=PowMod(s[n],MO-2);

	for(int i=n-1;i>0;i--)

		inv[i]=inv[i+1]*(i+1)%MO;

}

LL C(int a,int b)

{

	if(a<0||b<0) return 1;

	return s[a]*inv[b]%MO*inv[a-b]%MO;

}

int main()

{

	int h,w,A,B;

	scanf("%d%d%d%d",&h,&w,&A,&B);

	n=h+w-2;

	Pre();

	LL ans=C(h+w-2,h-1);

	for(int i=1;i<=B;i++)

	{

		ans-=C(h-A+i-2,h-A-1)*C(A-1+w-i,A-1)%MO;

		ans=(ans%MO+MO)%MO;

	}

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <climits>

#include <cstring>

#include <string>

#include <set>

#include <bitset>

#include <map>

#include <queue>

#include <stack>

#include <vector>

#define rep(i,m,n) for(i=m;i<=n;i++)

#define mod 1000000007

#define inf 0x3f3f3f3f

#define vi vector<int>

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define ll long long

#define pi acos(-1.0)

#define pii pair<int,int>

#define sys system("pause")

const int maxn=2e5+10;

const int N=1e3+10;

using namespace std;

ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}

ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}

int n,m,k,t,h,w,a,b;

ll fac[maxn],inv[maxn];

void init()

{

    fac[0]=1;

    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;

    inv[maxn-10]=qpow(fac[maxn-10],mod-2);

    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

}

ll C(int x,int y)

{

    return fac[x]*inv[y]%mod*inv[x-y]%mod;

}

int main()

{

    int i,j;

    init();

    scanf("%d%d%d%d",&h,&w,&a,&b);

    ll ret=C(h+w-2,h-1);

    for(i=0;i<=b-1;i++)ret=(ret-C(i+h-a-1,h-a-1)*C(w-i+a-2,a-1)%mod+mod)%mod;

    printf("%lld\n",ret);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 21.96919366628198x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MOD 1000000007

#define MAXN 200005

#define LL long long

LL inv[MAXN],s[MAXN];

int N;

int H,W,A,B;

LL Pow(LL a,int b) 

{

    LL ans=1;

    while(b) 

	{

        if(b&1) ans=ans*a%MOD;

        a=a*a%MOD;

        b>>=1;

    }

    return ans;

}

void Pre() 

{

    s[0]=1;

    for(int i=1; i<=N; i++)

        s[i]=s[i-1]*i%MOD;

    inv[0]=1;

    inv[N]=Pow(s[N],MOD-2);

    for(int i=N-1; i>0; i--)

        inv[i]=inv[i+1]*(i+1)%MOD;

}

LL C(int a,int b) 

{

    if(a<0||b<0) return 1;

    return s[a]*inv[b]%MOD*inv[a-b]%MOD;

}

int main() 

{

    scanf("%d %d %d %d",&H,&W,&A,&B);

	N=H+W-2;

	Pre();

	LL ans=C(H+W-2,H-1);

	for(int i=1;i<=B;i++)

	{

		ans-=C(H-A+i-2,H-A-1)*C(A-1+W-i,A-1)%MOD;

		ans=(ans%MOD+MOD)%MOD;

	}

    printf("%lld\n",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>

#include <cstdio>

#include <cstring>

typedef long long ll;

#define rep(i,s,t) for (ll i = s ; i < t ; ++ i)

#define mod 1000000007

#define maxn 200005



using namespace std;



ll fac[maxn],inv[maxn];



int f(ll a,ll b)

{

    ll ans = 1;

    while (b)

    {

        if (b%2)

           ans = ans * a % mod;

        a = a * a % mod;

        b /= 2;

    }

    return ans;

}



void init()

{

    fac[0] = 1;

    rep(i,1,maxn)

       fac[i] = fac[i-1] * i % mod;

    inv[maxn-1] = f(fac[maxn-1],mod-2);

    for (ll i = maxn-2 ; i >=0 ; -- i)

        inv[i] = inv[i+1] * (i+1) % mod;

}

int main()

{

    init();

    int h,w,a,b;

    cin>> h >> w >> a >> b;

    ll ans = 0;

    for (int i = b + 1 ; i <= w ; i++)

    {

        int sum = h - a + i - 2 ;

        ll cmp1 = fac[sum] * inv[i - 1] % mod;

        cmp1 = cmp1 * inv[h-a-1] % mod;



        sum = a + w - i - 1;

        ll cmp2 = fac[sum] * inv[a - 1] % mod;

        cmp2 = cmp2 * inv[w-i] % mod;



        cmp1 = cmp1 * cmp2 % mod;

        ans = (ans + cmp1) % mod;

    }

    cout<< ans <<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 22.041097968955853x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MOD 1000000007

#define MAXN 200005

#define LL long long

LL inv[MAXN],s[MAXN];

int N;

int H,W,A,B;

LL Pow(LL a,int b) 

{

    LL ans=1;

    while(b) 

	{

        if(b&1) ans=ans*a%MOD;

        a=a*a%MOD;

        b>>=1;

    }

    return ans;

}

void Pre() 

{

    s[0]=1;

    for(int i=1; i<=N; i++)

        s[i]=s[i-1]*i%MOD;

    inv[0]=1;

    inv[N]=Pow(s[N],MOD-2);

    for(int i=N-1; i>0; i--)

        inv[i]=inv[i+1]*(i+1)%MOD;

}

LL C(int a,int b) 

{

    if(a<0||b<0) return 1;

    return s[a]*inv[b]%MOD*inv[a-b]%MOD;

}

int main() 

{

    scanf("%d %d %d %d",&H,&W,&A,&B);

	N=H+W-2;

	Pre();

	LL ans=C(H+W-2,H-1);

	for(int i=1;i<=B;i++)

	{

		ans-=C(H-A+i-2,H-A-1)*C(A-1+W-i,A-1)%MOD;

		ans=(ans%MOD+MOD)%MOD;

	}

    printf("%lld\n",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <cstdio>

#include <algorithm>

#include <cmath>

using namespace std;

#define ll long long

#define maxn 210000

#define mod 1000000007

const int m=1e9+7;

ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}

ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}

int n,k,t,h,w,a,b;

ll fac[maxn],inv[maxn];

void init()

{

    fac[0]=1;

    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;

    inv[maxn-10]=qpow(fac[maxn-10],mod-2);

    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

}

ll C(int x,int y)

{

    return fac[x]*inv[y]%mod*inv[x-y]%mod;

}

int main()

{

    //freopen("de.txt","r",stdin);

    init();

    while (~scanf("%d%d%d%d",&h,&w,&a,&b)){

        ll ans=C(h+w-2,h-1);

        for (int i=0;i<b;++i){

            ll temp1=C(i+h-1-a,i);

            ll temp2=C(w-i+a-2,a-1);

            ll temp3=(temp1*temp2)%mod;

            ans=(ans-temp3+mod)%mod;

        }

        printf("%I64d\n",ans);

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 22.857790435227916x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MOD 1000000007

#define MAXN 200005

#define LL long long

LL inv[MAXN],s[MAXN];

int N;

int H,W,A,B;

LL Pow(LL a,int b) 

{

    LL ans=1;

    while(b) 

	{

        if(b&1) ans=ans*a%MOD;

        a=a*a%MOD;

        b>>=1;

    }

    return ans;

}

void Pre() 

{

    s[0]=1;

    for(int i=1; i<=N; i++)

        s[i]=s[i-1]*i%MOD;

    inv[0]=1;

    inv[N]=Pow(s[N],MOD-2);

    for(int i=N-1; i>0; i--)

        inv[i]=inv[i+1]*(i+1)%MOD;

}

LL C(int a,int b) 

{

    if(a<0||b<0) return 1;

    return s[a]*inv[b]%MOD*inv[a-b]%MOD;

}

int main() 

{

    scanf("%d %d %d %d",&H,&W,&A,&B);

	N=H+W-2;

	Pre();

	LL ans=C(H+W-2,H-1);

	for(int i=1;i<=B;i++)

	{

		ans-=C(H-A+i-2,H-A-1)*C(A-1+W-i,A-1)%MOD;

		ans=(ans%MOD+MOD)%MOD;

	}

    printf("%lld\n",ans);

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

#define MOD 1000000007

#define MAXN 200006

using namespace std;

long long fac[MAXN],inv[MAXN],ans;

int n,m,a,b;

long long ksm(long long a,long long m)

{

	if(m==0) return 1;

	long long nex=ksm(a,m/2);

	nex=(nex*nex)%MOD;

	if(m%2==0) return nex;

	else return (nex*a)%MOD;

}

void waiting()

{

	fac[0]=1;

	for(long long i=1;i<MAXN;i++)

		fac[i]=(fac[i-1]*i)%MOD;

	inv[MAXN-1]=ksm(fac[MAXN-1],MOD-2);

	for(long long i=MAXN-2;i>=0;i--)

		inv[i]=(inv[i+1]*(i+1))%MOD;

}

long long C(int n,int m)

{

	return (((fac[m]*inv[n])%MOD)*inv[m-n])%MOD;

}

int main()

{

	waiting();

	scanf("%d%d%d%d",&n,&m,&a,&b);

	for(int i=1;i<=n-a;i++)

	{

		long long p1=C(b-1,b+i-2);

		long long p2=C(m-b-1,m-b+n-i-1);

		long long p=(p1*p2)%MOD;

		ans=(ans+p)%MOD;

	}

	printf("%lld",ans);

}

// Faster C++ solution for the same problem (measured speedup: 17.803436186463305x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MOD 1000000007

#define MAXN 200005

#define LL long long

LL inv[MAXN],s[MAXN];

int N;

int H,W,A,B;

LL Pow(LL a,int b) 

{

    LL ans=1;

    while(b) 

	{

        if(b&1) ans=ans*a%MOD;

        a=a*a%MOD;

        b>>=1;

    }

    return ans;

}

void Pre() 

{

    s[0]=1;

    for(int i=1; i<=N; i++)

        s[i]=s[i-1]*i%MOD;

    inv[0]=1;

    inv[N]=Pow(s[N],MOD-2);

    for(int i=N-1; i>0; i--)

        inv[i]=inv[i+1]*(i+1)%MOD;

}

LL C(int a,int b) 

{

    if(a<0||b<0) return 1;

    return s[a]*inv[b]%MOD*inv[a-b]%MOD;

}

int main() 

{

    scanf("%d %d %d %d",&H,&W,&A,&B);

	N=H+W-2;

	Pre();

	LL ans=C(H+W-2,H-1);

	for(int i=1;i<=B;i++)

	{

		ans-=C(H-A+i-2,H-A-1)*C(A-1+W-i,A-1)%MOD;

		ans=(ans%MOD+MOD)%MOD;

	}

    printf("%lld\n",ans);

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <climits>

#include <cstring>

#include <string>

#include <set>

#include <bitset>

#include <map>

#include <queue>

#include <stack>

#include <vector>

#define rep(i,m,n) for(i=m;i<=n;i++)

#define mod 1000000007

#define inf 0x3f3f3f3f

#define vi vector<int>

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define ll long long

#define pi acos(-1.0)

#define pii pair<int,int>

#define sys system("pause")

const int maxn=2e5+10;

const int N=1e3+10;

using namespace std;

ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}

ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}

int n,m,k,t,h,w,a,b;

ll fac[maxn],inv[maxn];

void init()

{

    fac[0]=1;

    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;

    inv[maxn-10]=qpow(fac[maxn-10],mod-2);

    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

}

ll C(int x,int y)

{

    return fac[x]*inv[y]%mod*inv[x-y]%mod;

}

int main()

{

    int i,j;

    init();

    scanf("%d%d%d%d",&h,&w,&a,&b);

    ll ret=C(h+w-2,h-1);

    for(i=0;i<=b-1;i++)ret=(ret-C(i+h-a-1,h-a-1)*C(w-i+a-2,a-1)%mod+mod)%mod;

    printf("%lld\n",ret);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.332011900590633x):
#include <cstdio>

#include <iostream>

#include <cstring>

using namespace std;

#define LL long long



int h,w,a,b;

int mo = 1e9 + 7;



LL dp[1005][1005];

LL Line[100005];

LL F[200005];



LL expo( LL a , LL b ){

	if ( b == 0 ) return 1;

	if ( b == 1 ) return a;

	LL half = expo(a,b/2);

	half = (1LL * half * half ) % mo;

	if (b & 1 ) half = ( 1LL * half * a ) % mo;

	return half;

}



LL C( int n, int k ){

	LL ans = F[n];

	LL d1 = expo(F[n-k],mo-2), d2 = expo(F[k],mo-2);

	ans = ( 1LL * ans * d1 ) % mo;

	ans = ( 1LL * ans * d2 ) % mo;

	return ans; 

}



int main(){



	F[0] = 1;

	for ( int i = 1; i <= 200000; i++ ){

		F[i] = ( 1LL * F[i-1] * i ) % mo;

	}



	scanf("%d%d%d%d",&h,&w,&a,&b);

	// dp[1][0] = 1;

	// for ( int i = 1; i <= h; i++ ){

	// 	for ( int j = 1; j <= w; j++ ){

	// 		if ( j <= b && i >= h-a+1 ) continue;

	// 		dp[i][j] = dp[i-1][j] + dp[i][j-1];

	// 		cout << dp[i][j] << " ";

	// 	}

	// 	cout << endl;

	// }

	

	for ( int i = b+1; i <= w ; i++ ){

		Line[i] = C((h-a) + (i) - 2, i - 1);

	}

	LL sum = 0;

	for ( int i = b+1; i <= w; i++ ){

		// cout << i-b << " " << C(a-2 + i - b , i - b - 1) << endl;

		sum = ( sum + ( ( 1LL * C(a-2 + i - b, i - b - 1) * Line[w - ( i - b ) + 1] ) % mo ) ) % mo;

	}

	printf("%lld\n",sum);

	return 0;

}