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:
def examA():
    S = SI()
    T = SI()
    N = len(S)
    ans = "No"
    for i in range(N):
        cur = S[i:] + S[:i]
        #print(cur)
        if cur==T:
            ans = "Yes"
    print(ans)
    return

def examB():
    H, W = LI()
    S = [SI()for _ in range(H)]
    flag = True
    ans = 0
    print(ans)
    return

def examC():
    L, R = LI()
    ans = inf
    if R-L>=3000:
        R = L+3000

    for l in range(L, R + 1):
        for r in range(l+1, R + 1):
            now = (l*r) %2019
            ans = min(ans,now)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Accepted

Solution code:
def main():
    L, R = (int(i) for i in input().split())
    ans = 2*10**9
    for le in range(L, min(R, L+2020)+1):
        for ri in range(le+1, min(R, L+2020)+1):
            cur = le*ri
            cur %= 2019
            ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
m=l//2019
l-=m*2019
r-=m*2019
ans=2018
if r>=2019:exit(print(0))
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 >= 2040:
    print(0)
    exit(0)

res = 10 ** 100
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:
L, R = map(int, input().split())

reg = 2018
if R-L >= 3000:
    print(0)
else:
    for l in range(L, R):
        for r in range(l+1, R+1):
            tmp = (l * r) % 2019
            reg = min(reg, tmp)
    print(reg)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
