Problem:


Score : 300 points

Problem Statement

You are given two non-negative integers L and R.
We will choose two integers i and j such that L \leq i < j \leq R.
Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Constraints

All values in input are integers.

0 \leq L < R \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

L R

Output

Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.

Sample Input 1

2020 2040

Sample Output 1

2

When (i, j) = (2020, 2021), (i \times j) \mbox{ mod } 2019  = 2.

Sample Input 2

4 5

Sample Output 2

20

We have only one choice: (i, j) = (4, 5).



Sample input:
2020 2040


Sample output:
2

Submission status: Wrong Answer

Solution code:
a = input().split()
a = [int(i) for i in a]
a = sorted(a)
b = [i + 1 for i in range(abs(a[0] - a[1]) + 1)]
b_1 = [i for i in range(a[0], a[1] + 1)]
c = [i % 2019 for i in b_1]
if 0 in c:
    print(0)

else:
    c = sorted(c)
    print((c[0]*c[1])%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())

a = 2020

for i in range(L, R):
    for j in range(i+1,R):
        t = ((i % 2019) * (j % 2019)) % 2019
        if t < a:
            a = t

print(a)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
if r < 2019:
	print((l*(l+1)) % 2019)
	exit()
elif r-l >=  2019:
	print(0)
	exit()
elif r-l < 2019:
	mini = 2018
	for i in range(r-l+1):
		mod = (l*(l+1)) % 2019
		if mod < mini:
			mini = mod
		l += 1
		if l > r:
			break
print(mini)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if R-L > 2018:
    print(0)
else:
    if L//2019 != R//2019:
        print(0)
    else:
        print((L*(L+1))%2019)

Submission status: Wrong Answer

Solution code:
import math
l,r=map(int,input().split())
a=l%2019
b=r%2019
if l-r>=2018:
    print(0)
elif b-a<=0:
    print(0)
elif (a<=672)&(b>=673):
    print(0)
elif(a<=673)&(b>=675):
    print(0)
elif (a<=1345)&(b>=1346):
    print(0)
elif(a<=1346)&(b>=1348):
    print(0)
elif a<=20&b>=101:
    print(1)
else:
    ans=2018
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            ans=min(ans,i*j%2019)
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
  sum=0
  L,R=map(int,input().split())
  if (L+2019-L%2019<=R) or (R-R%2019) >=L:
    print(0)
  else:
    L_e=L%2019
    R_e=R%2019
    a=min(L_e,R_e)
    print((a*(a+1))%2019)
      
main()

Submission status: Wrong Answer

Solution code:
def main():
    L, R = map(int, input().split())

    ans = L * R % 2019
    if L // 2019 < R // 2019:
        ans = 0
    else:
        ans = (L % 2019) * (L % 2019+1)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
l,r = map(int,input().split(" "))

if r-l > 2019:
    print(0)
else:
    l2r = [[e%2019,e] for e in list(range(l,r+1,1))]
    if r-l > 2:
        if min([e%673 for e in list(range(l,r+1,1))]) == 0:
            print(0)
        else:
            l2r.sort(key=itemgetter(0))
            print((l2r[0][1] * l2r[1][1])%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())

#f = 0
l = []

if R-L>=2019:
    #f = 1
    print(0)
    exit()

for i in range(L,R+1):
    l.append(i%2019)
else:
    l.sort()

if 3 in l and 673 in l:
    print(0)
elif 3 in l:
    print(min((l[0]*l[1])%2019,637))
elif 637 in l:
    print(min((l[0]*l[1])%2019,3))
else:
    print((l[0]*l[1])%2019)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = 0
d = -1
for i in range(a + 1, b + 1):
    if d == -1:
        d = (i * (i-1)) % 2019
    elif d > (i * (i-1)) % 2019:
        d = (i * (i-1)) % 2019
    c += 1
    if c > 2019 * 3:
        break
print(d)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
if R*(R-1)<2019:
  print(L*(L+1))
