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

# 初期入力
import sys
from collections import defaultdict
input = sys.stdin.readline  #文字列では使わない
H,W,M = map(int, input().split())

bom_H ={i:0 for i in range(1,H+1)}
bom_W ={i:0 for i in range(1,W+1)}
posision =defaultdict(int)
for i in range(M):
    h,w = map(int, input().split())
    bom_H[h] +=1
    bom_W[w] +=1
    posision[(h,w)] =1
max_H = [kv for kv in bom_H.items() if kv[1] == max(bom_H.values())]
max_W = [kv for kv in bom_W.items() if kv[1] == max(bom_W.values())]
temp_H =max_H[0][1]
temp_W =max_W[0][1]

ans =temp_H +temp_W -1
for p_h,v_h in max_H:
    for p_w,v_w in max_W:
        if posision[(p_h,p_w)] ==0:
            ans =v_h +v_w 
            print(ans)
            sys.exit()

print(ans)

### FIXED CODE ###

import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
mod=1000000007
ans=0

for i in range (n-1):
    s=0
    for j in range(i+1,n):
        s=(s+a[j])%mod
    ans=(ans+(a[i]*(s))%mod)%mod

print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mod=1000000007
ans=0
s=0
for i in range (n-1):
    if i ==0:
        for j in range(i+1,n):
            s=(s+a[j])%mod
    else:
        s-=a[i]
    ans=(ans+(a[i]*(s))%mod)%mod

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

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

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
        
for i in range(2, N):
    for j in range(1, K + 1):
        dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])

### FIXED CODE ###

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

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
        
for i in range(2, N):
    for j in range(1, K + 1):
        dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

ball_dic = {}
for i in range(N):
    if A[i] in ball_dic.keys():
        ball_dic[A[i]] += 1
    else:
        ball_dic[A[i]] = 1

def cnt_ans(ball_sets):
    cnt = 0
    for ball_set in ball_sets:
        if ball_set > 1:
            cnt += ball_set * (ball_set - 1) // 2
        
    return cnt
    
for i in range(N):
    ball_dic_c = copy.deepcopy(ball_dic)
    ball_dic_c[A[i]] -= 1
    ball_sets = ball_dic_c.values()
    print(cnt_ans(ball_sets))
    
        


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

ball_dic = {}
for i in range(N):
    if A[i] in ball_dic.keys():
        ball_dic[A[i]] += 1
    else:
        ball_dic[A[i]] = 1

def cnt_ans(ball_sets):
    cnt = 0
    for ball_set in ball_sets:
        if ball_set > 1:
            cnt += ball_set * (ball_set - 1) // 2
    return cnt
    
basic_ans = cnt_ans(ball_dic.values())

for i in range(N):
    n = ball_dic[A[i]]
    if n > 1:
        ans = basic_ans - (ball_dic[A[i]] - 1)
    else:
        ans = basic_ans
    print(ans)
### BUGGY CODE ###

def main():
	N, M = map(int, input().split())
	A = []
	B = []
	for i in range(N):
		a, b = map(int, input().split())
		A.append(a)
		B.append(b)
	cost = 0
	while True:
		mc = 0
		mp = min(A)
		for i in range(N):
			if A[i] == mp:
				mc = B[i]
				A[i] = 10**10
		for i in range(mc):
			M -= 1
			cost += mp
			if M <= 0:
				print(cost)
				return
	return

if __name__ == '__main__':
	main()


### FIXED CODE ###

def main():
	N, M = map(int, input().split())
	S = []
	for i in range(N):
		a, b = map(int, input().split())
		S.append([a, b])
	sorted_shop_list = sorted(S, key=lambda x: x[0])
	cost = 0
	for i in sorted_shop_list:
		a = i[0]
		b = i[1]
		if b < M:
			M -= b
			cost += a * b
		else:
			cost += a * M
			break
	print(cost)
	return

if __name__ == '__main__':
	main()
### BUGGY CODE ###

N,K = map(int, input().split())
S = []
for i in range(K):
    L,R = map(int, input().split())
    S += [ j for j in range(L,R+1)]
S = set(S)

step = [0]*(N+1)
step[1] = 1

