Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if a>b :
        while b!=0:
            a,b = b,a%b
        return a
    elif a==b:
        return a
    else :
        while a!=0:
            a,b = b%a,a
        return b

def lcm(n,A):
    gcdn = [0]*n
    lcmn = [0]*n

    gcdn[0]=A[0]
    lcmn[0]=A[0]
    for i in range(n-1):
        gcdn[i+1] = gcd(lcmn[i],A[i+1])
        M = lcmn[i]*A[i+1]
        lcmn[i+1] =int(M/gcdn[i+1])
    return lcmn[n-1]


def examC():
    N = I()
    T = [I() for _ in range(N)]
    ans = lcm(N,T)
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x * y // gcd(x, y)


def examC():
    N = I()
    T = [I() for _ in range(N)]
    ans = 1
    for t in T:
        ans = lcm(ans, t)
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()
Buggy python submission (verdict: Runtime Error):
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

H, W =LI()
N = I()
a = LI()
c = [[0]*W for i in range(H)]
k = int(0)
cur = int(0)
kin = int(0)
for i,anum in enumerate(a):
#    print(k,cur)
    for j in range(anum):
        if (k+j)==W:
            cur +=1
            k = j-1
        if (W-j+k)==-1:
            cur +=1
            k = -j
        if cur%2==0:
            c[cur][k+j] = i+1
        else:
            c[cur][W-j+k] = i+1

    if cur % 2 == 0:
        k = k+j+1
    else:
        k =  - j + k-1

for v in c:
    print(" ".join(map(str,v)))



Fixed submission:
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

H, W =LI()
N = I()
a = LI()
c = [[0]*W for i in range(H)]
k = int(0)
cur = int(0)
kin = int(0)
for i,anum in enumerate(a):
#    print(k,cur)
    for j in range(anum):
#        print(k,j)
        if cur%2==0 and (k+j)==W:
            cur +=1
            k = j-1
        if cur%2==1 and (W-j+k)==-1:
            cur +=1
            k = -j
        if cur%2==0:
            c[cur][k+j] = i+1
        else:
            c[cur][W-j+k] = i+1

    if cur % 2 == 0:
        k = k+j+1
    else:
        k = -j+k-1

for v in c:
    print(" ".join(map(str,v)))
