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())
min_score = 2019
found = False
for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    if (i * j) % 2019 == 0:
      print(0)
      found = True
      break
    elif (i * j) % 2019 < min_score:
      min_score = (i * j) % 2019
  if found:
    break
if not found:
  print(min_score)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
x = l % 2019
y = r % 2019
if x > y:
    y += 2019
ans = 10 ** 7
for i in range(x, y + 1):
    for j in range(x, y + 1):
        if ans > (i * j) % 2019 and i != j:
            ans = (i * j) % 2019
if l + 2019 < r:
    ans = 0
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = pow(10,9)+7
for i in range(L,R):
  for j in range(i+1,R+1):
    val = ((i%mod) * (j%mod))%mod
    ans = min(ans, val)
    if ans == 0:
      break
  if ans == 0:
    break

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
L, R = map(int, input().split())
mod = 2019
ans = float("inf")
for i in range(L, R + 1):
    i_mod = i % mod
    if i_mod == 0:
        ans = 0
        break
    for j in range(i + 1, R + 1):
        j_mod = j % mod
        if j_mod == 0:
            ans = 0
            break
        else:
            ans = min(ans, i * j % mod)
print(ans)

Submission status: Accepted

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

def main():
  l, r = map(int, input().strip().split())
  x = 2019
  remains = [l%x]
  for i in range(l+1, r+1):
    remain = i % x
    if remains[0] == remain:
      break
    remains.append(remain)
    
  min = x
  for i in range(len(remains)-1):
    for j in range(i+1, len(remains)):
      remain = (remains[i] * remains[j]) % x
      if remain < min:
        min = remain
  print(min)

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    l, r = list(map(int, readline().split()))
    t = 10 ** 20
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            t = min(t, i * j % 2019)
            if t == 0:
                break
        if t == 0:
            break
    print(t)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if (r - l) > 2019:
    print(0)

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

    print(ans)

Submission status: Accepted

Solution code:
#n=int(input())
l,r=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
if (R-L)>=673:
  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:
import sys
import itertools as it
L, R = map(int, input().split())
if R-L > 2017: print(0); sys.exit()

DL = L % 2019
DR = R % 2019
if DL > DR: print(0); sys.exit()

