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: Wrong Answer

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

#i*jmodk=(imodk*jmodk)modk

#l以上r以下の整数で2019の倍数を含むものがあれば、imod2019=0となるiを選ぶことでijmod2019=0になり、最小
#場合１、r-lが2019より大きければかならずimod2019=0となるiを選べる
if r-l>=2019:
    print(0)
else:
    #場合2、r-lが2019より小さいが、中にimod2019=0となるiを選べるijmod2019=0がある　ijmod2019=0になり、最小
    for i in range(l,r+1):
        if i%2019==0:
            print(0)
            sys.exit()
    #場合3、r-lが2019より小さく、中にimod2019=0となるiがない　i=l,j=l+1のときijmod2019は最小値をとる
    ans=(l%2019 * (l+1)%2019)%2019
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
L=l%2019
R=r%2019
if l>r-2019 and L<R:
    print(L*(L+1))
else:print(0)

Submission status: Wrong Answer

Solution code:
def main():
    L, R = map(int, input().split())
    min_ = 2019
    left = L % 2019
    right = R % 2019
    if left >= right:
        return 0
    for i in range(left, right):
        for j in range(i + 1, right + 1):
            tmp = i * j % 2019
            if tmp < min_:
                min_ = tmp
    return min_

print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L,R= [int(i) for i in input().split()]
l = L % 2019
r = R % 2019
a = 2019*L+l
b = 2019*R+r
print(a,b)
print(a*(a+1) % 2019)

Submission status: Wrong Answer

Solution code:
import sys
L, R = map(int, input().split())
if R - L >= 2018 :
    print(0)
    sys.exit()
LM = L % 2019
RM = R % 2019
if RM < LM :
    print(0)
    sys.exit()
print(LM * (LM+1))

Submission status: Wrong Answer

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

L = L%2019
R = R%2019
MIN = 2020

for i in range(L,R):
    for j in range(L,R):
        if i == j:
            continue
        mod = i*j
        MIN = min(MIN,mod%2019)
if R - L == 1:
    print((R*L)%2019)
else:
    print(MIN)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
a,b=map(int,input().split())
num = 2018
z = 1
if b-a==1:
  print(a*b%2019)
  sys.exit(0)
for i in range(b-a):
  for j in range(z,b-a):
    c = a+i
    d = a+j
    if num > (c*d%2019):
      num = c*d%2019
  z+=1
print(num)

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
a = l % 2019
b = r % 2019
if r - l >= 2019:
    ans = 0
else:
    if a<b:
        ans = a*(a+1)%2019
    else:
        ans= 0
print(ans)

Submission status: Wrong Answer

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

i=2018
j=2018

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

for n in range(L,R+1):
    if n%2019<j%2019 and n!=i:
        j=n
    if j%2019==0:
        break

print(i*j%2019)

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
mod=2019
A=L%mod
B=R%mod
if A==0 or L+2019-A>=R:
    print(0)
else:
    print(A*((L+1)%mod)%mod)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
l,r=map(int,input().split())
flg=0
m=10*20
for i in range(10**7):
    if l<=2019*i<=r:
        flg=1
        m=0

for i in range(l,r): 
    if flg==1:
        break
    for j in range(l+1,r+1):
        if (i*j)%2019<m:
            m=(i*j)%2019

print(m)

Submission status: Wrong Answer

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

if R - L >= 2019:
    print(0)
else:
    a = L % 2019
    b = R % 2019
    if a >= b:
        print(0)
    else:
        print((a*(a+1))%2019)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
r1 = 2019
r2 = 2020
for i in range(L, R+1):
    if i%2019==0:
        r1=0
        break
    elif r1>r2:
        if i%2019<r1:
            r1 = i%2019
    else:
        if i%2019<r2:
            r2 = i%2019
print(r1*r2)

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
n = 2019
L %= n
R %= n
if L >= R:
    R += n
if L == 0 or R == 0:
    print(0)

list = []
for i in range(R-L):
    for j in range(R-L-i):
        list.append( ((L+i) * (L+i+j+1)) % n)

print(min(list))

Submission status: Wrong Answer

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

if(diff >= 2019):
  print(0)
else:
  lmod = l % 2019
  rmod = r % 2019
  if(rmod  < lmod):
    print(0)
  else:
    ans =2020
    for i in range(l,r+1):
      for j in range(i,r+1):
        if((i*j) % 2019 < ans):
          ans = (i*j) % 2019
    print(ans)

Submission status: Wrong Answer

