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())
cnt=0
c=L//2019
d=R//2019+1
for i in range(c,d+1):
    if L<=2019*i<=R:
        cnt+=1
        break
if cnt==1:
    print(0)
else:
    ans=100000
    for i in range(L,R+1):
        for j in range(L,R+1):
            if i==j:
                continue
            else:
                if ans>i*j%2019:
                    ans=i*j%2019
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

n = min(l+2020, r)

ans = 2018

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

print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split(' '))
if (r - l) > 2019:
  r = l + 2019
ary = [num for num in range(l, r+1)]
# print(ary)
ans = 10000

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

print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	L,R=map(int,input().split())
	ans=0
	LL, RR = L % 2019, R % 2019
	if R-L<2019 and LL<RR:
		ans=2018
		L,R=L%2019,R%2019
		for i in range(LL,RR):
			j=1
			while i+j<=RR:
				ans=min(ans,(i*(i+j))%2019)
				j+=1
	print(ans)
	





if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

print(out)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
mod=2019
a=l//mod
b=r//mod
if a<b:
  print(0)
else:
  c=l%mod
  d=r%mod
  p=8101919
  for i in range(c,d):
    for j in range(i+1,d+1):
      p=min(p,(i*j)%mod)
  print(p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
a=2019
lpre=l//a
rpre=r//a
if lpre==rpre:
    l=l%a
    r=r%a
else:
    l=l%a
    r=r%a+a
my_min=float("INF")
for i in range(l,r+1):
    for j in range(i+1,r+1):
        b=(i*j)%a
        if b<my_min:
            my_min=b

print(my_min)

Submission status: Accepted

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

ret = 2019 ** 2
flag = False
for l in range(L, R):
    for r in range(l + 1, R + 1):
        temp = (l % 2019) * (r % 2019) % 2019
        if ret > temp:
            ret = temp
            if ret == 0:
                print(0)
                exit()

print(ret)

Submission status: Accepted

Solution code:
def fun(L,R):
    if R-L>=2019:
        return 0
    else:
        ll = L%2019
        rr = R%2019
        if ll>R:
            return 0
        else:
            r = 2018
            for i in range(L,R+1):
                for j in range(i+1,R+1):
                    r=min(r,i*j%2019)
            return r
        


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

Submission status: Accepted

Solution code:
# 2019-11-15 13:51:51(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

mod = 2019

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# 2019-11-15 13:51:51(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 




mod = 2019

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

if (r-1) * r < 2019:
    print(l * (l+1))
elif r - l > 2019:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for k in range(i+1, r+1):
            a = ((i % 2019) * (k % 2019)) % 2019
            if a < ans:
                ans = a
    print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def print_ans(L, R):
    """Test Case
    >>> print_ans(2020, 2040)
    2
    >>> print_ans(4, 5)
    20
    """
    tmp = R - L
    if tmp > 2019:
        print("0")
    else:
        L = L % 2019
        R = L + tmp
        ans = 2019
        flg = False
        for i in range(L, R):
            for k in range(i + 1, R + 1):
                ans = min(ans, (i * k) % 2019)
                if ans == 0:
                    flg = True
                    break
            if flg :
                break
        print(ans)



if __name__ == '__main__':
    L, R = map(int, input().rstrip().split())
    print_ans(L, R)

Submission status: Accepted

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


def main():
    sc = Scan()
    l, r = sc.intarr()
    if r - l >= 2019:
        print('0')
        exit()
    minimum = 2019
    for i in range(l, r):
        for j in range(i+1, r+1):
            num = (i*j) % 2019
            if num < minimum:
                minimum = num
                if minimum == 0:
                    print('0')
                    exit()
    print(minimum)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()

Submission status: Accepted

Solution code:
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

[L,R] = inpl()
rL, rR = L%2019, R%2019
temp = INF
ans = INF
if R-L>= 2018 or rL > rR : ans = 0
else:
    for i in range(rL, rR):
        for j in range(i+1, rR+1):
            temp = ( i*j ) %2019
            if temp < ans: ans = temp
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
L,R=map(int,input().split(' '))
l,r=L%2019,R%2019
D=R-L
d=r-l
if D<2019:
  if D==d:
    res=[]
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        res.append((i*j)%2019)
    print(min(res))
  else:
    print(0)
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

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

flg = False

for i in range(l, (r + 1), 1):
    if ((i % mod) == 0):
        flg = True
        break

if (flg):
    print(0)
else:
    ans = 2019

    for i in range((l % mod), (r % mod), 1):
        for j in range(((l % mod) + 1), ((r % mod) + 1), 1):
            rep = (i * j) % mod

            if (rep < ans):
                ans = rep

    print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
    exit()
L_mod = L % 2019
R_mod = R % 2019
if L_mod > R_mod:
    R_mod += 2019
can = float('INF')
for i in range(L_mod, R_mod):
    for j in range(i + 1, R_mod + 1):
        if can > i * j % 2019:
            can = i * j % 2019
print(can)

Submission status: Accepted

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

total = 2019

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

for l in range(L,R):
  for r in range(L+1,R+1):
    if l*r%2019 == 0:
      print(0)
      exit()
    else:
      total = min(total,l*r%2019)
    
print(total)

Submission status: Accepted

Solution code:
import math

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

ans = 2019

for i, j in zip(range(2019), range(L, R)):
    for k in range(j+1, min(L + 2019*2, R + 1)):
        lr_mod = (j * k) % 2019
        if lr_mod < ans:
            ans = lr_mod
        if ans==0:break
    if ans==0:break

print(ans)

Submission status: Accepted

Solution code:
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

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

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

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

# %%
# from atcoder_test import doTest
# doTest("abc133","c",main)

Submission status: Accepted

Solution code:
import heapq

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

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

Submission status: Accepted

Solution code:
from itertools import combinations
_=list(map(int,input().split()))
print(min([i[0]*i[1]%2019 for i in list(combinations([i for i in range(_[0],_[1]+1)],2)if _[1]-_[0]<2019else combinations([i for i in range(_[0],_[0]+2020)],2))]))

Submission status: Accepted

Solution code:
from itertools import combinations
_=list(map(int,input().split()))
a=list(combinations([i for i in range(_[0],_[1]+1)],2) if _[1]-_[0]<2019 else combinations([i for i in range(_[0],_[0]+2020)],2))
print(min([i[0]*i[1]%2019 for i in list(a)]))

Submission status: Accepted

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

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# coding: utf-8
L,R = map(int, input().split())
mod_min=2020

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

Submission status: Accepted

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

Submission status: Accepted

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

li = []

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

print(ans)

Submission status: Accepted

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

mod_list = []
mul_list = []
if R >= L + 2019:
    print(0)
else: 
    for i in range(L, R+1):
        if i % 2019 == 0:
            print(0)
            break
        else:
            mod_list.append(i)
    else: #連続する2数の積が最小だが2019で割るとそれが最小になるかはわからない
        for i in range(len(mod_list)):
            for j in range(len(mod_list)):
                if i != j: #同じ数は選べない
                    k = (mod_list[i] * mod_list[j]) % 2019
                    mul_list.append(k)
                else:
                    pass

        print(min(mul_list))

Submission status: Accepted

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

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

elif (l % 2019) > (r % 2019):
    print(0)

else:
    li = [i for i in range((l % 2019),(r % 2019)+1)]
    c = 2020
    for i in range(len(li)-1):
        for j in range(i+1,len(li)):
            c1 = (li[i]*li[j]) % 2019
            c = min(c1,c)
    print(c)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
li = []
li_a =[]
if R-L+1 >= 2019:
  print(0)
else:
  for i in range(L, R+1):
    li.append(i%2019)
  for x in li:
    for y in li:
      if x != y:
        li_a.append((x*y)%2019)
  print(min(li_a))

Submission status: Accepted

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

if 2019 <= R - L:
  print('0')
  exit(0)
    
for i in range(L, R):
  for j in range(i+1, R+1):
    mods.append(i*j%2019)
print(min(mods))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    L,R=map(int,input().split())
    d=R-L
    L%=2019
    d=min(d,2019)
    from itertools import product
    ans=INF
    for i,j in product(range(d+1),repeat=2):
        if(i>=j): continue
        ans=min(ans,(L+i)*(L+j)%2019)
    print(ans)
resolve()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

modl = [0 for i in range(2019)]

if r - l > 2019:
    modl = [1 for i in range(2019)]
else:
    for i in range(l,r+1):
        modl[i%2019] = 1

ans = float("inf")
for i in range(2019):
    for j in range(i+1, 2019):
        if modl[i] == 1 and modl[j] == 1:
            tmp = i * j % 2019
            if tmp < ans:
                ans = tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2020, 2040), 2)

    def test_2(self):
        self.assertEqual(think(4, 5), 20)


