Problem:


Score : 300 points

Problem Statement

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

L R

Output

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

Sample Input 1

2020 2040

Sample Output 1

2

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

Sample Input 2

4 5

Sample Output 2

20

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



Sample input:
2020 2040


Sample output:
2

Submission status: Accepted

Solution code:
import atexit
import io
import sys

# _INPUT_LINES = sys.stdin.read().splitlines()
# input = iter(_INPUT_LINES).__next__
# _OUTPUT_BUFFER = io.StringIO()
# sys.stdout = _OUTPUT_BUFFER
#
#
# @atexit.register
# def write():
#     sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
ans = sys.maxsize
n,k = R()
for i in range(n,k):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)
        if ans==0:
            print(ans)
            exit()

print(ans)

Submission status: Accepted

Solution code:
import atexit
import io
import sys

_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER


@atexit.register
def write():
    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

import math
R = lambda : map(int,input().split())
ans = sys.maxsize
n,k = R()
for i in range(n,k):
    for j in range(i+1,k+1):
        ans = min(ans,(i*j)%2019)
        if ans==0:
            print(ans)
            exit()

print(ans)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

# L <= i < j <= R
if int(R / 3) - int((L-1) / 3) > 0 and int(R / 673) - int((L-1) / 673) > 0:
    print(0)
else:
    res = 2018
    R2 = min(R+1, L+2019)
    for i in range(L, R2):
        for j in range(i+1, R2):
            res = min(res, ((i % 2019) * (j % 2019)) % 2019)
            if res == 1:
                break
    
    print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations as f
l,r=map(int,input().split())
print(min([i*j%2019 for i,j in f(range(l,r+1)[:2019],2)]))

Submission status: Accepted

Solution code:
from itertools import combinations as f
l,r=map(int,input().split())
s=set(map(lambda x:x%2019,range(l,r+1)[:2019]))
print(min([i*j%2019 for i,j in f(s,2)]))

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r= map(int, input().split())
check=min(r-l+1,2019)
min_=2019

for i in range(l,l+check):
    for j in range(i+1,l+check):
        rest=(i*j)%2019
        if rest<min_:
            min_=rest
print(min_)

Submission status: Accepted

Solution code:
def main():
  l, r = map(int, input().split(' '))
  if r - l >= 2019:
    print(0)
  else:
    ans = l * r
    i = l
    while i < r:
      j = i + 1
      while j <= r:
        ij = i * j
        if mod(ij) < ans:
          ans = mod(ij)
        j += 1
      i += 1
    print(ans)


def mod(n):
  if n < 2019:
    return n
  else:
    return(n % 2019)


if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

		if (i*j)%2019 == 0:
			print(0)
			sys.exit()
print(min(a))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from itertools import combinations
import math


