Problem:


Score : 300 points

Problem Statement

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

L R

Output

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

Sample Input 1

2020 2040

Sample Output 1

2

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

Sample Input 2

4 5

Sample Output 2

20

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



Sample input:
2020 2040


Sample output:
2

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
ans=10**15
for i in range(l,min(r,l+2100)):
  for j in range(i+1,min(r+1,l+2100)):
    ans=min(ans,(i*j)%2019)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
a, b = map(int, input().split())
if b - a >= 2019:
  print(0)
  
else:
  all_ = np.mod([i for i in range(a, b+1)], 2019)
  all_ = np.outer(all_, all_)
  n = all_.shape[0]
  all_ = np.mod(all_ * (np.ones((n,n)) - np.eye(n)) + np.eye(n) * 2018, 2019)
  print(int(all_.min()))

Submission status: Accepted

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

ans = 2019
end_flag = False

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

        if ans==0:
            end_flag = True
            break

    if end_flag:
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

mod_L = L % mod
mod_R = R % mod

if mod_L >= mod_R:
    print(0)
    exit()

if mod_R - mod_L < R - L:
    print(0)
else:
    ans = False
    for i in range(mod_R - mod_L):
        for j in range(i + 1, mod_R - mod_L + 1):
            if ans is not False:
                ans = min(ans, (mod_L + i) * (mod_L + j) % mod)
            else:
                ans = (mod_L + i) * (mod_L + j) % mod
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
L, R = map(int, input().split(' '))
if R - L >= 2020:
    print(0)
    exit()

ret = float('inf')
for i1 in range(L, R+1):
    for i2 in range(i1+1, R+1):
        ret = min(ret, (i1*i2)%2019)

print(ret)

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mod = 2019
l, r = map(int, input().split())
m = min(r, l + mod)
MN=[]
for i in range(l, m):
    for j in range(i+1, m+1):
        MN.append(i*j%mod)
print(min(MN))

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
i=0
j=0
l=0
r=0
md=float("inf")
if R-L>=673:
    print("0")
else:
    l=L%2019
    r=R%2019
    if l>r:
        print("0")
    elif l<r:
        l=L%2019
        r=R%2019
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                if (i*j)%2019<md:
                    md=(i*j)%2019
                #print(i,j)
        print(md)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = [int(i) for i in input().split()]
ln = l // 2019
rn = r // 2019
if ln != rn:
	print (0)
else:
	ret = 2019 * 2019
	for i in list(range(l % 2019, r % 2019 + 1)):
		for j in list(range(i + 1, r % 2019 + 1)):
			ret = min(ret, (i * j) % 2019)
	print (ret)

Submission status: Accepted

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    MOD = 2019
    L,R = [int(s) for s in input().split()]
    if R-L+1 >= MOD:
        print(0)
        sys.exit()

    min_rmdr = MOD

    for i in range(L,R):
        for j in range(L+1,R+1):
            if (i * j) % MOD < min_rmdr:
                min_rmdr = (i * j) % MOD
    
    print(min_rmdr)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
l, r = list(map(int, input().split()))
MOD = 2019
#print(l // MOD)
#print(r // MOD)
#print(l % MOD)
#print(r % MOD)
result = 1 << 31
for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    i %= MOD
    j %= MOD
    if i == 0 or j == 0:
      print(0)
      exit(0)
    result = min(result, (i * j) % MOD)
print(result)

Submission status: Accepted

Solution code:
import os, sys, re, math

(L, R) = [int(n) for n in input().split()]

R = min(R, L + 2019)
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 = list(map(int, input().split(' ')))
hoge = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        hoge = min(hoge, (i*j) % 2019)
        if not hoge:
            break
    if not hoge:
        break
print(hoge)

Submission status: Accepted

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


if w>2019:
    print(0)
