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:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import random
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	#N = int(input())
	#S = list(input())
	L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))

	ans = -1
	ed = min(L+2020, R+1)


	for a in range(L, ed):
		for b in range(a+1, ed):
			tmp = (a*b)%2019

			if ans > tmp or ans == -1:
				ans = tmp

	print(ans)




if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
import numpy as np
L,R = (int(x) for x in input().split())

if R - L > 3000:
  print(0)
  exit()
  
x = np.arange(L,R+1,dtype=np.int64)
y = x[:,None] * x[None,:] % 2019
for i in range(len(x)):
  y[i,i] = 3000
answer = y.min()
print(answer)

Submission status: Accepted

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

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

x=l%2019
y=r%2019

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

Submission status: Accepted

Solution code:
import sys, math

readline = sys.stdin.readline

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

P = 2019
L_ = (L // P) * P

if R < L_ + P:
    m = 100000
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = min(m, (i * j) % P)
    print(m)
else:
    print(0)

Submission status: Accepted

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

    if R - L >= 2019:
        ans = 0

    else:
        ans = float('inf')
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                tmp = (i * j) % mod 
                if tmp < ans:
                    ans = tmp
    
    print(ans)

main()

Submission status: Accepted

Solution code:
# 2019/07/07
# AtCoder Beginner Contest 133 - C

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

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

# Output
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import functools as ft
import heapq
import itertools as it
import logging
import unittest
from collections import (
    OrderedDict,
    defaultdict,
    namedtuple,
    Counter,
)

import numpy as np

_ = [ft, it, np, heapq, namedtuple, Counter, defaultdict, OrderedDict]

debug = logging.getLogger(__name__).debug


def input_ints():
    return list(map(int, input().strip().split()))


def _main():
    l, r = input_ints()
    logging.debug([l, r])
    i_close = set()
    j_close = set()
    result = float('inf')
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            result = min(result, (i * j) % 2019)
            j_close.add(j % 2019)
            if len(j_close) == 2019:
                break
        i_close.add(i % 2019)
        if len(i_close) == 2019:
            break
    print(result)


class Test(unittest.TestCase):
    def setUp(self):
        import run
        self._test = run

    def test_main(self):
        self._test.test_files(self, _main)


if __name__ == '__main__':
    _main()

Submission status: Accepted

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

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

Submission status: Accepted

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

if r-l>=2019:
    print(0)
    exit()
else:
    x=[]
    for p in range(l,r):
        if p%n==0:
            print(0)
            exit()
        else:
            for q in range(p+1,r+1):
                x.append(p*q%n)
print(min(x))

Submission status: Accepted

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

if (L // 2019) == (R //2019):
    LL = L % 2019
    RR = R % 2019
    ans = 2019
    for i in range(LL, RR):
        for j in range(i+1, RR+1):
            ans = min(((i * j) % 2019), ans)
else:
    ans = 0

print(ans)

Submission status: Accepted

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

Lm = L%2019
Rm = R%2019

if Lm*Rm == 0 or R-L > 2017 or Rm <= Lm:
    print(0)
    exit()

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

Submission status: Accepted

Solution code:
L,R = map(int, input().split())
'''
if L <= 2019 <= R:
    print(0)
    exit()
'''
ans = 2020
for i in range(L,R):
    x = i % 2019
    for j in range(L+1,R+1):
        y = j % 2019
        tmp = (x * y) % 2019 
        if tmp < ans:
            ans = tmp
        if ans == 0:
            print(ans)
            exit()

print(ans)

Submission status: Accepted

Solution code:
import itertools
L,R = map(int,input().split())
if R-L >= 2018:
  print(0);exit()
li = [i%2019 for i in range(L,R+1)]
li = list(set(li))
if 0 in li or (3 in li and 673 in li):
  print(0);exit()
pro = []
for i,j in itertools.combinations(li,2):
  pro.append(i*j%2019)
print(min(pro))

Submission status: Accepted

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

mod = 2019

if l//mod != r//mod:
    print(0)
    exit()

l = l%mod
r = r%mod

m = mod
for i in range(l, r+1):
    for j in range(i+1, r+1):
        t = (i*j)%mod
        if t < m:
            m = t

print(m)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
# 2019 = 3*673
p = 673
if R-L>p:
    print(0)
else:
    ans = 2019
    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

input = sys.stdin.readline

L, R = map(int, input().strip().split(' '))
l = L % 2019
r = R % 2019
if l >= r or R - L >= 2019:
    print(0)
else:
    minimum = l * r % 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            minimum = min(minimum, (i*j) % 2019)
    print(minimum)

Submission status: Accepted

Solution code:
import math
[L,R] = list(map(int,input().split()))
#[L,R] = [2020,2040]
if R >= L+2019:
    print(0)
else:
    ans = 2020
    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
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MOD = 2019

def main():
    L, R = i2nn()
    LN = L // MOD
    RN = R // MOD
    if LN != RN:
        print(0)
        return
    LM = L % MOD
    RM = R % MOD
    LM2 = min(LM, RM)
    RM2 = max(LM, RM)
    n = int(1e+9)
    for i in range(LM2, RM2):
        for j in range(i+1, RM2+1):
            t = (i * j) % MOD
            if n > t:
                n = t
    print(n)

main()

Submission status: Accepted

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

mod_min = 2019

LRrange = min(2019, R-L+1)

for i in range(LRrange):
    for j in range(LRrange):
        if L+i+j+1>R:
            break
        else:
            mod_min = min(mod_min,(L+i)*(L+i+j+1) % 2019)

print(mod_min)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations

fin = sys.stdin.readline
L, R = [int(elem) for elem in fin().split()]

all_ij = list(range(L, min(R+1, L+2021)))

min_mod = 2020
for each_ij in combinations(all_ij, 2):
    result = (each_ij[0] * each_ij[1]) % 2019
    if result < min_mod:
        min_mod = result
        if min_mod == 0:
            break

print(min_mod)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
l, r = list(map(int, input().split(' ')))
mod = 2019
s1 = l % mod
rem = mod - s1
ans = -1
# print(l + rem)
if l + rem > r:
    maxi = r
    lowe = l
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            mini = ((i%mod) * (j%mod)) % mod
            if mini < ans or ans == -1:
                ans = mini
    print(ans)
    # print(((l%mod) * (l+1%mod)) % mod) 
else:
    print(0)

Submission status: Accepted

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

val = 2019

for l in range(L,min(R,L+2019)):
  for r in range(l+1,min(R+1,l+1+2019)):
    val = min((l*r)%2019,val)
    
print(val)

Submission status: Accepted

Solution code:
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
x,y = ips()

if y-x>=2019:
    print(0)
    exit(0)
x%=2019
y%=2019
if x>y:
    y+=2019
m = rem
for i in range(x,y):
    for k in range(i+1,y+1):
        m = min(m,(i*k)%2019)
print(m)

#3 * 673

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if r//2019 - l//2019 > 0:
    print(0)
else:
    newL = l%2019
    newR = r%2019
    minM = 2019
    index = newL
    while index < newR+1:
        index2 = index+1
        while index2 < newR+1:
            if minM > (index*index2)%2019:
                minM = (index*index2) % 2019
            index2+=1
        index+=1
    print(minM)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
# 2019 = 3 * 673

rr = min(r, l + 2020)

res = 1000000
for i in range(l, rr+1):
    for j in range(l + 1, rr + 1):
        #print("{0}, {1}".format(i, j))
        if i >= j:
            #print("skip")
            continue

        if res > i*j % 2019:
            #print("{0}, {1}".format(i, j))
            res = i*j % 2019
print(res)

Submission status: Accepted

Solution code:
line = input().split()
l = int(line[0])
r = int(line[1])

dist = r - l
if dist >= 2018:
    print(0)
else:
    l = l % 2019
    
    li = []
    for i in range(dist+1):
        li.append((l+i) % 2019)
    
    smallest = 2018
    for i in range(len(li)):
        for j in range(i+1, len(li)):
            if (li[i] * li[j]) % 2019 < smallest:
                smallest = (li[i] * li[j]) % 2019
                
    print(smallest)

Submission status: Accepted

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

Q = L // 2019
l = L - 2019 * Q
r = R - 2019 * Q

if l == 0:
    print(0)
elif 2019 <= r:
    print(0)
else:
    minimum = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            val = (i * j) % 2019
            minimum = min(minimum, val)
    print(minimum)

Submission status: Accepted

Solution code:
# 最初に入れておくとinputが早くなる
import sys
input = sys.stdin.readline

# スタック最大数をセット
sys.setrecursionlimit(10**6)

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

ans = 2018

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

Submission status: Accepted

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

import fractions

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def calc(n, x):
    return n // x

def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)

def main():
    l, r = rli()
    mod = [[None for _ in range(2019)] for _ in range(2019)]
    for i in range(2019):
        for j in range(i+1, 2019):
            mod[i][j] = i*j % 2019
    if r - l >= 2019:
        print(0)
        return
    l_mod = l % 2019
    r_mod = r % 2019
    if l_mod < r_mod:
        cand = list(range(l_mod, r_mod+1))
    else:
        cand = list(range(l_mod, 2019)) + list(range(0, r_mod+1))
    ans = 2018
    for i in cand:
        for j in cand:
            if i >= j:
                continue
            ans = min(ans, mod[i][j])
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

if r -l >= 2019:
    print(0)
else:
    res = 2018
    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:
#!/usr/bin/env python3
#ABC133 C

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
mod = 2019

l,r = LI()
mi = float('inf')
if r - l >= 2019:
    print(0)
else:
    for i in range(l+1,r+1):
        for j in range(l,i):
            mi = min(mi,(i*j)% mod)
    print(mi)

Submission status: Accepted

Solution code:
import itertools

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

if R - L >= 2019:
    L = 0
    R = 2018

print min([(i * j) % 2019 for i, j in itertools.combinations(range(L, R + 1), 2)])

Submission status: Accepted

Solution code:
L, R = [int(lr) for lr in input().split()]
if R//2019 != L//2019:
  print(0)
else:
  ans = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      mod = (i*j) % 2019
      if ans > mod:
        ans = mod
  print(ans)

Submission status: Accepted

Solution code:
import sys

l, r = [ int(x) for x in sys.stdin.readline().split() ]

lm = l % 2019

if lm + (r-l)>=2019:
    print(0)
    exit(0)
#
ans= 2019
rm= r % 2019 + 1
for i in range(lm,rm):
    for j in range(i+1,rm):
        ij = ( i * j ) % 2019
        if ij<ans: ans= ij
#
print( ans )

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split(" "))
p1, p2 = 3, 673
if (L <= p2 <= R and R - L >= p1) or (R - L >= p2):
    print(0)