else:
  val=(L+R)//2
  if (val+1)%2019<val%2019:
    p=val
    while (p+1)%2019<p%2019 and p<=R-1:
      p+=1
    if p/2>=L:
      print((p**2)%2019)
    else:
      print((p*(p-1))%2019)
  else:
    p=val
    while (p-1)%2019<p%2019 and p>=L+1:
      p-=1
    if p*2<=R:
      print((p**2)%2019)
    else:
      print(p*(p+1)%2019)

Submission status: Wrong Answer

Solution code:


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

if R-L>2019:
    print(0)
else:
    A =[]
    for i in range(R-L+1):
        A.append((L+i)%2019)
    A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

Solution code:
l, r = [int(i) for i in input().split()]

lower = 2020
lowest = 2020

for i in range(l, r+1):
	
	mod = i % 2019

	if mod==0:
		ans = 0
		break
	
	list_ = [lower, lowest, mod]
	list_.sort()
	lower = list_[1]
	lowest = list_[0]
	ans = lower * lowest

print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L %= 2019
R %= 2019
ans = 2020
if L > R:
    t = L
    L = R
    R = t
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, i*j%2019)
print(ans % 2020)

Submission status: Wrong Answer

Solution code:
import numpy as np


def calc(ell: int, r: int) -> int:
    if ell % 2019 == 0:
        return 0
    if r % 2019 == 0:
        return 0
    if ell % 2019 > r % 2019:  # 間に2019の倍数があるパターン1
        return 0
    if r >= ell + 2019:  # 間に2019の倍数があるパターン2
        return 0

    start = ell
    # stop = min(ell + 2019, r)
    stop = r

    searching_array = np.arange(start, stop, 1)
    searching_mat = np.tile(searching_array, (searching_array.shape[0],))
    seki = searching_mat * (searching_mat.T + 1)
    results = np.mod(seki, 2019)
    return results.min()


def load_input_as_int_array():
    return [int(v) for v in input().split(" ")]


ell, r = load_input_as_int_array()
print(calc(ell, r))

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())

ans = 2018

ml = l % 2019
mr = r % 2019

t = mr - ml

for i in range(t):
    for j in range(t - i):
        p = ((ml + i) * (ml + i + j + 1)) % 2019
        if p < ans:
            ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
[l,r] = [int(i) for i in input().split()]
i = 0
check = 1
ans = 0
p = l % 2019
q = r % 2019
# 2019の倍数が挟まっている
# lの方があまりが大きい → 挟まってる
# 差が2019以上 → 挟まってる
if p >= q or r - l >= 2019:
    print(0)
