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:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    L,R = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    if R-L>=2019:
        print(0)
        return
    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)





if __name__ == "__main__":
    main()

Submission status: Accepted

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

if r-l > 2018:
    print(0)
    exit()
else:
    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:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

l = L % 2019

nums = set()
for i in range(min(R - L + 1, 2019)):
    nums.add((l + i) % 2019)
# print(l, r)
# if r <= l:
#     r += 2019
ans = 2018
for i in nums:
    for j in nums:
        if i == j:
            continue
        ans = min(ans, (i * j) % 2019)
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
ans = 2019
    
if L//2019 != R//2019:
    print(0)
    exit(0)
else:
    L = L%2019
    R = R%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
l, r = map(int, input().split())
mod = 2019

if l%mod == 0 or r%mod == 0 or l//mod != r//mod:
  print(0)
  sys.exit()

ans = 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:
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

l,r = MAP()
if(l%2019>=r%2019) or (r-l>=2018):
  print(0)
  exit()
else:
  l %= 2019
  r %= 2019

ans = inf
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())
 
x = []
 
if r-l >4038:
    print(0)
else:
    for i in range(l,r+1):
        x.append(i%2019)
        
    x.sort()
    
    ans = x[0]*x[1]%2019
    
    x = list(set(x))
    
    for s in range(len(x)):
        for t in range(s+1,len(x)):
            ans = min(ans,x[s]*x[t]%2019)
        
    print(ans)

Submission status: Accepted

Solution code:
r,l = map(int,input().split())
if l-r+1 >= 2019:
    print("0")
    exit()
li = []
for i in range(l-r+1):
    li.append((r+i)%2019)
li.sort()
lia = []
for i in range(len(li)):
    for j in range(len(li)):
        if i != j:
            lia.append((li[i]*li[j])%2019)
print(min(lia))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = (int(x) for x in input().split())
ModL = list(x%2019 for x in range(L,min(L+2019,R+1)))
if 0 in ModL:
    print('0')
else:
    MIN = 2019
    for I in range(0,len(ModL)-1):
        for II in range(I+1,len(ModL)):
            if (ModL[I]*ModL[II])%2019<MIN:
                MIN = (ModL[I]*ModL[II])%2019
    print(MIN)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

R=min(R,L+2*M-1)

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

Submission status: Accepted

Solution code:
mod = 2019
l,r = map(int,input().split())
INF = float("inf")
if (r-l) >= mod:
    print(0)
else:
    a = l % mod 
    b = r%mod
    if b > a:
        m = +INF
        for i in range(a,b+1):
            for j in range(i+1,b+1):
                curr = (i*j) % mod
                if curr < m:
                    m =curr
        print(m)
    else:
        print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m, n = map(int, input().split(" "))
if n - m >= 673:
    print(0)
else:
    score = m * n % 2019
    for i in range(m, n + 1):
        for j in range(i + 1, n + 1):
            if (i * j) % 2019 < score:
                score = (i * j) % 2019
    print(score)

Submission status: Accepted

Solution code:
L, R = map(int, open(0).read().split())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
# R-L>=2019なら、[L,R]に2019の倍数が必ず存在する
# すなわちiやjが2019の倍数をとりうる
if R - L >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(L, R + 1):  # L<=i<=R
        for j in range(i + 1, R + 1):  # i<j<=R
            ans = min(ans, i * j % 2019)
    print(ans)

Submission status: Accepted

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

else:
    l%=2019
    r%=2019
    res = 10000000000

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

Submission status: Accepted

Solution code:
L,R = [int(_) for _ in input().split()]
if L//2019 != R//2019:
    mod_min=0
else:
    mod_list=[]

    mod_min = 10**10
    for i in range(L,R):
        for j in range(i+1,R+1):
            if mod_min >= i*j%2019:
                mod_min = i*j%2019
                
            if mod_min == 0:
                break
        if mod_min == 0:
                break
#                 print(i,j,mod_min)
print(mod_min)

Submission status: Accepted

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

if R-L >= 2100 :
    ans = 0
else :
    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
                if ans == 0 :
                    break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 前提として、LとRの差が2019より小さいとき

# modを比較し、LよりRの方が大きい時は2019の倍数を通り越していない
# modを比較し、LよりRの方が小さい時は2019の倍数を通り越している

deff = R - L
if (deff < 2019):
    min_num = 10**9 + 7
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            min_num = min(min_num, (i * j) % 2019)
    print(min_num)
else:
    print(0)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
l,r = map(int,input().split())
if l+2019<=r:
  print(0)
  sys.exit()
l=l%2019
r=r%2019
if l>=r:
  print(0)
  sys.exit()

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

Submission status: Accepted

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

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

ans = 10**9
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())
d=range(l,r+1)[:673]
print(min(i*j%2019 for i in d for j in d if i<j))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
if r-l>672: print(0); exit()
m=[i%2019 for i in range(l,r+1)]
a=2019
for i in m:
  for j in m:
    if i<j: a=min(a,i*j%2019)