else:
    mods = []
    mods_append = mods.append
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % 2019
            mods_append(m)
            if m == 1:
                break
        if m == 1:
            break

    print(min(mods))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    left, right = map(int, input().split())
    mod = 2019

    aaa = defaultdict(int)
    for i in range(left, min(right + 1, left + 5000)):
        aaa[i % mod] += 1

    score_sorted = list(sorted(aaa.items(), key=lambda x: x[0]))

    # print(score_sorted)

    ans = 2019
    for i in range(len(score_sorted)):
        if score_sorted[i][1] >= 2:
            ans = min(ans, (score_sorted[i][0] * score_sorted[i][0]) % mod)
        for j in range(i + 1, len(score_sorted)):
            ans = min(ans, (score_sorted[i][0] * score_sorted[j][0]) % mod)

    print(ans)







if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

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

if R - L + 1 >= 2019:
    print(0)
else:
    for i in range(L, R+1):
        if i % 2019 == 0:
            print(0)
            sys.exit()
    else:
        ans = 10**6
        for i in range(L, R):
            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:
def c_remainder_minimization_2019(L, R):
    ans = float('inf')
    for i in range(L, min(R, L + 2019)):
        for j in range(i + 1, min(R + 1, L + 2020)):
            ans = min(ans, (i * j) % 2019)
    return ans