elif (q // 673)-(p // 673) > 0 and q - p >= 3:
    print(0)
else:
    #p < q かつ r - l < 2019
    #すなわち 2020 2040みたいな状況
    print((p * (p+1))% 2019)

Submission status: Wrong Answer

Solution code:
import math

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

mod = 2019

l = L % 2019
r = R % 2019

print(l*(l+1))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
small = 1000
if L+1 == R:
    print(L*R)
else:
    for number in range(L,R-1):
        ans = number*(number+1)%2019
        if small > ans:
            small = ans

    print(small)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
mod = 2019
mod_min = 2100

s = l % mod
e = r % mod

if s > e:
    e = s + mod - 1


'''
if s > e:
    t = s
    s = e
    e = t

if s == e:
    e = s + mod - 1
'''
for i in range(s,e):
    for j in range(i+1,e+1):

        #m = ((i % mod) * (j % mod)) % mod
        m = (i * j) % mod
        #print(i,j,m)

        if m < mod_min:
            mod_min = m

print(mod_min)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
x = L // 2019
y = R // 2019
if y-x>0:
    min=0
else:
    min = (L*(L+1))%2019
print(min)

Submission status: Wrong Answer

Solution code:
A = [int(x)  for x in input().split()]
N = [i%2019 for i in range(A[0],A[1] + 1)]
a = min(N)
print(a*(a+1))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l+1>2020:
  x=list(range(l,l+2020))
else:
  x=list(range(l,r+1))
y=list()
for n in x:
  y=y+[n%2019]
y.sort()
print((y[0]*y[1])%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
left = L%2019
right = R%2019
if left > right:
    print(0)
else:
    l = [i for i in range(left, right+1)]
    ans = 9999
    for i in range(len(l)-1):
        for j in range(i+1, len(l)):
            mo = l[i]*l[j]%2019
            if mo<ans:
                ans = mo
    print(ans)

Submission status: Wrong Answer

Solution code:
print(2019 * 2020 % 2019)
a, b = map(int, input().split())
c = 0
d = -1
for i in range(a + 1, b + 1):
    if d == -1:
        d = (i * (i-1)) % 2019
    elif d > (i * (i-1)) % 2019:
        d = (i * (i-1)) % 2019
    c += 1
    if c > 2019 * 3:
        break
print(d)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())

ans = 3000

l = [-1] * 2019 
r = [-1] * 2019

flagl = False
for i in range(L, R+1):
    if l[i%2019] != -1:
        flagl = True
    l[i%2019] = i%2019
    flagr = False
    for j in range(i+1, R+1):
        if r[j%2019] != -1:
            flagr = True
            break
        r[j%2019] = j%2019
    if flagl == True and flagr == True:
        break

tmp = 0
for i in l:
    if i == -1:
        continue
    for j in r:
        if j == -1:
            continue
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, a = map(int, input().split())

    if n % 2019 == 0 or a % 2019 == 0 or n * a % 2019 == 0:
        print(0)

    elif n < 2019 and a < 2019:
        print((n * a) % 2019)

    elif 2019 < n and 2019 < a:
        print((n % 2019) * ((n+1) % 2019))

Submission status: Wrong Answer

Solution code:
l, r = [int(s) for s in input().split(" ")]

m = l * (l + 1) % 2019

print("%d" % m)

Submission status: Wrong Answer

Solution code:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for _i in range(L, R + 1):
    i = _i % 2019
    if i == 0: return 0
    v = i * (i + 1) % 2019
    if v < ans: ans = v
    # for _j in range(_i + 1, R + 1):
      # if v < ans: ans = v
      # v += i
      # v %= 2019
  return ans

print(solve())

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())

mod = []
if R-L<=2019:
    for i in range(L,R):
        for j in range(i+1,R):
            mod.append((i*j)%2019)

else:
    for i in range(L, L+2019):
        for j in range(i, L+2019+1):
            mod.append((i*j)%2019)


if len(mod)==0:
    print((L*R)%2019)
else:
    print(min(mod))

Submission status: Wrong Answer

Solution code:
MAX=2019
def resolve():
    l,r = map(int,input().split())
    if abs(l-r)>=(MAX-1):
        print(0)
        exit(0)
    ans = 10**9
    for i in range(l,r+1):
        ans = min(ans,(i*(i+1))%MAX)
    
    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().strip().split(' '))
def inNLR(l,r,n):
  return (r-l+1) >= n or l%n >= r%n

if inNLR(L,R,2019):
  print(0)
elif inNLR(L,R,3) and inNLR(L,R,673):
  print(0)
else:
  print(min((L*(L+1))%2019, R*(R-1)%2019, (R*L)%2019))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())

a = R//2019*2019
if L <= a <= R:
  print((a * (a+1))%2019)
elif a < L:
  print((L * (L+1))%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L1 = L%2019
R1 = R%2019
L2 = L//2019
R2 = R//2019
ans = 2018
if L2 != R2:#LとRの間に0でなるとき
  ans = 0
else:
  for i in range(L+1,R):
    for j in range(i+1,R):
      x = (i*j)%2019
      ans = min(ans,x)
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
listA = []
if L<2019:
    for i in range(L,R):
        for j in range(R-L):
            listA.append(i * (L + j+1) % 2019)
    print(min(listA))
elif L>=2019 and L+2019>R:
    print(0)
else:
    R=L+2019
    for i in range(L,R):
        for j in range(R-L):
            listA.append(i * (L%2019 + j+1) % 2019)
    print(min(listA))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
a=l//2019
b=r//2019
c=l%2019
d=r%2019
if b-a>=1:
  print(0)
else :
  ml=(c*(c+1))%2019
  mr=(d*(d-1))%2019
  mrl=(c*d)%2019
  print(min(ml,mr,mrl))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())

# mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ


def get_ans():
    # mod後の最小値コンビを十分大きな値で初期化しておく
    nums = [2019, 2020]
    for n in range(L, R + 1):
        mod = n % 2019
        # 0が来た瞬間終了
        if mod == 0:
            return 0

        # 最小値コンビの内どっちかより小さいなら置き換える
        if nums[0] > mod:
            nums[0] = mod
        elif nums[1] > mod:
            nums[1] = mod

    # ループ終わったら最小値コンビの積のmodを取る
    return (nums[0] * nums[1]) % 2019


print(get_ans())

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())

ans = 2018

ml = l % 2019
mr = r % 2019

t = mr - ml

for i in range(t):
    for j in range(t - i):
        p = ((ml + i) * (ml + j + 1)) % 2019
        if p < ans:
            ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
l, r = list(map(int, input().split()))

ans = []
flag = 0
ll = []

for i in range(l, r+1):
    ll.append(i%2019)
aa = min(ll)
ans.append(aa)
ll.remove(aa)
aaa = min(ll)
ans.append(aaa)

print(ans[0]*ans[1])

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
l,r = map(int,input().split(" "))

if r-l > 2019:
    print(0)
else:
    l2r = [[e%2019,e] for e in list(range(l,r+1,1))]
    if r-l > 2:
        if min([e%637 for e in list(range(l,r+1,1))]) == 0:
            print(0)
        else:
            l2r.sort(key=itemgetter(0))
            print((l2r[0][1] * l2r[1][1])%2019)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

str = [int(i) for i in input().split()]
l, r = str

if l == 2019:
    print(0)
elif l < 2019 and r >= 2019:
    print(0)
elif r - l >= 2019:
    print(0)
elif l >= 2019:
    print((l * (l+1)) % 2019)
elif l * r < 2019:
    print(l * (l + 1))
else:
    s = 2020
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            print(i, j)
            if (i * j) % 2019 < s:
                s = (i * j) % 2019
    print(s)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
target = 2019
L_mod = L % target
R_mod = R % target
#print(L_mod,'L',R_mod,'R')
if L_mod > R_mod:
    print(0)
    exit(0)
if L_mod == R_mod and L < R:
    print(0)
    exit(0)
if L_mod == R_mod:
    print(L_mod)
    exit(0)
if L+1 == R:
    print(L * R % target)
    exit(0)
if L_mod < R_mod and R-L >= target:
    print(0)
    exit(0)

ans = 2019
for i in range(R_mod-L_mod):
    for j in range(R_mod-L_mod):
        if ((L+i) * (L+j)) % target < ans:
            #print(L+i,'Li')
            #print(L+j,'Lj')
            ans = ((L+i) * (L+j)) % target
print(ans)

'''
2020 3000
2020 4040
2018 4040
2018 2020
'''

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    ans = []
    for i in range(len(candidate)):
        for j in range(len(candidate)):
            if i == j:
                continue
            else:
                ans.append((candidate[i] * candidate[j]) % 2019)
    print(ans[0])

Submission status: Wrong Answer

Solution code:
l, r = [int(s) for s in input().split(" ")]

m = l * (l + 1) // 2019

print("%d" % m)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
ans=2019
y=r
while l<r:
  while l<y:
    x=l*y
    x=x%2019
    if x<ans:
      ans=x
    y=y-1
  l=l+1
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = list(map(int, input().split()))

x = range(L, R + 1)

a = False
b = False
for i in range(len(x)):
  if x[i] % 3 == 0:
    a = True
  if x[i] % 673 == 0:
    b = True
  if a and b:
    print(0)
    break

