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())
ans = []

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
dl, ml = divmod(l, 2019)
dr, mr = divmod(r, 2019)
if ml == 0 or mr == 0 or dr - dl != 0 or ml >= mr:
  print(0)
else:
  mi = l*(l+1)%2019
  for i in range(l, r):
    for j in range(i+1, r+1):
      temp = i*j%2019
      if temp < mi:
        mi = temp
  print(mi)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from itertools import combinations
l,r = map(int, input().split())
if (r//673 - (l-1)//673 > 0)&(r-l >= 2):
    print(0)
else:
    print(min([l[0] * l[1] % 2019 for l in list(combinations(range(l,r+1),2))]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

	print(min(a))

Submission status: Accepted

Solution code:
import sys
import math
import itertools

input = sys.stdin.readline


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

    if r - l >= 2019:
        print(0)
        return
    else:
        num = [i for i in range(l, min(l + 2019, r + 1))]
        min_ = 2019
        for i, n in enumerate(num):
            for j in num[i + 1 :]:
                min_ = min([n * j % 2019, min_])
    print(min_)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

flag = 0
min_ = 2020
for i in range(L,R):
    for j in range(i+1,R+1):
        s = (i*j) % 2019
        if s == 0:
            print('0')
            exit()
        if s < min_:
            min_ = s
print(min_)

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

l = L % 2019
r = R % 2019

ans = 2019*2019

if L // 2019 == R // 2019:
    # print(l,r)
    for i in range(l, r):
        # print('i', i)
        for j in range(i+1,r+1):
            # print('j', j)

            ans = min(ans, (i*j)%2019)
else:
    ans = 0

print(ans)

Submission status: Accepted

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

ans = 10000
if r-l >= 2019:
    print(0)
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 = 2019
mod = 2019

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

Submission status: Accepted

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

    ans = L * R % 2019
    if R - L >= 2019:
        ans = 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)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MOD=2019
l,r=map(int,input().split()) #l<=i<i+1<=j<=r
res=[]

if r - l > 2019:
  print(0)
  
else:
  l=l%MOD
  r=r%MOD
  l,r=min(l,r),max(l,r)

  for i in range(l,r):
    for j in range(i+1,r+1):
      res += [(i*j)%MOD]

  print(min(res))

Submission status: Accepted

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

m = 2019
mod_min = m

is_return = False

for j in range(l,r+1,1):
    #j_ = j % m
    #if j_ == 0:
        #break
        
    if is_return:
        break
    for i in range(l,j,1):
        #i_ = i % m
        i_j = (i * j) % m
        
        if i_j < mod_min:
            mod_min = i_j
            
        if i_j == 0:
            is_return = True
            break
            
print(mod_min)

Submission status: Accepted

Solution code:
x,y = map(int,input().split())



t = 222222
gap = y - x
a = 111111
if y - x > 2018:
    a =0
else:
    for i in range(x,y+1):
        for j in range(i+1,y+1):
            t = min(t,(i*j)%2019)

print(min(a,t))

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
def doit(l, r):
  if r - l > 2019:
    return 0
  l = l % 2019
  r = r % 2019
  if l == 0:
    return 0
  if r == 0:
    return 0
  if r <= l:
    r += 2019
  res = 2019
  for x in range(l, r):
    for y in range(x + 1, r + 1):
      #print(x, y, file=sys.stderr)
      res = min(res, (x * y) % 2019)
      if res == 0:
        return 0
  return res % 2019

print(doit(l, r))

Submission status: Accepted

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

listX = []
for i in range(1, 990590):
  listX.append(i*2019)

sw = 0
for n in range(len(listX)):
  if L < listX[n] and R > listX[n]:
    sw += 1

if sw > 0:
  print(0)

elif sw == 0:
  idx1 = 0
  listA = []
  for idx1 in range(L, R):
    for idx2 in range(idx1 + 1, R + 1):
      listA.append(idx1 * idx2)
 
  idx3 = 0
  listB = []
  for idx3 in range(len(listA)):
    listB.append(listA[idx3] % 2019)
 
  print(min(listB))

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

l,r = list(map(int, input().split()))
imin = 10**9+7

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

Submission status: Accepted

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

# n mod 2019 の答えは 0 ~ 2018 のいずれか
# それぞれのmodを取った積のmodでも同じ答えになる


def get_ans():
    # 差が2018以上なら積が0の組み合わせが存在する
    if R - L >= 2018:
        return 0

    # 総当たり
    ans = 2019
    for X in range(L, R):
        for Y in range(X + 1, R + 1):
            ans = min((ans, (X * Y) % 2019))

    return ans


print(get_ans())

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if R - L >= 2050:
    print(0)
else:
    ans = 20000000
    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:
if __name__ == '__main__':
    l,r  = list(map(int, input().split(" ")))
    res = 2019
    n = l // 2019
    if l % 2019 == 0:
        print(0)
    elif l//(n+1) <= 2019  and 2019 <= r//(n+1):
        print(0)
    else:
        for i in range(2019):
            for j in range(i+1, 2019):
                if l+i > r or j+l > r:
                    break
                res1 = (((l+i) % 2019) * (l+j % 2019)) % 2019
                if res1 < res:
                    res = res1
        print(res)

Submission status: Accepted

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

l = L % 2019
r = R % 2019

ans = 2019*2019

if L // 2019 == R // 2019:
    # print(l,r)
    for i in range(l, r):
        # print('i', i)
        for j in range(l+1,r+1):
            # print('j', j)

            ans = min(ans, (i*j)%2019)
else:
    ans = 0

print(ans)

Submission status: Accepted

Solution code:
#coding:utf-8
def main():
    L,R = list(map(int,input().split()))
    if R - L >= 2019:
        print(0)
        return
    else:
        min_r = 2019
        for i in range(L,R):
            for j in range(i+1,R+1):
                min_r = min(min_r,(i*j)%2019)
        print(min_r)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

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

Submission status: Accepted

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

    a = l*r%2019
    for i in range(l,r) :
        for j in range(i+1,r+1):
            ij = i*j%2019
            
            if (a > ij) :
                a = ij

            if(a==0) :
                return a

    return a



print(yo())

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

Submission status: Accepted

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

def get_amari():
    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
    return min_
   
def get_flg3():
    if R-L >= 3:
        return True
    elif R//3 != L//3:
        return True
    else:
        return False
    

def get_flg673():
    if R-L >= 673:
        return True
    elif R//673 != L//673:
        return True
    else:
        return False

if get_flg3() & get_flg673():
    print(0)
else:
    print(get_amari())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    l, r = map(int, input().split())

    n = r // 2019 - l // 2019

    if n >= 1:
        print(0)
    else:
        minvalue = float("inf")
        for i in range(l, r):
            for j in range(i+1, r+1):
                minvalue = min(minvalue, i * j % 2019)
        print(minvalue)

Submission status: Accepted

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

ans = 2019


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

Submission status: Accepted

Solution code:

def input_from_console():
    l, r = map(int, input().split())
    return l, r


def solve(l, r):
    minimum = 2020
    if r - l >= 2019:
        return 0
    a, b = l % 2019, r % 2019
    if r // 2019 > l // 2019:
        return 0
    for i in range(a, b):
        for j in range(a + 1, b + 1):
            minimum = min(minimum, (i * j) % 2019)
    result = minimum
    return result


def main():
    l, r = input_from_console()
    print(solve(l, r))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R= list(map(int, input().split()))
# array = np.arange(L, R+1)


# flg = True

def get_amari():
    min_ = 2019
    for i in range(L,R):
        for j in range(i+1, R+1):
            # if (i*j)%2019==0:
            #     print(0)
            #     flg = False
            #     break
            # elif (i*j)%2019 < min_:
            #     min_ = (i*j)%2019
            if (i*j)%2019 < min_:
                min_ = (i*j)%2019
    return min_
#     if flg:
        # print(min_)
                
def get_flg3():
    if R-L >= 3:
        return True
    elif R//3 != L//3:
        return True
    else:
        return False
    

def get_flg673():
    if R-L >= 673:
        return True
    elif R//673 != L//673:
        return True
    else:
        return False

def mataganai_2019():
    return (L*(L+1))//2019 == ((R-1)*R)//2019
        
if get_flg3() & get_flg673():
    print(0)
else:
    print(get_amari())

Submission status: Accepted

Solution code:
from itertools import combinations

def min_mod(l, r):
    return min([(i * j) % 2019
        for i, j in combinations(
            range(l, min(l + 2020, r + 1)), 2)])
 
 
l, r = map(int, input().split())
print(min_mod(l, r))

Submission status: Accepted

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

if r - l + 1 >= 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())

result = None
for i in range(l, min(l + 2019 - l % 2019, r - 1) + 1):
    for j in range(i + 1, min(i + 2019, r) + 1):
        mod = i * j % 2019
        if result is None or result > mod:
            result = mod
            if result == 0:
                break
    if result is not None and result == 0:
        break
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

result = None
for i in range(l, min(l + 2019 - l % 2019, r - 1) + 1):
    for j in range(i + 1, min(i + 2019, r) + 1):
        mod = i * j % 2019
        if result is None or result > mod:
            result = mod
            if result == 0:
                break
    if result == 0:
        break
print(result)

Submission status: Accepted

Solution code:
# coding: utf-8

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


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

Submission status: Accepted

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

def baisuaru(l,r,m):
  if l//m < r//m:
    return True
  elif l%m==0:
    return True
  else:
    return False
    
if baisuaru(l,r,2019):
  print(0)
else:
  a=l%2019
  b=r%2019
  ans=99999999
  for i in range(a,b):
    for j in range(i+1,b+1):
      tmpans=(i*j)%2019
      if ans>tmpans:
        ans=tmpans
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R=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)):
        if i*j%2019<m:
            m=i*j%2019
        if m==0:
            break

