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 -*-
"""解説
2019で割った余りが同じであるような2数a, bにおいて、

a * c mod 2019
b * c mod 2019

は同じ値になる。

今求めたいのは、

(i*j) ≡ x (mod 2019)

のxの最小値である。

(例)
L=2020のとき、
mod 2019の世界では、2020は1と等価

よって、
2020 * 2021 は、
1 * 2 と等価

つまり、

(i*j) ≡ x (mod 2019) は、

(i%2019) * (j%2019) ≡ x (mod 2019) と同じ

そう考えると、i, jの調べる範囲は、

L%2019 ≦ i < j ≦ min(R, (L+2019)%2019)

なぜL+2019かというと、 mod2019の1周分の範囲を取れば、必ず0をかけることができ、そのとき最小値0になるから。

よって、(i, j)として調べる候補はたかだか2019**2 であり、全探索で間に合う。
"""

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

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

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

mini = 2018

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

    if mini==0:
      break
  if mini==0:
    break
print(mini)

Submission status: Accepted

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

# Rが2019未満のとき
if R < 2019 :
    print((L * (L + 1)) % 2019)
# 範囲内に2019を含む時
elif L <= 2019 and R >= 2019 :
    print(0)
# LもRも2019より高い場合
else :
    R = min(R, L + 2018)
    ans = 2018
    for i in range(L,R + 1):
        b = i + 1
        for j in range(b,R + 1):
            x = (i * j) % 2019
            ans = min(ans, x)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

mod_min = l * r
for i in range(l, r + 1):
    if mod_min == 0:
        break
    for j in range(i + 1, r + 1):
        mod_tmp = (i * j) % 2019
        if mod_tmp < mod_min:
            mod_min = mod_tmp
        if mod_min == 0:
            break

print(mod_min)

Submission status: Accepted

Solution code:
l,r=list(map(int,input().split()))
f=True
C=2019
if (r-l)<2019:
    for i in range(l,r+1):
        if C==0:
            break
        for t in range(i+1,r+1):
            if t*i%2019<C:
                C=t*i%2019
                if C==0:
                    break
else:
    C=0
print(C)

Submission status: Accepted

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

a = 100000000000
for i in range(L,R + 1):
  if a == 0:
    break
  for j in range(i + 1,R + 1):
    if a >= i * j % 2019:
      a = i * j % 2019
      if a == 0:
        break
  

print(a)

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
if r-l>2019:
    r=r-2019*((r-l)//2019-1)

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
L, R = map(int, input().split())
# 横
# L = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]
ans = 3000

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r = (int(i) for i in input().split())
mod = 2019
if r-l >=2019:
    print(0)
else:
    ans = float('inf')
    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())
ql, modl = divmod(L,2019)
qr, modr = divmod(R,2019)
min = 3000
if qr-ql>0 :
    min=0
else:
    for i in range(modl,modr):
        for j in range(i+1,modr+1):
            min = min if (i*j) % 2019 > min else (i*j) % 2019
print(min)

Submission status: Accepted

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

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

else:
    result = 2019
    for i in range(num, r-l+num):
        for j in range(i+1, r-l+num+1):
            result = min(result, i*j%2019)

    print(result)

Submission status: Accepted

Solution code:
L, R = map(int,input().split())
tmp = 2020
if R // 2019 != L // 2019 or R % 2019 == 0 or L % 2019 == 0:
    print('0')
else:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            modmin = i * j % 2019 
            if tmp > modmin:
                tmp = modmin
    print(tmp)

Submission status: Accepted

Solution code:
l,r = input().split()
l = int(l)
r = int(r)
N = int(2019)
  
ans = N
count = 0
right = min(l + N, r)
for i in range(l,right):
  for j in range(i+1,right+1):
    ans = min(ans, (i * j) % N)
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Line = list(map(int, input().split(" ")))
L = Line[0]
R = Line[1]

min=2018
if L//2019 != R//2019 or L%2019==0 or R%2019==0:
	print(0)