print(x[0] * x[1] % 2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
width = R-L

answer = 2019
if L%2019 + width >= 2019:
  answer = 0
else:
  for i in (L%2019,R%2019):
      for j in range(i+1,R%2019+1):
          answer = (i*j)%2019 if (i*j)%2019 < answer else answer
print(answer)

Submission status: Wrong Answer

Solution code:
L, R = [int(i) for i in input().split()]
tmp = 2018
diff = R-L
for i in range(diff):
    ii = L+i
    for j in range(diff-i):
#         ii = L+i
        jj = R-j
        mod = ii*jj%2019
        print(ii, jj, mod)
        if tmp>mod:
            tmp=mod
print(tmp)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if L == R:
    tmp = L % MOD
    print(tmp*tmp)
else:
    a = np.array(range(L, R+1)) % MOD
    b = np.sort(a,kind='quicksort')
    print(b[0]*b[1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

while L >= 2019:
    L -= 2019
while (R >= 2019) and (R-2019 >= L):
    R -= 2019
    
output = 10**8
for i in range(R-L):
    i += L
    for j in range(R-i):
        j += i+1
        #print(i, j)
        output = min(output, (i*j) % 2019)

print(output)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
a=L-1//2019
b=L%2019
c=R//2019
d=R%2019
if a!=c:
  print("0")
else:
  if b>=d:
    d=d+2019
  f=(b*d)%2019
  for i in range(b,d):
    for j in range(i+1,d+1):
      e=(i*j)%2019
      if e<f:
        f=e
      j=j+1
    i=i+1
  print(f)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())

mod_arr = []

i = l-1
j = l
while i < r:
  i += 1
  while j <= r:
    if i < j:
      mod = (i * j) % 2019
      mod_arr.append(mod)
    j += 1
    if j == 0:
      j = i

print(min(mod_arr))

Submission status: Wrong Answer

Solution code:
import sys

n, r = map(int, input().split())
min = 2019
if abs(n - r) == 1:
  print((n * r) % 2019)
  sys.exit(0)
for i in range(n, r):
  for j in range(i+1, r):
    if ((i * j) % 2019) < min:
      min = (i * j) % 2019
print(min)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())



#print(L%2019, R%2019)

#print((L + 2019 - L%2019))

tmp = 0

if L * R < 2019:
	i = L
	j = R

elif (L + 2019 - L%2019) + 1 <= R:
	if L < L + 2019 - L % 2019 and L + 2019 - L % 2019 + 1 < R:
		i =  L + 2019 - L % 2019
		j = i+1

elif L % 2019 < R % 2019:
	i = L
	j = i+1

elif R % 2019 > L % 2019:
	j = R
	i = j-1

else:
	i = L
	j = R


ans = i * j % 2019

print(ans)

Submission status: Wrong Answer

Solution code:
input_arr = [int(x) for x in input().split()]
 
L = input_arr[0]
R = input_arr[1]
 
min_ans = 10**9
for i in range(L,R):
    for j in range(i+1,R):
        ans = (i*j)%2019
        if ans < min_ans:
            min_ans = ans
print(min_ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

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

i_mod = 2020
i = L

for x in range(L, min((R+1, L+2019))):
    if x % 2019 < i_mod:
        i = x
        i_mod = x % 2019
if i_mod == 0:
    ans = 0
else:
    if i == R:
        j_mod = min((L % 2019, (i-1) %2019))
    else:
        j_mod = (i + 1) % 2019
    ans = (i_mod * j_mod) % 2019
print(ans)

Submission status: Wrong Answer

Solution code:
import math
l,r=map(int,input().split())
a=l%2019
b=r%2019
if l-r>=2018:
    print(0)
elif b-a<=0:
    print(0)
elif (a<=672)&(b>=673):
    print(0)
elif(a<=673)&(b>=675):
    print(0)
elif (a<=1345)&(b>=1346):
    print(0)
elif(a<=1346)&(b>=1348):
    print(0)
elif a<=20&b>=101:
    print(1)
else:
    ans=2018
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            print(i,j)
            ans=min(ans,i*j%2019)
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    l, r = map(int, input().split(' '))
    if (r - l) >= 2019:
        ans = 0
    else:
        while l > 2019:
            l %= 2019
        while r > 2019:
            r %= 2019
        ans = 0 if l >= r else (l * (l + 1)) % 2019
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
MAX=2019
def resolve():
    l,r = map(int,input().split())
    if abs(l-r)>=(MAX-1):
        print(0)
        exit(0)
    ans = 10**9
    for i in range(l,r+1):
        ans = min(ans,(i*(i+1)%MAX))
    
    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
ans = 2020

l = l % 2019
r = r % 2019
if l > r:
    r , l = l, r

for i in range(l, r):
    for j in range(i+1, r + 1):
        ans = min(ans, (i * j) % 2019)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

n1, n2 = [int(i) for i in input().split()]

r1 = 2018

if (n2 - n1) >= 4038:
    print(1)
    sys.exit()
elif n2 - n1 >= 2019:
    nt1 = n1 % 2019
    if nt1 + (n2 - n1 + 1) > 2019 or nt1 == 1:
        print(1)
        sys.exit()


for i3 in range(n2 - n1):
    n4 = i3 + n1

    t1 = n2 - n4
    if t1 >= 2019:
        t1 = 2019
    for i5 in range(t1):
        n5 = i5 + n4 + 1

        if ((n4 * n5) % 2019)  < r1:
            r1 = ((n4 * n5) % 2019)

print(r1)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())

mod = 2019

l %= mod
r %= mod

if r <= l:
    r += 2019

ans = 10**9 + 1
for i in range(l, r+1):
    for j in range(i+1, r+1):
        if ans > ((i*j)%mod):
            ans = (i*j)%mod

print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())