L, R = [int(i) for i in input().split()]
print(c_remainder_minimization_2019(L, R))

Submission status: Accepted

Solution code:
import numpy as np
import copy


def dist2(y, z):
    return np.sum((y - z)**2)


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

    m = R // 2019
    if L <= 2019 * m and 2019 * m <= R:
        ans = 0
    else:
        L -= 2019 * m
        R -= 2019 * m
        # assert L > 0
        # assert L < 2019
        # assert R > 0
        # assert R < 2019
        ans = 2018
        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())
L=l//2019
R=r//2019
k=[]
if L==R:
    for i in range(l,r):
        for j in range(i+1,r+1):
            k.append((i*j)%2019)
    print(min(k))
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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


#L, Rの間に2019の倍数が入っている時-->答え0(2019の倍数にできる)
if (R%2019 == 0) or (L%2019 == 0):
    print (0)
    exit()
if R//2019 > L//2019:
    print (0)
    exit()

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split()) # 横に2個

l = L // 2019
r = R // 2019
ll = L % 2019
rr = R % 2019

if l < r:
    ans = 0
else:
    ans = 2019
    for i in range(ll, rr+1):
        for j in range(i+1, rr+1):
            k = i * j % 2019
            ans = min(ans, k)

print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if R-L >= 2018:
    print(0)