else:
	for i in range(L,R+1):
		for j in range(i+1,R+1):
			if ((i%2019)*(j%2019))%2019<min:
				min=((i%2019)*(j%2019))%2019
	print(min)

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())
rec = 2019
for i in range (2020):
    for j in range(2020):
        if i >= j or (L+j) > R:
            continue
        elif (((L+i)*(L+j)) % 2019) < rec:
            rec = ((L+i)*(L+j)) % 2019
print(rec)

Submission status: Accepted

Solution code:
import itertools
l,r=map(int,input().split())
d = r-l
mod_min=2018
if d > 2017:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    if lmod < rmod:
        mod_set = set(range(lmod,rmod+1))
    else:
        mod_set = set(range(r+1))|set(range(l,2019))
    for x,y in itertools.combinations(mod_set,2):
        mod_min = min(mod_min,(x*y)%2019)
    print(mod_min)

Submission status: Accepted

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

ans = -1
if r - l >= 2019 or (l % 2019) - (r % 2019) > 0:
    ans = 0
else:
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            tmp = (i * j) % 2019
            if ans < 0 or ans > tmp:
                ans = tmp

print(ans)

Submission status: Accepted

Solution code:
l,r=[int(i) for i in input().split()]
l2,r2=l%2019,r%2019
if l//2019<r//2019:
  print(0)
else:
  k=2019*2019
  for i in range(l,r):
    for j in range(i+1,r+1):
      k=min(k,i*j%2019)
  print(k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())

ans=1145141919
for i in range(n,m+1):
  for j in range(n,i):
    ans=min(ans,(i*j)%2019)
    if ans==0:
      print(0)
      exit()
print(int(ans))

Submission status: Accepted

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

L, R = l_inpl()

if R-L>=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*j%2019)

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# この数の中に2019が含まれている．
# 2019 * 2019 - 2019 

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

Submission status: Accepted

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

Submission status: Accepted

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

while l<r:
  y=r
  while l<y:
    x=l*y
    x=x%2019
    if x<ans:
      ans=x
    if ans==0:
      break
    y=y-1
  if ans==0:
    break
  l=l+1
print(ans)

Submission status: Accepted

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

if R-L >= 2019:
    print("0")
else:
    sL = L % 2019
    sR = R % 2019
    minjo = 2019

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

    print(minjo)

Submission status: Accepted

Solution code:
def solve(string):
    l, r = map(int, string.split())
    if r - l >= 2019:
        return "0"
    return str(min([i * j % 2019 for i in range(l, r + 1) for j in range(i+1, r + 1)]))


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

Solution code:
L, R = list(map(int, input().split()))
RR = R + 1
ans = []

for i in range(L, R):
    for j in range(i + 1, RR):
        a = i * j % 2019
        ans.append(a)
        if a == 0:
            break
    # breakされなかったら
    else:
        continue
    break
print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import math

#L<=i<j<=R
# i*j mod 2019の最小値

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

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

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if ans == 0:
                    break
        if ans == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