if (r-l)>=2019:
    print(0)
else:
    l %= 2019
    r %= 2019

    min = 2020
    for i in range(l, r):
        for j in range(i+1, r+1):
            if (i*j)%2019 < min:
                min = (i*j)%2019


print(min)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, a = map(int, input().split())

    if n % 2019 == 0 or a % 2019 == 0:
        print(0)

    elif n < 2019 and a < 2019:
        print((n * a) % 2019)

    elif 2019 < n and 2019 < a:
        print((n % 2019) * ((n+1) % 2019))

Submission status: Wrong Answer

Solution code:
x, y = input().split()
L = int(x)
R = int(y)

list2019 = []
for i in range(5000000):
    list2019.append(2019*i)

answer = (L * (L + 1)) % 2019
for l2019 in list2019:
    if L <= l2019 and l2019 <= R:
        answer = 0
if L <= 3 and 673 <= R:
    answer = 0
print(answer)

Submission status: Wrong Answer

Solution code:
L, R = [int(x) for x in input().split()]

a = L%2019
b = R%2019

if R-L >= 2018:
	print(0)
elif ((L//2019) + 1)*2019 <= R:
	print(0)
else:
	print((a*(a+1))%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().strip().split(' '))
def inNLR(l,r,n):
  return (r-l+1) >= n or l%n >= r%2019

if inNLR(L,R,2019):
  print(0)
elif inNLR(L,R,3) and inNLR(L,R,673):
  print(0)
else:
  print(min((L*(L+1))%2019, R*(R-1)%2019, (R*L)%2019))

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
ans = 1000000
for i in range(2100):
    for j in range(2100):
        if i < j and L + i < R:
            tmp = ((L+i) * (L+i+1)) % 2019
            ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())

if r//673-l//673>0 and r//3-l//3>0:
    print(0)

else:
    res=float('inf')
    for i in range(l,l+2019):
        ed=min(r-l+2019,2019+i)
        for j in range(i+1,ed):
            res=min((i*j)%2019,res)
    print(res)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
b = []
d = [a[0]%10000,a[1]%10000]
e = sorted(d)

for i in range(d[0],d[1]+1):
  for j in range(d[0],i):
    c = (i*j)%2019
    b.append(c)
else:
  print(b)

Submission status: Wrong Answer

Solution code:
L, R = (int(i) for i in input().split())

if R == 2019:
    print(0)
    exit()

if R < 2019:
    print(L)
    exit()

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
la=l%2019
ra=r%2019
if la==0:
    print(0)
elif la+(r-l)>=2019:
    print(0)
else:
    ans=min(la*(la+1)%2019,ra*(ra-1)%2019)
    print(ans)

Submission status: Wrong Answer

Solution code:
l,n = map(int,input().split())

ans = 2018
x = 2018
x_min = 2018
if l - n >= 673:
    ans = 0
elif l - n > 2:
    for i in range(l,n):
        x = i % 673
        if x == 0:
            ans = 0
        else:
            x = i % 2019
            if x < x_min:
                x_min = x
            ans = x*(x+1)%2019
else:
    for i in range(l,n):
        for j in range(l,n):
            ansss = i*j%2019
            if ansss < ans:
                ans = ansss

print(ans)

Submission status: Wrong Answer

Solution code:
l,r = list(map(int,input().split()))
f = [0]*2020
x = []
if r-l == 1:
    print(((r%2019)*(l%2019))%2019)
    exit()
for i in range(l,r+1):
    n = i%2019
    if f[n] == 0:
        x.append(n)
        f[n] = 1
    else:
        break
x.sort()

print(x[0]*x[1])

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())