def solve():
    l, r = read()
    result = think(l, r)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(l, r):
    mode = 2019
    m = 2018

    for i in range(l, r):
        for j in range(i + 1, r + 1):
            if i % mode == 0 or j % mode == 0:
                return 0
            m = min(m, (i % mode * j % mode) % mode)
    return m


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
L,R = map( int,input().split() )
ans = ( L * (L+1) ) % 2019  
for i in range(L,R):
    if ans == 0:
        break
    j = i + 1
    a = ( i * j ) % 2019
    ans = min(a, ans)
    plus = i % 2019
    while(True):
        over = math.ceil( ( 2019 - a ) / plus )
        j = j + over
        if j > R:
            break
        a = ( i * j) % 2019
        ans = min(a,ans)
        if ans == 0:
            break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
a=(l-1)//2019
b=l%2019
c=r//2019
d=r%2019
if a<c:
  print("0")
else:
  if b>=d:
    d=d+2019
  e=(b*d)%2019
  for i in range(b,d):
    for j in range(i+1,d+1):
      f=(i*j)%2019
      if f<e:
        e=f
      j=j+1
    i=i+1
  print(e)

Submission status: Accepted

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

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

Submission status: Accepted

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

    print(m)

Submission status: Accepted

Solution code:
l, r = (int(i) for i in input().split())
if r - l > 2030: print(0)
else:
    ans = 2018
    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())