b=(a[0]*(a[0]+1))%2019
if (a[1]//2019)-(a[0]//2019) != 0:
  print(0)
else:
  for i in range(a[0],a[1]):
    for j in range(i+1,a[1]+1):
      if b>(i*j)%2019:
        b=(i*j)%2019
    if b==0:
      break
  print(b)

Submission status: Accepted

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

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

mod = 2019

if R - L > mod:
    print(0)
    exit()

if R % mod > L % mod:
    L_mod = L % mod
    R_mod = R % mod
else:
    L_mod = R % mod
    R_mod = L % mod

lowest = mod
for i in range(L_mod, R_mod):
    for j in range(i + 1, R_mod + 1):
        r = i * j % mod
        lowest = min(r, lowest)

print(lowest)

Submission status: Accepted

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

mod_l = l % 2019
mod_r = r % 2019

if (r - l >= 2019) or (mod_r < mod_l):
  print('0')
else:
  rem = 2018
  for i in range(mod_l, mod_r):
    for j in range(i+1, mod_r+1):
      if rem < (i*j)%2019:
        continue
      else:
          rem = (i*j)%2019

  print(rem)

Submission status: Accepted

Solution code:
l, r = [int(s) for s in input().split()]

mod_l = l % 2019
mod_r = r % 2019

if (r - l > 2018) or (mod_l > mod_r):
  print('0')
else:
  vmin = 2018
  for i in range(mod_l, mod_r):
    for j in range(i+1, mod_r+1):
      mod = (i * j) % 2019
      if mod < vmin:
        vmin = mod

  print(vmin)

Submission status: Accepted

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

#+++++
		
def main():
	l, r = map(int, input().split())
	
	if r - l >= 2019:
		return 0
	
	min_v = 2020
	for i in range(r+1)[l:]:
		for j in range(r+1)[i+1:]:
			v = i * j % 2019
			#print(i,j, i*j, v)
			min_v = v if v < min_v else min_v
		
	print(min_v)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

if r-l >= 2019:
    print "0"
else:
    res = 2018
    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())

m = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        if j % 2019 == 0:
            print(0)
            exit()
        else:
            tmp = (i % 2019) * (j % 2019) % 2019
            if tmp < m:
                m = tmp
print(m)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
R = min(L+2019, R)
ans = 2019
Flag = False

for i in range(L, R):
    for j in range(i+1, R+1):
        x = (i * j) % 2019
        ans = min(ans, x)
        if ans == 0:
            Flag = True
            break
    if Flag:
        break

print(ans)

Submission status: Accepted

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

def solve(L, R):
    if L // 2019 != R // 2019:
        return 0
    l, r = L % 2019, R % 2019
    if l == 0 or r == 0:
        return 0
    result = min(
        (i * j) % 2019
        for i in range(l, r)
        for j in range(i + 1, r + 1)
    )
    return result

print(solve(L, R))

Submission status: Accepted

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


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

yy = 2019

d = 2019

if R > L+2019:
    R = L+2019

for i in range(L,R):
    im = i % yy

    for j in range(i+1, R+1):
        jm = j % yy

        if im * jm % yy <= d:
            d = im * jm % yy

print(d)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
YEAR = 2019
ans_list = []

def main():
    l,r = map(int, input().split(" "))
    
    if l is 0:
        return l
    
    for i in range(l, r):
        for j in range(i+1, r+1):
            _i = i % YEAR
            _j = j % YEAR
            if ((_i * _j) % YEAR) is 0:
                return 0
            ans_list.append((_i * _j) % YEAR)
    
    if ans_list:
        return min(ans_list)
    else:
        return (r * l) % YEAR
    
if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
#if(mod[0]==mod[1]):
    #answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
print(answer)

Submission status: Accepted

Solution code:
#coding: utf-8
l, r = map(int,input().split())
l_mod, r_mod = map(lambda x: x % 2019, [l, r])
ans = 2019
#ans_i = 0
#ans_j = 0

if r - l <= 2019:
    R = r
    L = l
else:
    R = r_mod + 2019
    L = l_mod

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

Submission status: Accepted

Solution code:
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
print(answer)

Submission status: Accepted

Solution code:
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
    if count == 2018:
        break
    count = count + 1
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def calc():
  l, r = map(int,input().split())
  if r - l >= 2019:
    return 0
  ans = 2019
  for i in range(l, r):
    for j in range(i + 1, r + 1):
      n = (i * j) % 2019
      if n == 0:
        return 0
      elif n < ans:
        ans = n
  return ans
 
print(calc())

Submission status: Accepted

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

r_min = min(l+2019,r)
inf = float('inf')
ans = inf

for i in range(l,r_min+1):
    for j in range(i+1,r_min+1):
        modu = i*j
        if modu%2019 <= ans:
            ans = modu%2019

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

min_modulo = 2019
if R - L >= 2019:
    min_modulo = 0
