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
mina=10**10
L,R=map(int,input().split())
for i in range(L,R):
  for j in range(i+1,R+1):
    i=i%2019
    j=j%2019
    mina=min(mina,(i*j)%2019)
    if mina==0:
      print(0)
      sys.exit()
print(mina)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
sub = r-l
l %= 2019
r %= 2019

if(sub >= 2019):
    print(0)
    exit()

mina = float('INF')

for x in range(l,l+sub+1):
    for y in range(x,l+sub+1):
        if(x==y):
            continue
        
        ans = (x * y) % 2019
        if(mina > ans):
            mina = ans
       
print(mina)

Submission status: Accepted

Solution code:
def main():
    ans = 10**19
    l, r = map(int, input().split())
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i * j) % 2019)
            if ans == 0:
                print(0)
                return
    print(ans)              
        
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
sub = r-l
l %= 2019
r %= 2019

if(sub >= 2019):
    print(0)
    exit()

mina = float('INF')

for x in range(l,r+1):
    for y in range(x,r+1):
        if(x==y):
            continue
        
        ans = (x * y) % 2019
        if(mina > ans):
            mina = ans
       
print(mina)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
mini = 9999
if R - L >2019:
  R = L + 2019
for l in range(L, R + 1):
  for r in range(l + 1, R + 1):
    temp = (r * l) % 2019
    if temp < mini:
      mini = temp
    if mini == 0:
      break
print(mini)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
R = min(R, L+2018)
ans = 2018
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())

ind_s = L
ind_e = min(L + 2019, R)

choices_mod = [x%2019 for x in range(ind_s, ind_e+1)]

if len(choices_mod) == 1:
    print(choices_mod[0])
elif 0 in choices_mod:
    print(0)
else:
    import itertools
    pairs = list(itertools.combinations(choices_mod, 2))
    
    ans_list = []
    for a, b in pairs:
        ans_list.append((a*b)%2019)
        
    print(min(ans_list))

Submission status: Accepted

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

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

for i in range(l,r+1):
    for j in range(i+1,r+1):

        mod = min(mod,(i*j)%2019)
        if mod == 0:
            break

print(mod)

Submission status: Accepted

Solution code:
import sys

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

if 2019 <= r - l:
    print(0)
    sys.exit()

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

print(ans)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
k = 0
m = float("inf")
for i in range(L,R+1):
    k += 1
    if k >= 2019**2 + 1:
        break
    for j in range(i+1,R+1):
        m = min(m,(i*j)%2019)
        if m == 0:
            break
print(m)

Submission status: Accepted

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

ans = 1e20
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
    if ans == 0:
        break
print(ans)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
if R-L>2018:
    print(0)
else:
    res=2020
    L%=2019
    R%=2019
    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())
if R-L > 2019:
    print(0)
else:
    answers = []
    for a in range(L, R + 1):
        answers.append(a % 2019)
    answer=[]
    for a in range(len(answers)-1):
        for b in range(a+1,len(answers)):
            answer.append((answers[a]*answers[b])%2019)
    print(min(answer))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
lr = R-L
if lr >= 2019:
    print(0)
else:
    ans = 2018
    for i in range(L, R+1):
        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())

minv = float('inf')
if l == 0 or (l-1)//2019 != r//2019 or ((l-1)//3 != r//3 and (l-1)//673 != r//673):
	print(0)
	exit()
else:
	for a in range(l, r):
		for b in range(l + 1, r + 1):
			minv = min(minv, (a%2019)*(b%2019)%2019)
			if minv == 0:
				print(0)
				exit()
print(minv)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
l,r = map(int, raw_input().split(' '))
cc = collections.Counter([n % 2019 for n in range(l, min(r, l + 2019)+1) ])

m = +float('inf')
for a in cc:
	for b in cc:
		if a!=b or cc[a] > 1:
			m = min(m,(a*b) % 2019)
print 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+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())
import sys
ans = 2018
for i in range(l,r):
    for j in range(i+1,r+1):
        a = (i*j) % 2019
        if a < ans:
            ans = a
        if ans == 0:
            print(ans)
            sys.exit()
print(ans)

Submission status: Accepted

Solution code:
# lとrの差が2019以上ならば間に必ず2019の倍数が存在するので0になる
# lとrの差が2019より小さければ、余りのリストを作成しi、jの組み合わせをすべて計算してminを求める
# 2019C2なので10**8を上回ることはない
import itertools

l, r = map(int, input().split())
l_rest = l % 2019
r_rest = r % 2019

if l_rest == 0 or r_rest == 0:
    print(0)
elif r-l < 2019:
    lr_list = list(range(l_rest, r_rest+1))
    lr_comb = list(itertools.combinations(lr_list, 2))
    min_rest = 2018
    for comb in lr_comb:
        rest = comb[0] * comb[1]
        min_rest = min(min_rest, rest%2019)
    print(min_rest)
elif r-l >= 2019:
    print(0)

Submission status: Accepted

Solution code:
import itertools

