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 collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(2021):
    l.append(L%2019)
    if L==R:
        break
    L+=1
ans=2019999
for i in range(len(l)):
    for j in range(len(l)-1):
        ans=min(l[i]*l[j]%2019,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(2021):
    l.append(L%2019)
    if L==R:
        break
    L+=1


l.sort()
print(l[0]*l[1]%2019)

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(2021):
    l.append(L%2019)
    if L==R:
        break
    L+=1


l.sort()
print(l[0]*l[1])

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(10000):
    l.append(L%2019)
    if L==R:
        break
    L+=1


l.sort()
print(l[0]*l[1])

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(2022):
    l.append(L%2019)
    if L==R:
        continue
    L+=1

sorted(l)
print(l[0]*l[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def abc133_c():
    L, R = map(int, input().split())
    ld, lm = divmod(L, 2019)
    rd, rm = divmod(R, 2019)
    # 区間内に2019の倍数が含まれる場合
    if ld < rd or lm == 0 or rm == 0: return 0
    # 673の倍数と3の倍数が含まれる場合
    ld2, lm2 = divmod(L, 673)
    rd2, rm2 = divmod(R, 673)
    ld3, lm3 = divmod(L, 3)
    rd3, rm3 = divmod(R, 3)
    if ld2 < rd2 or lm2 == 0 or rm2 == 0:
        if ld3 < rd3 or lm3 == 0 or rm3 == 0:
            return 0
    # そうでない場合
    ans = (L % 2019) * ((L+1) % 2019) % 2019
    return ans

print(abc133_c())

Submission status: Wrong Answer

Solution code:
def abc133_c():
    L, R = map(int, input().split())
    ld, lm = divmod(L, 2019)
    rd, rm = divmod(R, 2019)
    # 区間内に2019の倍数が含まれる場合
    if ld < rd or lm == 0 or rm == 0: return 0
    # 673の倍数と3の倍数が含まれる場合
    ld, lm = divmod(L, 673)
    rd, lm = divmod(R, 673)
    if ld < rd or lm == 0 or rm == 0:
        if R - L >= 3: return 0
    # そうでない場合
    ans = (L % 2019) * ((L+1) % 2019) % 2019
    return ans

print(abc133_c())

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
if L+1==R: print((L*R)%2019)
else:
    c=0
    while (c+1)*2019<R: c+=1
    if c*2019<L: print((L*(L+1))%2019)
    else: print(((c*2019)*((c*2019)+1))%2019)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
if L+1==R: print((L*R)%2019)
else:
    c=0
    while (c+1)*2019<R: c+=1
    if c*2019>L: print((L*(L+1))%2019)
    else: print(((c*2019)*((c*2019)+1))%2019)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
if L+1==R: print((L*R)%2019)
else:
    c=0
    while c*2019<R: c+=1
    if c*2019>L: print((L*(L+1))%2019)
    else: print(((c*2019)*((c*2019)+1))%2019)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
num2019 = r//2019 - l//2019
ans = 9999999999
if num2019>=1 or l == 0 or l%2019 ==0:
    ans = 0
else:
    modr = r%2019
    modl = l%2019
    for i in range(l,r):
        tmp = (i*(i+1))%2019
    ans = min(ans,tmp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def remainder_minimization(l, r):

    ans = 10**9

    for i in range(l, r):
        for w in range(i+1, r):
            ans = min(ans, (i*w)%2019)
        if ans == 0:
            break

    return ans

def main():
    l, r = map(int, input().split())
    print(remainder_minimization(l, r))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def remainder_minimization(l, r):

    ans = 10**9

    for i in range(l, r):
        ans = min(ans, (i*(i+1))%2019)
        if ans == 0:
            break

    return ans

def main():
    l, r = map(int, input().split())
    print(remainder_minimization(l, r))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def remainder_minimization(l, r):

    ans = 10**9

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

    return ans

def main():
    l, r = map(int, input().split())
    print(remainder_minimization(l, r))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def remainder_minimization(l, r):

    ans = 10**5

    for i in range(l, r):
        ans = min(ans, (i*(i+1))%2019)
        if ans == 0:
            break

    return ans

def main():
    l, r = map(int, input().split())
    print(remainder_minimization(l, r))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if r-l>=2018:
    print(0)
else:
    num_li = []
    for i in range(l,r+1):
        if i%mod in num_li:
            break
        heapq.heappush(num_li,i%mod)
    a = heapq.heappop(num_li)
    b = heapq.heappop(num_li)
    print(a*b)

Submission status: Wrong Answer

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

if r-l>=2018:
    print(0)
else:
    print(min(r%mod,l%mod)*(min(r%mod,l%mod)+1))

Submission status: Wrong Answer

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

num_li = sorted([i%mod for i in range(l,r+1)])
print(num_li[0]*num_li[1])

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
l, r = list(map(int, input().split()))
ml, mr = l % 2019, r % 2019
def inc_maltiple(a, b, n):
    if b < n: return False
    if a % n >= b % n or b - a >= n: return True
    return False
if ml < mr and (not inc_maltiple(ml, mr, 3) or not inc_maltiple(ml, mr, 673)):
    print(ml * (ml + 1))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
l, r = list(map(int, input().split()))
ml, mr = l % 2019, r % 2019
def inc_maltiple(a, b, n):
    if b < n: return False
    if a % n >= b % n: return True
    return False
if ml < mr and (not inc_maltiple(ml, mr, 3) or not inc_maltiple(ml, mr, 673)):
    print(ml * (ml + 1))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
l, r = list(map(int, input().split()))
ml, mr = l % 2019, r % 2019
if ml < mr:
    print(ml * (ml + 1))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
if r-l>=673:
    print(0)
elif r-l==2:
    print(min((l*r)%2019,(l+1*r)%2019),(l*l+1)%2019)
elif r-l==1:
    print(l*r%2019)
else:
    if r%2019<=r-l:
        print(0)
    else:
        s=list(range(l,r+1))
        for _ in range(len(s)):
            s[_]=s[_]%2019
        s.sort()
        print(s[0]*s[1]%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
a=[]
if r-l>=2020:
  print(0)
  exit(0)
for i in range(l,min(l+2020,r+1)):
  a.append(i%2019)
a.sort()
ans=10*18
for i in range(len(a)-1):
  for j in range(i+1,len(a)):
    t=(a[i]*a[j])%2019
    ans=min(ans,t)
print(ans)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
a=[]
for i in range(l,min(l+2020,r+1)):
  a.append(i%2019)
a.sort()
ans=10*18
for i in range(len(a)):
  for j in range(i+1,len(a)):
    t=(a[i]*a[j])%2019
    ans=min(ans,t)
print(ans)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
a=[]
for i in range(l,min(l+2020,r+1)):
  a.append(i)
a=set(a)
a=list(a)
a.sort()
ans=10*18
for i in range(len(a)):
  for j in range(i+1,len(a)):
    t=(a[i]*a[j])%2019
    ans=min(ans,t)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f(l,r):
    p=2019
    for i in range(l,r+1):
        for j in range(l,r+1):
            p=min((i*j)%2019,p)
    return p
    
l,r=map(int,input().split())
print(0 if r//2019-(l-1)//2019!=0 or (r//673-(l-1)//673!=0 and r//3-(l-1)//3!=0) else f(l,r))

Submission status: Wrong Answer

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

for i in range(L,R+1):
    i %= 2019
    for j in range(i+1,R+1):
        ans = min(ans,i*j%2019)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    L, R = [int(item) for item in input().split()]
    aL, bL = divmod(L, 2019)
    aR, bR = divmod(R, 2019)

    if bL == 0:
        res = 0
    elif aL < aR:
        res = 0
    elif aL == aR:
        res = 2019
        for i in range(bL,bR+1):
            for j in range(bL,bR+1):
                res = min(res, i*j%2019)

    print(res)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    l,r=pin()
    L=l%2019
    R=r%2019
    #print(L,R)
    if R-L>=2019:R+=2019


    t=20192019
    for i in range(L,R):
        for j in range(i+1,R+1):
            t=min(t,(i*j)%2019)
    print(t)
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    L, R = [int(item) for item in input().split()]
    aL, bL = divmod(L, 2019)
    aR, bR = divmod(R, 2019)

    if bL == 0:
        res = 0
    elif aL < aR:
        res = 0
    elif aL == aR:
        res = bL*(bL+1)
    
    print(res%2019)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

if L2 == 0 or R2 == 0:
    print(0)
    exit()

if L + 2019 < R:
    print(0)
    exit() 
 
length = abs(R2-L2+1)
ans = []
for i in range(length):
    if L2 < R2:
        k = (L2+i) % 2019
        ans.append(k)
    elif L2 > R2:
        k = (R2+i) % 2019
        ans.append(k)
 
list.sort(ans)
print(ans)
print((ans[0]*ans[1])%2019)

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    L, R = [int(item) for item in input().split()]
    aL, bL = divmod(L, 2019)
    aR, bR = divmod(R, 2019)

    if bL == 0:
        res = 0
    elif aL < aR:
        res = 0
    elif aL == aR:
        res = bL*(bL+1)
    
    print(res)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    L, R = [int(item) for item in input().split()]
    aL, bL = divmod(L, 2019)
    aR, bR = divmod(R, 2019)

    if aL < aR:
        res = 0
    elif aL == aR:
        res = bL*(bL+1)
    
    print(res)
    
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
n = []
i = 1
if l <= 2019 * (l//2019) <= r or l <= 2019 * (l//2019 + 1) <= r: print(0)
else:print(min((l*(l+1))%2019, (r*(r-1))%2019))

Submission status: Wrong Answer

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

L2 = L%2019
R2 = R%2019

length = abs(R2-L2+1)
ans = []
for i in range(length):
    if L2 < R2:
        k = (L2+i) % 2019
        ans.append(k)
    elif L2 > R2:
        k = (R2+i) % 2019
        ans.append(k)

list.sort(ans)
print((ans[0]*ans[1])%2019)

Submission status: Wrong Answer

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

L2 = L%2019
R2 = R%2019

length = abs(R2-L2+1)
ans = []
for i in range(length):
    if L2 < R2:
        k = (L2+i) % 2019
        ans.append(k)
    elif L2 > R2:
        k = (R2+i) % 2019
        ans.append(R2+i)

list.sort(ans)
print((ans[0]*ans[1])%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

L2 = L%2019
R2 = R%2019

length = abs(R2-L2+1)
ans = []
for i in range(length):
    if L2 < R2:
        ans.append(L2+i)
    elif L2 > R2:
        ans.append(R2+i)


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

L2 = L%2019
R2 = R%2019

length = abs(R-L+1)
ans = []
for i in range(length):
    if L2 < R2:
        ans.append(L2+i)
    elif L2 > R2:
        ans.append(R2+i)


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

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

l,r = iim()

if l//2019 != r//2019 or l%2019 == 0 or r%2019 == 0:
    print(0)
else:
    print((l%2019*((l+1)%2019))%2019)

Submission status: Wrong Answer

Solution code:
l,r = map(int, input().split())
n = [2019]
while n[-1] < 2 * 10 **9:
  n.append(n[-1]*2)
for i in n:
  if l <= i <= r:
    print(0)
    exit()
print(min((l*(l+1))%2019, (r*(r-1))%2019))

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

l,r = iim()

if l//2019 != r//2019 or l%2019 == 0 or r%2019 == 0:
    print(0)
else:
    print(l%2019*((l+1)%2019))

Submission status: Wrong Answer

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

L2 = L%2019
R2 = R%2019

length = abs(R2-L2 +1)
ans = []
for i in range(length):
    if L2 < R2:
        ans.append(L2+i)
    elif L2 > R2:
        ans.append(R2+i)


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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 2019
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc133/tasks/abc133_c
# i,jの2019倍は必ず2019で割り切れる
# i+2019a ≡ i (mod 2019)より iもjもそれぞれ2019で割った余りを採用すれば良い

L, R = read_ints()
L = L % MOD
R = R % MOD

if R <= L:
    R += MOD

ans = INF
for i, j in combinations(ra(L, R + 1), r=2):
    # print(i, j, i * j % MOD)
    ans = min(ans, i * j % MOD)
print(ans)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
l1=l%2019
l2=(l+1)%2019
r1=r%2019
r2=(r-1)%2019
print(min((l1*l2)%2019, (r1*r2)%2019))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    l,r=pin()
    L=l%2019
    R=r%2019
    #print(L,R)
    if R<=L:R+=2019    
    
    
    t=20192019
    for i in range(L,R):
        for j in range(i+1,R+1):
            t=min(t,(i*j)%2019)
        print(t)
#%%submit!
resolve()

Submission status: Wrong Answer

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

x=10000
for i in range(l,l+min(r-l,2019)):
  x=min(x,i%2019)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x=10000
for i in range(l,l+min(r-l,2019)):
  x=min(x,i%2019)

print(x*(x+1))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    l,r=pin()
    L=l%2019
    R=r%2019
    #print(L,R)
    if R<=L:
        print(0)
        return
    
    else:
        t=20192019
        for i in range(L,R):
            for j in range(i+1,R+1):
                t=min(t,(i*j)%2019)
        print(t)
#%%submit!
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 2019


def resolve():
    L, R = map(int, input().split())

    for i in range(L, R + 1):
        if i % mod == 0:
            print(0)
            break
    else:
        print(L * (L + 1) % mod)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    l,r=pin()
    L=l%2019
    R=r%2019
    #print(L,R)
    if R<=L:
        print(0)
        return
    
    else:
        t=2019
        for i in range(L,R):
            for j in range(L+1,R+1):
                t=min(t,(i*j)%2019)
        print(t)
#%%submit!
resolve()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    l,r=pin()
    L=l%2019
    R=r%2019
    #print(L,R)
    if r-l>=2019 or R<=L:
        print(0)
        return
    
    else:print((L*(L+1))%2019)
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    l,r=pin()
    L=l%2019
    R=r%2019
    print(L,R)
    if r-l>=2019 or R<=L:
        print(0)
        return
    
    else:print((L*(L+1))%2019)
#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    L,R=pin()
    L%=2019
    R%=2019
    #print(L,R)
    if R<L:
        print(0)
        return
    
    else:print((L*(L+1))%2019)
#%%submit!
resolve()

Submission status: Wrong Answer

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

reg = 2018
if R-L >= 3000:
    print(0)
else:
    for l in range(L, R):
        for r in range(l+1, R+1):
            tmp = (l * r) % 2019
            reg = min(reg, tmp)
print(reg)

Submission status: Wrong Answer

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

reg = 10**9
if R-L >= 3000:
    print(0)
else:
    for l in range(L, R):
        for r in range(l+1, R+1):
            tmp = (l * r) % 2019
            reg = min(reg, tmp)
print(reg)

Submission status: Wrong Answer

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

reg = 10**9
if R-L >= 2019:
    print(0)
else:
    for l in range(L, R):
        for r in range(l+1, R+1):
            tmp = (l * r) % 2019
            reg = min(reg, tmp)
print(reg)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# mod2019 = 0を２つ以上含むなら答えは０
if R - L > 2019*3:
    print(0)
    exit()

# それ以外の時は，小さいのを２個取り出してかけて出力
# じゃダメで，３, 673,という訳すを持つ

mod_list = []
for i in range(L,R+1):
    mod_list.append(i % 2019)

if 673 in mod_list and (672 in mod_list or 675 in mod_list):
    print(0)

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

Submission status: Wrong Answer

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

# mod2019 = 0を２つ以上含むなら答えは０
if R - L > 2019*3:
    print(0)
    exit()

# それ以外の時は，小さいのを２個取り出してかけて出力
mod_list = []
for i in range(L,R+1):
    mod_list.append(i % 2019)

mod_list.sort()
print((mod_list[0] * mod_list[1]) % 2019)

Submission status: Wrong Answer

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

# mod2019 = 0を２つ以上含むなら答えは０
if R - L >= 2019*2:
    print(0)
    exit()

# それ以外の時は，小さいのを２個取り出してかけて出力
mod_list = []
for i in range(L,R+1):
    mod_list.append(i % 2019)

mod_list.sort()
print((mod_list[0] * mod_list[1]) % 2019)

Submission status: Wrong Answer

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

# mod2019 = 0を２つ以上含むなら答えは０
if R - L >= 2019*2:
    print(0)
    exit()

# それ以外の時は，小さいのを２個取り出してかけて出力
mod_list = []
for i in range(L,R+1):
    mod_list.append(i % 2019)

mod_list.sort()
print(mod_list[0] * mod_list[1])

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
"""
ans = 0
if R - L < 2019:
    l = L % 2019
    r = R % 2019
    if l < r:
        l_ = (L * (L + 1)) % 2019
        r_ = (R * (R - 1)) % 2019
        ans = min(l_, r_)
print(ans)
"""  

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

print(ans)

Submission status: Wrong Answer

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

ans = 0
if R - L < 2019:
    l = L % 2019
    r = R % 2019
    if l < r:
        l_ = (L * (L + 1)) % 2019
        r_ = (R * (R - 1)) % 2019
        ans = min(l_, r_)
print(ans)

Submission status: Wrong Answer

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

ans = 0
if R - L < 2019:
    l = L % 2019
    r = R % 2019
    if l < r:
        l_ = (l * ((L + 1) % 2019)) % 2019
        r_ = (r * ((R - 1) % 2019)) % 2019
        ans = min(l_, r_)
print(ans)

Submission status: Wrong Answer

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

ans = 0
if R - L < 2019:
    l = L % 2019
    r = R % 2019
    if l < r:
        if abs(2019 - l) < abs(2019 - r):
            ans = (l * ((L + 1) % 2019)) % 2019
        else:
            ans = (r * ((R - 1) % 2019)) % 2019
print(ans)

Submission status: Wrong Answer

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

ans = 0
if R - L < 2019:
    l = L % 2019
    r = R % 2019
    if l < r:
        ans = (l * ((L + 1) % 2019)) % 2019

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc133/tasks/abc133_c

l, r = map(int, input().split())

dp = [0] * 2019 
for i in range(2019 ** 2):
    n = l + i
    if n <= r:
        m = n % 2019
        dp[m] += 1
    else:
        break

ans = 1
c = 0
k = 0
while k < len(dp):
    if dp[k]:
        ans *= k
        dp[k] -= 1
        c += 1
    else:
        k += 1
    if c == 2:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc133/tasks/abc133_c

l, r = map(int, input().split())

dp = [0] * 2019 
for i in range(2019 * 3):
    n = l + i
    if n <= r:
        m = n % 2019
        dp[m] += 1
    else:
        break

ans = 1
c = 0
i = 0
while i < len(dp):
    if dp[i]:
        ans *= i
        dp[i] -= 1
        c += 1
    else:
        i += 1
    if c == 2:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc133/tasks/abc133_c

l, r = map(int, input().split())

dp = [0] * 2019 
for i in range(2019 * 2):
    n = l + i
    if n <= r:
        m = n % 2019
        dp[m] += 1
    else:
        break

ans = 1
c = 0
i = 0
while i < len(dp):
    if dp[i]:
        ans *= i
        dp[i] -= 1
        c += 1
    else:
        i += 1
    if c == 2:
        break
print(ans)

Submission status: Wrong Answer

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

res = 10**9
for i in range(n, m):
    res = min(res, (i*(i+1)) % 2019)
    if res == 0:
      print(0)
      exit()
print(res)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1

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

if temp==1:
  print(0)
else:
  print(count)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1

count=2019
r=r%2019
l=l%2019
for i in range(0,r+1):
  for j in range(l+1,r+1):
    temp=(i*j)%2019
    count=min(count,temp)

if temp==1:
  print(0)
else:
  print(count)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1

temp1=1
if r==l+1:
  if l%3!=0 and r%3!=0:
    temp1=0
  
i=1
temp2=0
while r>673*i:
  if l<=673*i:
    temp2=1
    break
  i=i+1

if temp==1:
  print(0)
elif temp1==1 and temp2==1:
  print(0)
else:
  print(((l*(l+1))%2019))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1

temp1=1
if r==l+1:
  if l%3!=0 and r%3!=0:
    temp1=0
  
i=1
temp2=0
while r>673*i:
  if l<=673*i:
    temp2=1
    break
  i=i+1

if temp==1:
  print(0)
elif temp1==1 and temp2==1:
  print(0)
else:
  print((l%2019)*((l+1)%2019))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1

temp1=1
if r==l+1:
  if l%3!=0 and r%3!=0:
    temp1=0
  
i=1
temp2=0
while r>673*i:
  if l<=673*i:
    temp2=1
    break
  i=i+1

if temp==1:
  print(0)
elif temp1==1 and temp2==1:
  print(0)
else:
  print(l%2019*(l+1)%2019)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1
if temp==1:
  print(0)
else:
  print(l%2019*(l+1)%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if R-L >= 2018:
    print(0)
else:
    m = 10*6
    for i in range(L, R):
        for j in range(i+1, R+1):
            m = min((i*j)%2019, m)
            if m == 0:
                break
        else:
            continue
        break

    print(m)

Submission status: Wrong Answer

Solution code:
import sys

L, R = map(int, input().split())
m = 10*100
for i in range(L, R):
    for j in range(i+1, R+1):
        tmp = (i*j)%2019
        if tmp == 0:
            print(0)
            sys.exit()
        else:
            m = min(m, tmp)

print(m)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if R-L >= 2019:
    print(0)
else:
    m = 10*100
    for i in range(L, R):
        for j in range(i+1, R+1):
            m = min(m, (i*j)%2019)

    print(m)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
if R-L >= 2018:
    print(0)
else:
    m = 10*100
    for i in range(L, R):
        for j in range(i+1, R+1):
            m = min(m, (i*j)%2019)

    print(m)