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())
# もう少し全探索を疑うことが大切。
if R - L >= 2019:
    print(0)
else:
    # なぜprint(L*(L+1)%2019)が不可なのかというと、2019が2019=3*673の合成数であるから。
    # だから取りうる最小と最小+1の積の2019MODが最小になるわけではない。
    # 加えて、かけるものどうしの余剰が最小であれば、その積の余剰も最小になるという前提が間違っている。
    ans = float("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())
if l//673 != r//673 and l//3 != r//3:
  print(0)
else:
  ans=2019**2
  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:
from sys import stdin

MOD = 2019
L, R = [int(x) for x in stdin.readline().split(' ')]

# 2019最大と最小の間が2019以上だったらピッタリ2019で割り切れる値が作れる
if R - L >= 2019:
    print(0)
    exit()

min_val = 2 * 10**9

for i in range(L, R):
    for x in range(i+1, R+1):
        a = (i % MOD * x % MOD) % MOD

        if a == 0:
            print(0)
            exit()

        if a < min_val:
            min_val = a

print(min_val)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections as cl
import sys


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


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


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


def main():
    l, r = MI()

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

    mod_l = l % 2019
    mod_r = r % 2019

    candidates = []

    if mod_l < mod_r:
        candidates.extend(range(mod_l, mod_r + 1))
    else:
        candidates.extend(range(0, mod_r + 1))
        candidates.extend(range(mod_l, 2019))
    min_ans = 2019

    for i in range(len(candidates)):
        for j in range(i + 1, len(candidates)):
            tmp = (candidates[i] * candidates[j]) % 2019
            if tmp < min_ans:
                min_ans = tmp

    print(min_ans)


main()

Submission status: Accepted

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

Submission status: Accepted

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

if r-l>2050:
  print(0)
  sys.exit()
else:
  for i in range(l,r+1):
    s.append(i%2019)

n=len(s)
ans=30000
for i in range(n-1):
  for j in range(i+1,n):
    ans=min(ans,(s[i]*s[j])%2019)


print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
  
if R - L >= 2018:
  print(0)
  exit()
  
lst = []
for i in range(L,R+1):
  lst.append(i%2019)
  
lst.sort()

if lst[0] == 0:
  print(0)
  exit()
  
rlt = 2020
for i in range(len(lst)):
  for j in range(i+1,len(lst)):
    rlt = min(rlt, (lst[i]*lst[j])%2019)
    
print(rlt)

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(l+1, r+1):
            ans = min(ans, (i*j)%2019)

    print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
ama=[]
for i in  range(L,R+1):
    amari = i%2019
    if amari ==0:
        print(amari)
        exit()
minimi = 2019
for j in range(L,R+1):
    for s in range(j+1,R+1):
        waka = (j*s)%2019
        minimi = min(minimi,waka)
print(minimi)

Submission status: Accepted

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

if r-l>2019:
  print(0)
else:
  mn=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:
L, R = map(int,input().rstrip().split())
if R - L >=2018:
    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
print(ans)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    l, r = map(int, input().split())
    ll = []

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

    ll.sort()
    ans = 2020

    for i in range(len(ll)):
        for j in range(i + 1, len(ll)):
            tmp = (ll[i] * ll[j]) % 2019
            if tmp < ans:
                ans = tmp

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2020 2040"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 5"""
        output = """20"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

Solution code:
r, l = map(int, input().split())
ans = 2018
for i in range(r,l):
    for j in range(r+1,l+1):
        if ans > (i*j) % 2019:
            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())
ans = 2018
for i in range(L, R):
    for j in range(L+1, R+1):
        if ans > (i*j) % 2019:
            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 >= 673:
    print(0)
elif R - L == 1:
    print((R*L)%2019)
else:
    L %= 2019
    R %= 2019
    if L > R:
        print(0)
    else:
        ans = (L*R)%2019
        for l in range(L, R):
            for r in range(l+1, R+1):
                val = (l*r)%2019
                ans = min(ans, val)
        print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
r = 2019
if R//2019 != L//2019:
    print(0)
else:
    Rmod = R%2019
    Lmod = L%2019
    for i in range(Lmod,Rmod+1):
        for j in range(i+1,Rmod+1):
            r = min(r,(i*j)%2019)
    print(r)

Submission status: Accepted

Solution code:
import math
INF = 2_000_000_001
L, R = list(map(int, input().split()))
if math.ceil(L / 2019) <= R // 2019:
    print(0)
else:
    res = INF
    for i in range(L % 2019, R % 2019):
        for j in range(L % 2019 + 1, R % 2019 + 1):
            res = min(res, (i * j) % 2019)
    print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__=='__main__':
    l,r=readinput()
    ans=main(l,r)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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


MOD = 2019

l = L % 2019
r = R % 2019

if (R//MOD) - (L//MOD) > 0:
    r += 2019

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

print(res)

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=2018**2
    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())
if L//2019 != R//2019:
    print(0)
elif L%2019==0:
    print(0)
else:
    ans=float("inf")
    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())

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

Submission status: Accepted

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

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

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

print(min_mod)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
s=10000
for i in range(l,r+1):
    if i%2019==0:
        s=0
        break
    elif (i%673==0 and r-l!=1) or (i%673==0 and (r%3==0 or l%3==0)):
        s=0
        break
if s==0:
    print(0)
else:
    t=10000
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ((i%2019)*(j%2019))%2019<t:
                t=((i%2019)*(j%2019))%2019
    print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
if r-l>=2018:
  print(0)
else:
  ans = float('inf')
  for i in range(r-l):
    for j in range(i+1,r-l+1):
      ans = min((((l+i)%2019)*((l+j)%2019))%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(L+1,R+1):
    s=(i*j)%2019
    
    if s==0:
      print(0)
      exit()
    else:
      ans=min(s,ans)
      
print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if (R - L) >= 2018:
    print(0)
    exit()
else:#普通に二重for文で全探索(高々2017の範囲のfor文なので)
    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 >= 2018:
    print(0)
    exit()

m=10000
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=map(int,input().split())
if r - l >= 2018:
    print(0)
    exit()
l %= 2019
r %= 2019

m=10000
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 = map(int, input().split())
if R - L > 2019:
  print(0)
else:
  l = []
  for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
      l.append(i * j % 2019)
  print(min(l))

Submission status: Accepted

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

minimize = 2018
P = 0

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

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())
n = r-l+1
ans1 = 0
ans2 = 0
min1 = 1000000000
min2 = 10000000000


for i in range(min(n, 2024)):
   # print(l+i)
    if (l+i) % 2019 == 0:
        print(0)
        break
else:
    ans = 10000000000
    for i in range(min(n, 2019)):
        for j in range(i+1, min(n, 2020)):
            # print(l+i, l+j)
            if ((l+i)*(l+j)) % 2019 < ans:
                ans = ((l+i)*(l+j)) % 2019
                # print(ans, l+i, l+j)
    print(ans)

Submission status: Accepted

Solution code:
l, r = list(map(int, input().split()))
# A = list(map(int, input().split()))
#a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
#a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#x = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
# for i in range(1, int(n**0.5)+1):

mod = 2019
a = l//mod
b = r//mod

if b-a > 0:
    print(0)
else:
    m = 2020
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            a = (i*j) % mod
            if a < m:
                m = a

    print(m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    l, r = [int(x) for x in input().split()]
    if r - l + 1 >= 5000:
        print(0)
    else:
        M = 2019
        mn = []
        for i in range(l, r + 1):
            for j in range(i+1, r + 1):
                mn.append((i*j)%M)

        mn.sort()
        print(mn[0])
        



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
ans = (l*r)%2019
for i in range(l,r):
    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+1 >= 2019:
	print(0)
else:
	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:
def main():
    l, r = map(int, input().split())
    ans = 2019
    for i in range(l, min(l+2019, r+1)):
        for j in range(l+1, min(l+2019, r+1)):
            if i < j:
                tmp = (i * j) % 2019
                #print(tmp)
                if tmp < ans:
                    ans = tmp
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

L %= 2019
R %= 2019

ans = 2019
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)%mod)

print(ans)

Submission status: Accepted

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

if l//2019 != r//2019:
    print(0)
else:
    ans = float('inf')
    for i in range(l,r):
        for j in range(l+1,r+1):
            ans = min(i*j%2019,ans)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 13, 2020 06:30:41 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


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

  if R-L+1 >= 2019:
    print(0)
    return
  else:
    mods = []
    for i in range(L, R+1):
      mods.append(i)
  mods = sorted(mods)
  min_ = float('inf')
  for i in mods:
    for j in mods:
      if i==j:
        continue
      min_ = min(min_, (i*j) % 2019)

  print(min_)


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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    mod  =2019
    L,R = map(int,input().split())
    if R //mod - (L-1) //mod >1:
        print(0)
        exit()
    ans = 10**9
    for i in range(L,R):
        for j in range(i+1,R+1):
            a = (i * j ) %mod
            ans = min(a,ans)
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[27]:


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


# In[30]:


MOD = 2019
res = MOD
if R - L < MOD:
    for l in range(L, R):
        for r in range(l+1, R+1):
            res = min(res, (l * r) % MOD)
else:
    res = 0
print(res)

Submission status: Accepted

Solution code:
MOD = 2019
L, R = map(int, input().split())
res = MOD
if R - L < MOD:
    for l in range(L, R):
        for r in range(l+1, R+1):
            res = min(res, (l * r) % MOD)
else:
    res = 0
print(res)

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

l,r = readInts()

ans = float("inf")
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*j)%2019)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

L, R = rl()

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

l,r = I()

if r-l >= 673:
    print(0)
    exit()
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:
import sys

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    L, R = mi()

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

    return

main()

Submission status: Accepted

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

if r-l >= 673:
    print(0)
    exit()
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=map(int,input().split())

min_val = 2019
flag = 1
for i in range(L, min(R,L+2019-1), 1):
  for j in range(i+1, min(R+1,L+2019), 1):
    tmp = (i*(j)) % 2019
    if tmp == 0:
      flag = 0
      break
    elif tmp < min_val:
      min_val = tmp
  if flag == 0:
    break
if flag == 0:
  print(0)
else:
  print(min_val)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
  
l,r=input2()


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:

def solve():
    i = (L//2019) + 1
    ans = 0
    if L <= 2019*i <= R:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
            if ans == 0:
                break
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()

Submission status: Accepted

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

ans = 2018

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

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
ans = float('inf')
for i in range(N,K):
    for j in range(i+1,K+1):
        mod = (i*j)%2019
        ans = min(mod, ans)
        if mod==0:
            break
    else:
        continue
    break
print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
ans = float('inf')
for i in range(l, min(l+2019, r)+1):
    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 >= 673:
    print(0)
    exit()
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:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    L, R = LI()

    ans = 2018    
    for i, j in itertools.combinations(range(L, min(L + 2018, R) + 1), 2):
        ans = min(i * j % 2019, ans)

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    L, R = LI()

    # L %= 2019
    # R %= 2019
    # if R <= L:
    #     R += 2019

    ans = 2018    
    for i, j in itertools.combinations(range(L, min(R, L + 2019) + 1), 2):
        ans = min(i * j % 2019, ans)

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
if R - L < 2019 and r > l:
    print(
        min(i * j % 2019 for i in range(l, r + 1)
            for j in range(i + 1, r + 1)))
else:
    print(0)

Submission status: Accepted

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

if l + 2019 <= r:
  print(0)
else:
  res = []
  for i in range(l, r+1):
     for j in range(i+1, r+1):
        res.append((i*j)%2019)
  print(min(res))

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if L+2019 <= R:
  print(0)
else:
  m = 2019
  for a in range(L, R+1):
    for b in range(a+1, R+1):
      m = min(m, ((a%2019)*(b%2019))%2019)
  print(m)

Submission status: Accepted

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

def main():
    l, r = map(int, input().split())
    if r - l >= 2018:
        print(0)
    else:
        ans = 2018
        for i, j in itertools.combinations(range(l, r+1), 2):
            ans = min(ans, i * j % 2019)
        print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

a = 0
while a < l:
    a += 2019
if r - a >= 2019:
    print(0)
    exit()

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

print(d)

Submission status: Accepted

Solution code:
def resolve():
    L, R = list(map(int, input().split()))
    MOD = 2019
    if R - L >= 2019:
        print(0)
        return
    import itertools
    ans = float("inf")
    for i, j in itertools.combinations(list(range(L, R+1)), 2):
        ans = min(ans, i*j%MOD)
    print(ans)

if '__main__' == __name__:
    resolve()