else:
    List = [int(i) for i in range(L,R+1)]
    Min = 2018
    for i in range(len(List)-1):
        for j in range(i+1,len(List)):
            l = (List[j]*List[i])%2019
            if l<Min:
                Min = l
    print(Min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def rem(L, R):
  if (R//2019) - (L//2019) > 0:
    return 0
  L = L % 2019
  R = R % 2019
  res = 2018
  for i in range(L, R):
    for j in range(i+1, R+1):
      m = (i*j)%2019
      if res > m:
        res = m
  return res

print(rem(L, R))

Submission status: Accepted

Solution code:
year = 2019

l, r = map(int, input().split())
d = l // year
l %= year
r -= d * year
if l == 0 or r >= year:
    print(0)
else:
    ans = year
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = i * j % year
            ans = min(ans, res)
            if res == ans: param = (i, j)
    print(ans)

Submission status: Accepted

Solution code:
#abc133 c
L,R=map(int,input().split())
x=R-L
ans=0
R=min(R,L+2019*2)
ans=2018
for i in range(L,R+1):
    for j in range(i+1,R+1):
        amari=(i*j)%2019
        ans=min(ans,amari)
        if ans==0:
            break
print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
r = min(r, l+(2019*2))
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 = map(int,input().split())

mod = 2019
ans = 10000
a = []
for i in range(l,r+1):
  a.append(i%2019)
  if len(a) == 2020*2:
    break


for i in range(len(a)):
	for j in range(len(a)):
		if i == j:
			continue
		ans = min(ans,(a[i]*a[j])%mod)
		if ans == 0:
			print(ans)
			sys.exit()

print(ans)

Submission status: Accepted

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

cand = []
for i in range(l,r+1):
  cand.append(i%2019)
  if len(cand) == 2020*2:
    break
    
ans = float('inf')
for i in range(len(cand)):
  for j in range(len(cand)):
    if i==j:
      continue
    ans = min(ans, (cand[i]*cand[j])%2019)
    if ans ==0:
      break
  else:
    continue
  break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
ans = 20000000
n = a//2019
m = b//2019
a = a % 2019
b = b % 2019

if a > b:
    ans = 0
else:
    for i in range(a, b):
        for j in range(a+1, b+1):
            ans = min(ans, i*j%2019)
if m != n:
    ans = 0

if a == b:
    ans = 0

print(ans)

Submission status: Accepted

Solution code:
# INF = 400000000

# import sys
# L, R = list(map(lambda x: int(x), input().split()))
# # この場合は0,1,2,~~2018の数字がmodで出てくる。ので最小値は決まっている。
# if R - L >= 2019:
#   print(0)
#   sys.exit()

# m = INF

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

# print(m)
L, R = map(int, input().split())
 
ans = 400000000
for i in range(L, R+1):
    for j in range(L, i):
        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())
mod = 2019
ans = 10**9
for i in range(L, min(R+1, L+2030)):
    for j in range(i+1, min(R+1, L+2030)):
        ans = min(ans, (i*j)%mod)
print(ans)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
ans = 1000000000000000000
if 2019 <= r-l:
    print(0)
    exit()
else:
    for i in range(l,r):
        for j in range(i+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())
mod = 2019
frem = []
srem = []
if r - l + 1 >= 2019:
    ans = 0
else:
    for i in range(l, r+1):
        frem.append(i % mod)
    for i in range(len(frem)):
        for j in range(i+1, len(frem)):
            # print(frem[i], frem[j])
            srem.append(frem[i]*frem[j] % mod)
    # srem.sort()
    ans = min(srem)

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


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

    min_mod = float("inf")

    for i in range(L, min(R, L + mod)):
        for j in range(i + 1, min(R + 1, i + 1 + mod)):
            curr_mod = i * j % mod
            min_mod = min(min_mod, curr_mod)
            if min_mod == 0:
                break

    print(min_mod)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

mini = (L * R) % 2019

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

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



print(mini)

Submission status: Accepted

Solution code:
L, R = map(int,input().split())
mod = 2019
#連続するn個の数字の列はnの倍数を含む
if R-L >= 2019: print(0)
else:
    res=2018 #2019の剰余なので最大でも2018
    for i in range(L,R):
        for j in range(i+1,R+1):
            res = min(res, (i*j)%mod)
    print(res)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
l,r=L%2019,R%2019
x,y=L//2019,R//2019
if x<y:
  print(0)
else:
  ans=10**9
  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:
    pass
    print(0)
    exit()
ans = 2020
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())
l0=l%2019
r0=r%2019
if r-l>=2019 or l0==0 or r0==0:
    print(0)