Buggy python submission (verdict: Time Limit Exceeded):
def examB():
    N = I()
    ansC = [(i+1) for i in range(N)]
    k = 0
    while(True):
        cur = []
        for i in ansC:
            if i % 2 == 0:
                cur.append(i // 2)
        ansC = cur
        k +=1
        if len(ansC)==1:
            break
    ans = 2**k
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Fixed submission:
def examB():
    N = I()
    ansC = [(i+1) for i in range(N)]
    k = 0
    while(len(ansC)>=2):
        cur = []
        for i in ansC:
            if i % 2 == 0:
                cur.append(i // 2)
        ansC = cur
        k +=1
        if len(ansC)==1:
            break
    ans = 2**k
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()
Buggy python submission (verdict: Runtime Error):
def examC():
    N = I()
    A = LI()
    sumA = [0]*N
    sumA[0] = A[0]
    for i in range(N-1):
        sumA[i+1] = sumA[i]+A[i+1]
    cur = bisect.bisect_left(sumA,sumA[N-1]//2)
    ans = abs(min(sumA[N-1] -sumA[cur]*2,sumA[cur+1]*2-sumA[N-1]))
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Fixed submission:
def examC(inf):
    N = I()
    A = LI()
    sumA = [0]*N
    sumA[0] = A[0]
    cur = inf
    for i in range(N-1):
        sumA[i+1] = sumA[i]+A[i+1]
    for i in range(N-1):
        if cur>abs(sumA[N-1]-sumA[i]*2):
            cur = abs(sumA[N-1]-sumA[i]*2)
    ans = cur
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC(inf)
Buggy python submission (verdict: Runtime Error):
def find(A,x) -> int:
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a

def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx
    
    def examD():
    N = I()
    x = [[] for _ in range(N)]; y = [[] for _ in range(N)]
    for i in range(N):
        a, b = LI()
        x[i] = (a-1,i)
        y[i] = (b-1,i)
    v = [ i for i in range(N)]
    x.sort(); y.sort()
    H = []
    heapify(H)
    for i in range(N - 1):
        x1, j1 = x[i]
        x2, j2 = x[i + 1]
        y1, k1 = y[i]
        y2, k2 = y[i + 1]
        heappush(H, (x2 - x1, j1, j2))
        heappush(H, (y2 - y1, k1, k2))
    ans = 0
#    print(H)
#    print(v)
    while H:
        w, s, t = heappop(H)
        if find(v, s) != find(v, t):
            union(v, s, t)
            ans += w
    print(ans)

import sys
import copy
import bisect
from heapq import *
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Fixed submission:
def examA():
    X, A, B = LI()
    if (B-A)<=0:
        ans = "delicious"
    elif (B-A)<=X:
        ans = "safe"
    else:
        ans = "dangerous"
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()
Buggy python submission (verdict: Runtime Error):
def bfs(n,e,fordfs):
    #点の数、スタートの点、有向グラフ
    W = [-1]*n
    #各点の状態量、最短距離とか,見たかどうかとか
    W[e] = 0
    que = deque()
    que.append(e)
    len = [float("inf")]*n
    len[e] = 0
    while que:
        now = que.popleft()
        nowv = W[now]
        nowlen = len[now]
        for ne in fordfs[now]:
            if nowv == W[ne]:
                #ループが嫌な時
                return -1
            elif W[ne] == -1:
                W[ne] = (nowv+1) % 2
                len[ne] = nowlen+1
                que.append(ne)
    return len


def examB():
    N = I()
    v = [[]for _ in range(N)]
    for i in range(N):
        a = I()
        v[i].append(a-1)
    v[1]=[]
    b = bfs(N,0,v)
    ans = b[1]
    if ans==float("inf"):
        ans = -1
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Fixed submission:
def bfs(n,e,fordfs):
    #点の数、スタートの点、有向グラフ
    W = [-1]*n
    #各点の状態量、最短距離とか,見たかどうかとか
    W[e] = 0
    que = deque()
    que.append(e)
    len = [float("inf")]*n
    len[e] = 0
    while que:
        now = que.popleft()
        nowv = W[now]
        nowlen = len[now]
        for ne in fordfs[now]:
            if nowv == W[ne]:
                #ループが嫌な時
                return -1
            elif W[ne] == -1:
                W[ne] = (nowv+1) % 2
                len[ne] = nowlen+1
                que.append(ne)
    return len


def examB():
    N = I()
    v = [[]for _ in range(N)]
    for i in range(N):
        a = I()
        v[i].append(a-1)
    v[1]=[]
    b = bfs(N,0,v)
    if b==-1:
        ans = -1
    else:
        ans = b[1]
    if ans==float("inf"):
        ans = -1
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()
Buggy python submission (verdict: Runtime Error):
def examC():
    N = I()
    S = [I() for _ in range(N)]
    S1 = []
    for s in S:
        if s%10==0:
            continue
        S1.append(s)
    S1.sort()
    ans = sum(S)
    if ans%10==0:
        ans -= S1[0]
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Fixed submission:
def examC():
    N = I()
    S = [I() for _ in range(N)]
    S1 = []
    for s in S:
        if s%10==0:
            continue
        S1.append(s)
    if S1==[]:
        print(0)
        return
    S1.sort()
    ans = sum(S)
    if ans%10==0:
        ans -= S1[0]
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""
Buggy python submission (verdict: Time Limit Exceeded):

def examD():
    N, W = LI()
    w = [0]*N
    v = [0]*N
    w[0], v[0] = LI()
    wbasic = w[0]
    for i in range(1,N):
        a, b = LI()
        w[i] = a-wbasic
        v[i] = b
    w[0] = 0
    dp =[[[0]*(3*N+1) for _ in range(N+1)]for _ in range(N+1)]
    for i in range(N):
        for j in range(N+1):
            for k in range(3*N+1):
                dp[i+1][j][k] = max(dp[i][j][k], dp[i+1][j][k])
                if w[i]<=k and j>=1:
                    if j*wbasic+k<=W:
                        dp[i+1][j][k] = max(dp[i][j-1][k-w[i]]+v[i], dp[i+1][j][k])
    ans = 0
    for v in dp[N]:
        ans = max(ans,max(v))
#        print(v)
    print(ans)


import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Fixed submission:

def examD():
    N, W = LI()
    w = [0]*N
    v = [0]*N
    w[0], v[0] = LI()
    wbasic = w[0]
    for i in range(1,N):
        a, b = LI()
        w[i] = a-wbasic
        v[i] = b
    w[0] = 0
    dp =[[[0]*(3*N+1) for _ in range(N+1)]for _ in range(N+1)]
    for i in range(N):
        for j in range(N+1):
            for k in range(3*N+1):
                dp[i+1][j][k] = max(dp[i][j][k], dp[i+1][j][k])
                if w[i]<=k and j>=1:
                    if j*wbasic+k<=W:
                        dp[i+1][j][k] = max(dp[i][j-1][k-w[i]]+v[i], dp[i+1][j][k])
    ans = 0
    for v in dp[N]:
        ans = max(ans,max(v))
#        print(v)
    print(ans)


import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()
Buggy python submission (verdict: Runtime Error):
def examD():
    N, M = LI()
    D = [[float("inf") for i in range(N)] for i in range(N)]
    # d[u][v] : 辺uvのコスト(存在しないときはinf)
    XY = [[0,0]]*M
    for i in range(M):
        x, y, z = map(int, input().split())
        XY[i] = [x-1,y-1]
        D[x - 1][y - 1] = z
        D[y - 1][x - 1] = z
    for i in range(N):
        D[i][i] = 0  # 自身のところに行くコストは０
    d = copy.deepcopy(D)
#    print(warshall_floyd(N, d))
    W = warshall_floyd(N, d)
    cur = int(0)
    for i in range(M):
        if D[XY[i][0]][XY[i][1]]>W[XY[i][0]][XY[i][1]]:
            cur += 1
    print(cur)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Fixed submission:
def warshall_floyd(n,d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

def examD():
    N, M = LI()
    D = [[float("inf") for i in range(N)] for i in range(N)]
    # d[u][v] : 辺uvのコスト(存在しないときはinf)
    XY = [[0,0]]*M
    for i in range(M):
        x, y, z = map(int, input().split())
        XY[i] = [x-1,y-1]
        D[x - 1][y - 1] = z
        D[y - 1][x - 1] = z
    for i in range(N):
        D[i][i] = 0  # 自身のところに行くコストは０
    d = copy.deepcopy(D)
#    print(warshall_floyd(N, d))
    W = warshall_floyd(N, d)
    cur = int(0)
    for i in range(M):
        if D[XY[i][0]][XY[i][1]]>W[XY[i][0]][XY[i][1]]:
            cur += 1
    print(cur)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()
Buggy python submission (verdict: Time Limit Exceeded):
def examC(mod):
    N = I()
    A = LI()
    num = (N+1)%2
    loop = (N+1)//2
    cur = int(1)
    if num==0:
        A.append(0)
        cur = cur/2
    for i in range(loop):
        if A.count(i*2+num)!=2:
            cur = int(0)
            break
        cur = int(cur*2)%mod
    print(cur)




import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC(mod)


Fixed submission:
def examC(mod):
    N = I()
    A = LI()
    num = (N+1)%2
    loop = (N+1)//2
    cur = int(1)
    L = [0]*loop
    if num==0:
        L[0] +=1
    for i in range(N):
        L[A[i]//2] += 1
        if L[A[i]//2]>=3:
            cur = int(0)
            break
    for _ in range(N//2):
        cur = (cur*2)%mod
    print(cur)





import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC(mod)

Buggy python submission (verdict: Time Limit Exceeded):
def examC(mod):
    N = I()
    A = LI()
    num = (N+1)%2
    loop = (N+1)//2
    cur = int(1)
    if num==0:
        A.append(0)
        cur = cur/2
    for i in range(loop):
        if A.count(i*2+num)!=2:
            cur = int(0)
            break
        cur = int(cur*2)%mod
    print(cur)




import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC(mod)


Fixed submission:
def examC(mod):
    N = I()
    A = LI()
    num = (N+1)%2
    loop = (N+1)//2
    cur = int(1)
    L = [0]*loop
    if num==0:
        L[0] +=1
    for i in range(N):
        L[A[i]//2] += 1
        if L[A[i]//2]>=3:
            cur = int(0)
            break
    for _ in range(N//2):
        cur = (cur*2)%mod
    print(cur)





import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC(mod)
Buggy python submission (verdict: Time Limit Exceeded):
def examD():
    H, W, N = LI()
    ab = set()
    for _ in range(N):
        a, b = list(map(int,input().split()))
        ab.add((a-1,b-1))
    check = set()
    for c in ab:
        for i in range(-1,2):
            for j in range(-1,2):
                if 1<=c[0]+i<H-1 and 1<=c[1]+j<W-1:
                    check.add((c[0]+i,c[1]+j))
#    print(check)
#    print(ab)
    ansC = [0]*10
    for c in check:
        cur = int(0)
        for i in range(-1,2):
            for j in range(-1,2):
                if (c[0]+i,c[1]+j) in ab:
                    cur += 1
        ansC[cur] +=1
    ansC[0] = (H-2)*(W-2)-sum(ansC)
    for v in ansC:
        print(v)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Fixed submission:
def examD():
    H, W, N = LI()
    ab = set()
    for _ in range(N):
        a, b = list(map(int,input().split()))
        ab.add((a-1,b-1))
    check = set()
    for c in ab:
        for i in range(-1,2):
            for j in range(-1,2):
                if 1<=c[0]+i<H-1 and 1<=c[1]+j<W-1:
                    check.add((c[0]+i,c[1]+j))
#    print(check)
#    print(ab)
    ansC = [0]*10
    for c in check:
        cur = int(0)
        for i in range(-1,2):
            for j in range(-1,2):
                if (c[0]+i,c[1]+j) in ab:
                    cur += 1
        ansC[cur] +=1
    ansC[0] = (H-2)*(W-2)-sum(ansC)
    for v in ansC:
        print(v)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()
Buggy python submission (verdict: Runtime Error):
def examC():
    N = I()
    a = LI()
    lower = min(a)
    L = (max(a)-min(a))
    cur = [0]*L
    for i in range(L):
        for j in range(N):
            cur[i] +=(a[j]-(i+lower))**2
    ans = min(cur)
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Fixed submission:
def examC():
    N = I()
    a = LI()
    lower = min(a)
    L = (max(a)-min(a))
    cur = [0]*L
    for i in range(L):
        for j in range(N):
            cur[i] +=(a[j]-(i+lower))**2
    if cur:
        ans = min(cur)
    else:ans = 0
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()
Buggy python submission (verdict: Time Limit Exceeded):
def examD():
    from operator import mul
    from functools import reduce
    def comb2(n, r):
        r = min(n - r, r)
        if r == 0: return 1
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1, r + 1))
        return over // under

    H, W, A, B =LI()
    k = W-B
    ans = int(0)
    C1 = [0]*k; C2 = [0]*k
    for i in range(k):
        C1[i] = comb2(H-A+B+i-1,H-A-1)%mod
        C2[i] = comb2(A+W-(B+i)-2,A-1)%mod
        ans = (ans+C1[i]*C2[i])%mod
    print(ans)
#    print(C1)
#    print(C2)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

examD()


Fixed submission:
def examD(mod):
    class combination():
        def __init__(self, n, mod):
            self.n = n
            self.fac = [1] * (n + 1)
            self.inv = [1] * (n + 1)
            for j in range(1, n + 1):
                self.fac[j] = self.fac[j - 1] * j % mod

            self.inv[n] = pow(self.fac[n], mod - 2, mod)
            for j in range(n - 1, -1, -1):
                self.inv[j] = self.inv[j + 1] * (j + 1) % mod

        def comb(self, n, r, mod):
            if r > n or n < 0 or r < 0:
                return 0
            return self.fac[n] * self.inv[n - r] * self.inv[r] % mod

    H, W, A, B =LI()
    N = H + W
    C = combination(N,mod)
    ans = C.comb(W+H-B-2, H-1,mod)
    pre = 1
    for i in range(1, H-A):
        ans += (C.comb(B+i,i,mod)-pre)*C.comb(W+H-B-2-i, H-1-i,mod)%mod
        ans %= mod
        pre = C.comb(B+i, i,mod)
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD(mod)