a = 2020

for i in range(L, R):
    for j in range(i+1,R):
        t = (i * j) % 2019
        if t < a:
            a = t

print(a)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
left = L%2019
right = R%2019
if left > right:
    print(0)
else:
    left = min(L%2019, R%2019)
    right = max(L%2019, R%2019)
    l = [i for i in range(left, right+1)]
    ans = 9999
    for i in range(len(l)-1):
        for j in range(i+1, len(l)):
            mo = l[i]*l[j]%2019
            if mo<ans:
                ans = mo
    print(ans)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
ans = 0
dis_modL = min(abs(2019 - L%2019),L%2019)
dis_modR = min(abs(2019 - R%2019),R%2019)
if(dis_modL < dis_modR):
    ans = (L+1)%2019 * L%2019
elif(dis_modL == dis_modR):
    ans = L%2019 * R%2019
elif(dis_modL > dis_modR):
    ans = (R-1)%2019 * R%2019

if((R - L) >= 2019):
    ans = 0
else:
    for i in range(L,R+1):
        if(i%2019 == 0):
            ans = 0
        
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
L,R = map(int, input().split())
if R - L >= 2019:
        print(0)
        exit()
if (R - 1) * R < 2019:
        print(L * R)
        exit()


if L % 2019 == 0 or R % 2019 == 0:
        print(0)
        exit()
else:
        li = range(L, R)
        cmb = list(itertools.combinations(li,2))
        ans = 2018*2017
        for i,j in cmb:
                ans = min(ans, (i*j) % 2019)
        print(ans)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
 
ans = 2019
m = []
for i in range(L,R+1):
	m.append(i%2019)
 
for i in range(len(m)-1):
	tmp = (m[i]*m[i+1])%2019
	if ans> tmp:
		ans = tmp
print(ans)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
x = L // 2019
y = R // 2019
if y-x>0:
    min=0
else:
    min = L % 2019
    min = min*(min+1)
print(min)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
div_number = 2019
if l <= div_number:
    l = l%div_number
if r <= div_number:
    r = r%div_number

min_value = div_number
for i in range(r-l):
    for j in range(r-l-i):
        hoge = ((l + i) * (r - j)) % div_number
        if hoge != 0 and min_value > hoge:
            min_value = hoge
print(min_value)

Submission status: Wrong Answer

Solution code:
import numpy as np

L, R = [int(i) for i in input().split()]

if R - L > 2019:
  print(0)