Solution code:
L,R = [int(i) for i in input().split()]
mod = 2019
if R-L >= 2019:
    print(0)
else:
    ans = []
    for i in range(L,R+1):
        ans.append(i % mod)
    ans = sorted(ans)
    ans2 = (ans[0]*ans[1])%mod
    print(ans2)

Submission status: Wrong Answer

Solution code:
l, r = [int(i) for i in input().split()]
if r//3 - l//3 >= 1 and r//673 - l//673 >= 1:
    print(0)
elif r//2019 - l//2019 >= 1:
    print(0)
else:
    print((l*(l+1))%2019)

Submission status: Wrong Answer

Solution code:
import math

x = input()
x = x.split()

l = int(x[0])
r = int(x[1])

if l % 2019 > r % 2019 or r-l >= 2018:
  print("0")
  exit()


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

Submission status: Wrong Answer

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

ans = []
for i in I:
    j = i + 1
    k = i * j
    m = k % 2019
    ans.append(m)

print(min(ans))

Submission status: Wrong Answer

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

for i in range(N):

    for j in range(i, R+1, N):
        if L <= j <= R:
            n.append(i)

    if len(n) >= 2:
        break

print(n[0]*n[1])

Submission status: Wrong Answer

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

D = R - L
Ans = {2018}
def cal(a, b):
    return int(((a%2019)*(b%2019))%2019)

for i in range(min(D, 2020)):
    for j in range(min(D-i+1, 2020)):
        Ans.add(cal(L+i, L+i+j+1))

