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

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

for i in range(m):
    if t[i] not in d:
        break
    else:
        d.pop(d.index(t[i]))
print("YES" if len(d) == n-m else "NO")

### FIXED CODE ###

from collections import Counter
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
d = Counter(sorted(d))
cnt = 0
for i in range(m):
    if t[i] in d and d[t[i]] > 0:
        d[t[i]] -= 1
        cnt += 1
    else: break
print("YES" if cnt == m else "NO")
### BUGGY CODE ###

K = int(input())
a = 0
for i in range(10**K):
    a += 7*(10**i)
    a = a % K
    if a == 0:
        print(i+1)
        exit()
print(-1)

### FIXED CODE ###

K = int(input())
a = 0
for i in range(K):
    a = (10*a+7)%K
    if a == 0:
        print(i+1)
        exit()
print(-1)
### BUGGY CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I() + 1
A = LI()
D = defaultdict(lambda:-1)
for i in range(n):
    if D[A[i]] != -1:
        l = D[A[i]]
        r = n - i - 1
        break
    else:
        D[A[i]] = i


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



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


for j in range(1, n + 1):
    ret = comb(n, j)
    for k in range(j):
        ret = (ret - comb(l, k) * comb(r, j - k - 1)) % mod
    print(ret)

### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I() + 1
A = LI()
D = defaultdict(lambda:-1)
for i in range(n):
    if D[A[i]] != -1:
        l = D[A[i]]
        r = n - i - 1
        break
    else:
        D[A[i]] = i


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



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


for j in range(1, n + 1):
    print((comb(n, j) - comb(r + l, j - 1)) % mod)
### BUGGY CODE ###

N=int(input())

a=1

for i in range(N):
  a*=i+1

a%=1000000007

print(a)

### FIXED CODE ###

N=int(input())
 
a=1
 
for i in range(N):
  a*=(i+1)
  a%=1000000007
 
print(a)
### BUGGY CODE ###

#!/usr/bin/env python3
# スペース区切りの整数の入力
n, k = map(int, input().split())
#配列の入力
data = list(map(int, input().split()))

temp = 1
old = 1
for i in range(k):
    temp *= data[i]

for i in range(k, n):
    old = temp
    temp = temp / data[i-k] * data[i]
    if temp > old:
        print("Yes")
    else:
        print("No")




### FIXED CODE ###

#!/usr/bin/env python3
# スペース区切りの整数の入力
n, k = map(int, input().split())
#配列の入力
data = list(map(int, input().split()))