print(min(x*y%2019 for x,y in it.combinations(range(DL, DR+1), 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())
miner = 2020
r = min(r,l+2020)
for i in range(l,r):
    for j in range(i+1,r+1):
        miner = min(miner,i*j%2019)
print(miner)

Submission status: Accepted

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

Submission status: Accepted

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

R_alt = min(L+2018, R)

ans = 2018 ** 2

for i in range(L, R_alt):
  for j in range(i+1, R_alt+1):
    tmp = i%2019 * j%2019
    if ans > tmp:
      ans = tmp

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
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 operator import itemgetter
from fractions import gcd
mod = 2019
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

l,r =mii()

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
ans = 10**100
for i in range(l,r):
    for j in range(i+1,r+1):
        ans = min(ans,mul(i,j))
        if ans ==0:
            print(0)
            exit()
print(ans)

Submission status: Accepted

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

if R - L >= 2019:
    Ans = 0
elif R_mod < L_mod:
    Ans = 0
elif R_mod > L_mod:
    Ans = 2019
    for i in range(L_mod, R_mod):
        for k in range(L_mod+1,R_mod+1):
            Ans = min(Ans,i*k % 2019)
        
print(Ans)

Submission status: Accepted

Solution code:
import sys

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

res = 2019

res_l = l % 2019
res_r = r % 2019

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R = [int(zz) for zz in 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:
def main():
  
  L,R=map(int,input().split())
  x,y=L//2019,R//2019
  
  if y-x>=1:
    print(0)
    
  else:
    i=R
    k=1
    ans=float("inf")
    while(L<i):
      ans=min(ans,i*(i-k)%2019)
      if ans==0:
        print(0)
        break        
      k+=1
      if i-k<L:
        k=1
        i-=1
        
    else:
      print(ans)
      
if __name__=="__main__":
  main()

Submission status: Accepted

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

for i in range(l,r):
    for j in range(i+1,r+1):
        now=int((i*j)%2019)
        if ans>now:
            ans=now

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L, R = MAP()

if R < 2019:
	li = [i for i in range(L, (R + 1))]
	co = list(combinations(li, 2))
	mi = INF
	for x in co:
		mi = min(mi, (x[0]*x[1])%2019)
	print(mi)
	exit()
if R == 2019:
	print(0)
	exit()
if R > 2019:
	if R - L < 2019:
		li = [i for i in range(L, (R + 1))]
		co = list(combinations(li, 2))
		mi = INF
		for x in co:
			mi = min(mi, (x[0]*x[1])%2019)
		print(mi)
		exit()
	else:
		print(0)
		exit()

Submission status: Accepted

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

if R-L >= 672:
    print(0)
    
elif R-L == 1:
    print((L*R) % 2019)

elif R-L >= 2:
    for i in range(L//673, R//673 + 1):
        if L <= 673 * i <= R:
            print(0)
            break
    else:
        ans = 2018
        for i in range(L, R):
            for j in range(i+1, R+1):
                k = (i*j) % 2019
                if k < ans:
                    ans = k
        print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

MOD = 2019

l, r = map(int, sys.stdin.readline().split())

def main():
    if r - l >= MOD - 1:
        return 0
    lm = l % MOD
    rm = r % MOD
    if lm == 0 or lm > rm:
        return 0
    else:
        res = MOD - 1
        for i in range(l, r):
            for j in range(i+1, r+1):
                res = min(res, i % MOD * j % MOD)
        return res
        
if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
r = min(r, l + 4038)
ans = 2018
for i in range(l, r):
  for j in range(i + 1, r + 1):
    ans = min((i * j) % 2019, ans)
    #割り切れた場合はそれが最小値なので探索終了とする
    if ans == 0:
      break

print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input=sys.stdin.readline
    L,R=map(int,input().split())

    if R-L>=2019:
        print(0)
    else:
        flag=False
        min_number=2019
        for i in range(L,R+1):
            for j in range(i+1,R+1):
                min_number=min(min_number,((i%2019)*(j%2019))%2019)
                if min_number==0:
                    print(0)
                    flag=True
                    break
            if flag:
                break
        if flag==False:
            print(min_number)
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(i+1,R+1)]
    print(min(x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
L, R = map(int, input().split())
ans = 2019
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:
            break
    if ans == 0:
        break
print(ans)

Submission status: Accepted

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

MOD = 2019

if R - L >= MOD or L%MOD == 0 or R%MOD == 0:
    print(0)
else:
    LR = list(range(L, R+1))
    minimum = 2*10**9
    for i in range(len(LR)):
        l = LR[i]
        for r in LR[i+1:]:
            minimum = min(l*r%MOD, minimum)
    print(minimum)

Submission status: Accepted

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

ans = 2018
for i in range(L, L+2019):
    for j in range(R-2019, R+1):
        if not i<j:
            continue
        ans = min(ans, (i*j)%2019)

print(ans)

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
mod = 2019
r = (r%mod) + 2019*(r-l>=2019)
l = l%mod
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 = [int(i) for i in input().split()]
if R - L > 2019:
    print(0)
    exit()
else:
    li = list(range(L,R+1))
    n = len(li)
ans = 10**9+7
for i in range(n-1):
    for j in range(i+1,n):
        count = (li[i]*li[j]) % 2019
        ans = min(ans,count)
        if ans == 0:
            print(0)
            exit()
print(ans)

Submission status: Accepted

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

if r-l>2019:
    print(0)
    exit(0)
else:
    a = list(range(l, r+1))

num = 0
ans = 2019

for i in range(len(a)):
    for j in range(len(a)):
        if a[i]<a[j]:
            num = (a[i]*a[j])%2019
            ans = min(ans, num)
            if ans == 0:
                print(0)
                exit(0)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = (int(lr) for lr in input().split())
min_mod = 2019
has_found = False
for l in range(L, R):
    for r in range(l+1, R+1):
        mod = (l*r) % 2019
        if mod == 0:
            min_mod = 0
            has_found = True
            break
        else:
            min_mod = min(min_mod, mod)
    if has_found:
        break

print(min_mod)

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:
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def main():
    l, r = map(int, input().split())
    if l <= 2019 and 2019 <= r:
        print(0)
        return 
    if r-l >= 2019:
        print(0)
        return

    m = 10**9

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans_list = []
for i in range(l, min(l+2019, r)):
  for j in range(i + 1, min(i + 2019, r + 1)):
    ans = (i * j) % 2019
    ans_list.append(ans)
    if ans == 0:
      break
print(min(ans_list))

Submission status: Accepted

Solution code:
def solve():
    L, R = map(int, input().split())
    ans = 10 ** 10
    for i in range(L, min(L+2019, R)):
        for j in range(L+1, min(L+2019, R) + 1):
            ans = min(ans, i * j % 2019)
    return ans

print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = 2020
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:
            print(0)
            exit(0)
        ans = min(ans, mod)
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = list(map(int,input().split(" ")))
l = L % 2019
r = R % 2019

ans = 2019

if R - L >= 2018 or L > R:
    print("0")
else:
    array = list(range(l,r+1))
    for i in array:
        for j in array:
            if i == j:
                continue
            temp = i * j % 2019
            if ans > temp:
                ans = temp
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

dif = R - L
_L, _R = L%2019,R%2019

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

Submission status: Accepted

Solution code:
i, j = map(int, input().split())
MOD = 2019
ans = float("inf")
for x in range(i, min(j+1, i+MOD)):
    for y in range(x+1, min(j+1, i+MOD)):
        ans = min(ans, x%MOD * y%MOD)
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):
        ans = min(ans,(i*j)%2019)
        if ans == 0:
            break
    if ans == 0:
        break

print(ans)

Submission status: Accepted

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

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        ans = 0
        break
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                ans = 0
                break
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

l,r = get_nums_l()
d = r-l

lm = l % 2019
rm = r % 2019


nums = [0] * 2019
for imod in range(2019):
    if (imod+(2019-lm))%2019 <= d:
        nums[imod] += 1 + (d - (imod+(2019-lm))%2019)//2019

min_ = 999999999999999999999
for a in range(2019):
    for b in range(2019):
        if a==b and nums[a] < 2:
            continue
        if nums[a] < 1 or nums[b] < 1:
            continue
        mo = a*b%2019
        if min_ > mo:
            min_ = mo
print(min_)

# m3   = 3 - l % 3
# m673 = 673 - l % 673

# if (m3==3 or m3 <= d) and (m673==673 or m673 <= d):
#     print(0)
# else:
#     print((l*(l+1)) % 2019)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
mindiv=1000000000
for i in range(a,b):
  for j in range(i+1,b+1):
    if i%2019==0 or j%2019==0:
      print(0)
      exit()
    else:
      mindiv=min(i*j%2019,mindiv)
print(mindiv)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if r-l >= 2019:
    ans = 0
else:
    n = 2019
    l = l%n
    r = r%n
    ans = 2019
    a = min(l,r)
    b = max(l,r)

    for i in range(a,b):
        for j in range(a+1,b+1):
            ans = min(ans, (i*j)%n)

print(ans)

Submission status: Accepted

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

ans = []
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        v = i * j % 2019
        ans.append(v)
        if v == 0:
            break
    else:
        continue
    break
    
print(min(ans))

Submission status: Accepted

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

if b-a > 2019:
	min_mod=0

else:	
	for aa in range(a,b):
	   for bb in range(aa+1,b+1):
	       if aa < bb:
	           cc=aa*bb
	 
	           if min_mod > cc%2019:
	               min_mod = cc%2019

print(min_mod)

Submission status: Accepted

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

if b-a > 2019:
	min_mod=0

else:	
	for aa in range(a,b):
	   for bb in range(a+1,b+1):
	       if aa < bb:
	           cc=aa*bb
	 
	           if min_mod > cc%2019:
	               min_mod = cc%2019

print(min_mod)

Submission status: Accepted

Solution code:
# かなり手こずった．
# 原因は最終行の print にインデントがなく
# c が空のケースでエラーが出ていた．

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

Submission status: Accepted

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

if b-a >= 2019:
    print(0)
else:
    c = []
    for i in range(a,b):
        for j in range(i+1,b+1):
            c.append(i*j % 2019)
    #print(c)
    print(min(c))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
mod = 2019
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)%mod)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
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) % 2019)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if r - l >= MOD:
    print(0)
else:
    min = MOD
    for i in range(l, r):
        if min == 0: break
        for j in range(i+1, r+1):
            im, jm = i % MOD, j % MOD
            val = (im * jm) % MOD
            if val < min:
                min = val
    print(min)

Submission status: Accepted

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

    if r - l + 1 >= 2019:
        print(0)
        exit()

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

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

Submission status: Accepted

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

def check(left, right):
  ans = 2018
  # a mod p = b mod p なら a*c ≡ b*c (mod p)
  # r - l
  if right-left >= 2019:
    ans = 0
  # 2018**2個調べる(最小値が出たら打ち切り)
  else:
    for i in range(left, right):
      for j in range(l+1, right+1):
        ans = min((i*j)%mod, ans)
        if ans==0: return ans
  return ans
ans = check(l, r)
print(ans)