Problem:


Score : 300 points

Problem Statement

You are given two non-negative integers L and R.
We will choose two integers i and j such that L \leq i < j \leq R.
Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Constraints

All values in input are integers.

0 \leq L < R \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

L R

Output

Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.

Sample Input 1

2020 2040

Sample Output 1

2

When (i, j) = (2020, 2021), (i \times j) \mbox{ mod } 2019  = 2.

Sample Input 2

4 5

Sample Output 2

20

We have only one choice: (i, j) = (4, 5).



Sample input:
2020 2040


Sample output:
2

Submission status: Accepted

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

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

L_waru = L // 2019
R_waru = R // 2019

#答えは2019以上にはならないので2019で初期化
ans = 2019

#両方同じ商のとき
if L_waru == R_waru :
    #i*j mod 2019 の最小値を探す
    for i in range(L,R):
        for j in range(i+1,R+1):
            if (ans > ( (i * j) % 2019)):
                ans = (i * j) % 2019
            if ( ( (i * j) % 2019) == 0 ):
                print(0)
                exit()
    print(ans)
#商が違うときは割り切れる数が間にあるので(i*j)は0
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin

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

    mod = []
    r = min(R, L + 2019)
    for i in range(L, r):
        for j in range(i + 1, r + 1):
            mod.append((i * j) % 2019)
    print(min(mod))

input = stdin.readline
main()

Submission status: Accepted

Solution code:
LR = input().split(' ')
L = int(LR[0])
R = int(LR[1])

min_num = 2000000001
flag = False
for l in range(L,R):
    for r in range(l+1,R+1):
        mod = (l*r) %2019
        if mod < min_num:
            min_num = mod
            if mod == 0:
                flag =True
                break
    if flag:
        break

print(min_num)

Submission status: Accepted

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

if R - L > 2019:
    print(0)