print(a)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
l=L%2019
r=R%2019
#print(l,r)
if l<r and L//2019 == R//2019:
    ans=10**18
    for i in range(l,r):
        for j in range(l+1,r+1):
            if ans>(i*j)%2019:
                ans=(i*j)%2019
    print(ans)
elif L//2019<R//2019:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    L,R = [int(x) for x in input().split()]
    ans = 2019
    for i in range(L,min(R,L+2018)+1):
        for j in range(i+1,min(R,L+2018)+1):
            tmp = (i*j) % 2019
            if tmp < ans:
                ans = tmp
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
import sys
mod=2019
ans=float('inf')

for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans=min((i*j)%mod,ans)
    if ans==0:
      print(0)
      sys.exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
if (R-L>3000) :
    print(0)
else :
    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 = [int(_) for _ in input().split()]

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
ans=l*r
if l//2019!=r//2019:
    ans=0
elif l%2019==0 or r%2019==0:
    ans=0
else:
    num1=l%2019
    num2=r%2019
    for i in range(num1,num2):
        for j in range(i+1,num2+1):
            num=(i*j)%2019
            if ans>num:
                ans=num
print(ans)

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc133/tasks/abc133_c"

def main():
    t = list(map(int, input().split()))
    ans = []
    for i in range(t[0], t[1]+1):
        for j in range(i+1, t[1]+1):
            val = (i*j) % 2019
            if val == 0:
                print(val)
                exit()
            ans.append(val)
    print(min(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans=2018
i=L
while i<R:
    j=i+1
    while j<=R:
        if i*j%2019==0:
            ans=0
            break
        else:
            ans=min(ans,i*j%2019)
            j+=1
    i+=1
    if ans==0:
        break

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    L, R = map(int, readline().split())

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
l,r=map(int,input().split())
#2019の剰余の範囲を調べ、その中で全探索
l_2019=l%2019
r_2019=r%2019
#範囲が2019以上 -> 割り切れるものが1つ以上ある
if r - l >= 2019:
  print(0)
  sys.exit()
#範囲が2018以下かつ0またぐ -> 割り切れるものが1つ以上ある
if l_2019 > r_2019:
  print(0)
  sys.exit()
res=2018
for i in range(l_2019, r_2019):
  for j in range(i+1,r_2019+1):
    res = min(res, (i*j)%2019)
    if res==0:
      break
print(res)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
if b-a>=2019:
    print(0)
    exit()
d=[]
for i in range(a,b+1):
    if i%2019==0:
        print(0)
        exit()
    for j in range(a,b+1):
        if i<j:
            d.append((i*j)%2019)
print(min(d))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n=int(input())
l,r=map(int,input().split())
#t=int(input())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

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

Submission status: Accepted

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

Submission status: Accepted

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

mod = 2019

lm = l % mod
rm = r % mod

ans = []
if r - l >= mod :
  print(0)
  exit()
else:
  for i in range(lm,rm):
    for j in range(i+1,rm+1):
      ans.append(i*j % mod)
  print(min(ans))

Submission status: Accepted

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

if(R - L) >= 2019:
    print(0)
    exit()
 
ans = float('inf')
for i in range(L, R):
    for j in range(i+1, R+1):
        t = i*j%2019
        ans = min(ans,t)
print(ans)

Submission status: Accepted

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

l = l%2019
r = r%2019

if l >= r:
    print(0)
else:
    ans = float('inf')
    for left in range(l, r):
        for right in range(left+1, r+1):
            ans = min(ans, (left*right)%2019)
    print(ans)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
ans = float("inf")

for i in range(L,min(R,L+2019)):
    for j in range(i+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())
 
cnt = 0
i = L
j = L+1
min_num = 2020
while i <= R and cnt <= 2019:
    j = i+1
    while j <= R:
        min_num = min(min_num,(i*j)%2019)
        if not min_num:
            break
        j += 1
    i += 1
    cnt += 1
print(min_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int, input().split())
l = L//2019
r = R//2019
m = L%2019
n = R%2019

ans = 2018
if l != r:
  print(0)
  exit()
else:
  for i in range(m,n):
    for j in range(i+1,n+1):
      ans = min((i*j) % 2019, ans)
      if ans == 0:
        print(ans)
        exit()
      
print(ans)

Submission status: Accepted

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

ans =[]
for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans.append(i*j%2019)
        if (i * j % 2019) == 0:
            break
    else:
        continue
    break

print(min(ans))

Submission status: Accepted

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

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

else:
    for i in range(R-L-1010,R-L+1010):
        for j in range(i,R-L+1010):
            ans.append(i*j%2019)

print(min(ans))

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
ll = l % 2019
rr = r % 2019
minn = 2019
if r - l > 2019:
    rr += 2019
for i in range(ll, rr):
    for j in range(ll + i - ll + 1, rr + 1):
        if minn > i * j % 2019:
            minn = i * j % 2019
print(minn)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

min_m = 2019

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

        min_m = min(min_m, m)

print(min_m)

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):
  for j in range(i+1, r+1):
  	t = i*j%2019
  	if t < ans: ans = t
print(ans)

Submission status: Accepted

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

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

ans = float('inf')
for i in range(l, r):
  for j in range(i+1, r+1):
  	t = i*j%2019
  	if t < ans: ans = t
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

MOD = 2019

#n = 2019
#pf = {}
#
#for i in range(2,int(n**0.5)+1):
#    while n % i == 0:
#        pf[i] = pf.get(i,0) + 1
#        n //= i
#if n > 1: pf[n] = 1
#print(pf)
## 2019=3*673

import itertools

l_mod = l%MOD
r_mod = r%MOD

if r-l > 2019:
    ans = 0
else:
    if l_mod <= 3 <= r_mod and l_mod <= 673 <= r_mod:
        ans = 0
    elif l_mod < r_mod:
        li = [i for i in range(l_mod, r_mod+1)]
        ans = 2018
        for v in itertools.combinations(li, 2):
            ans = min(ans, v[0]*v[1]%MOD)        
    else:
        ans = 0

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

MOD = 2019

#n = 2019
#pf = {}
#
#for i in range(2,int(n**0.5)+1):
#    while n % i == 0:
#        pf[i] = pf.get(i,0) + 1
#        n //= i
#if n > 1: pf[n] = 1
#print(pf)
## 2019=3*673

import itertools

l_mod = l%MOD
r_mod = r%MOD

if r-l > 2019:
    ans = 0
else:
#    if l_mod <= 3 <= r_mod and l_mod <= 673 <= r_mod:
#        ans = 0
    if l_mod < r_mod:
        li = [i for i in range(l_mod, r_mod+1)]
        ans = 2018
        for v in itertools.combinations(li, 2):
            ans = min(ans, v[0]*v[1]%MOD)        
    else:
        ans = 0

print(ans)

Submission status: Accepted

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

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

else:
    lm = list()
    for i in range(l, r):
        for j in range(i+1, r+1):
            lm.append((i*j)%2019)
    print(min(lm))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = map(int, input().split())
l = L//2019
r = R//2019
m = L%2019
n = R%2019

ans = 2018
if l != r:
  print(0)
  exit()
else:
  for i in range(m,n):
    for j in range(i+1,n+1):
      ans = min((i*j) % 2019, ans)
      if ans == 0:
        print(ans)
        exit()
      
print(ans)

Submission status: Accepted

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

for i in range(L, R):
    for j in range(i+1, R+1):
        mod = (i * j) % N
        if val > mod:
            val = mod
        if val == 0:
            print(val)
            sys.exit()
print(val)

Submission status: Accepted

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

N = 2019


ans = 2019

for i in range(L, R):
    for j in range(i + 1, R + 1):
        mod = (i * j) % N
        if ans > mod:
            ans = mod
        if ans == 0:
            print(ans)
            exit(0)

print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
L, R = list(map(int,input().split()))
if R - L >= 690:
    ans = 0
else:
    ans = 10 ** 9 + 7
    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:
    print(0)
    exit()

ans = 2019

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())

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

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