else:
  arr = np.array(range(L, R + 1))
  l4min = sorted(arr % 2019)
  l4max = sorted(arr % 2019, reverse=True)
  a_1 = (l4min[0] * l4min[1]) % 2019
  a_2 = (l4max[0] * l4max[1]) % 2019
  a_3 = (l4max[0] * l4min[0]) % 2019
  l4mod3 = sorted(arr % 3)
  l4mod673 = sorted(arr % 673)
  a_4 = (l4mod3[0] * l4mod673[0]) % 2019
  print(min([a_1, a_2, a_3, a_4]))

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
gap = r-l

vlist = []

for x in range(gap+1):
    v = (l+x) % 2019
    vlist.append(v)

vlist.sort()
#print(vlist)

#res = i*j % 2019
print((vlist[0]*vlist[1])%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
mod = 2019
li = []
for i in range(L,R+1):
    li.append(i%mod)
li.sort()
print(li[0]*li[1])

Submission status: Wrong Answer

Solution code:
L, R = list(map(int, input().split()))

if R - L >= 2019: print(0)
else:
    a = 0
    for i in range(L, R + 1):
        if i % 2019 == 0:
            a = 1

    if a == 1: print(0)
    else:
        L %= 2019
        print((L * (L + 1)) % 2019)

Submission status: Wrong Answer

Solution code:
p=2019
l,r=map(int,input().split( ))
if l%p==0 or r%p==0 or (r-l) >= p:
	print(0)
else:
	x=r%p
	bb=r-x
	if bb>=l:
		print(0)
	else:
		a,b=l,l+1
		print(((a%p)*(b%p))%p)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())

tmp = R - L + 1
if tmp >= 2019:
    print(0)
    exit()
else:
    start = L % 2019
    end = R % 2019
    candidate = []
    for i in range(start, end + 1):
        candidate.append(i % 2019)
    candidate.sort()
    ans = []
    for i in range(len(candidate)):
        if i == (len(candidate) - 1):
            continue
        for j in range(i + 1,len(candidate)):
            if i == j:
                continue
            else:
                ans.append((candidate[i] * candidate[j]) % 2019)
    print(ans[0])

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
a = (l-1)//2019
b = r//2019
c = l%2019
d = (l+1)%2019
e = (c*d)%2019
if b-a>0:
    print(0)
else:
    print(e)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
l = l % 2019
r = r % 2019
if r < l:
    r += 2019

mind = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        mind = min(mind,(i*j)%2019)
print(mind)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
mod = []
count = 0
for x in range(L, R+1):
    mod.append(int(x % 2019)) 
    count += 1
    if count > 2019:
        break
print(mod[0]*mod[1])

Submission status: Wrong Answer

Solution code:
def main():
    l,r = map(int,input().split(' '))
    tmp = 2019
    if l//2019 < r//2019:
        print(0)
    else:
        for i in range(l,r):
            for j in range(i+1,r+1):
                if tmp > (i*r)%2019:
                    tmp = (i*r)%2019
        print(tmp)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
L,R=map(int, input().split())
n=R-L
ans=[]

for i in range(n+1):
    l=L+i
    ans.append(l % 2019)

a=sorted(ans)
print(a[0]*a[1])

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

str = [int(i) for i in input().split()]
l, r = str

if l == 2019:
    print(0)
elif l < 2019 and r >= 2019:
    print(0)
elif r - l >= 2019:
    print(0)
elif l * r < 2019:
    print(l * (l + 1))
else:
    s = 2020
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            print(i, j)
            if (i * j) % 2019 < s:
                s = (i * j) % 2019
    print(s)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())


if l*r < 2019:
    print(l*r)
else:
    #1項
    mod1 = (l**2)%2019
    #2項
    mod2_min = 10000000
    for i in range(1,r-l+1):
        mod2 = i%2019
        if mod2 < mod2_min:
            mod2_min = mod2
    print(mod1+mod2_min)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
lmod=l%2019
rmod=r%2019
take=min(lmod,rmod)

if r-l>=2019:
  print(0)
elif take == lmod:
  print((l*(l+1))%2019)
else:
  print((r*(r-1))%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
m = L*(L+1) % 2019
print(m)