l, r = map(int, input().split())
l_rest = l % 2019
r_rest = r % 2019

if l_rest == 0 or r_rest == 0:
    print(0)
elif r-l < 2019:
    lr_list = list(range(l_rest, r_rest+1))
    lr_comb = list(itertools.combinations(lr_list, 2))
    min_rest = 2018
    for comb in lr_comb:
        rest = comb[0] * comb[1]
        min_rest = min(min_rest, rest%2019)
    print(min_rest)
elif r-l >= 2019:
    print(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
ans = 2019
if R-L >= 2018:
    ans = 0
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:
def main():
    L, R = map(int, input().split())
    check_point = 2019
    num_2019 = 0
    while check_point <= R:
        if check_point >= L and check_point <= R:
            num_2019 += 1
        check_point += 2019

    if num_2019 >= 1:
        print(0)
        return
 
    min_mod = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
            min_mod = min((i*j) % 2019, min_mod)
    print(min_mod)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
p = 2019
for i in range (a,b+1) :
    if i%673 == 0 and b-a > 2 :
        print(0)
        exit(0)
    elif i%2019 == 0 :
        print(0)
        exit(0)

for j in range (a,b) :
    for k in range (j+1,b+1) :
        p = min(p,(j*k)%2019)

print(p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    l, r = map(int, input().split())
    if r - l >= 2019:
        print(0)
    else:
        mods = []
        for i in range(l, r + 1):
            mods.append(i % 2019)
        ans = float('inf')
        for i in range(len(mods) - 1):
            for j in range(i + 1, len(mods)):
                tmp = (mods[i] * mods[j]) % 2019
                if tmp < ans:
                    ans = tmp
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


    


L,r=l()

if(r-L>=2019):
    print(0)
    exit()
if(r-L<2019 and 0 in [i%2019 for i in range(L,r+1)]):
    print(0)
    exit()
x=[(i*j)%2019 for i in range(L,r+1) for j in range(i+1,r+1)]
print(min(x))

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
ans = 2019
if R - L >= 2019:
    ans = 0
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:
L, R = map(int, input().split())

if R - L > 2019:
    print(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:
L, R = map(int, input().split())
MOD = 2019
ans = float("inf")
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, i * j % MOD)
        if ans == 0:
            print(0)
            exit()
print(ans)

Submission status: Accepted

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

ans = 3000
if R-L > 2019:
    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)

Submission status: Accepted

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

x = R - L
if x > 2018:
  ans = 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)
     if ans == 0:
       break

print(ans)
    
#332701087 1753412895

Submission status: Accepted

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

if L == 0 or R-L >= 2019:
    ans = 0
else:
    ans = 10**18
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp = (i*j)%2019
            ans = min(ans, tmp)
            if not ans:
                break
print(ans)

Submission status: Accepted

Solution code:
import sys

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

# define
nums = R - L + 1
mod = 2019
ans = float('inf')

# main
for i in range(L, R):
  for j in range(i+1, R+1):
    tmp = (i * j) % mod
    ans = min(ans, tmp)
    if tmp == 0:
      print(ans)
      exit()

# output
print(ans)

Submission status: Accepted

Solution code:
import sys

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    L, R = map(int, input().split())
    if R - L > 2017:
        print(0)
        return
    xs = [n % 2019 for n in range(L, R + 1)]
    ans = 2018
    for i, j in itertools.combinations(xs, 2):
        tmp = (i * j) % 2019
        if tmp == 0:
            ans = 0
            break
        else:
            if tmp < ans:
                ans = tmp

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
w = R - L
if l + w >= 2019:
  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 = map(int, input().split())

ans = 2019

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

print(ans)

Submission status: Accepted

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

L,R = map(int,input().split())
lst = []

if L <= 2019 and R >= 2019:
    print(0)
else:
    for i in range(L,R+1):
        if i % 2019 == 0:
            lst.append(0)
            break
        for j in range(i+1,R+1):
            if j % 2019 == 0:
                lst.append(0)
                break
            lst.append((i * j) % 2019)
        else:
            continue
        break
    print(min(lst))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    l,r = map(int, input().split())
    ans = 2019

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

    for i in range(l,r+1):
        for j in range(i+1,r+1):
            if i%2019 == 0 or j%2019 == 0:
                ans = 0
                break
            else:
                ans = min(ans, (i*j)%2019)
    print(ans)
   
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
l, r = map(int, input().split())
a = 2019
b = 0
for i in range(l, r + 1):
    for j in range(i+1, r + 1):
        if i % 2019 == 0 or j % 2019 == 0:
            print(0)
            b = 1
            break
        else:
            a = min(a, (i%2019)*(j%2019)%2019)
    else:
        continue
    break
if b == 0:
    print(a)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
if r-l >= 2019:
	ans = 0
else:
	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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(L, R):
  minmod = float('inf')
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      minmod = min((i * j) % 2019, minmod)
      if minmod == 0:
        return minmod
  return minmod

L, R = map(int, input().split(' '))
print(solve(L, R))