print(m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

if R - L > 2018:
    print(0)
    
else:
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019 
        
    ans = 2018        
    for i in np.arange(L, R+1):
        for j in np.arange(i+1, R+1):
            i = i % 2019
            j = j % 2019
            k = i * j % 2019
            ans = np.amin(np.array([k, ans]))
        
            if ans == 0:
                break
        if ans == 0:
            break        

    print(ans)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

def solve():
    l, r = map(int, input().split())
    if r - l >= 2019:
        print(0)
        return
    ans = 2019
    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)

if __name__=="__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
n, r = map(int, input().split())
if r-n >= 2019:
  print(0)
  sys.exit(0)
mini = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
mod_min=2019
zero_judge=0
for i in range(L,R):
    if zero_judge==1:
        break
    else:
        for j in range(i+1,R+1):
            mod_calc=(i*j)%2019
            if mod_calc<mod_min:
                mod_min=mod_calc
                if mod_min==0:
                    zero_judge=1
                    break

print(mod_min)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if (R - L) <= 2019:
    temp1 = float("inf")
    for i in range(R - L):
        for j in range(R - L):
            temp2 = ((R-i) * (R - 1 -j)) % 2019
            if temp2 < temp1:
                temp1 = temp2
    print(temp1)
else:
    temp1 = float("inf")
    for i in range(2019):
        if (R-i-1) < L:
            break
        for j in range(2019):
            temp2 = ((R - i) * (R - 1 - j)) % 2019
            if temp2 < temp1:
                temp1 = temp2
    print(temp1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys

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

# prime_factor = 3, 673
mod = 2019

for i in range(l, r + 1):
    if i % 2019 == 0:
        print(0)
        sys.exit(0)

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

print(ans)

Submission status: Accepted

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

data = 2019

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

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

print(data)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
L, R = list(map(int, input().split()))

min_val = 2019
for i in range(L, R):
  for j in range(i+1, R+1):
    val = (i*j)%2019
    if min_val > val:
      min_val = val
      if min_val == 0:
        break
  if min_val == 0:
    break
print(min_val)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=input().split()
L,R=int(l[0]),int(l[1])
a=0
if R-L<2019:
    a=2018
    for i in range(L,R):
        n=i%2019
        m=(i+1)%2019
        s=(n*m)%2019
        if s<a:
            a=s
        for j in range(R-i-1):
            s+=n
            s=s%2019
            if s<a:
                a=s   
print(a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

MOD = 2019

def solve(L, R):
    ans = 2019
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ij = i*j%MOD
            if ij == 0:
                print(0)
                return
            if ij < ans:
                ans = ij
    print(ans)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
L,R=map(int, raw_input().split())
a=L%2019
b=R%2019

T=[]
ans=float("inf")
if a<b:
	T=range(a,b+1)
	if R-L>2018:
		print 0
		quit()
	else:
		l=len(T)
		for i in range(l):
			for j in range(i+1,l):
				ans=min(ans, (T[i]*T[j])%2019 )

		print ans
else:
	print 0
	quit()

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline
MOD = 2019


def main():
    l, r = get_li()
    if r - l >= MOD:
        print(0)
        return
    ans = inf
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i * j) % MOD)
    print(ans)


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

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