ans = 2019

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())
if r-l<2019:
    l=l
    r=r
else:
    l=l
    r=l+2019
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())
if L==R:
  print(L%2019 * L%2019)
  exit()
if R-L >= 2019:
  print(0)
  exit()

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

    res = min(res, (i*j)%2019)

print(res)

Submission status: Accepted

Solution code:
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()


def solve():
    L, R = map(int, input().split())
    mod = 2019
    if R - L >= 4100:
        ans = 0
    else:
        N = R - L + 1
        mlist = []
        for i in range(L, R + 1):
            mlist.append(i % mod)

        mlist.sort()
        comb = list(itertools.combinations(range(N), 2))
        ans = mod  # inf
        for c in comb:
            ans = min(ans, (mlist[c[0]] * mlist[c[1]]) % mod)

    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import math

def main():
    l,r=map(int,input().split())
    m = 2020
    for i in range(l, r):
        for j in range(i+1, r+1):
            n = (i*j) % 2019
            m = min(m, n)
            if m == 0:
                print(m)
                return
    print(m)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

else:
    ans=2020
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp=(i*j)%2019
            if ans>tmp:
                ans=tmp

print(ans)

Submission status: Accepted

Solution code:
import math


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


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

_min = float("inf")
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        v = (i * j) % 2019
        # どっちかに2019の倍数が来るのは最大2019**2だから
        if v == 0:
            print(0)
            exit()
        else:
            _min = min(_min, v)

        #print(i, j, (i * j) % 2019)
        #print(prime_factorize(i), prime_factorize(j))
print(_min)