Submission status: Accepted

Solution code:
L,R = list(map(int, input().split()))
if R-L >= 2019:
    print(0)
    exit()
    
s=set()
for i in range(L,R+1):
    if i%2019 in s:
        break
    s.add(i%2019)
l = list(s)

if 3 in l and 673 in l:
    print(0)
    exit()
    
print(min([(i*j)%2019 for i in l for j in l if i != j]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def mod2019(x, y):
    return (x%2019 * y%2019 ) % 2019

L,R = list(map(int, input().split()))
ans=2019
s=set()
for i in range(L,R+1):
    if i%2019 in s:
        break
    s.add(i%2019)
l = list(s)
for i in range(len(l)):
    for j in range(i+1, len(l)):
#        print(i, j, l[i], l[j], mod2019(l[i], l[j]))
        ans=min(ans, mod2019(l[i], l[j]))
    
print(ans)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
if abs(l-r)>=673:
  print(0)
else:
  ans=float('inf')
  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 = float('inf')

for i in range(L,R):
    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:
L, R = map(int, input().split())
ans = 2019
R = min([R, L+2019])
for i in range(L, R+1):
    for j in range(i+1, R+1):
        res = (i*j)%2019
        ans = min([res, ans])
print(ans)

Submission status: Accepted

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

if R - L >= 2019:
  print(0)
else:
  ans = 2018
  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 = [int(x) for x in input().split()]

mod = 2019
ans = 2020
for i in range(l, r):
    if i % mod == 0:
        ans = 0
        break
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % mod == 0:
                ans = 0
                break
            else:
                ans = min(ans, (i*j)%mod)
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l,r=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*j)%2019)
        print(ans)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

if l==0 or l//m<r//m or l%m==0:
  print(0)
  exit()

import numpy as np
lr=m
for ii in np.arange(l,r):
  for jj in np.arange(ii+1,r+1):
    t=((ii%m)*(jj%m))%m
    if t==0:
        print(0)
        exit()
    if t<lr:
      lr=t
print(lr)

Submission status: Accepted

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

Submission status: Accepted

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


def solve(l,r):
    num = float("inf")
    count = 0
    for i in range(l,r):
        for j in range(i+1,r+1):
            if count >= 2019**2:
                print(num)
                return
            
            current = (i*j) % 2019
            if current == 0:
                print(current)
                return
            
            num = min(current,num)
            count += 1
    
    print(num)

solve(l,r)

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):
        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)
else:
    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())
ans = 2019
if r-l+1 >= 2019:
    print(0)
else:
    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,R):
	for j in range(i+1, R+1):
		if j%2019==0:
			print(0)
			exit()
		ans=min(ans,(i*j)%2019)
print(ans)

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
a,b=n1()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

MIN = 2018
if R-L > 4039:
    MIN = 0


MOD = 2019
L = L%MOD
R = R%MOD
if L > R:
    L, R = R, L
elif L == R:
    MIN = 0


for i in range(L, R):
    for j in range(i+1, R+1):
        buf = (i*j) % MOD
        #print(i, j)
        MIN = min(buf, MIN)

print(MIN)

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):
        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=[int(i) for i in range(2019)]

a=l%2019
b=r%2019

if a<b:
    if r-l<2019:
        d=d[a:b+1]
    else:
        d=d
elif a>b:
    if r-l<2019:
        d=d[b:a+1]
    else:
        d=d
else:
    d=d
    
ans=2019
for i in range(len(d)):
    for j in range(i+1,len(d)):
        ans=min(ans,(d[i]*d[j])%2019)
print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
ans = 2018
END = False

for i in range(2019):
    j = i + 1
    while j <= R-L:
        ans = min( ((L+i)*(L+j)) % 2019, ans)
        j += 1
        if ans == 0:
            END = True
            break
    if END or i > R-L:
        break

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

div_l, mod_l = divmod(l, 2019)
div_r, mod_r = divmod(r, 2019)
if div_l != div_r:
    print(0)
else:
    num = float('inf')
    for i in range(mod_l, mod_r + 1):
        for j in range(i + 1, mod_r + 1):
            num = min(num, (i * j) % 2019)
    print(num)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 2018

if R-L>=2019:
    print(0)
else:
    for i in list(range(L, R)):
        for j in list(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 (L // 2019) != (R // 2019):
    print(0)
    exit()
else:
    ans = float('inf')
    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:
L,R = map(int,input().split())

d = 10 ** 10

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 2020
if r - l >= 2019:
    ans = 0
else:
    for i, j in list(combinations(range(l, r+1), 2)):
        ans = min(ans, (i*j)%2019)

print(ans)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
n=l//2019
m=r//2019
p=l%2019
q=r%2019
a=2018
if p>q:
    print(0)
elif m>n:
    print(0)
else:
    for i in range(p,q):
        for j in range(p+1,q+1):
            c=(i*j)%2019
            if a>c:
                a=c
    print(a)

Submission status: Accepted

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

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