Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import numpy as np

n=int(input())
l=np.array(list(map(int, input().split())))
l.sort()
counter=0
for i in range(2, n):
  for j in range(1, i):
    counter+=j-np.sum(l[:j]<=(l[i]-l[j]))
                      
print(counter)

### FIXED CODE ###

def f(list, n):
  length=len(list)
  if list[-1]<n:
    return length
  elif list[0]>=n:
    return 0
  else:
    a=length//2
    b=length//4
    while b>=1:
      if list[a]<n:
        a+=b
      else:
        a-=b
      b=b//2
      
    if list[a]<n:
      while list[a+1]<n:
        a+=1
    else:
      while list[a]>=n:
        a-=1
        
    return a+1  

n=int(input())
l=list(map(int, input().split()))
l.sort()
counter=0
for i in range(n-2):
  for j in range(i+1, n-1):
    counter+=f(l[(j+1):], l[i]+l[j]) #f(list, n) counts num in the sorted list under n
    
print(counter)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

K = min(K, 50)
for _ in range(K):
    B = [0 for _ in range(N)]
    for i in range(N):
        l = max(0, i - A[i])
        r = min(N - 1, i + A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    
    for i in range(1, N):
        B[i] += B[i-1]
    
    A = B.copy()

print(" ".join(map(str, A)))

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(K):
    B = [0] * N
    for i, d in enumerate(A):
        l = max(0, i-d)
        r = min(N-1, i+d)
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    
    for i in range(1, N):
        B[i] += B[i-1]
    
    A = B.copy()
    if min(A) == N:
        break

print(" ".join(map(str, A)))
### BUGGY CODE ###

n=int(input())
a=list(map(float, input().split()))
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(n):
        if dp[i][j]==0:continue
        dp[i+1][j+1]+=dp[i][j]*a[i]
        dp[i+1][j]+=dp[i][j]*(1-a[i])
print(sum(dp[-1][n//2+1:]))

### FIXED CODE ###

n=int(input())
a=list(map(float, input().split()))
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(n):
        if dp[i][j]==0:continue
        dp[i+1][j+1]+=dp[i][j]*a[i]
        dp[i+1][j]+=dp[i][j]*(1-a[i])
print(sum(dp[-1][n//2+1:]))
### BUGGY CODE ###

n,a,b=map(int,input().split())

def modpow(a,m,n):
    b=bin(n)
    bi=[]
    for i in range(len(b)-2):
        c=str(b)[len(b)-1-i]
        c=int(c)
        bi.append(c)
    pre_pow=[a%m]
    num=a
    for j in range(len(b)-1):
        num*=num
        num=num%m
        pre_pow.append(num)
    ans=1
    for k in range(len(b)-2):
        if bi[k]!=0:
            ans*=pre_pow[k]
    return(ans%m)

cmba=1
cmbb=1
p=(10**9)+7
lst=[]
num=modpow(2,p,n)-1
for i in range(1,b+1):
  cmbb*=((n-i+1)%p)*(modpow(i,p,p-2)%p)%p
  cmba=cmbb
  if i==a:
    lst.append(cmba)
    
num=num-lst[0]-cmbb
num=num%p

print(num)

### FIXED CODE ###

n,a,b=map(int,input().split())

cmba=1
cmbb=1
p=(10**9)+7
lst=[]
num=pow(2,n,p)-1
for i in range(1,b+1):
  cmbb*=((n-i+1)*(pow(i,p-2,p)))%p
  if cmbb>p:
    cmbb=cmbb%p
  cmba=cmbb
  if i==a:
    lst.append(cmba)
    
num=num-lst[0]-cmbb
num=num%p

print(num)
### BUGGY CODE ###

[n,m] = [int(i) for i in input().split()]
a=[]
for i in range(1,m//n+1):
    if m % i == 0 and i <= m//n:
        a.append(i)

print(a[len(a)-1])


### FIXED CODE ###

[n,m] = [int(i) for i in input().split()]
if n == 1:
    print(m)
else:
    ans = -1
    #a1は高々この値
    a1_max = m // n
    for i in range(a1_max,0,-1):
        if (m - i) % i == 0 and (m - i)//i >= (n-1):
            ans = max(ans,i)
    print(ans)
### BUGGY CODE ###

N, P = map(int, input().split())
S = input()
ans = 0
if P in [2, 5]:
    for l, s in enumerate(S, 1):
        if int(s) % P == 0: ans += l
else:
    counter = {}
    counter[0] = 1
    for i in range(N-1, -1, -1):
        num = int(S[i:]) % P
        ans += counter.setdefault(num, 0)
        counter[num] += 1
print(ans)

### FIXED CODE ###

N, P = map(int, input().split())
S = input()
ans = 0
if P in [2, 5]:
    for l, s in enumerate(S, 1):
        if int(s) % P == 0: ans += l
else:
    counter = [0] * P
    counter[0] = 1
    prev = 0
    temp = 1
    for i, s in reversed(list(enumerate(S))):
        num = (int(s) * temp + prev) % P
        ans += counter[num]
        counter[num] += 1
        prev = num
        temp = (temp * 10) % P
print(ans)
### BUGGY CODE ###

n = int(input())
d = list(map(int, input().split()))
d = sorted(d)

banken = 1
for item in d:
    if len(d[:banken]) == len(d[banken:]):
        break
    if banken >= len(d):
        break
    banken += 1

print(d[banken] - d[banken-1])


### FIXED CODE ###

n = int(input())
d = list(map(int, input().split()))
d = sorted(d)

banken = len(d) // 2
print(d[banken] - d[banken-1])
### BUGGY CODE ###

import numpy as np

mod = 998244353
n, s = map(int, input().split())
arr = list(map(int, input().split()))
dp = np.zeros((n + 1, s + 1))
dp[0, 0] = 1

for i in range(1, n + 1):
    var = arr[i - 1]
    for j in range(0, s + 1):
        dp[i, j] = 2 * dp[i - 1, j]
        dp[i, j] %= mod
        if j - var >= 0 and dp[i - 1, j - var] != 0:
            dp[i, j] += dp[i - 1, j - var]
            dp[i, j] %= mod
print(int(dp[n, s]))


### FIXED CODE ###

mod = 998244353
n, s = map(int, input().split())
arr = list(map(int, input().split()))
dp = [[0] * (s + 1) for _ in range(n + 1)]
dp[0][0] = 1

for i in range(1, n + 1):
    var = arr[i - 1]
    for j in range(0, s + 1):
        dp[i][j] = 2 * dp[i - 1][j]
        dp[i][j] %= mod
        if j - var >= 0 and dp[i - 1][j - var] != 0:
            dp[i][j] += dp[i - 1][j - var]
            dp[i][j] %= mod
print(int(dp[n][s]))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)

def main():
    n=int(input())
    s=input()
    pre=[set() for _ in range(26)]
    nx=[set() for _ in range(n)]
    oa=ord("a")
    for i in range(n-1,-1,-1):
        ci=ord(s[i])-oa
        nx[i]|=pre[ci]
        pre[ci].add(i)
    #print(pre)
    #print(nx)
    ans=0
    for i in range(n):
        for ii in nx[i]:
            for di in range(1,n):
                if (not ii+di in nx[i+di]) or (i+di==ii):
                    L=di
                    break
            ans=max(ans,L)
    print(ans)
main()

### FIXED CODE ###

# YouTube
def main():
    n = int(input())
    s = input()
    dp = [[0] * (n + 1) for _ in range(n + 1)]
    for i, c in enumerate(s):
        for j in range(n):
            if c == s[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
    ans = 0
    for i in range(n):
        for j in range(i+1,n+1):
            tmp=min(dp[i][j],j-i)
            ans=max(tmp,ans)
    print(ans)

main()
### BUGGY CODE ###

from collections import deque

n, x, y = [int(x) for x in input().split()]
x -= 1
y -= 1
BIG = 65521
ans = {i: 0 for i in range(n)}


def bfs(start_v):
    """ある始点からほかの全点に行くまでの最短距離を求める。"""
    qu = deque()
    qu_append = qu.append
    qu_popleft = qu.popleft
    qu_append(start_v)
    # 始点からvに移動するまでの最短距離: dist[v]
    dist = [BIG] * n

    def push(v, d):
        """始点からvまでの最短距離が算出されていないときに，その距離を保存し，
        キューに頂点vを追加する。"""
        if dist[v] != BIG:
            # 既に訪問済みで距離が求められている。
            return
        dist[v] = d
        qu_append(v)

    push(start_v, 0)

    while len(qu):
        v = qu_popleft()
        # 始点からvの次の頂点へ移動する距離。
        d = dist[v] + 1
        if v < n - 1:
            push(v + 1, d)
        if v > 0:
            push(v - 1, d)
        if v == x:
            push(y, d)
        if v == y:
            push(x, d)

    for i in range(n):
        if dist[i] != 0:
            ans[dist[i]] += 1


def main():
    for i in range(n):
        bfs(i)

    for i in range(1, n):
        print(ans[i] // 2)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque

n, x, y = [int(x) for x in input().split()]
x -= 1
y -= 1
BIG = 65521
ans = {i: 0 for i in range(n)}


def bfs(start_v):
    """ある始点からほかの全点に行くまでの最短距離を求める。"""
    qu = deque()
    qu_append = qu.append
    qu_popleft = qu.popleft
    qu_append(start_v)
    # 始点からvに移動するまでの最短距離: dist[v]
    dist = [BIG] * n

    def push(v, d):
        """始点からvまでの最短距離が算出されていないときに，その距離を保存し，
        キューに頂点vを追加する。"""
        if dist[v] != BIG:
            # 既に訪問済みで距離が求められている。
            return
        dist[v] = d
        qu_append(v)

    push(start_v, 0)

    while len(qu):
        v = qu_popleft()
        # 始点からvの次の頂点へ移動する距離。
        d = dist[v] + 1
        if v < n - 1:
            push(v + 1, d)
        if v > 0:
            push(v - 1, d)
        if v == x:
            push(y, d)
        if v == y:
            push(x, d)

    for i in range(n):
        if dist[i] != 0:
            ans[dist[i]] += 1


def main():
    for i in range(n):
        bfs(i)

    for i in range(1, n):
        print(ans[i] // 2)


if __name__ == '__main__':
    main()

# TLE
### BUGGY CODE ###

n,m=map(int,input().split())
money=[]
for _ in range(n):
    a,b=map(int,input().split())
    money=money+[a]*b
money.sort()
print(sum(money[:m]))

### FIXED CODE ###

n,m=map(int,input().split())
ab=sorted([list(map(int,input().split())) for _ in range(n)])
ans=0
i=0
while i<n:
    if m>=ab[i][1]:
        ans+=(ab[i][0])*ab[i][1]
        m-=ab[i][1]
        i+=1
    else:
        ans+=(ab[i][0])*(m)
        break
print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
ans = 1
for a in A:
    ans *= a
if ans > 1e18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
t = int('1'+'0'*18)
ans = 1
if min(A)==0:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > t:
            print(-1)
            exit()
    print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))

# 累積和
c = [0] * (n+1)
for i in range(n):
  c[i+1] = c[i] + p[i]
#print(c)
mx = 0
mx_a = []
for i in range(n-k+1):
  t = p[i:i+k]
  st = c[i+k] - c[i]
  if st > mx:
    mx = st
    mx_a = t
ans = 0
for i in range(k):
  a = mx_a[i]
  ans += ((a * (a+1)) // 2) / a
print(ans)
# print(mx_a)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))

# 累積和
c = [0] * (n+1)
for i in range(n):
  c[i+1] = c[i] + p[i]
#print(c)
mx = 0
mx_i = -1
for i in range(n-k+1):
  st = c[i+k] - c[i]
  if st > mx:
    mx = st
    mx_i = i
ans = 0
for i in range(mx_i, mx_i+k):
  a = p[i]
  ans += ((a * (a+1)) // 2) / a
print(ans)
# print(mx_a)
### BUGGY CODE ###

N,W = map(int,input().split())
L = list(list(map(int,input().split())) for i in range(N))

dp = [[0 for x in range(W+1)] for y in range(N+1)]

for i in range(N) :
    weight_i,value_i = L[i]
    for weight in range(W+1) :
        if weight-weight_i >= 0 :
            dp[i+1][weight] = max(dp[i][weight-weight_i]+value_i, dp[i][weight])
        else :
            dp[i+1][weight] = dp[i][weight]

ans = dp[N][W]
print(ans)


### FIXED CODE ###

N,W = map(int,input().split())
L = list(list(map(int,input().split())) for i in range(N))

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for item in range(N) :
    w_i,v_i = L[item]
    for weight in range(W+1) :
        if weight - w_i >= 0 :
            dp[item+1][weight] = max(dp[item][weight], dp[item][weight-w_i] + v_i)
        else :
            dp[item+1][weight] = dp[item][weight]

ans = dp[N][W]

print(ans)
### BUGGY CODE ###

def factorial(integer) : 
    product = 1
    if integer == 0 : return 1
    for num in range(1 , integer + 1):
        product *= num
    return product

def solve():
    (n,m) = map(int,input().split())
    if(abs(n-m)>1):
        return 0
    if(n==m):
        return (factorial(n) * factorial(m) * 2) % 1000000007
    return (factorial(n) * factorial(m)) % 1000000007

if(__name__ == "__main__"):
    print(solve())


### FIXED CODE ###

import math

mod = 1000000007

def solve():
    (n,m) = map(int,input().split())
    if(abs(n-m)>1):
        return 0
    if(n==m):
        return (math.factorial(n)**2 * 2) % mod
    if(n > m):
        return (math.factorial(m)**2 * n) % mod
    else:
        return (math.factorial(n)**2 * m) % mod

if(__name__ == "__main__"):
    print(solve())
### BUGGY CODE ###

N= int(input())
S=input()
r=[]
g=[]
b=[]
for i in range(N):
    if S[i]=="R":
        r.append(i)
    elif S[i]=="G":
        g.append(i)
    else:
        b.append(i)

t=0
for i in range(len(r)):
    for j in range(len(g)):
        p=abs(r[i]-g[j])
        for k in range(len(b)):

            if p!=abs(b[k]-g[j]) and abs(r[i]-b[k])!=abs(b[k]-g[j]) and p!=abs(b[k]-r[i]):
                t=t+1

print(t)

### FIXED CODE ###

N= int(input())
S=input()
r=[]
g=[]
b=[]
A=0
B=0
C=0
for i in range(N):
    if S[i]=="R":
        r.append(i)
        A+=1
    elif S[i]=="G":
        g.append(i)
        B+=1
    else:
        b.append(i)
        C+=1
k=0
for i in range(N-2):
    for j in range(i+1,N-1):
        t=2*j-i
        if t<N:
            if S[i]!=S[j] and S[i]!=S[t] and S[t]!=S[j] :
                k+=1

print(A*B*C-k)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
a.append(0)
cost = [abs(x - y) for x ,y in zip(a[:-1], a[1:])]
for i in range(n):
    c = cost.copy()
    c.pop(i + 1)
    c.pop(i)
    c.append(abs(a[i] - a[i+2]))
    print(sum(c))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
c = [abs(x - y) for x, y in zip(a[:-1], a[1:])]
c_sum = sum(c)
for i in range(n):
    print(c_sum - c[i] - c[i + 1] + abs(a[i] - a[i + 2]))
### BUGGY CODE ###

N = int(input())
for i in range(N,10000000000):
    if i%2 == 0 and i%N == 0:
        print(i)
        break

### FIXED CODE ###

N = int(input())
 
if N % 2 == 0:
  print(N)
else:
  print(2 * N)
### BUGGY CODE ###

h,w,m = list(map(int,input().split()))
t = [list(map(int,input().split())) for _ in range(m)]
from collections import Counter

x,y = zip(*t)
xcnt = Counter(x)
ycnt = Counter(y)

xcmax = xcnt.most_common(1)[0][1]
ycmax = ycnt.most_common(1)[0][1]
xlist = [k for k,v in xcnt.items() if v == xcmax]
ylist = [k for k,v in ycnt.items() if v == ycmax]

tlist = [0 for i,j in zip(x,y) if (i in xlist) and(j in ylist)]
if len( xlist ) * len(ylist) == len(tlist):
  print( xcmax + ycmax -1 )
else:
  print( xcmax + ycmax )

### FIXED CODE ###

h,w,m = list(map(int,input().split()))
t = [list(map(int,input().split())) for _ in range(m)]
from collections import Counter
 
x,y = zip(*t)

xcnt = Counter(x)
ycnt = Counter(y)
 
xcmax = max( xcnt.values() )
ycmax = max( ycnt.values() )
xlist = [k for k,v in xcnt.items() if v == xcmax]
ylist = [k for k,v in ycnt.items() if v == ycmax]
if len(xlist) * len(ylist) > m:
  print( xcmax + ycmax )
else:
  xylist = { i*(10**6)+j for i in xlist for j in ylist }
  tlist = { i[0]*(10**6) + i[1] for i in t }
  if len( xylist - tlist ) == 0:
    print( xcmax + ycmax -1 )
  else:
    print( xcmax + ycmax )
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
if a[-1]==0:
    print(0)
    exit()
ans=a[0]
for i in range(len(a)-1):
    ans*=a[i+1]
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import sys
n=int(input())
List=list(map(int,input().split()))
List.sort(reverse=True)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in List:
    if ans<=10**18:
        ans*=i
    else:
        print(-1)
        sys.exit()
if ans<=10**18:
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

x, y, a, b, c = [int(t) for t in input().split()]
p = [int(t) for t in input().split()]
q = [int(t) for t in input().split()]
r = [int(t) for t in input().split()]
s = []
for i in range(x):
    p_max = max(p)
    if r:
        r_max = max(r)
    else:
        r_max = 0
    if p_max >= r_max:
        s.append(p.pop(p.index(p_max)))
    else:
        s.append(r.pop(r.index(r_max)))
for i in range(y):
    q_max = max(q)
    if r:
        r_max = max(r)
    else:
        r_max = 0
    if q_max >= r_max:
        s.append(q.pop(q.index(q_max)))
    else:
        s.append(r.pop(r.index(r_max)))
        
print(sum(s))

### FIXED CODE ###

x, y, a, b, c = [int(t) for t in input().split()]
p = [int(t) for t in input().split()]
q = [int(t) for t in input().split()]
r = [int(t) for t in input().split()]

s = []
p.sort(reverse=True)
p = p[:x]

q.sort(reverse=True)
q = q[:y]

s = p + q + r
s.sort(reverse=True)
s = s[:x+y]
print(sum(s))
### BUGGY CODE ###

k,s=list(map(int,input().split()))
print([x+y+z for x in range(k+1) for y in range(k+1) for z in range(k+1)].count(s))

### FIXED CODE ###

k,s=list(map(int,input().split()))
print([x+y+s-(x+y) for x in range(k+1) for y in range(k+1) if 0<= s-x-y <= k].count(s))
### BUGGY CODE ###

S=input()
l=len(S)

mod=10**9+7

a=0
ab=0
ans=0
all=1

for i in range(l):
	if S[i]=="A":
		a+=all
	elif S[i]=="B":
		ab+=a
	elif S[i]=="C":
		ans+=ab
	elif S[i]=="?":
		ans = ans*3 + ab
		ab = ab*3 + a
		a = a*3 + all
		all *= 3

	ans%=mod
	ab%=mod
	a%=mod
	all%mod


print (ans)


### FIXED CODE ###

S=raw_input()

M=10**9+7

all=1
abc=0
ab=0
a=0

for x in S:
	if x=="A":
		a+=all
	if x=="B":
		ab+=a
	if x=="C":
		abc+=ab

	if x=="?":
		abc=abc*3+ab
		ab=ab*3+a
		a= a*3+all
		all*=3

	abc%=M
	ab%=M
	a%=M
	all%=M


print abc%M
### BUGGY CODE ###

n, *a = map(int, open(0).read().split())
s = sum(a)
print(min(abs(s - sum(a[:i])*2) for i in range(1, n)))

### FIXED CODE ###

from itertools import*
_, *d = map(int, open(0).read().split())
*a, s = list(accumulate(d))
print(min(abs(s - x*2) for x in a))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))


def findProductSum(A, n):

    product = 0
    for i in range(n):
        for j in range(i+1, n):
            product = product + A[i]*A[j]
    return product%(10**9 + 7)
print(findProductSum(A,N))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))



A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) // 2
print(Answer%(10**9 + 7))
### BUGGY CODE ###

N = int(input())
P = list(map(int,input().split()))
ans = 1
Pj = []
Pj.append(P[0])
for i in range(1,N):
  Pj.append(P[i])
  if P[i] <= min(Pj):
    ans += 1
  else:
    pass
print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
ans = 1
Pj = P[0]
for i in range(1,N):
  Pj = min(Pj,P[i])
  if P[i] <= Pj:
    ans += 1
  else:
    pass
print(ans)
### BUGGY CODE ###

n = int(input())
A = [int(x) for x in input().split()]

B = {}
for i, a in enumerate(A):
    aa1 = i + 1 - a
    if aa1 > 0:
        if aa1 not in B:
            B[aa1] = []
        B[aa1].append((i + 1, a))

count = 0
for i, a in enumerate(A):
    aa1 = i + 1 + a
    if aa1 in B:
        for b in B[aa1]:
            if b[0] > i + 1:
                count += 1
print(count)

### FIXED CODE ###

n = int(input())
A = [int(x) for x in input().split()]

B = {}
for i, a in enumerate(A):
    aa1 = i + 1 - a
    if aa1 > 0:
        if aa1 not in B:
            B[aa1] = []
        B[aa1].append((i + 1, a))

count = 0
for i, a in enumerate(A):
    aa1 = i + 1 + a
    if aa1 in B:
        count += len(B[aa1])
print(count)
### BUGGY CODE ###

s = str(input())
q = int(input())
inv = False
for i in range(q):
    a = input()
    if a == '1':
        inv = not inv
        continue
    a = a.split()
    if (a[1] == '1')^inv:
        s = a[2] + s
    else:
        s += a[2]
if inv:
    print(s[::-1])
else:
    print(s)

### FIXED CODE ###

s = str(input())
q = int(input())
inv = False
head = ''
tail = ''

for i in range(q):
    a = input()
    if a == '1':
        inv = not inv
        continue
    a = a.split()
    if (a[1] == '1')^inv:
        head = a[2] + head
    else:
        tail += a[2]
s = head + s + tail
if inv:
    print(s[::-1])
else:
    print(s)
### BUGGY CODE ###

L, R = map(int, input().split())
mod = 2019

m = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        m = min(m, ((i % mod) * (j % mod)) % mod)

print(m)

### FIXED CODE ###

L, R = map(int, input().split())
mod = 2019

if R - L >= 2018:
    print(0)
elif R - L == 1:
    print(((L % mod) * (R % mod)) % mod)
else:
    m = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = min(m, ((i % mod) * (j % mod)) % mod)
    print(m)
### BUGGY CODE ###

class ModInt:
    def __init__(self, num, mod):
        self.num = num
        self.mod = mod

    def __str__(self):
        return str(self.num)

    def __repr__(self):
        return "ModInt(num: {}, mod: {}".format(self.num, self.mod)

    def __add__(self, other):
        ret = self.num + other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __sub__(self, other):
        ret = self.num - other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __mul__(self, other):
        ret = self.num * other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def pow(self, times):
        pw = pow(self.num, times, self.mod)
        return ModInt(pw, self.mod)

    def inverse(self):
        return self.pow(self.mod - 2)

    def __truediv__(self, other):
        num = self * other.inverse()
        return ModInt(num, self.mod)


h, w, a, b = map(int, input().split())
mod = 10 ** 9 + 7

power = [ModInt(1, mod)]
inv = [ModInt(1, mod).inverse()]


def comb(n, r):
    return power[n] * inv[r] * inv[n-r]


for i in range(1, h + w - 1):
    power.append(power[-1] * ModInt(i, mod))
    inv.append(power[-1].inverse())

ans = ModInt(0, mod)
for wi in range(b, w):
    ans += comb(h - a - 1 + wi, wi) * comb(a - 1 + w - wi - 1, a - 1)

print(ans)


### FIXED CODE ###

class ModInt:
    def __init__(self, num, mod):
        self.num = num
        self.mod = mod

    def __str__(self):
        return str(self.num)

    def __repr__(self):
        return "ModInt(num: {}, mod: {}".format(self.num, self.mod)

    def __add__(self, other):
        ret = self.num + other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __sub__(self, other):
        ret = self.num - other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __mul__(self, other):
        ret = self.num * other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def pow(self, times):
        pw = pow(self.num, times, self.mod)
        return ModInt(pw, self.mod)

    def inverse(self):
        return self.pow(self.mod - 2)

    def __truediv__(self, other):
        num = self * other.inverse()
        return ModInt(num, self.mod)


h, w, a, b = map(int, input().split())
mod = 10 ** 9 + 7

power = [ModInt(1, mod)]
inv = [ModInt(1, mod).inverse()]


def comb(n, r):
    return power[n] * inv[r] * inv[n-r]


for i in range(1, h + w - 1):
    power.append(power[-1] * ModInt(i, mod))
    inv.append(power[-1].inverse())

ans = ModInt(0, mod)
for wi in range(b, w):
    ans += comb(h - a - 1 + wi, wi) * comb(a - 1 + w - wi - 1, a - 1)

print(ans)
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*(n-1)
from collections import defaultdict
c = defaultdict(list)
for i in range(n-1):
    num = int(input())
    c[num].append(i+2)

def sub(winner):
    l = len(c[winner])
    vs = []
    for p in c[winner]:
        vs.append(sub(p))
    vs.sort()
    ans = l
    for i,v in enumerate(vs):
        ans = max(ans, l-(i)+v)
#     print(winner, ans, l, vs)
    return ans
ans = sub(1)
print(ans)

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = [None]*(n-1)
from collections import defaultdict
c = defaultdict(list)
for i in range(n-1):
    num = int(input())
    c[num].append(i+2)

def sub(winner):
    l = len(c[winner])
    vs = []
    for p in c[winner]:
        vs.append(sub(p))
    vs.sort()
    ans = l
    for i,v in enumerate(vs):
        ans = max(ans, l-(i)+v)
#     print(winner, ans, l, vs)
    return ans
ans = sub(1)
print(ans)