def repeat_division(n):
    while True:
        if n < 2019:
            break
        n %= 2019
    return n

l = repeat_division(L)
r = repeat_division(R)

if R - L  >= 2019:
    print(0)
elif l > r:
    print(0)
else:
    min = 2019
    for k in range(l, r):
        for i in range(k+1,r+1):
            if min > repeat_division(k * i):
                min = repeat_division(k * i)
    print(min)

Submission status: Accepted

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

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l = lr[0]
r = lr[1]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tmp = list(map(int, input().split()))
l = tmp[0]
r = tmp[1]

ans = 2019
if (l // 2019) == (r // 2019):
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      rem = i * j % 2019
      if rem < ans:
        ans = rem
else:
  ans = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    MOD = 2019
    L, R = map(int, input().split())
    # R = min(R, L+MOD*2)
    ans = MOD - 1

    if R - L >= 3000:
        print(0)
        return

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

    print(ans)


if __name__ == '__main__':
    main()

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:
            print(ans)
            exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC133C - Remainder Minimization 2019
def main():
    L, R = map(int, input().split())
    MOD = 2019
    if R - L + 1 >= MOD:  # L <= 2019n <= R
        print(0)
    else:  # max: 2018 * 2017 patterns
        L, R = L % MOD, R % MOD
        if L <= 3 and R >= 673:  # 2019 = 3 * 673
            print(0)
            return
        # 3 < L < R < 673
        ans = min((i * j) % MOD for i in range(L, R) for j in range(i + 1, R + 1))
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

mod = 2019
minij = 2020

for i in range(l, r):
    for j in range(i+1, r+1):
        if (i * j) % mod < minij:
            minij = (i*j) % mod
            if minij == 0:
                print(minij)
                exit(0)

print(minij)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
l,r = map(int, input().split())

if r-l+1>=2019 or l==0:
    print(0)
else:
    res = 2019*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 L%2019==0 or R%2019==0:
  print(0)
else:
  start=L%2019
  end=R%2019
  if start>=end or R-L>=2018: #中に2019の倍数が含まれるとき
    print(0)
  else:
    m=(L*(L+1))%2019
    for i in range(L,R):
      for j in range(i+1,R+1):
        s=(i*j)%2019
        m=min(m,s)
    print(m)

Submission status: Accepted

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

Submission status: Accepted

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

l=L%2019
r=R%2019

ans=0

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

print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
ans = []
for i in range(l, r+1):
    for j in range(i+1, r+1):
        if j == i+1:
            start = (i*j) % 2019
        tmp = (i*j) % 2019
        if tmp == 0:
            print(0)
            exit()
        # if j != i+1 and tmp == start:
        #     break
        # else:
        #     ans.append(tmp)
        ans.append(tmp)
print(min(ans))

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
ans = []
for i in range(l, r+1):
    for j in range(i+1, r+1):
        if j == i+1:
            start = (i*j) % 2019
        tmp = (i*j) % 2019
        if tmp == 0:
            print(0)
            exit()
        if j != i+1 and tmp == start:
            break
        else:
            ans.append(tmp)
print(min(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    ans = float('inf')
    if R-L >= 672:
        ans = 0
        print(ans)
        return
    for i in range(L,R):
        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:
import sys


def slove():
    input = sys.stdin.readline
    l, r = list(map(int, input().rstrip('\n').split()))
    mt = 10 ** 10
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            mt = min(mt, (i * j) % 2019)
            if mt == 0:
                print(mt)
                exit()
    print(mt)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
amari_list =[]
count = 0
for i in range(R-L+1):
  (L+i)
  amari_list.append((L+i) % 2019)
  count += 1
  if count > 2019:
    break   
answer_list =[]
for i in range(len(amari_list)):
  for j in range(len(amari_list)-i-1):
    answer_list.append((amari_list[i]*amari_list[len(amari_list)-j-1])%2019)
print(min(answer_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
d = 2019 - (L % 2019)
ans = 2019 * 2019

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

print(ans)