for j in range(1,N+1):
    for s in S:
        if j + s > N:
            continue
        elif step[j] == 0:
            continue
        step[j+s] += step[j]
        step[j+s] %= 998244353
print(step[N])

### FIXED CODE ###

mod = 998244353
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(k)]
for i in range(k):
    lr[i][1] += 1

dp = [0]*n
dp[0] = 1
for i in range(1,n):
    dp[i] = dp[i-1]
    if i == 1:
        dp[1] = 0
    for l,r in lr:
        if i - l >= 0:
            dp[i] += dp[i-l]
        if i - r >= 0:
            dp[i] -= dp[i-r]
        dp[i] %= mod
print(dp[n-1])
### BUGGY CODE ###

N, Q = map(int, input().split())
s = input()
td = []
for i in range(Q):
    td.insert(0, input().split())
#print("td = {}".format(td))

llim = 0
rlim = N - 1
for t, d in td:
    if((s[llim] == t) and ("L" == d)):
        llim += 1
    elif(llim - 1 >= 0):
        if((s[llim - 1] == t) and ("R" == d)):
            llim -= 1
    if((s[rlim] == t) and ("R" == d)):
        rlim -= 1
    elif(rlim + 1 <= N - 1):
        if((s[rlim + 1] == t) and ("L" == d)):
            rlim += 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, rlim - llim + 1)))


### FIXED CODE ###

N, Q = map(int, input().split())
s = " " + input() + " "
td = []
for i in range(Q):
    td.append(input().split())
#print("td = {}".format(td))

llim = 0
rlim = N + 1
for t, d in reversed(td):
    if((s[llim + 1] == t) and ("L" == d)):
        llim += 1
    elif((s[llim] == t) and ("R" == d)):
        llim -= 1
    if((s[rlim - 1] == t) and ("R" == d)):
        rlim -= 1
    elif((s[rlim] == t) and ("L" == d)):
        rlim += 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, rlim - llim - 1)))
### BUGGY CODE ###

N = int(input())
S = str(input())


S_R = []
S_G = []
S_B = []


for i in range(N):
    s = S[i]
    if (s == 'R'):
        S_R.append(i)
    if (s == 'G'):
        S_G.append(i)
    if (s == 'B'):
        S_B.append(i)

count = len(S_R) * len(S_G) * len(S_B)
#rgb = {'R', 'G', 'B'}


#for i in range(N):
    #for j in range(i):
        #x = S[j::i]
        #for a, b, c in zip(x, x[1:], x[2:]):
            #if({a,b,c} == rgb):
                #count -=1

for i in range(N):
    for j in range(N):
        if(i + j*2 >= N):
            continue
        if((S[i] != S[i + j]) & (S[i + j] != S[i + 2 * j]) & (S[i + 2 * j] != S[i])):
            count -= 1




print(count)

### FIXED CODE ###

n = int(input())
s = input()
 
r, b, g = 0, 0, 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    if s[i] == 'G':
        g += 1
    if s[i] == 'B':
        b += 1
ans = r * g * b
 