else:
    num_list =\
        list(itertools.combinations(list(range(L, R + 1)), 2))
    for x, y in num_list:
        modulo = (x * y) % 2019
        if modulo == 0:
            min_modulo = 0
            break
        else:
            if modulo < min_modulo:
                min_modulo = modulo

print(min_modulo)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
L, R = [int(_) for _ in input().split()]
if R - L > 2017 or L % 2019 > R % 2019:
    print(0)
    exit()

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
right = min(L+2019, R+1)
minimum = 2019

for i in range(L,right):
    for j in range(i+1,right):
         minimum = min(minimum,(i*j) % 2019)

print(minimum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    minCount = float('inf')

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

if __name__ == "__main__":
     main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
ans=2019
for i in range(b-a+1):
  for j in range(b-a+1):
    hoge=a+i
    huga=a+j
    if(hoge<huga and huga<=b):
      ans=min((hoge*huga)%2019,ans)
      if(ans==0):
        print(0)
        exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

minmod = 2 * 10 ** 9


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

for i in range(l,r):
    imod = i % 2019
    for j in range(i+1,r+1):
        jmod = j % 2019
        minmod = min(minmod, (imod * jmod) % 2019)
        if minmod == 0:
            break

print(minmod)

Submission status: Accepted

Solution code:
import itertools

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

R = min(R, L+2019)

minimum = 2018

for c in list(itertools.combinations(list(range(L, R+1)),2)):
    mod = (c[0]*c[1]) % 2019
    if mod < minimum:
        minimum = mod
        
print(minimum)

Submission status: Accepted

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


ans = 2020
if R-L>=2019:
    ans = 0
L %= 2019
R %= 2019


if L>=R:
    R+=2019

# print(L,R)

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


        

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

R = min(R, L+2019)

mods = []

for c in list(itertools.combinations(list(range(L, R+1)),2)):
    mods.append((c[0]*c[1]) % 2019)

print(min(mods))

Submission status: Accepted

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

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

print(minimum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

BASE = 2019


def find_min_val(L, R):
    if R - L > 3000:
        return 0

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

    return res


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

    ans = find_min_val(L, R)
    print(ans)


main()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

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

  ans=[]
  for i in range(l,min(l+2020,r+1)):
    for j in range(i+1,min(l+2020,r+1)):
      ans.append((i*j)%2019)

  ans.sort()

  return ans[0]

print(main())

Submission status: Accepted

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

    print(res)

main()

Submission status: Accepted

Solution code:
L,R= list(map(int, input().split()))
N = min(R-L+1,2019)
MOD = 2019
m = MOD

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

print(m)

Submission status: Accepted

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

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

print(minimum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""ABC133_C"""
l,r = map(int,input().split())
ans = 999999
if r-l<672:
    for i in range(l,r):
        for j in range(i+1,r+1):
            if((i*j)%2019 < ans):
                ans = (i*j)%2019
else:
    ans = 0
print(ans)

Submission status: Accepted

Solution code:
l, r = [int(i) for i in input().split()]

base = 2019
l_mod = l % base
r_mod = r % base

if r - l >= base:
    print(0)
elif r_mod <= l_mod:
    print(0)
else:
    # print(l_mod * (l_mod + 1))
    ans = base
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j) % base)
    print(ans)

Submission status: Accepted

Solution code:
def main():
  l, r = map(int, input().split())
  LUT = [[(i*j)%2019 for i in range(2019)] for j in range(2019)]
  ans = 2018
  m = 2019
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      ans = min(ans, LUT[i % m][j % m])
      if ans == 0:
        return 0
  return ans

print(main())

Submission status: Accepted

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

rl = r-l
l2 = l%2019
r2 = l2+rl

if rl>2019:
    print(0)
else:
    min_dif = 2019
    for i in range(l2, r2):
        for j in range(i+1, r2+1):
            if (i*j)%2019 < min_dif:
                min_dif = (i*j)%2019
    print(min_dif)