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())

ansL = []
for i in range(2019):
    if L + i > R:
        break

    ansL.append((L + i) % 2019)

ans = 999999
for i in range(len(ansL)):
    for j in range(i, len(ansL)):
        if i == j:
            continue
        
        ans = min([ans, ((ansL[i] * ansL[j] ) % 2019)])

print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
MOD = 2019
L,R = list(map(int,input().split()))
R = min(R, L + MOD)
nums = range(L,R+1)
answer = MOD
for i in range(L,R+1):
    for j in range(max(i+1,L), R+1):
        c = (i*j)%MOD
        # if c < answer:
            # print(c,i,j)
        answer = min(c,answer)
print(answer)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
C - Remainder Minimization 2019
https://atcoder.jp/contests/abc133/tasks/abc133_c

"""
import sys
from itertools import combinations

def solve(l, r):
    res = set()
    for i in range(l, r+1):
        res.add(i % 2019)
        if len(res) == 2019:
            break
    ans = set()
    for a, b in combinations(res, 2):
        ans.add(a * b % 2019)
    return min(ans)


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


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
l, r = (int(x) for x in input().split())
if r-l>= 2019:  # if range is big, then it is fine
    print(0)
else:
    cur = min(2019, (l % 2019) + (r - l))  # if within small range there would be number mod 2019 == 0
    if cur == 2019:
        print(0)
    else:
        # else just loop thorguh
        min_mod = float('inf')
        for i in range(l, r+1):
            for j in range(i+1,r+1):
                val = (i*j) % 2019
                if val < min_mod:
                    min_mod = val
                    if min_mod == 0:
                        break
            if min_mod == 0:
                print(0)
                break
        else:
            print(min_mod)

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
if R - L >= 2019 :
    print(0)
else:
    K = []
    for i in range(L,R+1,1):
        a = i % 2019
        K.append(a)
    ans = 10**9+7
    size = len(K)
    for x in range(size):
        for y in range(x+1,size):
            o = K[x] * K[y] % 2019
            if o < ans :
                ans = o
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
# L <= i < j <= R
# (i*j)%2019 の最小値
M=[]
for i in range(L, R):
    for j in range(i+1, R+1):
        #print(i,j)
        M.append((i*j)%2019)
        if M[-1]==0:
            print(0)
            exit()
print(min(M))

Submission status: Accepted

Solution code:
import sys
a, b = map(int, input().split())
if b-a >= 2019:
    print(0)
    sys.exit()

ans = 2018
for i in range(a, b):
    for j in range(i+1, b+1):
        mod = (i % 2019)*(j % 2019) % 2019
        if ans > mod:
            ans = mod

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def f(i, j):
    if j - i >= MOD:
        return 0
    i %= MOD
    j %= MOD
    if i > j:
        return 0
    ans = 2018
    for a in range(i, j):
        for b in range(a+1, j+1):
            ans = min(ans, a*b%MOD)
    return ans

print(f(L,R))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
l,r=(int(x) for x in input().split())
s=2020
for i in range(l, min(l+2021,r+1)):
  for j in range(i+1, min(l+2021, r+1)):
    n=i%2019*j%2019%2019
    if n<s:
      s=n
    if s==0:
      print(s)
      sys.exit()
print(s)

Submission status: Accepted

Solution code:
import numpy as np

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

if R - L >= 2019:
    ans = 0
elif L % 2019 > R % 2019:
    ans = 0
else:
    X =[]
    l = L % 2019
    r = R % 2019
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            X.append(i*j)
    X_np = np.array(X)
    X_np_mod = X_np % 2019
    ans = min(X_np_mod)

print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

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

if R-L > 1000:
    print(0)
    exit()
x = np.arange(L,R+1)
x = x[:,None] * x[None,:] % 2019
np.fill_diagonal(x,2019)
answer = x.min()
print(answer)

Submission status: Accepted

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

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())

l = L // 2019
r = R // 2019

mi = 2019
if l == r:
	L = L % 2019
	R = R % 2019
	for i in range(L, R):
		for j in range(i+1, R+1):
			mi = min((i*j)%2019, mi)
else:
	L = L % 2019
	for i in range(L, 2019):
		for j in range(i+1, 2020):
			mi = min((i*j)%2019, mi)
print(mi)

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
ans=2018
d=r-l
if d>2019:
    d=2019

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

Submission status: Accepted

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

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

print(out)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if r-l >= 2018:
  answer = 0
else:
  l = [i%2019 for i in range(l, r+1)]
  l.sort()
  for i in range(len(l)):
    for j in range(i+1, len(l)):
      answer = min(answer, l[i]*l[j]%2019)

print(answer)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
div = 2019
if __name__ == '__main__':
    L, R = [int(i) for i in input().split()]
    if R - L > div - 1:
        R = L + div - 1
    number_ref = [num for num in range(L, R + 1, 1)]

    min_mod = 2018
    for idx, i in enumerate(number_ref):
        for j in number_ref[idx + 1:]:
            if (i * j) % div < min_mod:
                min_mod = (i * j) % div
    print(min_mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    l, r = list(map(int, input().rstrip('\n').split()))
    m = 10 ** 10
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            m = min(m, (i * j) % 2019)
            if m == 0:
                print(m)
                exit()
    print(m)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations
import sys

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

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

A = list(range(l,r+1))

ans_L = [i[0]*i[1]%2019 for i in combinations(A,2)]
print(sorted(ans_L)[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(lr):
    L, R = lr
    ans = 2018
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            x = i * j % 2019
            if x == 0:
                return 0
            if x < ans:
                ans = x
    return ans

print(solve(tuple(int(i) for i in input().split())))

Submission status: Accepted

Solution code:
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    l, r = list(map(int, input().rstrip('\n').split()))
    mmod = 10 ** 10
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            mmod = min(mmod, (i * j) % 2019)
            if mmod == 0:
                break
        if mmod == 0:
            break
    print(mmod)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            m = i * j % 2019
            lst.append(m)
            if m == 0:
                break
        if m == 0:
            break
    print(min(lst))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            m = i * j % 2019
            lst.append(m)
            if m <= 1:
                break
        if m <= 1:
            break
    print(min(lst))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            lst.append(i * j % 2019)
            m = i * j % 2019
            if m <= 1:
                break
        if m <= 1:
            break
    print(min(lst))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            lst.append(i * j % 2019)
            if i * j % 2019 <= 1:
                break
        if i * j % 2019 <= 1:
            break
    print(min(lst))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if i * j % 2019 == 0:
                print(0)
                return
            lst.append(i * j % 2019)
            if i * j % 2019 == 1:
                break
        if i * j % 2019 == 1:
            break
    print(min(lst))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    lst = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if i * j % 2019 == 0:
                print(0)
                return
            lst.append(i * j % 2019)
    print(min(lst))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    s = set()
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if i * j % 2019 == 0:
                print(0)
                return
            s.add(i * j % 2019)
    print(min(s))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            if i * j % 2019 == 0:
                print(0)
                return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    elif 0 in (L % 2019, R % 2019):
        print(0)
        return
    elif R % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    elif 0 in (L % 2019, R % 2019):
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    elif L % 2019 == 0:
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    elif L % 673 == 0 and L + 2 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    elif R % 673 < L % 673 and L + 2 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Submission status: Accepted

Solution code:
def main():
    L, R = map(int, input().split())
    # [3, 673]
    if L + 672 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()

Submission status: Accepted

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

l_mod = l % 2019
if r - l >= 2019:
    r_mod = l_mod + (r - l - 2019) % 2019 + 2019
else:
    r_mod = l_mod + (r - l) % 2019

ans = 2019
for i in range(l_mod, r_mod):
    for j in range(i + 1, r_mod + 1):
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

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)):
    ans = min(ans, (i*j) % 2019)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
if l//2019!=r//2019:
    print(0)
    exit()

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
if l//2019!=r//2019:
    print(0)
    exit()

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

Submission status: Accepted

Solution code:
l, r = map(int, input().split())
m = []
if r-l >= 2018:
  print(0)
else:
  L = l%2019
  R = r%2019
  if L == 0 or R == 0:
    print(0)
  elif L>R:
    print(0)
  else:
    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())
b = 2018
if R - L >= 2019:
  print(0)
else:
  L = L % 2019
  R = R % 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      if b > (i * j) % 2019:
        b = (i * j) % 2019
  print(b)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

if r - l >= 2019:
    print(0)
else:
    m = 2019
    for i, j in combinations(range(l, r+1),2):
        tmp = i*j % 2019
        if m > tmp:
            m = tmp
    print(m)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

MOD2019 = 2019

ans = INF

right = min(R+1, L+2019)
for l in range(L, right):
    for r in range(l+1, right):
        ans = min(ans, (l*r) % MOD2019)

print(ans)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

MOD2019 = 2019

ans = INF

right = min(R+1, L+2019+1)
for l in range(L, right):
    for r in range(l+1, right):
        ans = min(ans, (l*r) % MOD2019)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
 
if R - L >= 2017:
  print(0)
  exit()
 
ans_list = []
 
for x in range(L, R):
  for y in range(x+1, R+1):   
    ans_list.append((x * y) % 2019)
    
print(min(ans_list))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    l, r = map(int, open(0).read().split())
    MOD = 2019
    if r - l >= MOD:
        print(0)
        return()
    l %= MOD
    r %= MOD
    if l == 0 or r == 0:
        print(0)
        return()
    if l > r:
        r += MOD

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

    print(ans)
    return()

if __name__ == '__main__':
    main()

Submission status: Accepted

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

# L <= i,j <== R の中で、i*j mod 2019の最小値を求めよ

# L,R は 0 ~ 2*10^9

# (i*j) mod 2019 = (i mod 2019) * (j mod 2019) %2019

# =============================================================================
# for i in range(2019):
#     for j in range(i,2019):
#         a = (i*j) % 2019
#         b = (i % 2019)*(j % 2019) % 2019
#         if a != b:
#             print(i,a,b)
# =============================================================================

# 全探索: 2019*2019が最大

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    L,R = map(int, input().split())
    diff = R-L
    L %= 2019
    diff = min(diff, 2019)

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

solve()

Submission status: Accepted

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

    a = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            a = min(a,i*j%2019)
            if a == 0:
                return 0
    return a

print(main())

Submission status: Accepted

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

ans = 10**9
rng = R - L
if rng > 2019:
    ans = 0
else:
    for i in range(L, R+1):
        for j in range(L, R+1):
            if i != j:
                ans = min(ans, i*j % 2019)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
b, c = map(int, input().split())
if c-b >=2018:
    print(0)
else:
    t = b%2019
    if t+(c-b+1) >= 2019:
        print(0)
    else:
        import numpy as np
        ind = [t+i for i in range(c-b+1)]
        mask = np.array([[True if i!=j else False for i in range(len(ind))] for j in range(len(ind))])
        tmp = ind*np.array(ind).reshape((len(ind),-1))%2019
        print(np.min(tmp[mask]))

Submission status: Accepted

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

print(temp)

Submission status: Accepted

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