Problem:


Score : 300 points

Problem Statement

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

L R

Output

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

Sample Input 1

2020 2040

Sample Output 1

2

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

Sample Input 2

4 5

Sample Output 2

20

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



Sample input:
2020 2040


Sample output:
2

Submission status: Accepted

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

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

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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  L, R = input_list()
  ans = []
  for x in range(L, R+1):
    for y in range(x+1, R+1):
      ans.append((x*y)%2019)
      if (x*y) % 2019 == 0:
        print(0)
        exit(0)
  print(min(ans))  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
a,b = map(int, input().split())
mod = 2019
min_score = 2019

for i in range(a, b+1):
    for j in range(a, b+1):
        if i != j:
            temp = (i)*(j) %mod
            if min_score > temp:
                min_score = temp
            if min_score == 0:
                print(min_score)
                exit()

print(min_score)

Submission status: Accepted

Solution code:
import numpy as np
a,b = map(int, input().split())
mod = 2019
min_score = 2019

for i in range(a, b+1):
    for j in range(a, b+1):
        if i != j:
            temp = (i%mod)*(j%mod) %mod
            if min_score > temp:
                min_score = temp
            if min_score == 0:
                print(min_score)
                exit()

print(min_score)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
if R - L >= 2018:
    res = 0
else:
    res = 2019 
    for i in range(L, R):
        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())
m=2019
s=l%m
e=r%m
q=(r-l)//m
A=[0]*m
if s<=e:
    for i in range(m):
        if i<s or e<i:
            A[i]=q
        else:
            A[i]=q+1
else:
    for i in range(m):
        if i<=e or s<=i:
            A[i]=q+1
        else:
            A[i]=q
            
