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:
import math

div1 = 3
div2 = 673

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

L %= 2019
R %= 2019

if L >= R:
    R += 2019

min_v = 2018

for i in range(L, R):
    for j in range(i + 1, R + 1):
        v = i * j % 2019
        if v == 0:
            print(v)
            exit()
        min_v = min(min_v, v)

print(min_v)

Submission status: Wrong Answer

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

count_limit = 0 # count limit is 2019
min_num = 2020
for i in range(L+1, R+1):
    min_num = min(min_num, (L*i)%2019)

    # limit process
    count_limit = count_limit + 1
    if count_limit>2019:
        break

print(min_num)

Submission status: Wrong Answer

Solution code:
ll, rr = map(int, input().split())
if rr - ll >= 2019:
    print(0)
    exit()

l = ll % 2019
r = rr % 2019

if l > r:
    print(0)
    exit()
print(l,r)
ans = 10**9
for i in range(l, r + 1):
    for j in range(i+1, r+1):
        x = (i * j) % 2019
        print(x)
        ans = min(x, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
ll, rr = map(int, input().split())
if rr - ll >= 2019:
    print(0)
    exit()
ans = 2020
l = ll % 2019
r = rr % 2019

if l > r:
    print(0)
    exit()

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

print(ans)

Submission status: Wrong Answer

Solution code:
ll, rr = map(int, input().split())
if rr - ll >= 2019:
    print(0)
    exit()
ans = 2020
l = ll % 2019
r = rr % 2019
if l > r:
    print(0)
else:
    print(l * (l+1) % 2019)

Submission status: Wrong Answer

Solution code:
ll, rr = map(int, input().split())
if ll - rr > 2019:
    print(0)
    exit()
ans = 2020
l = ll % 2019
r = rr % 2019
if l > r:
    print(0)
else:
    print(l * (l+1) % 2019)

Submission status: Wrong Answer

Solution code:
ll, rr = map(int, input().split())
ans = 2020
l = ll % 2019
r = rr % 2019
if l > r:
    print(0)
else:
    print(l * (l+1) % 2019)

Submission status: Wrong Answer

Solution code:
ll, rr = map(int, input().split())
ans = 2020
l = ll % 2019
r = rr % 2019
if l > r:
    print(0)
else:
    print(l * (l+1))

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
ans = 2020
for i in range(1, min(r-l+1, r+2019)):
    x = (l * (l + i)) % 2019
    ans = min(x, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
ans = 2020
for i in range(1, min(r-l+1, r+2019)):
    x = (l * (l + i)) % 2019
    print(x)
    ans = min(x, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if l-r+1 >= 2019:
    print(0)
else:
    l %= 2019
    r %= 2019
    if l <= r:
        ans = float('inf')
        for i in range(l, r):
            for j in range(i+1, r+1):
                ans = min(ans, (i*j)%2019)
    else:
        ans = 0
    print(ans)

Submission status: Wrong Answer

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

LENGTH = (R-L+1) / MOD
if LENGTH < 1:
    ans = float("inf")
    for i in range(L, R):
        for j in range(i+1, R+1):
            answer = min(ans, (i * j) % MOD)
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
mod=2019
ans=0
if r-l+1>=2019 or r%mod<l%mod:
    ans=0
else:
    for i in range(l%mod,r%mod):
        for j in range(i+1,r%mod+1):
            temp=(i*j)%mod
            ans=max(ans,temp)
print(ans)

Submission status: Wrong Answer

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

l %= 2019
r %= 2019

L = min(l,r)
R = max(l,r)

a = 201900000
# print(L,R)
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a = min(a,(i*j)%2019)
if r-l > 2018:
    a= 0

print(a)

Submission status: Wrong Answer

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

sub = R - L + 1

ans = 0
if sub < MOD * 2:
    cnt = [0] * MOD
    for i in range(L,R+1):
        cnt[i % MOD] += 1
    tmp = []
    for i in range(MOD):
        if cnt[i] == 0:
            continue
        while cnt[i]:
            tmp.append(i)
            cnt[i] -= 1
        if len(tmp) >= 2:
            break
    ans = tmp[0] * tmp[1]
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

l %= 2019
r %= 2019

L = min(l,r)
R = max(l,r)

a = 2019
# print(L,R)
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a = min(a,(i*j)%2019)
if r-l > 2018:
    a= 0

print(a)

Submission status: Wrong Answer

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

l %= 2019
r %= 2019

L = min(l,r)
R = max(l,r)

a = 2019
# print(L,R)
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a = min(a,(i*j)%2019)
if r-a > 2018:
    a= 0

print(a)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
mod=2019
if r-l+1>=2019 or r%mod<l%mod:
    ans=0
else:
    ans=l*(l+1)%mod
print(ans)

Submission status: Wrong Answer

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

l %= 2019
r %= 2019

L = min(l,r)
R = max(l,r)

a = 2019
# print(L,R)
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a = min(a,(i*j)%2019)
        if a == 0:
            print(0)
            exit()
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l %= 2019
r %= 2019

L = min(l,r)
R = max(l,r)

a = 2019
# print(L,R)
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a = min(a,(i*j)%2019)
print(a)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
min_score = 2019
for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    if (i * j) % 2019 == 0:
      print(0)
    elif (i * j) % 2019 < min_score:
      min_score = (i * j) % 2019
print(min_score)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
x = l % 2019
y = r % 2019
if x > y:
    y += 2019
ans = 10 ** 7
for i in range(x, y + 1):
    for j in range(x, y + 1):
        if ans > (i * j) % 2019 and i != j:
            ans = (i * j) % 2019
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if R - L >= 2018:
    print(0)
else:
    min = 2020
    for i in range(L,R):
        for j in range(i+1,R+1):
            mod = i * j % 2019
            if mod <= min:
                min = mod

print(min)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())

A = []

for i in range(a, b+1):
    A.append(i%2019)

A = sorted(A)

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

Submission status: Wrong Answer

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

if (R-L) > 2018:
    print(0)
else:
    if L%2019 > R%2019:
        print(0)
    else:
        print(min(L*(L+1)%2019, (R-1)*R%2019))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
i,j=map(int,input().split())
if j-i>=2019:
  print(0)
elif j%2019<i%2019:
  print(0)
else:
  min=2018
  for p in range(i,j):
    for q in range(p,j+1):
      if ((p%2019)*(q%2019))%2019<min:
        min=((p%2019)*(q%2019))%2019
  print(min)

Submission status: Wrong Answer

Solution code:
i,j=map(int,input().split())
if j-i>=2019:
  print(0)
elif j%2019<i%2019:
  print(0)
else:
  print(((i%2019)*((i+1)%2019))%2019)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mn = 2018
if r >= 2019:
    mn = 0
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            mn = min(mn,i*j % 2019)
print(mn)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mn = 2018
if l >= 2019:
    mn = 0
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            mn = min(mn,i*j % 2019)
print(mn)

Submission status: Wrong Answer

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

minimum = 2020

R = min(R,2020)

for i in range(L,R-1):
    for j in range(i+1,R):
        mod = (i*j)%2019
        if minimum > mod:
            minimum = mod
print(minimum)

Submission status: Wrong Answer

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

minimum = 2020

R = min(R,2020)

for i in range(L,R):
    for j in range(i+1,R-1):
        mod = (i*j)%2019
        if minimum > mod:
            minimum = mod
print(minimum)

Submission status: Wrong Answer

Solution code:
import sys
L, R = map(int, input().split())
if R-L > 2017: print(0); sys.exit()

DL = L % 2019
DR = R % 2019
if DL > DR: print(0); sys.exit()

print(L*(L+1)%2019)

Submission status: Wrong Answer

Solution code:
import sys
L, R = map(int, input().split())
if R-L > 2017: print(0); sys.exit()

DL = L % 2019
DR = R % 2019
if DL > DR: print(0); sys.exit()

print(DL*(DL+1)%2019)

Submission status: Wrong Answer

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

if r-l > 2017:
    print(0)
else:
    d,e = map(lambda x: x%2019, (l,r))
    
    if d < e:
        print(d * (d+1))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
d,e = map(lambda x: x%2019, (l,r))

if r-l > 2018:
    print(0)
else:
    print((d*(d+1))%2019) if d < e else print(0)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
d,e = map(lambda x: x%2019, (l,r))
print((d*(d+1))%2019) if d < e else print(0)

Submission status: Wrong Answer

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


la = l%2019
ra = r%2019

if la == 0 or ra == 0 or ra <= la:
    print(0)
else:
    print(l*(l+1)%2019)

Submission status: Wrong Answer

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

ans = 0

if L == 0:
  ans = 0
elif (L+2018)//2019 < (R+2018)//2019:
  ans = 0
elif (L+672)//673 < (R+672)//673 and (L+2)//3 < (R+2)//3:
  ans = 0
else:
  ans = L%2019 * (L+1)%2019

print(ans)

Submission status: Wrong Answer

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

ans = 0

if L == 0:
  ans = 0
elif L//2019 < R//2019:
  ans = 0
elif L%2019 == 0 or R%2019 == 0:
  ans = 0
elif L//673 < R//673 and L//3 < R//3:
  ans = 0
else:
  ans = L%2019 * (L+1)%2019

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 2019
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

l,r =mii()
l,r=l%2019,r%2019
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

l,r=min(l,r),max(l,r)

print(l*(l+1)%mod)

Submission status: Wrong Answer

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

ans = 0

if L == 0:
  ans = 0
elif L//div < R//div:
  ans = 0
elif L%div == 0 or R%div == 0:
  ans = 0
else:
  ans = L%div * (L+1)%div

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L_mod = L % 2019
R_mod = R % 2019

if R - L >= 2019:
    Ans = 0
elif R_mod < L_mod:
    Ans = 0
elif R_mod > L_mod:
    Ans = 2019
    for i in range(L_mod, R_mod):
        Ans = min(Ans,i*(i+1) % 2019)
        
print(Ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
L_mod = L % 2019
R_mod = R % 2019

if R - L >= 2019:
    Ans = 0
elif R_mod < L_mod:
    Ans = 0
elif R_mod > L_mod:
    Ans = ((L_mod+1)*L_mod) % 2019
    
print(Ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
result = 10 ** 9
if r-l == 1:
  print((l * r) % 2019)
else:
  r = min(r, l + 2019)
  for i in range(l, r+1):
    for j in range(l, r+1):
      if i < j:
        result = min(result, (i*j)%2019)
        
print(result)

Submission status: Wrong Answer

Solution code:
L, R = [int(i) for i in input().split()]
a = [9999999999999999, 99999999999999999]
for i in range(L, R+1):
    a = sorted([a[0], a[1], i % 2019])
    if not a[0]:
        break
print(a[0]*a[1])

Submission status: Wrong Answer

Solution code:
L, R = [int(i) for i in input().split()]
a = []
for i in range(L, R+1):
    a.append(i % 2019)
    if i > L and i % 2019 == a[0]:
        break
a.sort()
if a[0]:
    print((a[0]*a[1]) % 2019)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def main():
  import itertools
  
  L,R=map(int,input().split())
  x,y=L//2019,R//2019
  if y-x>=1:
    print(0)
  else:
    i=L
    ans=float("inf")
    while(i+1<=R):
      ans=min(ans,i*(i+1)%2019)
      if ans==0:
        print(0)
        break
      i+=1
    else:
      print(ans)
  
if __name__=="__main__":
  main()

Submission status: Wrong Answer

Solution code:
def main():
  import itertools
  
  L,R=map(int,input().split())
  x,y=L//2019,R//2019
  if y-x>=1:
    print(0)
  else:
    print(L*(L+1)%2019)
  
if __name__=="__main__":
  main()

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l>2019:
    print(0)
    exit()

ans=int(10000000)
for i in range(l,r):
    for j in range(i+1,r+1):
        if ans>i*j:
            ans=i*j

print(ans)

Submission status: Wrong Answer

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

min_mod=2018
if r-l>=3000: print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            min_mod = min(min_mod, (i*j)%2019)
print(min_mod)

Submission status: Wrong Answer

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

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

else:
    l %= 2019
    r %= 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            i %= 2019
            j %= 2019
            answer = (i*j)%2019
            minimum = min(answer, minimum)

print(minimum)

Submission status: Wrong Answer

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

if r-l>=2018:
    print(0)

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

Submission status: Wrong Answer

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

if r-l>=2018:
    print(0)

else:
    l %= 2019
    r %= 2019
    if r<l:
        print(0)
    else:
        print(l*(l+1)%2019)

Submission status: Wrong Answer

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

if r-l>=2018:
    print(0)

else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            i %= 2019
            j %= 2019
            answer = (i*j)%2019
            if answer<minimum:
                minimum = answer

print(minimum)

Submission status: Wrong Answer

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

if r-l>=2018:
    print(0)

else:
    l %= 2019
    r %= 2019
    l,r = sorted([l,r])

    remainder1 = l
    remainder2 = l+1
    minimum = remainder1*remainder2%2019

    print(minimum)

Submission status: Wrong Answer

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

if r-l>=2018:
    print(0)

else:
    for i in range(l,r+1):
        remainder_lst.append(i%2019)

    remainder_lst.sort()
    minimum = remainder_lst[0]*remainder_lst[1]%2019
    print(minimum)

Submission status: Wrong Answer

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

if r-l>=2019:
    print(1)

else:
    for i in range(l,r+1):
        remainder_lst.append(i%2019)
    
    remainder_lst.sort()
    minimum = remainder_lst[0]*remainder_lst[1]%2019
    print(minimum)

Submission status: Wrong Answer

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

for i in range(l,r+1):
    remainder_lst.append(i%2019)

remainder_lst.sort()
minimum = remainder_lst[0]*remainder_lst[1]%2019

print(minimum)

Submission status: Wrong Answer

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

for i in range(l,r+1):
    remainder_lst.append(i%2019)

remainder_lst.sort()
minimum = remainder_lst[0]*remainder_lst[1]

print(minimum)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
MOD=2019
x=dict()
ans=2*(10**10)
flag=True
for i in range(L,R):
    for j in range(i+1,R+1):
        a=i*j
        t=a%MOD
        if t==0:
            flag=False
            break
        ans=min(ans,t)

    if not flag:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
MOD=2019
x=dict()
ans=2*(10**10)
flag=True
for i in range(L,R):
    for j in range(i+1,R+1):
        a=i*j
        t=a%MOD
        if t in x:
            flag=False
            break
        else:
            x[t]=1
            ans=min(ans,t)
    if not flag:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
MOD=2019
x=dict()
ans=2*(10**9)
flag=True
for i in range(L,R):
    for j in range(i+1,R+1):
        a=i*j
        t=a%MOD
        if t in x:
            flag=False
            break
        else:
            x[t]=1
            ans=min(ans,t)
    if not flag:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
ls=[]
LS=[]
if L-R>=672 or L==0:
  print(0)
else:
  ans=2019
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      if i>=j:
        print(ans)
        exit()
      x=(i*j)%2019
      ans=min(x,ans)

Submission status: Wrong Answer

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

num = R - L - 1

if R - L == 1:
    print(R*L % 2019)

else:
    print((R-num)*L % 2019)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L, R = MAP()

if R < 2019:
	re = L//2019
	li = [i for i in range(L%2019, (R + 1)%2019)]
	co = list(combinations(li, 2))
	mi = INF
	for x in co:
		mi = min(mi, (x[0]+(re*2019))*(x[1]+(re*2019))%2019)
	print(mi)
	exit()
if R == 2019:
	print(0)
	exit()
if R > 2019:
	if R - L < 2019:
		re = L//2019
		li = [i for i in range(L%2019, (R + 1)%2019)]
		co = list(combinations(li, 2))
		mi = INF
		for x in co:
			mi = min(mi, (x[0]+(re*2019))*(x[1]+(re*2019))%2019)
		print(mi)
		exit()
	else:
		print(0)
		exit()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L, R = MAP()

if R < 2019:
	l = L//2019
	r = R//2019
	li = [i for i in range(L%2019, (R + 1)%2019)]
	co = list(combinations(li, 2))
	mi = INF
	for x in co:
		mi = min(mi, (x[0]+(l*2019))*(x[1]+(r*2019))%2019)
	print(mi)
	exit()
if R == 2019:
	print(0)
	exit()
if R > 2019:
	if L%2019 < R%2019:
		l = L//2019
		r = R//2019
		li = [i for i in range(L%2019, (R + 1)%2019)]
		co = list(combinations(li, 2))
		mi = INF
		for x in co:
			mi = min(mi, (x[0]+(l*2019))*(x[1]+(r*2019))%2019)
		print(mi)
		exit()
	else:
		print(0)
		exit()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L, R = MAP()

if R < 2019:
	re = L//2019
	li = [i for i in range(L%2019, (R + 1)%2019)]
	co = list(combinations(li, 2))
	mi = INF
	for x in co:
		mi = min(mi, (x[0]+(re*2019))*(x[1]+(re*2019))%2019)
	print(mi)
	exit()
if R == 2019:
	print(0)
	exit()
if R > 2019:
	if L%2019 < R%2019:
		re = L//2019
		li = [i for i in range(L%2019, (R + 1)%2019)]
		co = list(combinations(li, 2))
		mi = INF
		for x in co:
			mi = min(mi, (x[0]+(re*2019))*(x[1]+(re*2019))%2019)
		print(mi)
		exit()
	else:
		print(0)
		exit()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L, R = MAP()

if R < 2019:
	re = L//2019
	li = [i for i in range(L%2019, (R + 1)%2019)]
	co = list(combinations(li, 2))
	mi = INF
	for x in co:
		mi = min(mi, (x[0]*re)*(x[1]*re)%2019)
	print(mi)
	exit()
if R == 2019:
	print(0)
	exit()
if R > 2019:
	if L%2019 < R%2019:
		re = L//2019
		li = [i for i in range(L%2019, (R + 1)%2019)]
		co = list(combinations(li, 2))
		mi = INF
		for x in co:
			mi = min(mi, (x[0]*re)*(x[1]*re)%2019)
		print(mi)
		exit()
	else:
		print(0)
		exit()

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L, R = MAP()

if R < 2019:
	li = [i for i in range(L, R + 1)]
	co = list(combinations(li, 2))
	mi = INF
	for x in co:
		mi = min(mi, (x[0]%2019)*(x[1]%2019))
	print(mi)
	exit()
if R == 2019:
	print(0)
	exit()
if R > 2019:
	if L%2019 < R%2019:
		li = [i for i in range(L%2019, (R + 1)%2019)]
		co = list(combinations(li, 2))
		mi = INF
		for x in co:
			mi = min(mi, (x[0])*(x[1]))
		print(mi)
		exit()
	else:
		print(0)
		exit()

Submission status: Wrong Answer

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

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

if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

if l == 0:
    print('0')
else:
    min_num = 2020
    for left in range(l, r):
        for right in range(left+1, r+1):
            mod = (left * right) % 2019
            min_num = min(min_num, mod)
        if min_num == 1:
            break
    print(min_num)

Submission status: Wrong Answer

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

if l == 0:
    print('0')
elif (r % 2019 == 0) or (l % 2019 == 0) or (r-l >= 2019):
    print('1')
else:
    min_num = 2020
    for left in range(l, r):
        for right in range(left+1, r+1):
            mod = (left * right) % 2019
            min_num = min(min_num, mod)
    print(min_num)

Submission status: Wrong Answer

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

if (r % 2019 == 0) or (l % 2019 == 0) or (r-l >= 2019):
    print('1')
elif l == 0:
    print('0')
else:
    min_num = 2020
    for left in range(l, r):
        for right in range(left+1, r+1):
            mod = (left * right) % 2019
            min_num = min(min_num, mod)
    print(min_num)

Submission status: Wrong Answer

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

if (r % 2019 == 0) or (l % 2019 == 0) or (r-l >= 2019):
    print('1')
else:
    min_num = 2020
    for left in range(l, r):
        for right in range(left+1, r+1):
            mod = (left * right) % 2019
            min_num = min(min_num, mod)
    print(min_num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
s=[]
for i in range(l,min(l+2020,r+1)):
  s.append(i%2019)
s.sort()
print(s[0]*s[1])

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
count=0
for i in range(l,min(r+1,l+2020)):
  if i%2019==0:
    count+=1
if count>0:
  print(0)
else:
  print((l%2019)*((l+1)%2019))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
count=0
for i in range(l,min(r+1,l+2019)):
  if i%2019==0:
    count+=1
if count==1:
  print(0)
else:
  print((l%2019)*((l+1)%2019))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
s=[]
for i in range(l,min(l+4038,r+1)):
  s.append(i%2019)
s.sort()
print(s[0]*s[1])

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
s=[]
for i in range(l,min(l+2019,r+1)):
  s.append(i%2019)
s.sort()
print(s[0]*s[1])

Submission status: Wrong Answer

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

MOD = 2019

if R - L >= MOD or L%MOD == 0 or R%MOD == 0:
    print(0)
else:
    minimum = 2*10**9
    for i in range(L, R):
        minimum = min((i*(i+1))%MOD, minimum)
    print(minimum)

Submission status: Wrong Answer

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

MOD = 2019

if R - L >= MOD or L%MOD == 0 or R%MOD == 0:
    print(0)
else:
    minimum = MOD
    for i in range(L, R):
        minimum = min(i%MOD, minimum)
    print((minimum*(minimum+1))%MOD)

Submission status: Wrong Answer

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

MOD = 2019

if R - L >= MOD or L%MOD == 0 or R%MOD == 0:
    print(0)
else:
    minimum = MOD
    for i in range(L, R):
        minimum = min(i%MOD, minimum)
    print(minimum*(minimum+1))

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mod = 2019
r = (r%mod) + 2019*(r-l>=2019)
l = l%mod
ans = float("inf")
for i in range(l,r):
  for j in range(i+1,r+1):
    ans = (i*j)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mod = 2019
r = (r%mod) + 2019*(r-l>=2019)
l = l%mod
ans = float("inf")
for i in range(l,r+1):
  for j in range(i,r+1):
    ans = (i*j)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
L,R = [int(i) for i in input().split()]
l = L
r = R
L %=2019
R %=2019
if L>=R or (l<2019 and r>2019):
    print(0)
    exit()
else :
    if L<=3 and R>=673:
        print(0)
    else:
        print(L*(L+1))

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mn1 = 2020
mn2 = 2020
for i in range(l,r+1):
    if i%2019 < mn1:
        mn2 =mn1
        mn1 = i%2019
        if mn1==0:
            break
    elif i%2019 < mn2:
        mn2 = i%2019
print(mn1*mn2)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mn1 = 2019
mn2 = 2019
for i in range(l,r+1):
    if i%2019 <= mn1:
        mn2 =mn1
        mn1 = i%2019
        if mn1==0:
            break
    elif i%2019 <= mn2:
        mn2 = i%2019
print(mn1*mn2)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
mn1 = 2019
mn2 = 2020
for i in range(l,r+1):
    if i%2019 < mn1:
        mn2 =mn1
        mn1 = i%2019
    elif i%2019 <mn2:
        mn2 = i%2019
print(mn1*mn2)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
x=[]
flag_3=False
flag_673=False
if (r-l)>=2019:
    print(0)
else:
    for i in range(l,r+1):
        x.append(i%2019)
        if i%3==0:
            flag_3==True
        if i%673==0:
            flag_673==True
    x.sort()
    if flag_3 and flag_673:
        print(0)
    else:
        print(min(x[0]*x[1]%2019,x[r-l]*x[r-l-1]%2019))