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: Accepted

Solution code:
l, r = map(int, input().split())
dif = r - l
ans = 30000
if dif >= 2019:
    ans = 0
else:
    mod_l = l % 2019
    mod_r = r % 2019
    if mod_l < mod_r:
        if 3 >= mod_l and mod_r >= 673:
            ans = 0
        else:
            for i in range(mod_l, mod_r + 1):
                for j in range(i + 1, mod_r + 1):
                    ans = min(ans, (i * j) % 2019)
    else:
        ans = 0
#print(dif, mod_l, mod_r)
print(ans%2019)

Submission status: Accepted

Solution code:

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

if R - L >= 2019:
    print("0")
else:
    ans = 2018
    for i in range(mod_l, mod_r):
        for j in range(i+1, mod_r+1):
            _ans = (i * j) % MOD
            if ans > _ans:
                ans = _ans
    print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
l_mod = l % 2019
r_mod = r % 2019
if l + 2019 <= r:
    print(0)
    exit()
m = 3000
for i in range(l_mod, r_mod+1):
    for j in range(i+1, r_mod+1):
        m = min(m, i * j % 2019)
print(m)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
k = 0
l = 2020
m = 2020
apList = [0]*2019
for i in range(L,R+1):
  k = i % 2019
  if apList[k] != 0:
    break
  else:
    apList[k] += 1
res = 2018
for i in range(2019):
  for j in range(i+1,2019):
    if apList[i] != 0 and apList[j] !=0:
      res = min(i*j %2019,res)
print(res)

Submission status: Accepted

Solution code:
MOD = 2019

l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
    exit()
lst = []
for num in range(l, r + 1):
    lst.append(num % MOD)
ans = 2020
ll = len(lst)
for i in range(ll):
    for j in range(i + 1, ll):
        tmp = (lst[i] * lst[j]) % MOD
        ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

def mod(num):
    return num % 2019


#  (2019a + x)(2019b + y) = 2019(n) + xy

ans = 10 ** 9

lr = min(R, L + 2019) + 1

for i in range(L, lr):
    for j in range(i + 1, lr):
        ans = min(ans, mod(i * j))
        
print(ans)

Submission status: Accepted

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

if R-L > 2019:
  print(0)
  exit()
  
res = 100000
for i in range(L,R):
  ii = i%2019
  for j in range(i+1,R+1):
    j %= 2019
    res = min(res,ii*j%2019)
  
print(res)

Submission status: Accepted

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

ans = 2019
for a in range(L, min(L+2019, R)+1):
    for b in range(L, min(L+2019, R)+1):
        if a == b:
            continue
        ans = min(a*b%2019, ans)
        if ans == 0:
            print(0)
            exit()
print(ans)

Submission status: Accepted

Solution code:
import math

L,R=map(int, input().split())
d=R-L
r=R%2019
l=L%2019

if d>=2019 or r<l:
  print(0)
  
else:
  k=2020
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      k=min(k,i*j%2019)
  print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#/usr/bin/env python

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

if R-L >= MOD:
    print(0)
    exit()

ans = MOD 
tmp = 0 
for i in range(L, R+1):
    for j in range(i+1, R+1):
        tmp = ((i%MOD)*(j%MOD))%MOD
        if tmp <= ans:
            ans = tmp 
print(ans)

Submission status: Accepted

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

minv = 3000

if r//2019!=(l-1)//2019:
    print(0)

else :
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            if minv > i*j%2019:
                minv = i*j%2019

    print(minv)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
ans = float('inf')
for i in range(L,R):
  for j in range(i+1,R+1):
    if (i*j)%2019==0:
      print(0)
      exit()
    ans = min(ans,(i*j)%2019)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""
t=1
#t=ii()
for _ in range(t):
    a,b=ml()
    if(b-a>=2019):
        print(0)
    else:
        ans=1e18
        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: Accepted

Solution code:
L, R = map(int, input().split())
R = min(R, L+2019)
print(min([i * j % 2019 for i in range(L, R+1) for j in range(i+1, R+1)]))