ans=m
for i in range(m):
    for j in range(m):
        if i==j:
            if A[i]>=2:
                ans=min(i*j%m,ans)
        else:
            if A[i]>0 and A[j]>0:
                ans=min(i*j%m,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number_list = (lambda: list(map(int, input_list())))

    L, R = input_number_list()
    m = float('inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = min(m, (i * j) % 2019)
            if m == 0:
                print(0)
                exit()
    print(m)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

l, r = load_list()
mn = 2019
for i in range(l, l+2019):
    if l > r:
        break
    for j in range(i+1, l+2019):
        if j > r:
            break
        mn = min(mn, (i*j) % 2019)

print(mn)

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:
import sys
input = sys.stdin.readline

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

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

Submission status: Accepted

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

tmp=10**9+1
ans=10**9+1

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


# 332701087 1753412895

Submission status: Accepted

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

MOD = 2019  # type: int


def solve(L: int, R: int):
    if L // 2019 == R // 2019:
        minL = L % 2019
        maxR = R % 2019
        ans = 2019
        for i in range(minL, maxR):
            for j in range(i + 1, maxR + 1):
                com = (i * j) % 2019
                ans = min(ans, com)
        print(ans)
    else:
        print(0)
    return


# Generated by 1.1.6 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())



l=(L//2019, L%2019)
r=(R//2019, R%2019)

if l[0] != r[0]:
    print(0)
else:
    lst = []
    bottom=min(l[1], r[1])
    up=max(l[1], r[1])
    for i in range(bottom,up):
        for j in range(i + 1, up+1):
            lst.append((i * j) % 2019)
    print(min(lst))

Submission status: Accepted

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

MOD = 2019  # type: int


def solve(L: int, R: int):
    LmM = L % MOD
    minimum = L - LmM + MOD
    if minimum < R:
        print(str(0))
    else:
        result = 10**16
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                result = min(result, i*j % MOD)
        print(result)


# Generated by 1.1.6 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:
import math
import collections
from operator import mul
from functools import reduce

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

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

L%=2019
R%=2019

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


m=1000000000000000000;
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:
import sys
L, R = map(int, input().split())
ans = 10**10
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:
l,r = map(int,input().split())
if(r-l >= 2019):
    print(0)
    exit()

mod = 2019

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans=2019

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

Submission status: Accepted

Solution code:
l,r = map(int,input().split())
mod = 2019
min = 10**9
c = 0
for i in range(l,r):
    for j in range(l+1,r+1):
        if (i*j)%mod < min:
            min = (i*j)%mod
    
        if min == 0:
            break
    if min == 0:
        break

print(min)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

mn = 4038

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
l,r = map(int,input().split())

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

ans = temp
print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

Submission status: Accepted

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

Submission status: Accepted

Solution code:
low,high = list(map(int,input().split()))
min_number = 2018
for i in range(low,high):
    for j in range(i+1,high+1):
        A = i * j % 2019
        if A < min_number:
            min_number = A
        if min_number == 0:
            print(0)
            exit()
print(min_number)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

def main():
    l,r=map(int,input().split())
    if r-l>=2019:
        print(0)
    else:
        ans=[]
        for i in range(l,r):
            for j in range(i+1,r+1):
                ans.append((i*j)%2019)
        ans.sort()
        print(ans[0])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    L,R=map(int,input().split())
    if R-L<2018:
        print(min([(i*j)%2019 for i in range(L,R) \
                   for j in range(i+1, R+1)]))
    else:
        print(0)

resolve()

Submission status: Accepted

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

MOD = 2019  # type: int


def solve(L: int, R: int):
    list_lr_mod = []
    ans = 2018

    if R - L >= 2018:
        print(0)
        return

    for i, x in enumerate(range(L, R + 1)):
        xmod = x % MOD
        if xmod == 0:
            print(0)
            return
        else:
            list_lr_mod.append(xmod)


    for i in range(len(list_lr_mod) - 1):
        for j in range(i + 1, len(list_lr_mod)):
            tmp = list_lr_mod[i] * list_lr_mod[j]
            ans = min(ans, tmp % MOD)

    print(ans)

# Generated by 1.1.6 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:
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int


def solve(L: int, R: int):
    list_lr_mod = []
    ans = 2018

    for i, x in enumerate(range(L, R + 1)):
        list_lr_mod.append(x % MOD)

        if i + 1 >= 2019:
            print(0)
            return

    if 0 in list_lr_mod:
        print(0)
        return

    for i in range(len(list_lr_mod) - 1):
        for j in range(i + 1, len(list_lr_mod)):
            tmp = list_lr_mod[i] * list_lr_mod[j]
            ans = min(ans, tmp % MOD)

    print(ans)

# Generated by 1.1.6 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:
#!/usr/bin/env python3
import sys

MOD = 2019  # type: int


def solve(L: int, R: int):
    list_lr_mod = []
    ans = 2018

    for x in range(L, R + 1):
        list_lr_mod.append(x % MOD)

        if len(list_lr_mod) >= 2019:
            print(0)
            return

    list_lr_mod = list(set(list_lr_mod))

    if 0 in list_lr_mod:
        print(0)
        return

    for i in range(len(list_lr_mod) - 1):
        for j in range(i + 1, len(list_lr_mod)):
            tmp = list_lr_mod[i] * list_lr_mod[j]
            ans = min(ans, tmp % MOD)

    print(ans)

# Generated by 1.1.6 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:
#133c
L,R = map(int, input().split())

#https://ttrsq.exblog.jp/24409121/
#a*b%MOD = a%MOD * b%MOD

MOD = 2019

#ありえる%MODを列挙
ij_set = set()
for i in range(L,R+1):
    #print(i)
    if i%MOD not in ij_set:
        ij_set.add(i%MOD)
    else:
        break #MODした値が一緒になる→2019の倍数を挟んでいる→%MODが0になる値が含まれているので、それ以上考える必要なし。
        
ij_list = list(ij_set)
ij_list.sort(reverse=False)
#print(ij_list)

ans = MOD - 1

#ありえる%MODの組み合わせを全て試す
for i in range(len(ij_list) - 1):
    for j in range(i+1,len(ij_list)):
        if ans > ij_list[i]*ij_list[j]%MOD:
            ans = ij_list[i]*ij_list[j]%MOD
            #print(ij_list[i],ij_list[j])
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ume 20/03/18

def main():
  l,r=map(int,input().split())
  if r-l>2018:
    return 0
  else:
    c=2019
    for i in range(l,r):
      for j in range(i+1,r+1):
        c=min(c,i*j%2019)
        if c==0: return c
    return c

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

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 2019
L, R = lr()
if (R-L) > 2019 * 2:
    R = L + (R-L)%MOD + 2019

answer = 2019
for i in range(L, R):
    for j in range(i+1, R+1):
        temp = i * j % MOD
        if temp < answer:
            answer = temp

print(answer)

Submission status: Accepted

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

l1 = l%2019
r1 = r%2019
if r >= l + 2019 - l1:
    r1 = 2019

ans = float("inf")
for i in range(l1,r1):
    for j in range(i+1, r1+1):
        ans = min(ans, ((i*j)%2019))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
M=2019
l,r,a=L%M,R%M,M
if l<r and R-L<672:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min(a,i*j%M)
      if a<2: break
    if a<2: break
else: a=0
print(a)

Submission status: Accepted

Solution code:
M=2019;L,R=map(int,input().split())
l=L%M;r=R%M;a=M
if l<r and R-L<672:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min(a,i*j%M)
      if a<2: break
    if a<2: break
else: a=0
print(a)

Submission status: Accepted

Solution code:
M=2019;L,R=map(int,input().split())
l=L%M;r=R%M;a=M-1
if l<r and R-L<672:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min(a,i*j%M)
      if a<2: break
    if a<2: break
else: a=0
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l,r=map(int,input().split())
print(0 if r-l>671 else 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(x) for x in input().split()]
NUM = 2019
if r // NUM - (l + NUM - 1) // NUM >= 0: #2019の倍数を区間に含む
    res = 0
elif r // 3 - (l + 3 - 1) // 3 >= 0 and r // 673 - (l + 673 - 1) // 673 >= 0:
    res = 0
else: #mod 2019 = 0にできない場合
    res = 2019
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            res = min(res, (i * j) % NUM)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
M=2019;l,r=L%M,R%M
print(0 if R//M-L//M>0 else min(i*j%M 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:
    ans = 10 ** 9
    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:
# C
l,r = map(int, input().split())
mod = 2019
if r-l >= mod:
    print(0)
else:
    minnum = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = ((i%mod)*(j%mod))%mod
            if tmp < minnum:
                minnum = tmp
    print(minnum)

Submission status: Accepted

Solution code:
MOD = 2019

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

if (L // MOD) != (R // MOD):
  print(0)
else:
  res = R*R
  for i in range(L, R):
    for j in range(i+1, R+1):
      _, r = divmod(i*j, MOD)
      if r < res:
        res = r
  print(res)

Submission status: Accepted

Solution code:
def solve():
    N, M = map(int, input().split())
    m = 10 ** 9
    for i in range(N, min(N+2019, M)):
        for j in range(N+1, min(N+2019, M)+1):
            m = min(m, i * j % 2019)
    return m

print(solve())

Submission status: Accepted

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

m = 2019

if R - L > 2100:
    print(0)
else:
    tmp_min = 2018
    for i in range(L, R):
        mod_i = i % m
        for j in range(i + 1, R+1):
            mod = (mod_i * j) % m
            if tmp_min > mod:
                tmp_min = mod
    print(tmp_min)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import os

MOD = 2019


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L, R = list(map(int, sys.stdin.readline().split()))
    ret = float('inf')

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

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

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
L,R=map(int,input().split())
if R-L>2017:
    mod=[i for i in range(2019)]
else:
    l=L%2019
    r=R%2019
    mod=[i for i in range(2019)]*2
    mod=mod[mod.index(l):]
    mod=mod[:mod.index(r)+1]
ans=3000
for i in range(len(mod)-1):
    for k in range(len(mod)-i-1):
        min=mod[i]*mod[i+k+1]%2019
        if min<ans:
            ans=min
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for a in range(L, end):
    for b in range(a + 1, end+ 1):
        tmp = (a * b) % 2019
        if tmp < ans:
            ans = tmp

print(ans)

Submission status: Accepted

Solution code:
L, R = map(int, input().split())
i = 2017
j = 2018
i_mod = 2017
j_mod = 2018
end = min(R, L + 4038)

ans = 2018

# for n in range(L, (end + 1)):
#     n_mod = n % 2019
#     if n_mod < i_mod:
#         i, j = n, i
#         i_mod, j_mod = n_mod, i_mod
#     elif n_mod < j_mod:
#         j = n
#         j_mod = n_mod

# print((i * j) % 2019)

for a in range(L, end):
    for b in range(a + 1, end+ 1):
        tmp = (a * b) % 2019
        if tmp < ans:
            ans = tmp

print(ans)

Submission status: Accepted

Solution code:
l,r = map(int, input().split())
if r - l > 2018:
  print(0)
else:
  a = []
  min_a = 10**9
  for i in range(r-l+1):
    a.append((l+i)%2019)
  for i in range(len(a)):
    for j in range(1,len(a)-i):
      min_a = min(min_a,(a[i]*a[i+j])%2019)
#      print(i,j,(a[i]*a[i+j])%2019)
  print(min_a)