else:
    ans = 2020
    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>3:
  r=l+2019*2
ans=10000
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:
from sys import stdin

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

A = [(L + x) % 2019 for x in range(min(2019, R - L + 1))]
A.sort()

ans = 10 ** 8
for l in range(len(A) - 1):
    for m in range(l + 1, len(A)):
        if (A[l] * A[m]) % 2019 < ans:
            ans = (A[l] * A[m]) % 2019

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
l,r = list(map(int,input().split()))
MOD = 2019
res = 100000000000000000000000000000000
ans = []
for i in range(l,r+1):
    if res == 0:
        break
    for j in range(i+1,r+1):
        if res == 0:
            break
        if (i*j)%2019 < res:
            res = (i*j)%2019
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Lq = L // 2019
l = L % 2019
Rq = R // 2019
r = R % 2019

if Lq != Rq:
    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())

MOD = 2019

l = L%MOD

if R-L+1 >= 2019:
    print(0)
else:
    ans = 10**10
    for i in range(R-L+1):
        for j in range(i+1,R-L+1):
            s1 = l + i
            s2 = l + j
            ans = min(ans, s1*s2%MOD)
            #print(s1,s2,ans)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if R - L >= 2018: 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:
import sys

L, R = map(int, input().split())
ans = 2020
for i in range(L, R+1):
    if i % 2019 == 0:
        print(0)
        sys.exit()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

L,R=MAP()

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())

if b -a >= 2019:
    print(0)
    exit()
a %= 2019
b %= 2019

if b <= a:
    b += 2019
ans = 10 ** 10
for i in range(a,b):
    for j in range(i+1,b+1):
        ans = min(ans,(i * j) % 2019)
print(ans)

Submission status: Accepted

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

ans = 2019
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())
MOD = 2019

lmod = L%MOD
rmod = R%MOD

ans = 0
if R-L >= 2019:
    ans = 0
else:
    if lmod >= rmod:
        ans = 0
    else:
        ans = float("inf")
        for i in range(lmod,rmod+1):
            for j in range(i+1,rmod+1):
                x = i*j%MOD
                if ans > x:
                    ans = x
print(ans)

Submission status: Accepted

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

l=min(L,R)
r=max(L,R)
x=[]
for i in range(l,(r+1)) :
    for j in range(i+1,r+1):
        x.append((i*j)%2019)
if L==0 or R==0:
    print(0)
elif RR-LL>=2019:
    print(0)
else:
    print(min(x))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2019  # type: int


def solve(L: int, R: int):
    lmod = L % MOD
    rmod = R % MOD
    if R-L > MOD:
        # すべて使えるので、0
        print(0)
        return
    elif rmod < lmod:
        # 0を使える
        print(0)
        return
    else:
        # 2019よりも小さいから、全探索が間に合う
        m = +INF
        for i in range(lmod, rmod+1):
            for j in range(i+1, rmod+1):
                curr = (i*j) % MOD
                if curr < m:
                    m = curr
                    # print(i, j, curr)
        print(m)
        return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

# debug = True
# debug = False
#
# def dprint(*objects):
#     if debug == True:
#         print(*objects)

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

    l = L % 2019
    r = R % 2019
    if R - L >= 2019:
        print(0)
        return

    if r <= l:
        r = min(r+2019, R)

    mn = 2019
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            md = i * j % 2019
            #print(i, j, md, mn)
            if md < mn:
                mn = md
    print(mn)
solve()

Submission status: Accepted

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

if L // 2019 != R // 2019:
    print(0)
    exit()

l = L % 2019
r = R % 2019

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

print(minval)

Submission status: Accepted

Solution code:
mod = 2019
L,R = [int(x) for x in input().split()]
if(R-L>=2018):
    print(0)
else:
    l = L%mod
    r = R%mod
    if(r<l):
        print(0)
    elif(l<=3 and r>=673):
        print(0)
    else:
        ans = 2020
        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:
def main():
  l, r = map(int, input().split())
  if r - l >= 2019:
    print(0)
  else:
    ans = 2020
    for li in range(l, r+1):
      for ri in range(li+1, r+1):
        if (li*ri)%2019 < ans:
          ans = (li*ri)%2019
    print(ans)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

l,r = inm()
if r-l >= 2018:
    print(0)
    exit()
mn = 2020
for i in range(l,r):
    for j in range(i+1,r+1):
        s = (i*j)%2019
        if s < mn:
            mn = s
print(mn)

Submission status: Accepted

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

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