Submission status: Accepted

Solution code:
s, e = map(int, input().split())
ans = 10 ** 9
b = min(s+2019, e)
for i in range(s, b + 1):
    for j in range(i+1, b+1):
        ans = min(ans, i*j%2019)
print(ans)

Submission status: Accepted

Solution code:
l, r = (int(_) for _ in input().split())

if abs(l - r) == 1:
    print(l * r % 2019)
else:
    lower = l // 2019
    upper = r // 2019
    start = l % 2019
    stop = r % 2019
    if 2019 * (lower + 1) < r:
        print(0)
    else:
        ans = 1000000
        if start == 0:
            print(0)
        elif stop == 0:
            print(0)
        elif stop < start:
            print(0)
        elif stop > start:
            for i in range(start, stop + 1):
                for j in range(i+1, stop + 1):
                    if i * j % 2019 < ans:
                        ans = i * j % 2019
            print(ans)

Submission status: Accepted

Solution code:
in_ = [int(i) for i in input().split()]
L = in_[0]
R = in_[1]
mod_min = 100000
# L = L % 2019
# R = R % 2019
# tab = [[-1 for r in range(R+1)] for l in range(L+1)]
# print(tab)
i_list = []
j_list = []
for i in range(L, R):
    i_mod = i % 2019
    for j in range(i+1, R+1):
            j_mod = j % 2019
            mod = i_mod * j_mod % 2019
            if mod < mod_min:
                mod_min = mod
                if mod_min == 0:
                    break
    if mod_min == 0:
        break
print(mod_min)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def slv(L, R):
    if R -L > 2019:
        return 0
    ans = sys.maxsize
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min((i*j) % 2019, ans)
    return ans

@mt
def slv2(L, R):
    ans = sys.maxsize
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            if ans > (i*j) % 2019:
                print(i, j)
            ans = min((i*j)%2019, ans)
    return ans

def main():
    L, R = read_int_n()
    print(slv(L, R))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
l, r = map(int, input().split())
mod = 2019
ans = 2*10**9
for i in range(l, r+1):
    i_mod = i % mod
    if i_mod == 0:
        print(0)
        exit()
    for j in range(i+1, r+1):
        j_mod = j % mod
        if j_mod == 0:
            print(0)
            exit()
        ans = min(ans, (i*j)%mod)
print(ans)

Submission status: Accepted

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