else:
    for k in range(L, R):
        for j in range(k + 1, R + 1):
            ans.append((k * j) % 2019)
    print(min(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
#余りが0になった時点で以降の処理をやめる
import math
l, r = map(int, input().split())
ans = 2018

for i in range(l, r+1):
    for j in range(i+1, r+1):
        mod = (i * j) % 2019
        if mod < ans:
            ans = mod
        if mod == 0:
            ans = 0
            break
    else:
    #最小値が入れ替わらない、もしくは0が出なかった場合は次の数と比較
        continue
    break

print(ans)

Submission status: Accepted

Solution code:
##C
l,r=map(int,input().split())
c=(r-l)
d=2018
if c>=2018:
    print(0)
else:
    for i in range(l,r):
        for k in range(l+1,r+1):
            
            if (i*k)%2019<d:
                d=(i*k)%2019
    print(d)

Submission status: Accepted

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

Submission status: Accepted

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

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

l_q, l_mod = divmod(l, 2019)
r_q, r_mod = divmod(r, 2019)

min_v = 2019
if l_q == r_q:
    for i in range(l_mod, r_mod+1):
        for j in range(l_mod, r_mod+1):
            if i != j:
                mul = (i * j) % 2019
                if mul < min_v:
                    min_v = mul
else:
    min_v = 0

print(min_v)

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    d = dict()
    for i in range(L, min(R+1, L+2019*2)):
        v = i % 2019
        if v not in d: d[v] = 1
        else: d[v] += 1

    min_r = 2018
    for i in d:
        if i in d and d[i] > 1:
            min_r = min(min_r, (i*i) % 2019)

    for i in d:
        for j in d:
            if i < j: min_r = min(min_r, (i*j) % 2019)

    return min_r



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

Submission status: Accepted

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

Submission status: Accepted

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

print(tmp)

Submission status: Accepted

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

for n in range(l,r+1):
    for m in range(n+1,r+1):
        tmp = n*m%2019
        if tmp == 0:
            print(0)
            exit()
        ans.append(tmp)
print(min(ans))

Submission status: Accepted

Solution code:
L, R = map(lambda x: int(x),input().split(" "))
num_list = []

while L > 2019:
  L = int(L-2019)
  R = int(R-2019)

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

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
waruL = l // 2019
waruR = r // 2019
if waruL < waruR :
    modMin = 0
else:
    modMin = 2018
    modL = l%2019
    modR = r%2019

    for i in range(modL,modR):
        for j in range(i+1,modR+1):
            modIJ = (i*j)%2019

            if modIJ < modMin:
                modMin = modIJ
print(modMin)

Submission status: Accepted

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

    else:
        print(0)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
ans =[]
if R-L>=2019:
    print(0)
    exit()

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:
L, R = map(int, input().split())
mod = 2019

minimum = 2019
for i in range(L, R):
    mod_i = i % mod
    for j in range(i+1, R+1):
        mod_j = j % mod
        result = (mod_i * mod_j) % mod
        if result < minimum:
            minimum = result
        if minimum == 0:
            print(0)
            exit(0)
print(minimum)

Submission status: Accepted

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


ans = 10 ** 10


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

print(ans)

Submission status: Accepted

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

if (R - L) >= 2019:
    print (0)
else:
    min_p = 2019
    for n in range(L, R):
        for n2 in range(n + 1, R + 1):
            tmp_p = (n * n2) % 2019
            if (tmp_p < min_p):
                min_p = tmp_p

    print (min_p)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(L, R+1):
    if i % 2019 == 0:
        print(0)
        check = True
        break
    else:
        ans.append(i % 2019)

if not check:
    ij = 2019
    for i in range(len(ans)-1):
        for j in range(i+1, len(ans)):
            temp = ans[i] * ans[j] % 2019
            if temp < ij:
                ij = temp
    print(ij)

Submission status: Accepted

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

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

print(min_remaider)

Submission status: Accepted

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

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

        ans = i*j%2019
        
        if i == l and j == l+1:
            min = ans
    
        if ans < min:
            min = ans
        
        if min == 0:
            break

    if min == 0:
        break

print(min)

Submission status: Accepted

Solution code:
inp = [int(v) for v in input().split(' ')]
L = inp[0]
R = inp[1]

minv = 2020
for i in range(L, min(R + 1, L + 2019)):
    for j in range(i + 1, min(R + 1, i + 1 + 2019)):
        v = (i * j) % 2019
        if v < minv:
            minv = v
print(minv)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
R = min(L + 2019, R)
lst = list(range(L, R + 1))
ret = 2018
for idx, x in enumerate(lst):
    for y in lst[idx + 1:]:
        ret = min(ret, x * y % 2019)
print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def mod(x,y):
    return (x*y)%2019

ans = 2020
if l-r >= 2019:
    ans = 0
elif l-r < 2019:
    for i in range(l,r,1):
        for j in range(i+1,r+1,1):
            temp = mod(i,j)
            ans = min(temp,ans)
            if ans == 0:
                break
        else:
            continue
        break

print(ans)

Submission status: Accepted

Solution code:
#######################################
p = 2019

l,r = map(int, input().split())
n = r-l+1

if n<2*p:
  tmps = [(i*j)%p for i in range(l,r) for j in range(i+1,r+1)]
  mini = min(tmps)

else:
  #lis = list(range(l,r+1))[:p+1]
  #lis = list(set([li%p for li in lis]))
  #tmps = [(i*j)%p for i in lis for j in lis]
  #mini = min(tmps)
  mini = 0

print(mini)

Submission status: Accepted

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

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

print(mod)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
r = min(r, l+2019)
# ある数を2019で割った時の余りの最大値(2018)でminを初期化
min = 2018
for i in range(l,r):
  for j in range(i+1,r+1):
    value = (i*j)%2019
    if min > value:
      min = value
print(min)

Submission status: Accepted

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

r = min(r, l+4038)

min = 99999999
for i in range(l,r):
  for j in range(i+1,r+1):
    value = (i*j)%2019
    if min > value:
      min = value
print(min)

Submission status: Accepted

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

# L と Rの差が十分に大きければ、答えは0になる
# それ以外の状況であれば愚直に計算しても大した計算量ではない。

MOD = 2019
ouput = 2020 * 2020
for i in range(L, R + 1):
    for j in range(L, R + 1):
        if j > i and ouput > (i * j) % MOD:
            ouput = (i * j) % MOD
            if ouput == 0:
                print(ouput)
                exit()

print(ouput)

Submission status: Accepted

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

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

Submission status: Accepted

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

if r-l > 2019:
    s=list(range(0, 2019))
else:
    s=set()
    for i in range(l, r+1):
        s.add(i%2019)
    s=list(s)

ans=float('inf')
for i in range(len(s)):
    for j in range(i+1, len(s)):
        ans=min(ans, (s[i]*s[j])%2019)

print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
mod = 2019
ans = mod
for l in range(L, L + mod + 2):
    for r in reversed(range(R - mod - 2, R + 1)):
        if l >= r:
            break
        ans = min(ans, (l * r) % mod)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

least = 2*(10**9)+1
for i in range(l, r):
    for j in range(i+1, r+1):
        if (i * j % 2019) == 0:
            print(0)
            exit()
        least = min(least, (i * j % 2019))

print(least)

Submission status: Accepted

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

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)
        if min_mod == 0:
            print('0')
            exit(0)

print(min_mod)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
l_mod2019 = l % 2019
r_mod2019 = r % 2019
x_list = [2019]
if r - l >=2018 or l_mod2019 >= r_mod2019:
    print(0)
else:
    for i in range(l_mod2019, r_mod2019):
        for j in range(l_mod2019 + 1, r_mod2019 + 1):
            if i < j:
                x = (i * j) % 2019
                if x < min(x_list):
                    x_list.append(x)
                else:
                    pass
            else:
                pass
    print(x_list[-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

print(min(a))

Submission status: Accepted

Solution code:
L,R = list(map(int,input().split()))
 
min = 20000000
 
#探索範囲決め
for i in range(L,R+1):
    tmp = i
    if tmp % 2019 == 0:
        break

for i in range(L,tmp+2):
    for j in range(i + 1,tmp+2):
        if min > (i * j) % 2019 and i <= R and j <= R and L <= i:
            min = (i * j) % 2019
            if min == 0:
                break
    if min == 0:
        break
 
print(min)

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):
		temp = (i*j)%2019
		#print("{} {}".format(i,j))
		if ans > temp:
			ans = temp
			if ans == 0:
				print(ans)
				exit()
if ans == 2019:
	ans = l*r
print(ans)

Submission status: Accepted

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

    sort_list = sorted(count_list)
    print(sort_list[0])

Submission status: Accepted

Solution code:
import math
from operator import itemgetter as ig
from collections import defaultdict as dd
# 定数
INF = float("inf")
MOD = int(1e9 + 7)
# データ構造：ヒープ
import heapq
class heapque:
    def __init__(self, *args):
        self.que = []
        for arg in args:
            self.push(arg)
    def push(self, v):
        heapq.heappush(self.que, v)
    def pop(self):
        return heapq.heappop(self.que)
# 最大公約数 / 最小公倍数
def gcd(v1, v2):
    if v2 == 0:
        return v1
    return gcd(v2, v1 % v2)
def lcm(v1, v2):
    return (v1 // gcd(v1, v2)) * v2
# 二分探索
def bsr(a, v, lo=0, hi=None):
    if hi == None:
        hi = len(a) - 1
    if hi < lo:
        return lo
    mi = (lo + hi) // 2
    if v < a[mi]:
        return bsr(a, v, lo, mi - 1)
    else:
        return bsr(a, v, mi + 1, hi)
# Union-Find木
class uft:
    def __init__(self, n):
        self.height = [1] * n
        self.group = [-1] * n
    def root(self, v):
        if self.group[v] < 0:
            return v
        self.group[v] = self.root(self.group[v])
        return self.group[v]
    def size(self, v):
        return - self.group[self.root(v)]
    def merge(self, v1, v2):
        v1, v2 = self.root(v1), self.root(v2)
        if v1 == v2:
            return
        if self.height[v1] < self.height[v2]:
            self.group[v2] += self.group[v1]
            self.group[v1] = v2
            self.height[v2] = max(self.height[v1] + 1, self.height[v2])
        else:
            self.group[v1] += self.group[v2]
            self.group[v2] = v1
            self.height[v1] = max(self.height[v1] , self.height[v2] + 1)

def main():
    L, R = map(int, input().split())
    if 2019 < (R - L + 1):
        print(0)
    else:
        min_mod = INF
        for l in range(L, R + 1):
            for r in range(l + 1, R + 1):
                min_mod = min(min_mod, l * r % 2019)
        print(min_mod)

main()

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    l, r = list(map(int, input().split(" ")))

    ans = 3000
    for i in range(l, r):
        for j in range(i+1, r+1):
            candidate = (i * j) % 2019
            if candidate < ans:
                ans = candidate
            if ans == 0:
                print(ans)
                return
    print(ans)
    return

main()

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    l, r = list(map(int, input().split(" ")))
    
    ans = 3000
    for i in range(l, r):
        for j in range(i+1, r+1):
            candidate = (i * j) % 2019
            if candidate < ans:
                ans = candidate
            if ans == 0:
                return ans
    return ans


print(main())

Submission status: Accepted

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

ans = 3000

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, r = map(int, 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())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
mod=2019
ans=2019
start=L//mod
goal=R//mod
if start!=goal:
  print(0)
else:
  a=L%mod
  b=R%mod
  for i in range(a,b):
    for j in range(i+1,b+1):
      if ans>(i*j)%mod:
        #print(i,j)
        ans=(i*j)%mod
  print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools

input = sys.stdin.readline

def func(l, r):
    mod_min = float('inf')

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

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

            elif mod < mod_min:
                mod_min = mod

    print(mod_min)

def main():
    l, r = [int(i) for i in input().split()] 
    func(l, r)
    
# main関数呼び出し
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(l, r):
    score = float('inf')

    for i in range(l, r):
        for j in range(i + 1, r + 1):
            current = i * j % 2019
            score = min(score, current)
            if score == 0:
                return score

    return score


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
mod1 = []
mod2 = []
cccc=0
for i in range(l,r+1):
  b=i%2019
  mod1.append(b)
  if b==0:
    cccc=1
    break
#print(mod1)
if cccc==1:
  print(0)
else:
  for i in range(len(mod1)-1):
    for j in range(i+1,len(mod1)):
      mod2.append((mod1[i]*mod1[j])%2019)
	#print(mod2)
  print(min(mod2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if R-L >= 2018:
    print(0)
else:
    out = 2019
    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:
#30 ABC133C
l,r=map(int,input().split())
j=(r-l>=2019)
l%=2019
r%=2019
if l>=r:
	print(0)
elif j:
	print(0)
else:
	res=1<<32
	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:
import math
L, R = map(int, input().split())
R=min(R,L+2019)
m=2018
for i in range(L,R+1):
  for j in range(i,R+1):
    if i==j:
      continue
    if (i*j)%2019<m:
      m=(i*j)%2019
print(m)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
width = min(2019, r-l)
ans = float('inf')
for i in range(l, l+width):
    for j in range(i+1, l+width+1):
        mo = (i*j)%2019
        if mo < ans:
            ans = mo
print(ans)

Submission status: Accepted

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

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

minmod = 2019
for i in range(L, R):
    for j in range(i+1, R+1):
        mod = (i * j) % 2019
        if minmod > mod:
            minmod = mod

print( minmod )

Submission status: Accepted

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

Submission status: Accepted

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

    for i in range(l, r+1):
        for j in range(i+1, r+1):
            mod = i * j % 2019
            if mod == 0:
                return 0
            elif mod < ans:
                ans = mod

    return ans


print(main())

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

L,R = II()

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

Submission status: Accepted

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

Submission status: Accepted

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

s = set(map(lambda x:x%2019, range(L, R+1)[:2019]))

print(min([i*j%2019 for i, j in f(s, 2)]))

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
an=(l*(l+1))%2019

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

print(an)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# Remainder Minimization 2019

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

for i in range(L, R):
    for j in range(i+1,R+1):
        a.append((i*j)%2019)
        if (i*j)%2019 == 0:
            print("0")
            exit()

print(min(a))

Submission status: Accepted

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

ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    X = list(range(L, R+1))
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)

Submission status: Accepted

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

for i in range(L, R):
	for j in range(i+1,R+1):
		a.append((i*j)%2019)
		if (i*j)%2019 == 0:
			print("0")
			sys.exit()

print(min(a))

Submission status: Accepted

Solution code:
l, r = map(int,input().split())
min_val = float('inf')
for i in range(l,r):
  for j in range(l+1, r+1):
    tmp = i*j%2019
    if min_val>tmp:
      min_val = tmp
    if min_val == 0:
      break
  if min_val == 0:
    break
print(min_val)

Submission status: Accepted

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

Submission status: Accepted

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

min_value = 2019

for i in range(L, R+1):
	for j in range(L, R+1):
		if i >= j:
			continue

		value = (i * j) % 2019
		if value < min_value:
			min_value = value

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

print(min_value)

Submission status: Accepted

Solution code:
l, r = (int(i) for i in input().split())
ans = float('inf')
for i in range(l,min(l+2019,r)):
    for j in range(i+1,min(i+1+2019,r+1)):
        val = i*j % 2019
        if val < ans:
            ans = val
print(ans)

Submission status: Accepted

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

m = 2018

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

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

print(m)