Submission status: Accepted

Solution code:
l,r=[int(x) for x in input().split()]
L=l%2019
a=2020
for i in range(1,2020):
  if l+i<=r:
    for j in range(i):
      a=min((L+j)*(L+i)%2019,a)
print(a)

Submission status: Accepted

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

ans = float("inf")

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

Submission status: Accepted

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

ans = 2020
if R - L < 2019:
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min((i*j)%2019, ans)

else:
    for i in range(L, L+2019):
        for j in range(i+1, L+2019):
            ans = min((i*j)%2019, ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    l,r = LI()
    num = r-l+1
    ans = 0
    if num < 2019:
        ans = 2020
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                ans = min(ans,i*j%2019)

    print(ans)
main()

Submission status: Accepted

Solution code:
import math
L, R = map(int, input().split())
m = 2018
for i in range(L, min(L+2018, R)+1):
    for j in range(i+1, min(i+2019, R)+1):
        m = min(m, i*j%2019)
print(m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


l, r = inintm()

ans = 2019

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=n//2019
b=m//2019
if n*m%2019==0 or b-a>=1:
  print(0)
else:
  best=2018
  for c in range(n%2019,m%2019):
    for d in range(c+1,m%2019+1):
      if c*d%2019<best:
        best=c*d%2019
  print(best)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! python3
#  solve_133C.py

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

ans = 3000

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=2019
    L,R=MI()
    
    if R-L>=2019:
        print(0)
        exit()
    a=L%mod
    b=R%mod
    if b<=a:
        print(0)
        exit()
    
    ans=mod
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            temp=(i*j)%mod
            ans=min(ans,temp)
            
    print(ans)
            

main()

Submission status: Accepted

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

if R-L >= 2019:
    print(0)
    sys.exit()
elif R-L == 1:
    print((R*L)%2019)
    sys.exit()

ans = 10*100
for i in range(L,R):
    for j in range(i+1,R+1):
        number = (i*j)%2019
        ans = min(ans,number)

print(ans)

Submission status: Accepted

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

if R-L >= 2019:
    print(0)
    sys.exit()
elif R-L == 1:
    print((R*L)%2019)
    sys.exit()

ans = 4000

for i in range(L,R):
    for j in range(i+1,R+1):
        number = (i*j)%2019
        ans = min(ans,number)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc133_c

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

res = 2019

if r - l >= 2019 or r % 2019 < l % 2019:
    res = 0
else:
    for i in range(l, r+1):
        for j in range(l, i):
            x = i % 2019
            y = j % 2019
            z = (x * y) % 2019
            if z < res:
                res = z

print(res)

Submission status: Accepted

Solution code:
from itertools import combinations

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

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

else:
    cmb = list(combinations(range(l, r+1), 2))
    mod = [(cmb[i][0] * cmb[i][1]) % 2019 for i in range(len(cmb))]
    print(min(mod))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

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

if abs(R - L) >= 2019:
  print(0)
  exit(0)
  
L %= 2019
R %= 2019

if L > R:
  L,R = R,L

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

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
dl = l % 2019
dr = r % 2019
lis = []
if r - l >= 2019 - dl or dl == 0:
    print(0)
else:
    for i in range(dl,dr):
        for j in range(i+1,dr+1):
            lis.append((i*j)%2019)
    print(min(lis))

Submission status: Accepted

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

amr = []
for x in range(l,r+1):
    if len(amr) >= 2019:
        break
    amr.append(x%2019)
# print(amr)
amr = list(set(amr))
ij_mod = []
for i in range(len(amr)-1):
    for j in range(i+1,len(amr)):
        ij_mod.append((amr[i]*amr[j])%2019)
print(min(ij_mod))

Submission status: Accepted

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

sho_l = l // 2019
sho_r = r // 2019

if sho_r-sho_l >= 1:
  print(0)
else:
  ans = 2018
  flg_end = 0
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans = min((i*j)%2019,ans)
      if ans == 0:
        flg_end = 1
    if flg_end == 1:
      break
  print(ans)

Submission status: Accepted

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

sho_l = l // 2019
sho_r = r // 2019

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L,R=list(map(int, input().split()))
M=2019
if R-L==1:
  print(((R%M)*(L%M))%M)
  exit()
if L//M!=R//M:
  print(0)
  exit()
L=L%M
R=R%M
ans=M
for i in range(L,R+1):
  for j in range(i+1,R+1):
    ans=min(ans,(i*j)%M)
print(ans)

Submission status: Accepted

Solution code:
def main():
    l, r= map(int, input().split())
    if l+1 == r:
        return (l*r) % 2019
    ls = []
    for i in range(l,r+1):
        if i %673 ==0:
            return 0
        ls.append(i%2019)
        
    #print(ls)
    ans =2018
    for a in range(len(ls)):
        for b in range(1,len(ls)-a):
            ans = min(ans, (ls[a]*ls[a+b])%2019) 
    return ans
                

if __name__=='__main__':
    print(main())

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    if R//2019 - L//2019 > 1:
        print(0)
        return
    elif R//2019 == L//2019:
        U = list(range(L%2019, R%2019+1))
    else:
        print(0)
        return
    ans = 2019
    for i in U:
        for j in U:
            if i == j:
                continue
            ans = min(ans, (i*j)%2019)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

n = 2019
l, r = map(int, input().split())
if l // n < r // n:
    print(0)
else:
    print(min((i * j) % n for i, j in combinations(range(l % n, r % n + 1), 2)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if R-L>2019 or L>R :
    print(0)
    exit()
if L%2019+(R-L)>=2019 :
    print(0)
    exit()
l1=L%2019
r1=R%2019

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

print( ans )

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    l,r = map(int, input().split())
    if r-l > 2019:
        print(0)
        exit()
    ans = []
    for i in range(l,r+1):
        ans.append(i%2019)
    p = []
    ans = list(itertools.combinations(ans, 2))
    for k in ans:
        c = k[0]*k[1]
        p.append(c%2019)
    print(min(p))

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
m=10**4
a=min(R,L+2019)

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

Submission status: Accepted

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

MOD = 2019

a = 0

if r - l >= MOD:
    a = 0

else:
    x = l % MOD
    y = r % MOD
    if x > y:
        a = 0
    else:
        a = 2018
        for i in range(x, y):
            for j in range(i+1, y+1):
                a = min(a, i * j % MOD)

print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#　あまりの問題は周期性がある
#  R-Lが201９を超えたら必ず2019の倍数のものが存在するのでR-Lが2019より小さい時に絞って考えればいい
#  小さい時では高々要素数は2019より小さいので全部探索すればいい
l,r=list(map(int,input().split()))
if r-l>=2019:
  print(0)
else:
  ans=2019
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans=min(ans,(i%2019)*(j%2019)%2019)
      
      
  print(ans)

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

l,r = LI()
m = 2019

end = min(l+2019,r)

ar = []
for i in range(l,end):
    for j in range(i+1,end+1):
        ar.append((i*j)%m)
print(min(ar))

# ans = (l * r) % m
# print(ans)

# N = I()
#A,B = LI()
#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

# if ans:
#     print('Yes')
# else:
#     print('No')

Submission status: Accepted

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

if (2019*math.ceil(l/2019) <= r):
    print(0)
else:
    minres = 2018

    for i in range(l, r+1):
        im = i % 2019
        for j in range(i+1, r+1):
            res = (im*(j%2019))%2019
            if res < minres:
                minres = res

    print(minres)

Submission status: Accepted

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

t = []

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
x=l//2019
y=l%2019
z=r//2019
w=r%2019
if x<z:
    print(0)
else:
    if y==0:
        print(0)
    else:
        ans=2020
        for i in range(y,w):
            for j in range(i+1,w+1):
                ans=min(ans,(i*j)%2019)
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(min_mod)

Submission status: Accepted

Solution code:
def min2(x,y):
    return x if x < y else y

from itertools import combinations
MOD = 2019
L, R = map(int, input().split())
data = [L%MOD]
for i in range(L+1, R+1):
    if data[0] ==i%MOD:
        break
    data.append(i%MOD)
res = float("inf")
for x, y in combinations(data, 2):
    res = min2((x*y)%MOD,res)
print(res)

Submission status: Accepted

Solution code:
l,r=map(int,open(0).read().split())

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

m=[]
for i in range(l,r+1):
    m.append(i%2019)

n=len(m)
ans=2019

for i in range(n):
    for j in range(i+1,n):
        ans=min(ans,(m[i]*m[j])%2019)
    
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

x = []
for i in range(L,R+1):
    if i % 2019 in x:
        break

    x.append(i % 2019)

ans = 9999
for i in range(len(x)):
    for j in range(i+1,len(x)):
        ans = min(ans, x[i] * x[j] %2019)

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
inp=list(map(int,input().split()))
l=inp[0]
r=inp[1]
c=Counter([])
arr=[]
for i in range(l,r+1):
    if c[(i%2019)]==0:
        c[(i%2019)]+=1
        arr.append((i%2019))
        continue
    else:
        break
if c[0]!=0:
    print (0)
else:
    ans=99999999999
    for i in range(len(arr)):
        for j in range(i+1,len(arr)):
            ans=min(ans,(arr[i]*arr[j])%2019)
            if ans==0:
                break
        if ans==0:
            break
    print (ans)

Submission status: Accepted

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

Submission status: Accepted

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

rem_l = l%2019
rem_r = r%2019

ans = -1

if r - l >= 2019:
    ans = 0

elif rem_l >= rem_r:
    ans = 0

else:
    ans = float('INF')
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            temp = (i * j) % 2019
            if temp < ans:
                ans = temp

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
R = min(R,L+2019)
ans = 2019

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
R=min(L+2019,R)
m=3000
for x1 in range(L,R):
    for x2 in range(x1+1,R+1):
        if m>(x1*x2)%2019:m=(x1*x2)%2019
print(m)

Submission status: Accepted

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

ans = 2019
for i in range(L, min(L + 2019, R)):
    for j in range(i + 1, min(L + 2020, R + 1)):
        ans = min(ans, (i * j) % 2019)

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


L, R = zz()
mod = 2019

range_ = min(R-L+1, 2019)
kouho = []
kouho = [i for i in range(L, L + range_)]
ans = (kouho[0]*kouho[1]) % mod
for i, j in itertools.product(kouho, repeat=2):
    if (i == j):
        continue
    ans = min(ans, (i*j) % mod)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(L,R+1):
    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: Accepted

Solution code:
#!/usr/bin/env python3

# from numba import njit

# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

YEAR = 2019
INF = 10**8

def calcMod(x,y):
  return x*y % YEAR

# @njit
def solve(l,r):
  ans = INF
  if r - l > YEAR:
    r = l + YEAR
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans = min(ans,calcMod(i,j))

  return ans



def main():
  L,R = map(int,input().split())
  print(solve(L,R))
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
A = []
for i in range(min((R-L), 2020)):
    for j in range(i+1, min((R-L+1), 2021)):
        A.append((i+L)*(j+L)%2019)
print(min(A))

Submission status: Accepted

Solution code:
import sys
L,R = map(int,input().split())
mn = 10**10
cal = 0
for i in range(L,R+1):
    for j in range(i+1,R+1):
        
        cal = ((i%2019)*(j%2019))%2019
        if cal < mn:
            mn = cal
        if cal == 0:
            print(0)
            sys.exit()
print(mn)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
mn = 10**10
cal = 0
for i in range(L,R+1):
    for j in range(i+1,R+1):
        
        cal = ((i%2019)*(j%2019))%2019
        if cal < mn:
            mn = cal
        if cal == 0:
            break
    else:
        continue
    break
print(mn)

Submission status: Accepted

Solution code:

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

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

print(ans)

Submission status: Accepted

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

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

l %= 2019
r %= 2019

if l > r:
    print(0)

min_val = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        x = i * j % 2019
        if x < min_val:
            min_val = x
print(min_val)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)