print(min(Ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
l, r = map(int, input().split())
mod = 2019
mods = l // mod + 1
l_mod = l % mod
r_mod = r % mod
if l <= mod*mods <= r:
    print(0)
elif l_mod < r_mod:
    print(l_mod * (l_mod+1))
else:
    print(r_mod * (r_mod+1))

Submission status: Wrong Answer

Solution code:
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

L,R = IL()

if R-L >= 2019:
  print(2)
else:
  print(min(L*(L+1)%2019,(R-1)*R%2019))

Submission status: Wrong Answer

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

flag = True
ans = 2019
for i in range(L, L+2017):
    if flag:
        for j in range(i+1, L+2018):
            if j > R:
                flag = False
                break
            ans = min(((i % 2019) * (j % 2019)) % 2019, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
MIN = min(R-L+1, 4040)
counter = []
ite = 0
for i in range(L, R+1):
    counter.append(i % 2019)
    ite += 1
    if ite > 4040:
        break
counter = sorted(counter)
ans = counter[0]*counter[1]
print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
mod_n = 2019
if (mod_n*2) < (R - L + 1):
    R = L + mod_n*2

v = []
for i in range(L,R+1):
    v.append(i % mod_n)
v.sort()
#print(v)
ans = (v[0] * v[1]) % mod_n
print(ans)

Submission status: Wrong Answer

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

import sys

input = sys.stdin.readline

def main():
    L, R = map(int, input().split())
    m = 10000000000
    l = L % 2019
    r = R % 2019

    if l > r:
        l, r = r, l

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

main()

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
modl = []
result = float("INF")
for i in range(l, r + 1):
    num = i % 2019
    if num == 0:
        print(0)
        exit()
    modl.append(num)
for i in range(r - l + 1):
    for j in range(i + 1, r - l + 1):
        result = min(modl[i] * modl[j], result)
print(result)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

l = l % 2019
r = r % 2019
if r <= l:
  r += 2019

print(min([(i * j) % 2019 for i, j in combinations(range(l, r+1), 2)]))

Submission status: Wrong Answer

Solution code:
import sys
L, R = map(int, input().split())
    
if R - L + (L % 2019) >= 2019:
    print(0)
    sys.exit()
else:
    print((L % 2019) * ((L+ 1) % 2019))

Submission status: Wrong Answer

Solution code:
def main():

    """ convenient functions
    # for i, a in enumerate(iterable)
    # q, mod = divmod(a, b)
    # divmod(x, y) returns the tuple (x//y, x%y)
    # Higher-order function: reduce(operator.mul, xyz_count, 1)
    # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
    """

    """convenient decorator
    # @functools.lru_cache():
    # to facilitate use of recursive function
        # ex:
        # from functools import lru_cache
        # import sys
        # sys.setrecursionlimit(10**9)
        # @lru_cache(maxsize=None)
        # def fib(n):
        #     if n < 2:
        #         return n
        #     return fib(n-1) + fib(n-2)
        # print(fib(1000))
    """
    
    # import numpy as np
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html
    # accumulate() returns iterator! to get list: list(accumulate())
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  # prime factor
        b, e = 2, 0  # base, exponent
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        # TODO: How should I do when n - r is negative?
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
    from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
    import operator
    from operator import itemgetter
    # ex1: List.sort(key=itemgetter(1))
    # ex2: sorted(tuples, key=itemgetter(1,2))
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)

    # first create factorial_list
    # fac_list = mod_factorial_list(n)
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow!
    def modinv(a, p = MOD):
        # evaluate reciprocal using Fermat's little theorem:
        # a**(p-1) is identical to 1 (mod p) when a and p is coprime
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        # fac_list = modfactorial_list(100)
        # print(modcomb(100, 5, modfactorial_list(100)))
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    """ initialize variables and set inputs
    # initialize variables
        # to initialize list, use [0] * n
        # to initialize two dimentional array, use [[0] * N for _ in range(N)]
    # set inputs
        # open(0).read() is a convenient method:
        # ex) n, m, *x = map(int, open(0).read().split())
        #     min(x[::2]) - max(x[1::2])
        # ex2) *x, = map(int, open(0).read().split())
        #     don't forget to add comma after *x if only one variable is used
    # preprocessing
        # transpose = [x for x in zip(*data)]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
        # flat = [flatten for inner in data for flatten in inner]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9]
    # calculate and output
        # output pattern
        # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6
    """

    # functions used
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    R = lambda: list(map(int, r().split()))
    Rmap = lambda: map(int, r().split())
    Rfloat = lambda: list(map(float, r().split()))
    Rtuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    # single int: int(r())
    # single string: r()
    # single float: float(r())
    # line int: R()
    # line string: r().split()
    # line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())]
    # lines int: [R() for _ in range(n)]
    """

    if __name__ != '__main__':
        # for test
        sys.stdin = open('sample.txt')

    # ----------------------------------
    # main
    
    # 2019 => 1, 3, 673, 2019
    inputL, inputR = R()
    md = 2019
    modl = inputL % md
    modr = inputR % md
    
    if inputR - inputL >= 2018 or modl > modr:
        print(0)
        exit()
    
    ans = 10000000000000000
    for i in range(modl, modr+1):
        for j in range(modl, modr+1):
            if i == j:
                continue
            else:
                ans = min(ans, (i*j)%md)
            if j == 673:
                print(j)
    
    print(ans)
    # print(min(modl*(modl+1), modr*(modr+1)))
    # if inputL > inputR:
    #     print(inputL * (inputL+1))
    # else:
    #     print(inputR * (inputR+1))
        
        
    # end of main
    # ----------------------------------

    """memo: how to use defaultdict of list
    # initialize
    Dic = defaultdict(list)
    # append / extend
    Dic[x].append(y)
    # for
    for k, v in Dic.items():
    """

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
L,R=map(int,input().split())
A=[i%2019 for i in range(L,R+1)]
a=min(A)
A.remove(a)
b=min(A)
print((a*b)%2019)

Submission status: Wrong Answer

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

mod = 2019

if r-l >= 2018:
    print(0)
    exit()
    
l_s = l % mod
r_s = r % mod


if r_s > l_s:
    print(l_s*(l_s+1))
    exit()
else:
    print(0)
    exit()

Submission status: Wrong Answer

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

ret=(L%2019)*(L%2019+1)


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

if 2019 < L - R:
    print(0)

else:
    res = 2*10**9
    for i in range(R-L):
        tmp = (L * (L + i + 1)) % 2019
        '''
        print(L)
        print(L+i+1)
        print((L * (L + i + 1)))
        '''
        if tmp < res:
            res = tmp
    print(res)

Submission status: Wrong Answer

Solution code:
import sys

L, R = map(int, sys.stdin.readline().split())
mod = 2019

mod_L = L%2019
mod_R = R%2019

if R - L > 2019:
    temp_i = mod_L
    temp_j = 2018
else:
    temp_i = mod_L
    temp_j = mod_R

min_mod = 9999
for i in range(mod_L, mod_R + 1):
    for j in range(i + 1, mod_R + 1):
        if ((i*j)%mod) < min_mod:
            min_mod = (i*j)%mod
print(min_mod)

Submission status: Wrong Answer

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


def solve(l, r):
    first = min(l % 2019, r % 2019)
    result = (first * (first + 1)) % 2019
    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: Wrong Answer

Solution code:
l, r = map(int, input().split())
hage = [i % 2019 for i in range(l, r+1)]
a = l // 2019
b = r // 2019
l = l - 2019*min(a,b)
r = r - 2019*min(a,b)
nums = [i % 2019 for i in range(l, r+1)]
nums.sort()
print(nums[0] * nums[1])

Submission status: Wrong Answer

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

temp = 2019
for i in range(1,min(r-l+1,2020)):
    temp = min(temp,(l+i)%2019)
    
print(temp*(temp+1))

Submission status: Wrong Answer

Solution code:
def resolve():
    l,r=map(int,input().split())
    k=min(r+1,l+2021)
    lst=[i%2019 for i in range(l,k)]
    a=min(lst)
    lst.remove(a)
    b=min(lst)
    print(a*b)
resolve()

Submission status: Wrong Answer

Solution code:
num = input().split()
l, r = int(num[0]), int(num[1])
tmp = []

if r-l>2019:
  for i in range(l,l+2019):
    tmp.append(i%2019)
else:
  for i in range(l,r+1):
    tmp.append(i%2019)
tmp = list(set(tmp))
print(tmp[0]*tmp[1] if tmp[0]!=0 else tmp[1]*tmp[2])

Submission status: Wrong Answer

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

min_mod = MOD
for i in range(mL, mR):
    for j in range(i+1, mR+1):
        min_mod=min(i*j%MOD, min_mod)
print(min_mod)

Submission status: Wrong Answer

Solution code:
MOD = 2019

l, r = sorted(map(lambda x: int(x) % MOD, input().split()))
if l == r == 0:
    print(0)
    exit()
ret = MOD
for i in range(l, r):
    for j in range(i + 1, r + 1):
        ret = min(ret, (i * j) % MOD)
print(ret)

Submission status: Wrong Answer

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

MOD = 2019  # type: int

def solve(L: int, R: int):
    # L = min(L,MOD-1)
    # R = min(R,MOD-1)
    L = L % MOD
    R = R % MOD
    if(L == 0):
        L += MOD
    if(R == 0):
        R += MOD
    if(R < L):
        R += MOD

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

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(x)

Submission status: Wrong Answer

Solution code:
L, R = [int(x) for x in input().split()]
MOD = 2019
if (R - L > 2017):
    print(0)
    exit()
L %= MOD
R %= MOD
if (L * R == 0 or R < L):
    print(0)
    exit()
elif (R-L == 1):
    print(L*R % MOD)
    exit()
i = L
ans = 2018
while(i != R-1):
    j = i+1
    while (j != R):
        if (ans > (i*j % MOD)):
            ans = i*j % MOD
        j += 1
    i += 1
print(ans)

Submission status: Wrong Answer

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

from collections import defaultdict

d = defaultdict(int)

for i in range(L,R+1):
  d[i%2019] += 1
  if d[0]>0 and len(d)>1:
    break
cnt = 0
ans = list()

for k,v in sorted(d.items()):
  _v = v
  
  while _v > 0:
    cnt +=1
    ans += [k]
    _v -= 1
    if cnt >=2:
      print((ans[0]*ans[1])%2019)
      break
  if cnt >=2:
    break

Submission status: Wrong Answer

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

R = R % 2019 + L

ans = float('inf')

for i in range(L, R + 1):
    for j in range(i + 1, R + 1):

        ans = min((i * j) % 2019, ans)
print(ans)

Submission status: Wrong Answer

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

base = 2019
l_mod = l % base
r_mod = r % base

if r - l >= 2019:
    print(0)
elif r_mod <= l_mod:
    print(0)
else:
    print(l_mod * (l_mod + 1))

Submission status: Wrong Answer

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

if R <= 2019:
    ans = (R * (R - 1)) % 2019
elif L <= 2019 and 2019 <= R:
    ans = 0
else:
    ans = (L * (L + 1)) % 2019
    
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/local/bin/python3
#coding:utf-8
#import numpy as np


def main():

   in0 = input()

   IN = in0.split(' ')

   L = int(IN[0])
   R = int(IN[1])
   y = 2019

   min_mod = (L*R)%y
   for i in range(L,R-1):
      for j in range(i+1,R):
          cal = (i*j)%y
          if (min_mod>cal):
              min_mod = cal


   print ("%s" % (min_mod))




if __name__ == "__main__":
   main()

Submission status: Wrong Answer

Solution code:
l,r = map(int,input().split())
if r - l >= 2019:
    print(0)
s= 0
for x in range(l,r+1):
    if x % 2019 == 0:
        s += 1
if s >0:
    print(s)

print(min((r%2019-1)*(r%2019),(l%2019+1)*(l%2019)))

Submission status: Wrong Answer

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

m_l = L % 2019
m_r = R % 2019


import numpy as np
ms = np.arange(min(m_l, m_r), max(m_l, m_r)+1)
Ms = ms.reshape(-1,1)*ms.reshape(1,-1)
Ms = Ms % 2019
Ms += np.eye(Ms.shape[0], dtype=int)*2019
print(np.min(Ms))

Submission status: Wrong Answer

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

def gcd(m,n):
    temp=0
    while m%n!=0:
        temp=n
        n=m%n
        m=temp
    return n
def lcm(m,n):
    return m*n/gcd(m,n)


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

print(min([min(e) for e in temp]))

Submission status: Wrong Answer

Solution code:
l,r  = map(int,input().split())
small = l // 2019
big = r // 2019
num = [l % 2019,r % 2019,l % 2019 + 1,r % 2019 - 1]
num.sort()
num = list(set(num))
if big - small >= 1:
    print(0)
    exit()
else:
    print(num[0] * num[1])

Submission status: Wrong Answer

Solution code:
LR = list(map(int,input().split()))
L = LR[0]%2019
R = LR[1]%2019
K = 2018
if R >= L:
    for j in range(L,R+1):
        for i in range(L,j):
            if K > (i*j)%2019:
                K =  (i*j)%2019
else:
    for j in range(R,L+1):
        for i in range(R,j):
            if K > (i*j)%2019:
                K =  (i*j)%2019
print(K)

Submission status: Wrong Answer

Solution code:
import itertools as it
L, R = map(int, input().split())
l = L % 2019
r = R % 2019

result = 2020
if l < r:
    for x, y in it.combinations([i for i in range(l, r + 1)], 2):
        temp = (x * y) % 2019
        if temp < result:
            result = temp
        if result == 0:
            break
elif l > r:
    for x, y in it.combinations([i for i in range(0, r + 1)] + [i for i in range(r, 2019)], 2):
        temp = (x * y) % 2019
        if temp < result:
            result = temp
        if result == 0:
            break
else:
    result = 0
print(result)

Submission status: Wrong Answer

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

from collections import defaultdict

d = defaultdict(int)

for i in range(L,R+1):
  d[i%2019] += 1
  if d[0]>0 and len(d)>1:
    break

print(d)
cnt = 0
ans = list()

for k,v in sorted(d.items()):
  _v = v
  
  while _v > 0:
    cnt +=1
    ans += [k]
    _v -= 1
    if cnt >=2:
      print((ans[0]*ans[1])%2019)
      break
  if cnt >=2:
    break

Submission status: Wrong Answer

Solution code:
import math

x = input()
x = x.split()

l = int(x[0])
r = int(x[1])

if l % 2019 > r % 2019 or r-l >= 2018:
  print("0")
  exit()


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

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
def judge_distance(i,j):
    if j-i >= 2019:
        return True

def search_2019(i,j):
    for p in range(j-i+1):
        if i+p % 2019 == 0:
            return True

if judge_distance(L,R) or search_2019(L,R):
    print(0)
else:
    print(min(L*(L+1)%2019,(R-1)*R%2019))

Submission status: Wrong Answer

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

l = l % 2019
r = r % 2019

mod_min = 2019

if l < r:
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            mod = i * j % 2019
            if mod < mod_min:
                mod_min = mod
else:
    for i in range(l, r + 2019 + 1):
        for j in range(i+1, r+2019 + 1):
            mod = i * j % 2019
            if mod < mod_min:
                mod_min = mod

print(mod_min)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
N = min([R - L , 2018])
m = 2018
if N == 1:
  m = (R*L)%2019
for i in range(N):
  for j in range(N - i - 1):
    M = ((L + i)*(L + N - j - 1))%2019
    if M < m:
      m = M
print(m)

Submission status: Wrong Answer

Solution code:
import math

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

ls = l % 2019
rs = r % 2019

dif = r // 2019 - l // 2019

#print("dif = {}".format(dif))

if (dif != 0):
    print(0)
else:
    print(ls*(ls+1) % 2019)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

MOD = 2019
ub = max(R % MOD, L % MOD)
lb = min(R % MOD, L % MOD)

if ub == lb:
    ub += MOD

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