for i in range(n-k):
    if data[i] < data[k+i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

n,Y = map(int,input().split())
for x in range(min(-(-Y//10000)+1,n+1)):
    for y in range(min(-(-Y//5000)+1,n+1)):
        for z in range(min(-(-Y//1000)+1,n+1)):
            if x+y+z==n and x*10000+y*5000+z*1000==Y:
                print(x,y,z)
                exit()
else:
    print(-1,-1,-1)

### FIXED CODE ###

n,Y = map(int,input().split())
for z in range(n+1):
    for y in range(n-z+1):
        if 0<=n-z-y<=2000 and (n-z-y)*10000+y*5000+z*1000==Y:
            print(n-z-y,y,z)
            exit()
else:
    print(-1,-1,-1)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

MAX = 10**5
Xs = [[] for _ in range(MAX+1)]
Ys = [[] for _ in range(MAX+1)]
for i, (x, y) in enumerate(XY):
    Xs[x].append(i)
    Ys[y].append(i)

ans = 0
checked = [False]*N
for i in range(N):
    if checked[i]: continue
    q = [i]
    checked[i] = True
    X = set()
    Y = set()
    c = 0
    while q:
        qq = []
        for p in q:
            x, y = XY[p]
            X.add(x)
            Y.add(y)
            c += 1
            for ni in Xs[x]:
                if not checked[ni]:
                    checked[ni] = True
                    qq.append(ni)
            for ni in Ys[y]:
                if not checked[ni]:
                    checked[ni] = True
                    qq.append(ni)
        q = qq
    ans += len(X)*len(Y)-c

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    N = int(input())
    XY = [list(map(int, input().split())) for _ in range(N)]

    MAX = 10**5
    Xs = [[] for _ in range(MAX+1)]
    Ys = [[] for _ in range(MAX+1)]
    for i, (x, y) in enumerate(XY):
        Xs[x].append(i)
        Ys[y].append(i)

    ans = 0
    checked = [False]*N
    for i in range(N):
        if checked[i]: continue
        q = [i]
        checked[i] = True
        X = set()
        Y = set()
        c = 0
        while q:
            qq = []
            for p in q:
                x, y = XY[p]
                X.add(x)
                Y.add(y)
                c += 1
                for ni in Xs[x]:
                    if not checked[ni]:
                        checked[ni] = True
                        qq.append(ni)
                for ni in Ys[y]:
                    if not checked[ni]:
                        checked[ni] = True
                        qq.append(ni)
            q = qq
        ans += len(X)*len(Y)-c

    print(ans)


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

n,k = map(int,input().split())
MOD = 10**9+7

history = {}
def comb(n,k):
  if (n,k) in history:
    return history[(n,k)]
  res = 1
  for i in range(k):
    res *= n-i
    res *= pow(i+1,MOD-2,MOD)
  res = res % MOD
  history[(n,k)] = res
  history[(n,n-k)] = res
  return res

for i in range(k):
  #print(comb(k-1,i),comb(n-k+1,i+1))
  ans = comb(k-1,i) * comb(n-k+1,i+1)
  print(ans % MOD)



### FIXED CODE ###

n,k = map(int,input().split())
MOD = 10**9+7

history = {}
def comb(n,k):
  if (n,k) in history:
    return history[(n,k)]
  if k == 0:
    return 1
  res = (n-k+1)*pow(k,MOD-2,MOD)*comb(n,k-1)
  res = res%MOD
  history[(n,k)] = res
  history[(n,n-k)] = res
  return res

for i in range(k):
  #print(comb(k-1,i),comb(n-k+1,i+1))
  ans = comb(k-1,i) * comb(n-k+1,i+1)
  print(ans % MOD)
### BUGGY CODE ###

k = int(input())
cnt = 0
num = 0

while True:
    if cnt == k:
        break
    num += 1
    list_num = list(str(num))
    a = 0
    for i in range(len(list_num)):
        if i+1 == len(list_num):
            break
        if abs(int(list_num[i])-int(list_num[i+1])) > 1:
            a = 1
    if a == 0:
        cnt += 1

print(num)


### FIXED CODE ###

k = int(input())
cnt = 9
q = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]

if k <= cnt:
    print(q[k-1])

while True:
    if cnt >= k:
        break
    num = q.pop(0)
    list_num = list(num)
    a = int(list_num[-1])
    for i in range(10):
        if abs(a-i) < 2:
            cnt += 1
            if i == 0:
                q.append(num+"0")
            elif i == 1:
                q.append(num +"1")
            elif i == 2:
                q.append(num +"2")
            elif i == 3:
                q.append(num+"3")
            elif i == 4:
                q.append(num+"4")
            elif i == 5:
                q.append(num+"5")
            elif i == 6:
                q.append(num+"6")
            elif i == 7:
                q.append(num+"7")
            elif i == 8:
                q.append(num+"8")
            elif i == 9:
                q.append(num+"9")

if k > 9:
    print(q[k-cnt-1])
### BUGGY CODE ###

n, k = map(int, input().split())
p = [int(x) for x in input().split()]
ans = 0
for i in range(n-k+1):
    a = 0
    for j in range(k):
        a += (1+p[i+j])/2
    ans = max(ans, a)
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
p = [int(x) for x in input().split()]
ans_list = [0]
a = 0
ans = 0
ans_ = 0
for i in range(n):
    a += (1+p[i])/2
    ans_list.append(a)
for i in range(n-k+1):
    ans_ = ans_list[i+k]-ans_list[i]
    ans = max(ans, ans_)
    
print(ans)
### BUGGY CODE ###

n, m = list(map(int, input().split()))
a = []
b = []
for i in range(n):
    k, l = list(map(int, input().split()))
    a.append(k)
    b.append(l)
sum = 0
money = 0
index = a.index(min(a))
while sum < m:
    if b[index] > 0:
        b[index] -= 1
        sum += 1
        money += a[index]
    else:
        del a[index]
        del b[index]
        index = a.index(min(a))
print(money)

### FIXED CODE ###

n, m = list(map(int, input().split()))
a = []
b = []
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
data.sort()
sum = 0
money = 0
index = 0
while sum + data[index][1]< m:
    sum += data[index][1]
    money += data[index][0] * data[index][1]
    del data[index]
money += (m - sum) * data[index][0]
print(money)
### BUGGY CODE ###

import sys
import numpy as np

N, M = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

for _ in range(M):
    a = max(A)
    n = A.index(a)
    A[n] = int(a / 2)
    
ans = sum(A)

print(ans)

### FIXED CODE ###

import sys
import numpy as np
import bisect

N, M = map(int, sys.stdin.readline().split())
A = np.array(list(map(int, sys.stdin.readline().split())))
A.sort()

max = A[N - 1]

count = 0

while count < M:
    max = A[N - 1]
    c = bisect.bisect_left(A, int(max / 2))
    add = N - c
    if count + add > M:
        d = M - count
        A[-d:] = A[-d:] // 2
        break
    else:
        A[c:] = A[c:] // 2
        count += add
        if count == M:
            break
    A.sort()
    
ans = int(sum(A))

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

import sys
input = sys.stdin.readline
from operator import itemgetter

N, M = map(int,input().split())
work_list = [list(map(int, input().split())) for i in range(N)]

#sort by hosyu
work_list.sort(key=itemgetter(1), reverse=True)
sum = 0
workdays = list(range(M+1))

for day, reward in work_list:
    latest = M - day

    #find maximum day
    k = list(filter(lambda x:x<latest+1, workdays))
    if len(k) == 0:
        continue
    else:
        work_day = max(k)
        workdays.remove(work_day)
        sum += reward

print(sum)


### FIXED CODE ###

import sys
input = sys.stdin.readline
from heapq import heappop, heappush

N, M = map(int,input().split())
work_list = [[] for j in range(M+1)]
for i in range(N):
    temp = list(map(int,input().split()))
    if temp[0] > M:
        continue
    work_list[temp[0]].append(temp[1])

sum = 0
works = []

for i in work_list:
    for j in i:
        heappush(works, -1*j)
    if len(works) == 0:
        continue
    sum -= (heappop(works))

print(sum)
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
C = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = A[i][j]-B[i][j]
M = 80*(H+W)
dp = [[set() for i in range(W)] for j in range(H)]
c = C[0][0]
dp[0][0].add(c)
dp[0][0].add(-c)
for s in range(1, H+W):
    for b in range(W):
        a = s-b
        if a<0 or a>=H:
            continue
        c = C[a][b]
        if a>=1:
            for i in dp[a-1][b]:
                dp[a][b].add(i+c)
                dp[a][b].add(i-c)

        if b>=1:
            for i in dp[a][b-1]:
                dp[a][b].add(i+c)
                dp[a][b].add(i-c)
ans = min(abs(i) for i in dp[-1][-1])
print(ans)

        









### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
C = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])
M = 80*(H+W)
dp = [[0 for i in range(W)] for j in range(H)]
c = C[0][0]
dp[0][0]+=(1<<(c+M))|(1<<(M-c))
for s in range(1, H+W):
    for b in range(max(s-H+1, 0), min(s+1, W)):
        a = s-b
        c = C[a][b]
        if a>=1:
            d = dp[a-1][b]
            dp[a][b]|=(d<<c)|(d>>c)
        if b>=1:
            d = dp[a][b-1]
            dp[a][b]|=(d<<c)|(d>>c)
ans = 10**10
d = dp[-1][-1]
for i in range(0, M*2+1):
    if 1<<i&d:
        ans = min(ans, abs(i-M))
print(ans)
### BUGGY CODE ###

a, b, x = map(int, input().split())
c = 0
for i in range(a, b+1):
  if i % x == 0:
    c += 1
print(c)

### FIXED CODE ###

a, b, x = map(int, input().split())
print(b//x - (a-1)//x)
### BUGGY CODE ###

N, W = map(int, input().split())

dp = [[0 for _ in range(W)] for _ in range(N + 1)]
weight = []
value = []
for _ in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)

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

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

for i in range(N):
    for w in range(W + 1):
        if weight[i] <= w:
            dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w])
        else:
            dp[i + 1][w] = dp[i][w]

print(dp[N][W])


### FIXED CODE ###

N, W = map(int, input().split())

dp = [[0 for _ in range(W)] for _ in range(N + 1)]
weight = []
value = []
for _ in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)

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

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

for i in range(N):
    for w in range(W + 1):
        if weight[i] <= w:
            dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w])
        else:
            dp[i + 1][w] = dp[i][w]

print(dp[N][W])
### BUGGY CODE ###

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

#print(s)

status = s[0]
count = 1
info = []

for i in range(1,n):
    if s[i] == status:
        count = count + 1
    else:
        info.append([status,count])
        count = 1
        status = s[i]

info.append([status,count])

#print(info)

c = 0
for x in range(0,len(info)):
    if info[x][0] == 0:
        c = c + 1

#print(c)

if c <= k:
    print(n)

else:
    p = 0
    l = []

    if s[0] == 0:
        while 2*(p+k-1) < len(info):
            w = 0
            for q in range(2*p-1,2*(p+k)):
                if q >= 0 and q < len(info):
                    w += info[q][1]
            l.append(w)
            p += 1

    else:
        while 2*(p+k-1)+1 < len(info):
            w = 0
            for q in range(2*p,2*(p+k)+1):
                if q >= 0 and q < len(info):
                    w += info[q][1]
            l.append(w)
            p += 1
    print(max(l))


### FIXED CODE ###

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

l = [0]

for i in range(0,n-1):
    if s[i] != s[i+1]:
        l.append(i+1)

t = len(l)

for x in range(0,2*k+1):
    l.append(n)

#print(l)

can = []

for j in range(0,t):
    if s[l[j]] == 0:
        can.append(l[j+2*k]-l[j])
    elif s[l[j]] == 1:
        can.append(l[j+2*k+1]-l[j])
    else:
        break

#print(can)
print(max(can))
### BUGGY CODE ###

from collections import deque

N, M = map(int, input().split())
graph = [[] for i in range(N)]
for i in range(M):
  u, v = map(int, input().split())
  u -= 1; v -= 1
  graph[u].append(v)

S, T = map(int, input().split())
S -= 1; T -= 1
  
def search(node, k):
  s = set()
  if k == 0:
    return set([node])
  children = graph[node]
  for child in children:
    s |= search(child, k-1)
  return s


# 距離が3のノード間にだけ辺を張り直す
g = [[] for i in range(N)]
for i in range(N):
  g[i] = search(i, 3)

dist = [-1] * N
dist[S] = 0
d = deque([[S, -1]])
while d:
  node, par = d.popleft()
  children = g[node]
  for child in children:
    if dist[child] < 0:
      dist[child] = dist[node] + 1
      d.append([child, node])

if dist[T] > 0:
  print(dist[T])
else:
  print(-1)

### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())

graph = [[] for i in range(3*N)]
for i in range(M):
  u, v = map(int, input().split())
  u, v = 3*(u - 1), 3*(v - 1)
  graph[u].append(v+1)
  graph[u+1].append(v+2)
  graph[u+2].append(v)

s, t = map(int, input().split())
s, t = 3*(s - 1), 3*(t - 1)


dist = [10**9] * 3*N
dist[s] = 0
d = deque([s])
while d:
  node = d.popleft()
  children = graph[node]
  for child in children:
    if dist[child] > dist[node] + 1:
      d.append(child)
      dist[child] = dist[node] + 1

if dist[t] < 10**9:
  print(dist[t]//3)
else:
  print(-1)
### BUGGY CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(1,k+1):
        if((i-j)>=0):
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
            
print(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(1,k+1):
        if((i-j)>=0):
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
            
print(dp[n-1])
### BUGGY CODE ###

n = int(input())
s_list = [''.join(sorted(input())) for _ in range(n)]
cnt = 0
for i in range(len(s_list) - 1):
    for j in range(i + 1, len(s_list)):
        if s_list[i] == s_list[j]:
            cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
cnt = 0
s_dic = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in s_dic.keys():
        s_dic[s] += 1
        cnt += s_dic[s]
    else:
        s_dic[s] = 0

print(cnt)
### BUGGY CODE ###

N,K = map(int,input().split())
A = [int(i) for i in input().split()]
loop = min(41,K)
for _ in range(loop):
    B = [0]*N
    for n in range(N):
        l = max(0,n-A[n])
        r = min(N-1,n+A[n])
        #print(l,r)
        B[l]+=1
        if r+1<N:
            B[r+1] -= 1
    #print(B)
    for n in range(1,N):
        B[n] += B[n-1]
    A = B
print(*A)

### FIXED CODE ###

N,K = map(int,input().split())
A = [int(i) for i in input().split()]
loop = min(41,K)
for _ in range(loop):
    B = [0]*N
    for n in range(N):
        l = max(0,n-A[n])
        r = min(N-1,n+A[n])
        B[l]+=1
        if r+1<N:
            B[r+1] -= 1
    for n in range(1,N):
        B[n] += B[n-1]
    A = [b for b in B]
print(*A)
### BUGGY CODE ###

n=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)


    return divisors
l=make_divisors(n)


aa=0
bb=0
for i in range(len(l)):

    t=0
    a=0
    while t==0:
        if a**5-(a-l[i])**5==n:
            t=2
            aa=a
            bb=a-l[i]

        elif a>l[i] and a**5-(a-l[i])**5>n:
            t=1

        a+=1

print(str(aa)+" "+str(bb))


### FIXED CODE ###

N= int(input())
x=0
a=0


for a in range(121):
    for b in range(-120,120):
        x = a ** 5 - b ** 5
        if x==N:
            an=str(a)+" "+str(b)
print(an)
### BUGGY CODE ###

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

for _ in range(k):
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 1
print(str(a) + ' ' + str(b))

### FIXED CODE ###

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

if a > k:
  print(str(a-k) + ' ' + str(b))
elif a <= k and a+b > k:
  print(str(0) +  ' ' + str(a + b -k))
else:
  print('0 0')
### BUGGY CODE ###

n = int(input())
import itertools
import functools
import math
l = list(range(1,n+1))
counter = 0
for v in itertools.product(l, repeat=3):
    gcd = functools.reduce(math.gcd, v)
    counter+=gcd
print(counter)

### FIXED CODE ###

n = int(input())
import itertools
import functools
import math
l = list(range(1,n+1))
counter = 0
for v in itertools.product(l, repeat=3):
    gcd = functools.reduce(math.gcd, v)
    counter+=gcd
print(counter)
### BUGGY CODE ###

L, R = map(int, input().split())
mod = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        num = i*j % 2019
        mod = min(mod, num)
print(mod)

### FIXED CODE ###

L, R = map(int, input().split())
mod = 2018
i = L
if R-L >= 2019:
    mod = 0
else:
    for i in range(L, R):
        for j in range(i+1, R+1):
            num = (i*j) % 2019
            mod = min(mod, num)
            if mod == 0:
                break
print(mod)