def solve():
    l, r = map(int, input().split())
    a = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            amari = (i * j) % 2019
            if amari == 0:
                return 0
            elif amari < a:
                a = amari
    return a


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
"""
# 標準入力取得
## 文字列
     = sys.stdin.readline().rstrip()
     = list(sys.stdin.readline().rstrip())

## 数値
     = int(sys.stdin.readline())
     = map(int, sys.stdin.readline().split())
     = list(map(int, sys.stdin.readline().split()))
     = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 2019

if __name__ == "__main__":
     L, R = map(int, sys.stdin.readline().split())
     if R - L > 2019:
          print(0)
          exit()
     mod_min = 2020
     for i in range(L, R + 1):
          for j in range(i + 1, R + 1):
               m_tmp = (i * j) % mod
               #print("i {}, j {}, m_tmp {}".format(i, j, m_tmp))
               if m_tmp < mod_min:
                    mod_min = m_tmp
     print(mod_min)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
div = 2019
min_mod = div - 1
flag = False

for i in range(L, R):
  for j in range(i+1, R+1):
    mod = (i * j) % div
    if mod == 0:
      min_mod = mod
      flag = True
    elif mod < min_mod:
      min_mod = mod
    if flag:
      break
  if flag:
    break
    
print(min_mod)

Submission status: Accepted

Solution code:
def remainder_min(l,r):
    sml = 2*(10**9)**2+1
    _r = min(r,l+2019)
    for i in range(l,_r):
        for j in range(i+1,_r+1):
            num = i * j
            rem = num % 2019
            if rem == 0:
                return 0
            sml = min(sml,rem)
    return sml

if __name__ == '__main__':
    l,r = map(int,raw_input().split())
    print remainder_min(l,r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R= (int(i) for i in input().split())  
 
_min = 2018
 
for g in range(R-L):
	_start = (L+g)*(L+g+1)
	for i in range(R-L-g):
		_min = min(_min, _start%2019)
		_start += L+g
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

Submission status: Accepted

Solution code:
L, R= (int(i) for i in input().split())  

_min = 2018
_init = L%2019

for g in range(R-L):
	plus = _init + g
	_start = (plus*(plus+1))%2019
	for i in range(R-L-g):
		_min = min(_min, _start)
		_start += plus
		_start = _start%2019
		if _min == 0:
			break
	if g == 2019 or _min == 0:
		break

print(_min)

Submission status: Accepted

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

#2019以上の差があれば、2019の倍数が必ずあるので、i,jのどちらかをそれにすれば、余りは０
if R - L >= mod:
  print(0)
else:
  s = []
  for i in range(L, R):# iをLからR-1まで
    for j in range(i+1, R+1):#Rをi+1からRまで
      s.append((i*j) % mod)#i*jを2019で割った余りをlistに追加
  s.sort()#昇順でsort
  print(s[0])#先頭が一番最小なので、それが答え

Submission status: Accepted

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

if R - L >= mod:
  print(0)
else:
  s = []
  for i in range(L, R):
    for j in range(i+1, R+1):
      s.append((i*j) % mod)
  s.sort()
  print(s[0])

Submission status: Accepted

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

if R - L >= mod:
    print(0)
else:
    s = []
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            s.append((i * j) % mod)
    s.sort()
    print(s[0])

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
flag=False
for amari in range(2019):
    for i in range(L,R):
        for j in range(i+1,R+1):
            if (i*j-amari)%2019==0:
                print(amari)
                flag=True
            if flag:break
        if flag:break
    if flag:break

Submission status: Accepted

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

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

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

        if res == 0: break

print(res % 2019)

Submission status: Accepted

Solution code:
import sys
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 tmp == 0:
            print(0)
            sys.exit()
        elif tmp < ans:
            ans = tmp
print(ans)

Submission status: Accepted

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

MOD = 2019  # type: int

def solve(L: int, R: int):
    if(R-L >= 2019):
        print(0)
    else:
        m = 2020
        for i in range(L,R+1):
            for j in range(i+1,R+1):
                m = min(m,(i*j)%2019)
        print(m)
    return


# Generated by 1.1.4 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 2018
tmp = 0

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

		if tmp == 0:
			ans = tmp
			print(ans)
			exit()
		else:
			ans = min(tmp, ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(L,R+1):
  counterJ = 0
  for j in range(i+1, R+1):
    modResult = (i * j) % 2019 
    if i == L and j == L+1:
      result = modResult
    elif result > modResult:
      result = modResult
    if counterJ == 2019:
      break
    counterJ += 1
    
  counter += 1
  if counter == 2019:
    break;
    
print(result)

Submission status: Accepted

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

ans=2019
for i in range(L,min(R,L+2018)):
    for j in range(i+1,min(R+1,L+2019)):
        mod = (i*j) % 2019
#        print(str(i)+' '+str(j)+' '+str(mod))
        if mod == 0:
            ans = 0
            break
        if mod < ans:
            ans = mod
print(ans)

Submission status: Accepted

Solution code:
#133 11:06
L,R=map(int,input().split())
a=[]
for i in range(L,R):
    for j in range(i+1,R+1):
        a.append((i*j)%2019)
        
        if (i*j)%2019==0:
            print(0)
            exit(0)
print(min(a))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc133/tasks/abc133_c
# C - Remainder Minimization 2019

l, r = list(map(int, input().split()))
count = 0
amari_list = []

for i in range(l, r+1):
    count_j = 0
    for j in range(i+1, r+1):
        amari_list.append(i * j % 2019)
        if count_j == 2019:
            break
        count_j += 1

    if count == 2019:
        break
    count += 1

ans = min(amari_list)
print(ans)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
d=R-L
ans=2019

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if (R-L) > 2019:
  R = 2019 + L

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

Submission status: Accepted

Solution code:
N=list(map(int,input().split()))
#A=list(map(int,input().split()))
if N[1]>=((673-N[0]%673)+N[0]):
  if N[1]==N[0]+1:
    p=(N[1]*N[0])%2019
  else:
    p=0
else:
 a=N[0]%2019
 b=N[1]%2019
 max1=2018
 for i in range(a,b):
     for j in range(i+1,b+1):
         if max1>(i*j)%2019:
           max1=(i*j)%2019
 p=max1

print(p)

Submission status: Accepted

Solution code:
l,r=[int(i) for i in input().split()]
if r-l>2019:
    r=l+2018

minnum=1000000000000
for i in range(l,r):
    for j in range(i+1,r+1):
        check=(i*j)%2019
        if check<minnum:
            minnum=check
            
print(minnum)

Submission status: Accepted

Solution code:
A = list(map(int,input().split()))
L = A[0]
R = A[1]
if R - L >= 673:
    print(0)
else:
    B = []
    C = []
    for _ in range(L,R + 1):
        B.append(_ % 2019)
    k,l = 0,1
    count = 0
    N = len(B)
    while k < N - 1:
        while l < N:
            C.append((B[k] * B[l]) % 2019)
            l += 1
        k += 1
        l = k + 1
    print(min(C))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

#n = int(input())
l, r= [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = [input() for i in range(n)]
#s = input()
#list = list(s)
#temp = [[0 for _ in range(13)] for _ in range(13)]

ans = 2019

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

print(ans)

Submission status: Accepted

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

print(b)

Submission status: Accepted

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

if r - l >= 2019:
    print(0)
else:
    print(mod2019(l,r))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

R = min(R, L + 2030)

res = 2019

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())
a = 10**10
for i in range(L,min(R,L+2019)+1):
    for j in range(i+1,min(R,L+2019)+1):
        a = min(a,(i*j)%2019)
print(a)

Submission status: Accepted

Solution code:
from itertools import combinations as comb

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

min = 2018
if r-l >= 2018:
    print(0)
else:
    range_list = [i for i in range(l, r + 1)]
    comb_list = list(comb([i for i in range(r - l + 1)], 2))
    for comb in comb_list:
        if range_list[comb[0]]*range_list[comb[1]]%2019 < min:
            min = range_list[comb[0]]*range_list[comb[1]]%2019
    print(min)

Submission status: Accepted

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

if r-l >= 2018:
  print(0)
else:
  l_mod = l%2019
  r_mod = r%2019
  min_mod = float('inf')
  if l_mod <= r_mod:
    for c in itertools.combinations(range(l_mod, r_mod+1), 2):
      min_mod = min(min_mod, (c[0]*c[1])%2019)
    print(min_mod)
  else:
    print(0)

Submission status: Accepted

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

p, q = L%2019, R%2019
z = R - L

if (p == 0) or (q == 0) or (z > 2019) or (p >= q):
    print(0)
else:
    answer = []
    for i in range(z):#669
        for j in range(z-i):#669-i
            k1 = p + i#3
            k2 = j + k1 + 1
            X = k1 * k2 % 2019
            answer.append(X)
    A = min(answer, key=int)
    print(A)

Submission status: Accepted

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

diff = R - L
min_mod = 2020
second_min_mod = 2021
for i in range(L, min(L+2019, L+(diff)+1)):
    for j in range(i+1, min(L+2019, L+(diff)+1)):
        if min_mod > (i*j) % 2019:
            min_mod = (i*j) % 2019
print(min_mod)

Submission status: Accepted

Solution code:
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#h,w
def main():
	l,r = map(int,input().split())
	if(r-l+1>2018):
		print(0)
		exit()
	else:
		min = 2020
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				if(min>i*j%2019):
					min=i*j%2019
	print(min)
	exit()


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

Solution code:
#C
import sys
L, R = list(map(int, input().split()))
if (R - L) == 2019:
    result = 0
else:
    result = 2018
    for i in range(L,R+1):
        for s in range(i+1,R+1):
            x = (i*s)%2019
            if x == 0:
                result = 0
                print(0)
                sys.exit()
            elif result > x:
                result = x
print(result)

Submission status: Accepted

Solution code:
import sys
a = input().split()

L = int(a[0])
R = int(a[1])
if R - L == 2019:
  print(0)
  sys.exit()

mm = 2018

for i in range(L , R + 1):
  for j in range(L , R + 1):
    if i < j:
      n = (i * j) % 2019
      if n == 0:
        print(0)
        sys.exit()
      elif n < mm:
        mm = n
print (mm)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c = [2019]*2
p = 0
flag = 0
if (b-a) >= 2019:
    for j in range(a,a+2020):
        if j%2019 == 0:
            flag = 1
            break
        for l in range(j+1,a+2020):
            if l%2019==0:
                flag = 1
                break
            c[1] = (j*l)%2019
            c[0] = (j*l)%2019 if c[0] > c[1] else c[0]
else:
    for m in range(a,b+1):
        if m%2019 == 0:
            flag = 1
            break
        for n in range(m+1,b+1):
            if n%2019==0:
                flag = 1
                break
            c[1] = (n*m)%2019
            c[0] = (n*m)%2019 if c[0] > c[1] else c[0]
if flag == 1:
    print(0)
else:
    print(c[0])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
def min_mod2019(L, R):

    mod_list = [i for i in range(2019)]

    imin=0
    jmin=0
    
    if L%2019 < R%2019 and R < L+2019:
        mod_list = mod_list[L%2019:R%2019 + 1]
        min_mod = 2019
        for i in range(len(mod_list)-1):
            for j in range(i+1, len(mod_list)):
                if min_mod > (mod_list[i]*mod_list[j])%2019:
                    #imin=mod_list[i]
                    #jmin=mod_list[j]
                    min_mod=(mod_list[i]*mod_list[j])%2019
        return min_mod
    return 0

if __name__ == '__main__':
    L, R =map(int,input().split(' '))
    print(min_mod2019(L, R))

Submission status: Accepted

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

a = []

for i in range (R-L+1):
    
    x = L + i
    a.append((x)%2019)        

    
ans = 2019

for i in range (R-L+1):

    for j in range (R-L+1):

        if i == j :
            continue
        
        ans_tmp = ( a[i] * a[j] )%2019
        
        if ans_tmp < ans:
            ans = ans_tmp
        
print (ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l, r = [int(e) for e in input().split()]
m = 2019
for i in range(l, r):
  for j in range(i + 1, r + 1):
    t = (i * j) % 2019
    if t < m:
      m = t
    if m == 0:
      break
  if m == 0:
    break
print(m)

Submission status: Accepted

Solution code:
l, r = [int(e) for e in input().split()]
m = 2019
for i in range(l, r):
  ir = i % 2019
  for j in range(i + 1, r + 1):
    t = (ir * j) % 2019
    if t < m:
      m = t
    if m == 0:
      break
  if m == 0:
    break
print(m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

ans = sys.maxsize

for i in range(L, R+1):
    for j in range(i+1, R+1):
        minNum = (i * j) % 2019
        if minNum == 0:
            ans = minNum
            break
        else:
            ans = min(ans, minNum)
    else:
        continue
    break

print(ans)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
if R//2019-L//2019>=1:
  print(0)
  exit()
A=0
B=0
ans=float('inf')
for i in range(L,R):
  for j in range(1,R-i+1):
    A=i*(i+j)
    B=A%2019
    ans=min(ans,B)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inf = [int(i) for i in input().split()]
L = inf[0]
R = inf[1]

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

Submission status: Accepted

Solution code:
import sys

L,R = (int(i) for i in input().split())

mod = 2019
ans = 2018

for i in range(L,R):
    for j in range(i+1,R+1):
        temp = (i*j) % mod
        if temp < ans:
            ans = temp
        if temp ==0:
            print(0)
            sys.exit()

print(ans)

Submission status: Accepted

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

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

print(min)

Submission status: Accepted

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

K = 2019

def f(a):
	return a // K

def main():
	l, r = map(int, input().strip().split())
	ans = 0
	if f(r) - f(l) >= 1:
		pass
	else:
		t = 10**9
		for i in range(l, r):
			for j in range(l+1, r+1):
				t = min(t , (i*j) % K)
		ans = t
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import numpy as np
L, R = [int(x) for x in input().split(" ")]
N = 2019

minimum_mod = N
for i in range(L, R):
    for j in range(i + 1, R + 1):
        if (i * j) % N == 0:
            print(0)
            exit(0)
        elif (i * j) % N < minimum_mod:
            minimum_mod = (i * j) % N

print(minimum_mod)

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

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


def solve(l, r):
    N = 2019

    r = min(r, l+N)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# +2019までを調べれば十分

l, r = map(int, input().split())
ans = 10**9

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

print(ans)

Submission status: Accepted

Solution code:
from itertools import*
a,b=map(int,input().split())
if b-a>=2019:
    print(0)
else:
    print(min(s*t%2019 for s,t in combinations(range(a,b+1),2)))

Submission status: Accepted

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

ans = 2018
mod = 2019

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
if r - l > 3000:
  print(0)
else:
  ans = 3000
  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())
mod = 2019
if r - l > 3000:
  print(0)
else:
  ans = mod
  for i in range(l, r + 1):
    for j in range(r, l, -1):
      #print(str(i) + ' ' + str(j))
      if j <= i: break
      ans = min(ans, (i * j) % mod)
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 28 20:37:55 2019

@author: avina
"""

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

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