ans = 2018
for i in range(L, min(R, 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())
if R >= L + 2019:
    R = R + 2019

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

Submission status: Accepted

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

z = 2019

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
"""
ans = 0
if R - L < 2019:
    l = L % 2019
    r = R % 2019
    if l < r:
        l_ = (L * (L + 1)) % 2019
        r_ = (R * (R - 1)) % 2019
        ans = min(l_, r_)
print(ans)
"""  

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

print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc133/tasks/abc133_c

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 13:43:11 2020

@author: shinba
"""
import sys 
import itertools

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

if l % 2019 == 0:
    print(0)
    sys.exit()
else:
    if l//2019 +1 <= r/2019:
        print(0)
        sys.exit()

l %= 2019
r %= 2019
ans = float("inf")

for i in itertools.combinations(range(l,r+1),2):
    mod = (i[0]*i[1])%2019
    ans = min(mod,ans)
    
print(ans)

Submission status: Accepted

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

if L // 2019 != R // 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:
n, m = list(map(int,input().split()))

res = 10**9
for i in range(n, m):
    for j in range(i+1, m+1):
        res = min(res, (i*j % 2019))
        if res == 0:
            print(0)
            exit()
print(res)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1

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

if temp==1:
  print(0)
else:
  print(count)

Submission status: Accepted

Solution code:
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)

mo=10**9+7
#n=int(input())
l,r=map(int,input().split())
r=min(l+2019+10,r)

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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
L,R = map(int,input().split())
i = L
j = i+1
p =2019
min_ij = ((i%p)*(j%p))%p
for i in range(L,R):
  for j in range(i+1,R+1):
    if i % p == 0 or j %p == 0:
      print(0)
      sys.exit()
    if min_ij > ((i%p)*(j%p))%p:
      min_ij = ((i%p)*(j%p))%p

print(min_ij)

Submission status: Accepted

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

nl = l%MOD
diff = r-l
li1 = []
li2 = []

if diff>2018:
  print(0)
else:
  for i in range(diff+1):
    li1.append(nl+i)
  for j in range(len(li1)):
    for k in range(j+1,len(li1)):
      li2.append(li1[j]*li1[k]%MOD)
  print(min(li2))

Submission status: Accepted

Solution code:

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

flag=0
for i in range(L,R+1):
    if i%2019 == 0:
        flag=1
        break

LL = L%2019
RR = R%2019
dammy=[]
for i in range(LL,RR):
    for j in range(i+1,RR+1):
        dammy.append((i*j)%2019)

if flag==0:
    print(min(dammy))
else:
    print(0)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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

for i in range(L,R+1,1):
    if i%2019 == 0:
        print(0)
        exit()

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

r = min( r, l + 2019 )

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

print( min_ixj )

Submission status: Accepted

Solution code:
def ABC133C(l, r):
    Min = 1e10
    for i in range(l, r):
        for j in range(i+1, r+1):
            a = (i * j) % 2019
            if a < Min:
                Min = a
                if a == 0: # ここに注目
                    print(Min)
                    return
    print(Min)

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

Submission status: Accepted

Solution code:
import numpy as np

def ABC133C(l, r):
    Min = np.inf
    for i in range(l, r):
        for j in range(i+1, r+1):
            a = (i * j) % 2019
            if a < Min:
                Min = a
                if a == 0: # ここに注目
                    print(Min)
                    return
    print(Min)

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

Submission status: Accepted

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

a = 0
ans = 10 ** 9
r = min((L + 2018), R)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
r = min(r,l+2017)
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:
L, R = map(int, input().split())
lista = []
for i in range(L, min(R + 1, L + 2019)):
    lista.append(i % 2019)
ans = float('inf')
for i in range(len(lista)):
    for j in range(i + 1, len(lista)):
        ans = min(ans, lista[i] * lista[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, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L, R = MAP()

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

a = list(range(L, R+1))
ans = 2019

for x, y in combinations(a, 2):
	ans = min(ans, (x*y)%2019)

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

def solve():
    l, r = MI()
    mod = 2019

    r = min(r, l+673)
    ans = 2018
    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__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

if r-l+1>=2019:
    print(0)
else:
    ans=float('inf')
    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=L%2019
r=R%2019
if l<r and L+2019>=R:
  c=2020
  a=list(range(l,r+1))
  for i in range(len(a)-1):
    for j in range(i+1,len(a)):
      s_=a[i]*a[j]
      s=s_%2019
      c=min(c,s)
elif l>=r and L+2019>=R:
  r+=2019
  c=2020
  a=list(range(l,r+1))
  for i in range(len(a)-1):
    for j in range(i+1,len(a)):
      s_=a[i]*a[j]
      s=s_%2019
      c=min(c,s)
else:
  c=0
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


L, R = Is()
mod = 2019

n = min(R-L+1, 2019)
li = [-1]*n

tmp = L % 2019
for i in range(n):
    if tmp + i == 2019:
        print("0")
        exit()
    li[i] = tmp + i

ans = INF
for x, y in combinations(range(n), 2):
    ans = min(ans, li[x]*li[y]%mod)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

left = L % 2019
right = R % 2019

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

elif left > right:
    print(0)
    sys.exit(0)

elif left==0 or right==0:
    print(0)
    sys.exit(0)

for i in range(left, right):
    for j in range(i+1, right+1):
        x = calc_mod(i, j)
        if x==0:
            print(0)
            sys.exit(0)
        ans.append(x)

print(min(ans))

Submission status: Accepted

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

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

left = L % 2019
right = R % 2019

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

elif left > right:
    print(0)
    sys.exit(0)

elif left==0 or right==0:
    print(0)
    sys.exit(0)

for i in range(left, right):
    for j in range(i+1, right+1):
        ans.append(calc_mod(i, j))

print(min(ans))

Submission status: Accepted

Solution code:
# C - Remainder Minimization 2019

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

mn = float('inf')
for i in range(L, L + 2019):
    for j in range(i + 1, L + 2019 + 1):
        if L <= i < j and i < j <= R:
            mn = min(mn, i * j % 2019)

print(mn)

Submission status: Accepted

Solution code:
import sys
import itertools


def solve():
    L, R = map(int, input().split())
    lst_mod = [-1]*min((R-L+1), 2019)
    counter = L % 2019
    for i in range(len(lst_mod)):
        lst_mod[i] = counter
        counter += 1
        if counter == 2019:
            print(0)
            sys.exit(0)
    num = 2019
    for comb_lst in itertools.combinations(lst_mod, 2):
        if num > (comb_lst[0]*comb_lst[1]) % 2019:
            num = (comb_lst[0]*comb_lst[1]) % 2019
    print(num)


solve()

Submission status: Accepted

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

d = r - l + 1

if d >= 2019:
    print(0)
else:
    ans = 2018

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

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#from bisect import bisect_left
#import heapq
#import math
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
L,R = map(int, stdin.readline().rstrip().split())
#S = [list(stdin.buffer.readline().decode().rstrip()) for _ in range(h)]

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

ans = 2018
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:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
L,R = map(int,input().split())

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

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

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

Submission status: Accepted

Solution code:
import itertools
L,R = list(map(int,input().split()))
if R-L >= 2020:
  print(0)
  exit()
N_list = [i for i in range(L,R+1)]
P = itertools.combinations(N_list,2)
P = list(P)
ans = L*(L+1)%2019
for p in P[1:]:
    ans = min(ans,p[0]*p[1]%2019)
print(ans)

Submission status: Accepted

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

else:
  for j in range(L, R+1):
    for i in range(L, j):
      A.append((i*j) % 2019)
  print(min(A))

Submission status: Accepted

Solution code:
import sys, heapq, bisect, math, fractions
from collections import deque

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

res = 10 ** 15
if R - L > 2030:
    res = 0
else:
    for l in range(L, R):
        for r in range(l + 1, R + 1):
            res = min(res, (l * r) % mod)

print(res)

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())
if r //2019 > l //2019:
    print(0)
else:
    res = 2018
    for i in range(l%2019, (r%2019)+1):
        for j in range(i+1, (r%2019)+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()
la = l % 2019
ra = r % 2019
diff = ra - la
if diff <= 0:
  print("0")
  exit()
ans = 2019
for i in range(la, ra):
  for j in range(i+1, ra+1):
    mul = (i*j) % 2019
    if mul <= ans:
      ans = mul
print(int(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if R<L+2019:
  end=R
else:
  end=L+2018

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

Submission status: Accepted

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

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

Submission status: Accepted

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


print(ans)

Submission status: Accepted

Solution code:
def main():
    L, R = list(map(int, input().split(' ')))
    if R - L >= 2019:
        # exists numbers which can be divided by 2019.
        print(0)
    else:
        min_value = 2019
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                r = (i * j) % 2019
                if r == 0:
                    print(0)
                    exit(0)
                min_value = min([r, min_value])
        print(min_value)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


# def convert(LL,LR):
#     LL = LL % 2019
#     LR = LR % 2019

#     return LL,LR

def kansu(LL,LR):

    ans = 2020
    flg = False

    for ll in range(LL,LR):
        for lr in range(ll+1,LR+1):
            tmp  = (ll * lr) % 2019
            if ans > tmp:
                ans = tmp
                if ans == 0:
                    flg =True
                    break
        if flg == True:
            break

    print(ans)

ML,MR = nyu()
#ML,MR = convert(ML,MR)
kansu(ML,MR)

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

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

t1 = L - (L // 2019) * 2019
t2 = R - (L // 2019) * 2019
temp = 0
min_temp = 2019

if R - L >= 2019:
    print("0")
else:
    for i in range(t1, t2):
        for j in range(i + 1, t2 + 1):
            temp = (i * j) % 2019
            if temp < min_temp:
                min_temp = temp

    print(min_temp)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

MOD = 2019

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

Submission status: Accepted

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


if(abs(l-r) > 2050): print(0)
else:
    num = []
    for i in range(l,r+1):
        num.append(i)
    minimum = 10**9
    for v in itertools.combinations(num, 2):
        minimum = min(minimum,v[0]*v[1]%2019)
    print(minimum)

Submission status: Accepted

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

if r < 2019:
    print(l*(l+1)%2019)
    exit()

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

print(ans)

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
ans = 10**10
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
    if i*j%2019==0:
        break
print(ans)

Submission status: Accepted

Solution code:
def main():
  l,r=map(int,input().split())
  ans=10**9
  if any([r//2019>l//2019,r==0,l==0]):
    ans=0
    print(ans)
  else:
    l%=2019
    r%=2019
    for i in range(l,r):
      for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
    print(ans)
main()

Submission status: Accepted

Solution code:
mod, min_value = 2019, 2019
l, r = map(int, input().split())
length = r - l
for i in range(mod):
  for j in range(mod):
    if length - j - i <= 0 or min_value == 0:
      break
    min_value = min(min_value, (l + i) * (r - j) % mod)
print(min_value)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
i, j = map(int,input().split())
ans = 100000000

for m in range(i, min(j, i+2019)): #高々O(2019**2)
  for n in range(m+1, min(j+1, i+2020)):
    x = m * n % 2019
    if x < ans:
      ans = x

print(ans)

Submission status: Accepted

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

tmp = float("INF")
ans = tmp
for i in range(L, R):
  for j in range(i+1, R+1):
    tmp = (i % 2019) * (j % 2019) % 2019
    ans = min(ans, tmp)
    if ans == 0:
      print(0)
      exit()
      
print(ans)