elif l-l%2019+2019<=r:
    print(0)
else:
    ans=2019
    for i in range(l0,r0):
        for j in range(i+1,r0+1):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
    print(ans)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
mod=2019
cnt=0
a=[]
for i in range(l,r+1):
    cnt+=1
    a.append(i)
    if cnt>=2020:
        break
ans=10**10
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        ans=min(ans,(a[i]*a[j])%mod)

print(ans)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
ans=[]
i=0
while i<1000 and a+i<=b:
    ans.append((a+i)%2019)
    i+=1
ans.sort()
minn=10**6
for i in range(len(ans)):
    for j in range(i+1,len(ans)):
        minn=min(minn,(ans[i]*ans[j])%2019)
print(minn)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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(i*j%2019, ans)
    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:
# coding: utf-8


def get_ans():
    (l, r) = [int(i) for i in input().rstrip().split(" ")]
    if r - l <= 3000:
        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:
                    return 0
        return ans
    return 0


print(get_ans())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

lmod = l%2019
rmod = r%2019

if r-l>=2018:
    print(0)
elif lmod < rmod:
    for i in range(lmod, rmod+1):
        lst.append(i)
    ans = 2018
    for i in range(len(lst)):
        for j in range(i+1,len(lst)):
            ans = min(ans, (lst[i]*lst[j])%2019)
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
from sys import maxsize

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

min = maxsize
m = l
while m <= r:
    n = m + 1
    while n <= r:
        mod = m * n % 2019
        if mod < min:
            min = mod
        if mod == 0:
            break
        n += 1
    else:
        m += 1
        continue
    break

print(min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

div1 = 3
div2 = 673

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

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

min_v = 2018

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

print(min_v)

Submission status: Accepted

Solution code:
import math

div1 = 3
div2 = 673

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

min_v = 2018

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

print(min_v)

Submission status: Accepted

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

Submission status: Accepted

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

count_limit = 0 # count limit is 2019
min_num = 2020
for i in range(L, R+1):

    count_limit_j = 0
    for j in range(i+1, R+1):
        min_num = min(min_num, (i*j)%2019)
        count_limit_j = count_limit_j + 1
        if count_limit_j>2020:
            break

    # limit process
    count_limit = count_limit + 1
    if count_limit>2020:
        break

print(min_num)

Submission status: Accepted

Solution code:
ll, rr = map(int, input().split())
if rr - ll >= 2019:
    print(0)
    exit()

l = ll % 2019
r = rr % 2019

if l > r:
    print(0)
    exit()

ans = 10**9
for i in range(l, r + 1):
    for j in range(i+1, r+1):
        x = (i * j) % 2019
        ans = min(x, ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if r-l+1 >= 2019:
    print(0)
else:
    l %= 2019
    r %= 2019
    if l <= r:
        ans = float('inf')
        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)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

LENGTH = (R-L+1) / MOD
if LENGTH < 1:
    ans = float("inf")
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i * j) % MOD)
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
l,r = list(map(int,input().split()))
a = 201900000
if r-l > 2018:
    a= 0

l %= 2019
r %= 2019

L = min(l,r)
R = max(l,r)

# print(L,R)
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 sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    L,R=MI()
    ans = inf
    for i in range(L,min(R+1,L+2019)):
        for j in range(i+1,min(R+1,L+2019)):
            ans = min(ans, i*j%2019)      
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

dl, ml = divmod(L, 2019)
dr, mr = divmod(R, 2019)

if dl < dr:
    ans = 0
else:
    ans = 10 ** 18
    for x in range(L, R):
        for y in range(x + 1, R + 1):
            ans = min(ans, (x * y) % 2019)

print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
M = (L+2019-1)//2019*2019

if M<=R:
    print(0)
    exit()

ans = 10**18

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():
    L, R = (int(i) for i in input().split())
    MOD = 2019
    R = min(L + 2020, R)
    ans = 2020
    for i in range(L, R):
        for j in range(i+1, R+1):
            # print(i, j)
            ans = min(ans, (i*j) % MOD)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    L, R = map(int, input().split())
    if R - L >= 2019: print(0)
    else:
        minMod = 2019
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                minMod = min((i * j) % 2019, minMod)
        print(minMod)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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