for i in range(n):
    for j in range(1, n // 2 + 1):
        if i + 2 * j >= n:
            break
        if s[i] != s[i+j] and s[i] != s[i+2*j] and s[i+j] != s[i+2*j]:
            ans -= 1
 
print(ans)
### BUGGY CODE ###

H, N = map(int, input().split())
dp = [ 0 for _ in range(H+1)]
dp[0] = 0
AB = [list(map(int, input().split())) for _ in range(N)]
for j in range(1, H+1):
  dp[j] = min([dp[max(0, j-a)] + b for a, b in AB])
print(dp[H])


### FIXED CODE ###

H, N = map(int, input().split())
dp = [ 1001001001 for _ in range(H+1)]
dp[0] = 0
for i in range(N):
  A, B = map(int, input().split())
  for j in range(H):
    nj = min(j+A, H)
    dp[nj] = min(dp[nj], dp[j] + B)

print(dp[H])
### BUGGY CODE ###

import fractions

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

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

import copy
N = int(input())
Ps = list(map(int,input().split(" ")))
org_Ps = copy.deepcopy(Ps)
prime_nums = primes(10 ** 5)


mul = 1
used = False
for p in prime_nums:
    used = False
    for i in range(len(Ps)):
        if Ps[i] %p == 0:
            Ps[i]//=p
            if not used:
                used = True
                mul *= p

MOD = 10 ** 9 + 7
g = 1

for p in Ps:
    g = g* p // fractions.gcd(g, p)
g *= mul
ans = 0

for p in org_Ps:
    ans += g//p
    ans %= MOD
ans %= MOD

print(ans)





### FIXED CODE ###

from fractions import gcd

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

N = int(input())
Ps = list(map(int,input().split(" ")))
MOD = 10 ** 9 + 7
g = 1
for p in Ps:
    g = lcm(g,p)
ans = 0

print(sum([g // p for p in Ps]) % (10 ** 9 + 7))
### BUGGY CODE ###

def main():
    s = list(input())[::-1]
    ary_mod = [0] * 2019
    ary_mod[0] = 1
    now = 0

    for i, ss in enumerate(s):
        now += (int(ss) * 10 ** i)
        remind = now % 2019
        ary_mod[remind] += 1
    ans = 0
    for i, n in enumerate(ary_mod):
        ans += (n*(n-1)) // 2
    print(ans)
if __name__=='__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)


S = input()
N = len(S)
P = 2019

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    sys.exit()

num = [0] * P
num[0] = 1
now, ans = 0, 0
_10 = 1
for i in range(N-1, -1, -1):
    now = (now + int(S[i]) * _10) % P
    _10 *= 10
    _10 %= P
    ans += num[now]
    num[now] += 1

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

n = int(input())
cnt = 0

for i in range(1,n):
  for j in range(1,n//i+1):
    if i * j < n:
      cnt +=1
      
print(cnt)

### FIXED CODE ###

n = int(input())
cnt = 0

for i in range(3,n):
  for j in range(1,n//i+1):
    if i * j < n:
      cnt +=1
      
print(cnt+n-1+(n-1)//2)
### BUGGY CODE ###

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

t = 1
for i in range(K):# A[0] ~ A[K-1]
  t *= A[i]
  
for i in range(K, N):
  temp = t // A[i-K] * A[i]
  if t < temp:
    print('Yes')
  else:
    print('No')
  t = temp


### FIXED CODE ###

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

for i in range(K, N):
  if A[i-K] < A[i]:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

#5.3
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

findCount = 0

for t in T:
    left = 0
    right = n - 1
    center = right // 2
    while left != right:
        if S[center] == t:
            findCount += 1
            break
        
        if S[center] >= t:
            right = center
        else:
            left = center
            
        center = (left + right) // 2

print(findCount)

### FIXED CODE ###

#5.3
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

findCount = 0

for t in T:
    left = 0
    right = n
    center = right // 2
    preCenter= 0
    while left < right:
        if S[center] == t:
            findCount += 1
            break
        
        if S[center] > t:
            right = center
        else:
            left = center + 1
        
        center = (left + right) // 2

print(findCount)
### BUGGY CODE ###

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

for i in range(n):  
  print(a.count(i+1))

### FIXED CODE ###

import collections

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

c = collections.Counter(a)

for i in range(n):  
  print(c[i+1])
### BUGGY CODE ###

N = int(input())
A = input().split(' ')

intAList = [int(i) for i in A]
sortA = sorted(intAList)
#print(sortA)

for i in range(1,N+1):
  hoge = sortA.count(i)
  print(hoge)
  sortA = sortA[hoge:]

### FIXED CODE ###

N = int(input())
A = input().split(' ')

intAList = [int(i) for i in A]

backet = list([0]*N)
#print(backet)

for i in intAList:
  backet[i-1] += 1

for i in backet:
  print(i)
### BUGGY CODE ###

N = int(input())
L = list(map(int,input().split()))
for i in range(N):
  A = L[:i]+L[i+1:]
  A.sort()
  print(A[(N-2)//2])

### FIXED CODE ###

import copy

N = int(input())
L = list(map(int,input().split()))
A = copy.deepcopy(L)
A.sort()
for i in range(N):
  if (L[i] <= A[(N//2)-1]):
    print(A[N//2])
  else:
    print(A[(N//2)-1])
### BUGGY CODE ###

def findlcs(x, y):
    dp = [0]*(len(y)+1)

    for c in x:
        tmp = dp[:]
        for j in range(len(y)):
            if c == y[j]:
                dp[j+1] = tmp[j] + 1
            else:
                dp[j+1] = max(dp[j+1], dp[j])

    return dp[-1]


q = int(input())
for k in range(q):
    X = input()
    Y = input()
    print(findlcs(X, Y))

### FIXED CODE ###

def findlcs(x, y):
    dp = [0]*(len(y)+1)

    for c in x:
        tmp = dp[:]
        for j in range(len(y)):
            if c == y[j]:
                dp[j+1] = tmp[j] + 1
            elif dp[j+1] < dp[j]:
                dp[j+1] = dp[j]

    return dp[-1]


q = int(input())
for k in range(q):
    X = input()
    Y = input()
    print(findlcs(X, Y))
### BUGGY CODE ###

import math

Q = int(input())
L = [0]*Q
R = [0]*Q
for i in range(Q):
    L[i], R[i] = map(int, input().split())

# print(Q, L, R)

def gen_primes():
    max_lr = 10**5
    primes = [2]
    for i in range(3, max_lr, 2):
        is_prime = True
        limit = int(math.sqrt(i)) + 1
        for p in primes:
            if p > limit:
                break
            if i % p == 0:
                is_prime = False
                break
        if is_prime:
            primes.append(i)
    # print(len(primes))
    return primes

primes = gen_primes()

def is_2017_like(n):
    m = (n + 1) // 2
    return n in primes and m in primes

for i in range(Q):
    ans = 0
    for j in range(L[i], R[i] + 1, 2):
       if is_2017_like(j):
           ans += 1
    print(ans)


### FIXED CODE ###

import math

Q = int(input())
L = [0]*Q
R = [0]*Q
for i in range(Q):
    L[i], R[i] = map(int, input().split())

# print(Q, L, R)

max_lr = 10**5

def gen_primes():
    primes = [2]
    for i in range(3, max_lr, 2):
        is_prime = True
        limit = int(math.sqrt(i)) + 1
        for p in primes:
            if p > limit:
                break
            if i % p == 0:
                is_prime = False
                break
        if is_prime:
            primes.append(i)
    # print(len(primes))
    return primes

primes = gen_primes()

def is_2017_like(n):
    m = (n + 1) // 2
    return n in primes and m in primes

A = [0]*(max_lr//2 + 1)
a = 0
for i in range(1, max_lr, 2):
    if is_2017_like(i):
        a += 1
    A[i//2 + 1] = a

for i in range(Q):
    ans = A[R[i]//2 + 1] - A[L[i]//2]
    print(ans)
### BUGGY CODE ###

import bisect
from itertools import product
A,B,Q = map(int,input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
stlist = [s,t]
ab = [A,B]
for i in range(Q):
    x = int(input())
    cand = []
    for i in range(2):
        st = stlist[i]
        cand1 = set()
        l1 = bisect.bisect_left(st,x)
        r1 = bisect.bisect_right(st,x)
        if 0 <= l1 <= ab[i]-1:
            cand1.add(st[l1])
        if 0 <= l1-1 <= ab[i]-1:
            cand1.add(st[l1-1])  
        if 0 <= r1 <= ab[i]-1:
            cand1.add(st[r1])
        if 0 <= r1+1 <= ab[i]-1:
            cand1.add(st[r1+1])
        cand.append(cand1)
        
    ans = float('inf')
    for a,b in product(cand[0],cand[1]):
        c = min(abs(x-a)+abs(b-a),abs(x-b)+abs(b-a))
        ans = min(ans,c)
    print(ans)
        
        
    

### FIXED CODE ###

import sys
import bisect
from itertools import product
def input(): return sys.stdin.readline().strip()
A,B,Q = map(int,input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
stlist = [s,t]
ab = [A,B]
for i in range(Q):
    x = int(input())
    cand = []
    for i in range(2):
        st = stlist[i]
        cand1 = set()
        l1 = bisect.bisect_left(st,x)
        r1 = bisect.bisect_right(st,x)
        if 0 <= l1 <= ab[i]-1:
            cand1.add(st[l1])
        if 0 <= l1-1 <= ab[i]-1:
            cand1.add(st[l1-1])  
        if 0 <= r1 <= ab[i]-1:
            cand1.add(st[r1])
        if 0 <= r1+1 <= ab[i]-1:
            cand1.add(st[r1+1])
        cand.append(cand1)
        
    ans = float('inf')
    for a,b in product(cand[0],cand[1]):
        c = min(abs(x-a)+abs(b-a),abs(x-b)+abs(b-a))
        ans = min(ans,c)
    print(ans)
### BUGGY CODE ###

N = int(input())
X = input()
ans = [1 for _ in range(N)]
#original 1 count
l = 0
for k in range(N):
  if X[k] == '1':
    l+=1


intN = int(X, 2)
if l >1:
  N1 = intN %(l-1)
N0 = intN % (l+1)


start = []
if N == 1:
  if X[0] == '1':
    print(0)
    exit()
  else:
    print(1)
    exit()

else:
  for k in range(N):
    if X[k] == '1':
      if l == 1:
        ans[k] = 0
        ia =0
      else:  
        ia = (N1 - pow(2,N-k-1))%(l-1)
    else:
      ia = (N0 + pow(2, N-k-1))%(l+1)
    start.append(ia)
"""
ml = len(bin(l+1))-2
poplist = [0 for _ in range(N)]
t = 1
while t < N + 1:
  t *= 2
  for k in range(t//2, N, t):
    for j in range(t//2):
      if k+j>N-1:
        break
      poplist[k+j] += 1
"""

def popcount(n):
  c = 0
  n = bin(n)[2:]
  for k in range(len(n)):
    if n[k] == '1':
      c+=1
  return c

for k in range(len(start)):
  for count in range(10*5):
    if start[k] == 0:
      ans[k] += count
      break
    else:
      start[k] = start[k] % popcount(start[k])

for k in range(N):
  print(ans[k])

### FIXED CODE ###

N = int(input())
X = input()
ans = [1 for _ in range(N)]
#original 1 count
l = 0
for k in range(N):
  if X[k] == '1':
    l+=1
if l == 0:
  for _ in range(N):
    print(1)
  exit()
if l == 1:
  if X[-1] == '1':
    for _ in range(N-1):
      ans[_] = 2
  else:
    ans[-1] = 2 
  for k in range(N):
    if X[k] =='1':
      ans[k] = 0 
  for _ in range(N):
    print(ans[_])
  exit()


intN = int(X, 2)
N1 = intN %(l-1)
N0 = intN % (l+1)


start = []
if N == 1:
  if X[0] == '1':
    print(0)
    exit()
  else:
    print(1)
    exit()
else:
  s1 = 1
  s0 = 1
  for k in range(N-1, -1, -1):
    if X[k] == '1':      
      ia = (N1 - s1)%(l-1)
    else:
      ia = (N0 + s0)%(l+1)
    start.append(ia)
    s1 = s1*2%(l-1)
    s0 = s0*2%(l+1)
start = start[::-1]
"""
ml = len(bin(l+1))-2
poplist = [0 for _ in range(N)]
t = 1
while t < N + 1:
  t *= 2
  for k in range(t//2, N, t):
    for j in range(t//2):
      if k+j>N-1:
        break
      poplist[k+j] += 1
"""

def popcount(n):
  c = 0
  n = bin(n)[2:]
  for k in range(len(n)):
    if n[k] == '1':
      c+=1
  return c

for k in range(len(start)):
  for count in range(10*5):
    if start[k] == 0:
      ans[k] += count
      break
    else:
      start[k] = start[k] % popcount(start[k])

for k in range(N):
  print(ans[k])
### BUGGY CODE ###

n = int(input())
print(0)
sys.stdout.flush()
maes = input()
if maes == "Vacant":
    sys.exit()
print(n-1)
sys.stdout.flush()
maes = input()
if maes == "Vacant":
    sys.exit()
lef = 0
rig = n -1 
print((lef+rig)//2 - ((lef+rig)//2)%2)
sys.stdout.flush()
p = 0
while abs(rig-lef)<=2:
    s = input()
    if s == "Vacant":
        sys.exit()
    else:
        if maes == s:
            if p == 0:
                lef = (lef+rig)//2 - ((lef+rig)//2)%2
            elif p == 1:
                rig = (lef+rig)//2 + ((lef+rig)//2)%2
        elif maes != s:
            if p == 0:
                p = 1
                rig = (lef+rig)//2 + ((lef+rig)//2)%2
            elif p == 1:
                lef = (lef+rig)//2 - ((lef+rig)//2)%2
    maes = s
    print((lef+rig)//2 - ((lef+rig)//2)%2)
    sys.stdout.flush()

print((lef+rig)//2)
sys.stdout.flush()
if maes == "Vacant":
    sys.exit()

### FIXED CODE ###

n = int(input())

print(0)
lf = input()
if lf == "Vacant":
    exit()

print(n-1)
rf = input()
if rf == "Vacant":
    exit()
l = 0
r = n-1

while True:
    k = (l+r)//2
    print(k)
    f = input()
    if f == "Vacant":
        exit()
    else:
        if (abs(r-k) % 2 == 1 and rf == f) or (abs(r-k) % 2 == 0 and rf != f):
            l = k
            lf = f
        elif (abs(l-k) % 2 == 1 and lf == f) or (abs(l-k) % 2 == 0 and lf != f):
            r = k
            rf = f
### BUGGY CODE ###

S = input()
lenq = int(input())
Q = [input() for _ in range(lenq)]

# len(S) <= 100000
# lenq <= 2 * 10 ** 5
for q in Q:
    if q == '1':
        S = S[::-1]
    else:
        _, f, c = q.split()
        if f == '1':
            S = c + S
        else:
            S = S + c

print(S)


### FIXED CODE ###

from collections import deque

S = deque(input())
lenq = int(input())
Q = [input() for _ in range(lenq)]

# len(S) <= 100000
# lenq <= 2 * 10 ** 5

# q == '1' のとき、実際に反転すると O(N)かかるので反転しないで、
# どちらが先頭かだけの情報を持っておく
head = 1 # or -1
for q in Q:
    if q == '1':
        head *= -1
    else:
        _, f, c = q.split()
        if f == '1':
            if head == 1:
                S.appendleft(c)
            else:
                S.append(c)
        else:  # f == '2'
            if head == 1:
                S.append(c)
            else:
                S.appendleft(c)
S = ''.join(list(S))
if head == -1:
    S = S[::-1]
print(S)
### BUGGY CODE ###

#TLE
N = int(input())
A = list(map(int, input().split()))
ans = 0
for l in range(N):
    ans += A.count(A[l]) - 1
ans /= 2
for k in range(N):
    answer = ans - (A.count(A[k]) - 1)
    print(int(answer))

### FIXED CODE ###

#TLE
n = int(input())
a = input().split()
ans = 0
import collections
dic = collections.Counter(a)
for i in dic.values():
    ans += i * (i-1)
ans /= 2
for i in range(n):
    print(int(ans - dic[a[i]] + 1))
### BUGGY CODE ###

n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for a in A:
    B2 = [i for i in B if i > a]
    for b in B2:
        ans += len([j for j in C if j > b])
    
print(ans)

### FIXED CODE ###

import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
    
print(ans)
### BUGGY CODE ###

a,b = map(int,input().split())
if a-b+1>=2019:
    print(0)
else:
    mini = 2020
    for i in range(a,b+1):
        for j in range(a,i):
            if i*j%2019<mini:
                mini = i*j%2019
    print(mini)

### FIXED CODE ###

import sys
from math import ceil
from operator import itemgetter as get

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nod(a, b):
    while b: 
        a, b = b, a % b
    return a
 
def calc(n, c, d):
    return n - n // c - n // d + n // (c * d // nod(c, d))   


def main():
    l, r = rinput()
    q = []
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = i * j % 2019
            q.append(res)
            if res == 0:
                print(0)
                return 0
    print(min(q))
main()