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:
L, R = map(int, input().split())

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

if ub == lb:
    print(ub * lb % MOD)
    exit()

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)

Submission status: Wrong Answer

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

if R-L >= 2019:
    ans = 0
else:
    ans = 4000
    for i in range(L,R):
        p = (i%2019) * ((i+1)%2019)
        if p < ans:
            ans = p

    for i in range(L,R):
        p = ((2019-i)%2019) * ((2018-i)%2019)
        if p < ans:
            ans = p

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input().split()
a = [int(i) for i in a]

a[0] = a[0] % 2019
a[1] = a[1] % 2019

print((a[0] * a[1]) % 2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l=l%2019
r=r%2019

if l>r:
    tmp=r
    r=l
    l=tmp

ans=(l*r)%2019
for l1 in range(l,r):
    for r1 in range(l1+1,r+1):
        ans=min(ans,(l1*r1)%2019)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

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

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

r = np.array(list(i%2019 for i in range(L, R+1)))

r = np.sort(r)

print(r[0] * r[1] % 2019)

Submission status: Wrong Answer

Solution code:
import sys

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

if L == 0:
    print(0)
    sys.exit()

temp = R // t
temp2 = L // t
kouho = []
if temp != temp2:
    print(0)
    sys.exit()
else:
    for i in range(L, R+1):
        kouho.append(i)
    kouho.sort()
    ans = (kouho[0] * kouho[1]) % t
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=[int(i) for i in input().split()]
ss=2019
ans=2020
for i in range(1,10**9):
    ss=2019*i
    if l<=ss<=r:
        print(ss*(ss+1)%2019)
        break
    elif ss<=l and r<ss+2019:
        print(l*(l+1)%2019)
        break
    elif ss>r:
        for j in range(l,r):
            ans=min(j*(j+1)%2019,ans)
        print(ans)
        break

Submission status: Wrong Answer

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

l = L // mod
r = R // mod

if l != r:
    print(0)
else:
    print(L * (L+1) % mod)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [L, R] = string_to_int(inputs[0])
    left = L % 2019
    right = R % 2019
    if left > right:
        start = right
        end = left
    else:
        start = left
        end = right

    min = start * end
    for i in range(start, end-1):
        for j in range(start+1, end):
            if min > i*j:
                min = i*j
    return min


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Wrong Answer

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

mods = []
for i in range(l, r):
    for j in range(i + 1, r + 1):
        mods.append((i % 2019) * (j % 2019))

print(min(mods))

Submission status: Wrong Answer

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

LR = input().split(' ')
L = int(LR[0])
R = int(LR[1])

L2 = L % 2019
R2 = R % 2019
if L2 > R2:
    R2 += 2019

r = sorted(map(lambda x: x % 2019, range(L2, R2 + 1)))

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

Submission status: Wrong Answer

Solution code:
l,r=[int(i) for i in input().split()]
tmpl=2019*(l//2019+1)
modl=10000000000
numl=0
for i in range(l,min(tmpl,r+1)):
    if i%2019<modl:
        modl=i%2019
        numl=i
tmpr=2019*(r//2019)
modr=10000000000
numr=0
for i in range(max(tmpr,l),r+1):
    if i%2019<modr and i!=numl:
        modr=i%2019
        numr=i
print((numl*numr)%2019)

Submission status: Wrong Answer

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

num_list = []

for i in range(L, R+1):
    num_list.append((i*(i+1))%2019)


print(min(num_list))

Submission status: Wrong Answer

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

if R-L > 2019:
    print(0)
else:
    i_mod = 2019
    j_mod = 2019
    for k in range(L,R+1):
        mod = k%2019
        if mod < i_mod:
            j_mod = i_mod
            i_mod = mod
        elif mod < j_mod:
            j_mod = mod
    print(i_mod*j_mod)

Submission status: Wrong Answer

Solution code:

def main():

   in0 = input()

   IN = in0.split(' ')

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

   min_mod = 2019
   for i in range(L,R):
      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 = list(map(int, input().split(' ')))
#print(L, R)

min_i = 2020
for i in range(L, R):
    mod_i = i % 2019
    if min_i > mod_i:
        min_i = mod_i
        Li = i
        if min_i == 0:
            break

min_j = 2020
for j in range(Li + 1, R + 1):
    mod_j = j % 2019
    if min_j > mod_j:
        min_j = mod_j
        if min_j == 0:
            break


print(min_i * min_j)

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(0,min(r-l,2020)):
    temp = min(temp,(l+i)%2019)
    
print(temp*(temp+1))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
import itertools
  
if R - L  >= 2018:
  print(1)
  exit()
else:
  minV = 2*10**9
  for i in itertools.combinations(range(L, R+1), 2):
    val = (i[0]*i[1]) % 2019
    if val <= minV:
      minV = val
  print(minV)

Submission status: Wrong Answer

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

for i in range(l, r):
    for j in range(l+1, r+1):
        tmp = (i*j % 2019)
        if (i == l and j == l+1) or tmp < mod:
            mod = tmp
        if mod == 1:
            break
    if mod == 1:
        break
print(mod)

Submission status: Wrong Answer

Solution code:
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

num = 2019
l, r = na()
if r < num:
    print(l * r)
elif l <= num <= r:
    print(0)
elif l > num:
    i = l % num
    j = r % num
    if i<j:
        print(i*(i+1))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
L_2019 = L%2019
R_2019 = R%2019
ans1 = (L_2019*R_2019)%2019
if R_2019 < L_2019 :
    print(0)
else:
    for i in range(L_2019,R_2019):
        for j in range(i+1,R_2019+1):
            ans2 = (i*j)%2019
            ans1 = min(ans1,ans2)
print(ans1)

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

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

L = L % 2019
R = R % 2019
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
print(ans)

Submission status: Wrong Answer

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

ld = L // MOD
rd = R // MOD

ans = 0
if ld != rd:
    ans = 0
else:
    lm = L % MOD
    ans = (lm * (lm + 1)) % MOD

print(ans)

Submission status: Wrong Answer

Solution code:

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



if l % 2019 == 0:
    ans = 0
elif r % 2019 == 0:
    ans = 0
elif l // 2019 == r // 2019:
    ans = 10**6
    l, r = l // 2019, r // 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans, (i*j) % 2019 )


elif l // 2019 != r // 2019:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

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

min = 2019

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

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

print(min)

Submission status: Wrong Answer

Solution code:
a = input().split()
a = [int(i) for i in a]

a[0] = a[0] % 2019
a[1] = a[0] % 2019

print((a[0] * a[1]) % 2019)

Submission status: Wrong Answer

Solution code:
# lll = [i*2019 for i in range(1, 1000000)]

L, R = map(int, input().split())
# if L == R - 1:
#     print((L * R) % 2019)
# elif L <= 2019 or R >= 2019:
#     print(0)
# else:
#     pass


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

Submission status: Wrong Answer

Solution code:
# coding; utf-8
l, r = map(int, input().split())

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
l,r=map(int, input().split())
List=[]
for i in range(l, r+1):
    List.append(i%2019)
List=sorted(List)
print(List[0]*List[1])

Submission status: Wrong Answer

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

L = L % 2019
R = R % 2019

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

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

    ans = sys.maxsize

    # 0 がある場合
    # 0 がない場合→全探索

    if R//2019 - (L-1)//2019 > 0:
        return

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

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

Submission status: Wrong Answer

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

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

print(min_)

Submission status: Wrong Answer

Solution code:
def main():
    L, R = map(int, input().split())
    if R // 2019 > L // 2019:
        print(0)
        return
    print(min(L%2019, R%2019) * (min(L%2019, R%2019) + 1))
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if r - l > 2020:
    r = l + 2020

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

        if sub < ans:
            ans = sub

print(ans)

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:
  print( (l*(l+1) ) % 2019)

Submission status: Wrong Answer

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

if r//2019 - l//2019 >= 1:
    print(0)
else:
    print((l%2019)*((l+1)%2019))

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

Submission status: Wrong Answer

Solution code:
MOD = 2019

l, r = sorted(map(lambda x: int(x) % MOD, input().split()))
if l == r:
    r += 1
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:
L,R = map(int,input().split())
md = 2019
if R - L >= 2019:
    print(0)
else:
    p = min(L%md,R%md)
    print(p*p+1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 20

# 0<= L < R <= 2*10^9 
L, R = [int(x) for x in stdin.readline().rstrip().split()]
MODN = 2019

if R < 2019:
    print(L*R)
    exit()

ans = INF
for i in range(L, L + 2019 + 3):
    if i > R:
        break
    for j in range(i+1, L + 2019 + 3):
        if j > R:
            break

        tmp = (i * j) % MODN
        ans = min(ans, tmp)

print(ans)

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

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

Submission status: Wrong Answer

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

if (l//2019+1)*2019 >= r:
    print((l * (l + 1)) % 2019)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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 % 2019
    R = R % 2019
    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())

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

Submission status: Wrong Answer

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

if L <= R//d * 2019 <= R: print(0)
else: 
    print((L%d)*(L+1)%d)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
d = R - L
if d > 2019:
  print(0)
else:
  lst = [i % 2019 for i in range(L,R+1)]
  lst.sort()
  print((lst[0]*lst[1])%2019)

Submission status: Wrong Answer

Solution code:
num = input().split()
l, r = int(num[0]), int(num[1])
tmp = list(set([i%2019 for i in range(l,r+1)]))

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

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().rstrip().split(" ")))
if n[1] - n[0] >= 2019:
    print(0)
else:
    n1 = (n[0] * (n[0]+1))%2019
    n2 = (n[1] * (n[1]-1))%2019
    if n1 < n2:
        print(n1)
    elif n1 > n2:
        print(n2)
    elif n[1] - n[0] == 1:
        print(n1)
    else:
        print(0)

Submission status: Wrong Answer

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


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


def main():
    l, r = get_li()
    if r - l >= MOD:
        print(0)
        return
    lm = l % MOD
    rm = r % MOD
    if lm < rm:
        print((l * (l + 1)) % MOD)
        return
    else:
        print(0)
        return


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


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


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


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


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


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


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


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

Submission status: Wrong Answer

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

l_mod = l % 2019
r_mod = r % 2019

if l_mod >= r_mod:
    print(0)
else:
    min_val = 2020
    for i in range(r_mod - l_mod + 1):
        for j in range(r_mod - l_mod + 1):
            if i >= j:
                continue
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
            
    print(min_val)

Submission status: Wrong Answer

Solution code:
def solve():
  l,r = (int(i) for i in input().split())
  mod = 2019
  l %= mod
  r %= mod
  ans = 10**15
  if l >= r :
    print(0)
    exit()
  elif l == 0 or r == 0:
    print(0)
    exit()
  else:
    for i in range(l,r):
      for j in range(i+1,r+1):
         ans = min(ans,(i*j)%mod)
  print(ans%mod)

solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if l == r:
    l = 0
    r = 2018
elif r > l:
    pass
else:
    for i in range(0, r):
        for j in range(1, r + 1):
            if j <= i:
                continue
            else:
                ans = min(ans, i * j % MOD)
    for i in range(l, 2018):
        for j in range(l + 1, 2019):
            if j <= i:
                continue
            else:
                ans = min(ans, i * j % MOD)
    
    print(ans)
    exit()
    

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

print(ans)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
L_2019 = L%2019
R_2019 = R%2019
ans1 = L_2019*R_2019
if R_2019 < L_2019 :
    print(0)
else:
    for i in range(L_2019,R_2019):
        for j in range(i+1,R_2019+1):
            ans2 = (i*j)%2019
            ans1 = min(ans1,ans2)
print(ans1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

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

    nl = [ i % 2019 for i in range(l, r+1)]
    nl.sort()
    print(nl[0] * nl[1])

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:
    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 = [int(x) for x in input().split()]
s = min([i%2019 for i in range(L,R)])
print(s*(s+1))

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
s=[]
for i in (l,r):
    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())
list1 = []
i = L
j = L + 1
jcount = 0
amari = 0
while True:
    if i < R-1 :
        list1.append(i*j)
        if j <= R:
            j += 1
        else:
            jcount += 1
            j = L + jcount
            i += 1
    else:
        break

if len(list1) == 0:
    print((i*j)%2019)
else:
    for i in range(len(list1)):
        list1[i] = list1[i]%2019

    list1.sort
    print(list1[0])

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
L=[]
L2=[]
LL=[]
for i in range(0,min(4038,r-l+1)):
  LL.append((l+i)%2019)
  if (l+i)%2019<1009:
    L.append((l+i)%2019)
  else:
    L2.append(2019-(l+i)%2019)
L.sort()
L2.sort()
LL.sort()
x=99999;y=99999
if len(L)>1:
  x=(L[0]*L[1])%2019
if len(L2)>1:
  y=(L2[0]*L2[1])%2019
z=(LL[0]*LL[1])%2019
print(min(x,y,z))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

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

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

r = np.array(list(i%2019 for i in range(L, R+1)))

r = np.sort(r)

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

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if r-l >= 2018:
	print(0)
else:
	ll, rr = l%2019, r%2019
	if ll < rr:
		print(ll*(ll+1)%2019)
	else:
		n1 = [i for i in range(ll+1)]
		n2 = [i for i in range(rr, 2019)]
		n = n1 + n2
		print(n[0]*n[1]%2019)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
mod = 2019
d = R - L + 1
c = d // mod 
a = L % mod
b = R % mod
if c >= 2 :
    print(1)
else :
    if a > b :
        print(0)
    else :
        print(a*(a+1)%mod)

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 % 2019
    R = R % 2019
    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:
input = input().split()

L = int(input[0])
R = int(input[1])

memo = 100000000

for l_i in range(L,R-1):
  for r_i in range(l_i+1,R):
    result = (l_i*r_i)%2019
    if memo > result:
      memo = result

print(memo)

Submission status: Wrong Answer

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

a=l%2019
b=r%2019

if l+(2019-a)>l and l+(2019-a)<r:
  print(0)
else:
  if a<b:
    print((l*(l+1))%2019)
  else:
    print((r*(r-1))%2019)

Submission status: Wrong Answer

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

if R-L >= 2018:
    print(0)
    import sys
    sys.exit()
first = 2020
second = 2020
for n in range(L, R+1):
    mod = n%2019
    if mod < first:
        first, second = mod, first
    elif mod < second:
        second = mod
print(first * second)

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):
        m = min(m, i % 2019)
    print(m * (m+1))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc133/tasks/abc133_c

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

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

    l_i = l // 2019
    r_i = r // 2019
    if l_i != r_i:
        print(0)
    else:
        ans = l * r % 2019
        for k in range(l, r):
            ans = min(ans, k * (k + 1) % 2019)
        print(ans)


if __name__ == '__main__':
    main()

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 != 0:
    print(0)
    exit()
else:
    print(num[0] * num[1])

Submission status: Wrong Answer

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

d = R - L
if d >= 2020:
    ans = 0
elif d == 2019:
    ans = 0
else:
    l = L % 2019
    r = R % 2019
    
    if l + d >= 2019:
        ans = 0
    else:
        ans = l * (l+1)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    print(val)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
base = 2019
L,R = LI()
l = L % base
r = R % base
if l >= r:
    r += 2019

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

Submission status: Wrong Answer

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

if L // 2019 < R // 2019:
    ans = 0
else:
    res = L % 2019
    ans = (res * (res + 1)) % 2019
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
L, R = map(int , input().split())
mod = 2019
ans = float('inf')
for i in range(mod):
    if L + 1 + i > R:
        print(ans)
        exit()
    tmp_mod = ((L + i) * (L + 1 + i)) % mod
    if ans > tmp_mod:
        ans = tmp_mod

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# 0<= L < R <= 2*10^9 
L, R = [int(x) for x in stdin.readline().rstrip().split()]
MODN = 2019

if R < 2019:
    print(L*R)
    exit()

ans = INF
for i in range(L, L + 2019 + 3):
    if i > R:
        break
    for j in range(i+1, L + 2019 + 3):
        if j > R:
            break

        tmp = (i * j) % MODN
        ans = min(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
L,R = map(int,input().split())
mod = 2019
L_mod = L%mod
R_mod = R%mod
sa = R-L
if sa >= mod*2:
    ans = 1
elif sa >= mod:
    ans = L_mod-1
    if L_mod == 2:
        ans = 2
else:
    if R_mod < L_mod:
        ans = 2
    else:
        ans = L_mod*(L_mod+1)
print(ans)

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 i%2019<r1:
        r1 = i%2019
    elif i%2019<r2:
        r2 = i%2019
print(r1*r2)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
answer = 2019
while l != r:
    answer = min(answer, (l % 2019)*(l+1)%2019)
    l += 1
print(answer)

Submission status: Wrong Answer

Solution code:
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
L, R = [int(x) for x in input().split()]
MOD = 2019

l = L
r = min(l + MOD * 2, R)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l_mod = l % 2019
r_mod = r % 2019

if l_mod > r_mod:
    print(0)
else:
    min_val = 2020
    for i in range(r_mod - l_mod + 1):
        for j in range(r_mod - l_mod + 1):
            if i >= j:
                continue
            min_val = min([min_val, ((l_mod+i)*(l_mod+j))%2019])
            
    print(min_val)

Submission status: Wrong Answer

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

num = L*(L+1)

if L*R < 2019:
    print(L*R)
else:
    ans = 1e+1000
    while True:
        if num > L*R:
            break

        mod = num % 2019
        if num % 2019 < ans:
            ans = mod
        else:
            pass
        num += L
    print(ans)