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:
# [i, j] の中に2019の倍数があれば、その倍数を選択すれば最小値を0

import math

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

# (A * B) % mod = (A % mod) * (B % mod) % mod
l = L % 2019
r = R % 2019

ans = None
# mod以上差があれば2019の倍数を含んでいる (ex. 2 & 2025)
if R - L >= mod:
    ans = 0
else:
    # mod以上差がなくても、あまりが0をまたぐ (ex. 2018 & 2025 => 2018 & 6) 場合
    if l > r:
        ans = 0
    else:
        ans = l * (l+1) % mod

    # _min = 2*1000000000+5
    # for i in range(l, r):
    #     for j in range(i+1, r+1):
    #         _min = min(_min, i*j%mod)

print(ans)

Submission status: Wrong Answer

Solution code:
mod=2019
l,r=map(int,input().split())
d={}
for i in range(l,min(r+1,l+2021)):
    w=i%2019
    if w in d:
        d[w]+=1
    else:
        d[w]=1
ans=2020
for i in d:
    for j in d:
        if i!=j:
            ans=min(ans,i*j)
        elif i==j and d[i]>1:
            ans=min(ans,i*j)
print(ans)

Submission status: Wrong Answer

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

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


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

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

    return ans


print(get_ans())

Submission status: Wrong Answer

Solution code:
# [i, j] の中に2019の倍数があれば、その倍数を選択すれば最小値を0
# それ以外はL, L+1を選択する

import math

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

# (A * B) % mod = (A % mod) * (B % mod) % mod
l = L % 2019
r = R % 2019

ans = None
# mod以上差があれば2019の倍数を含んでいる (ex. 2 & 2025)
if R - L >= mod:
    ans = 0
else:
    # mod以上差がなくても、あまりが0をまたぐ (ex. 2018 & 2025 => 2018 & 6) 場合
    if l > r:
        ans = 0
    else:
        ans = L * (L+1) % mod

print(ans)

Submission status: Wrong Answer

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

mod = 2019

l %= mod
r %= mod
ans = 2020
if r < l:
    r += 2019
elif r == l:
    ans = 0


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

print(ans)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
def mul(a,b):
    return ((a % 2019) * (b % 2019)) % 2019
ans=mul(l,l+1)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

L,R = map(int,input().split())
if R-L>673:
    print(0)
else:
    A =[]
    for i in range(R-L+1):
        n = (L+i)
        if n % 673 == 0 and (R-L+1) >= 3:
            print(0)
            sys.exit()
        else:
            A.append(n%2019)
    A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MIN = 2020
flag = 0

for i in range(L,R+1):
    for j in range(i+1,R+1):
        mod = i*j % 2019
        MIN = min(MIN,mod%2019)
        if MIN == 1:
            print(i)
            print(j)
        if MIN == 0:
            flag = 1
            break
    if flag == 1:
        break

if R == 0 or L == 0:
    print(0)
elif R - L == 1:
     print((R*L)%2019)
else:
    print(MIN)

Submission status: Wrong Answer

Solution code:
import sys

L,R = map(int,input().split())
if R-L>673:
    print(0)
else:
    A =[]
    for i in range(R-L+1):
        n = (L+i)
        if n % 673 == 0 and (R-L+1) >= 3:
            print(0)
            sys.exit()
        else:
            A.append(n%2019)
    print(A)
    A.sort()
    print((A[0]*A[1])%2019)

Submission status: Wrong Answer

Solution code:
l, r = list(map(int,input().split()))
if(r-l) >= 2018:
	answer = 0
elif((l % 2019) > (r % 2019)):
	answer = 0
else:
	Set = set([l%2019])
	for i in range(r-l):
		Set.add((l+1+i)%2019)
	List = list(Set)
	if(0 in List):
		print(0)
	else:
		answer = (l * r) % 2019
		for i in range(len(List)):
			for j in range(len(List)):
				if(i < j):
						if(answer > (List[i] * List[j])% 2019):
							answer = (List[i] * List[j])% 2019
		print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

    if L == 0:
        return 0

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

    if (R // 673) > ((L-1) // 673):
        if R - L >= 2:
            return 0
        if (R % 3) == 0 or (L % 3) == 0:
            return 0

    left = L % 2019
    return (left * (left + 1)) % 2019


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

Submission status: Wrong Answer

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

MIN = 2020
flag = 0

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

if R == 0 or L == 0:
    print(0)
elif R - L == 1:
     print((R*L)%2019)
else:
    print(MIN)

Submission status: Wrong Answer

Solution code:
mod=2019
l,r=map(int,input().split())
t=[2000000000]*2
for i in range(l,min(r+1,l+2021)):
    if i%2019<t[0]:
        t[1]=t[0]
        t[0]=i%2019
    elif i%2019<t[1]:
        t[1]=i%2019
print(t[0]*t[1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  7 20:52:12 2019

@author: YudNK
"""

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

if R - L >= 2019:
    print(0)
else:
    a = L%2019
    l = [a]
    for i in range(R - L):
        l.append(a + i + 1)
    while len(l) > 1:
        m = 2018
        for i in range(len(l) - 1):
            b = (l[-1] * l[i]) % 2019
            if b < m:
                m = b
        l.pop(-1)
    print(m)

Submission status: Wrong Answer

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if L ==0:
    ans = 0
elif R == L+1:
    ans = R*L%2019
else:
    if L == R:
        ans = L * R %2019
    if l >= r:
        r += 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            temp = (i * j) % 2019
            if bool:
                min = temp
                ans = min
                bool = False
            elif min > temp:
                min = temp
                ans = min
print(ans)

Submission status: Wrong Answer

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


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

print(mod_min)

Submission status: Wrong Answer

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

i = l
ans = 2018
while i < r:
    ans = min(ans, (i*(i+1))%2019)
    i += 1

print(ans)

Submission status: Wrong Answer

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

ans = float('inf')
for i in range(L, L + 2020):
    for j in range(L + 1, L + 2020):
        if (i >= j) or (i > R):
            continue
        ans = min(ans, (i * j) % MOD)

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
L, R = map(int, input().split())
modL = L % 2019
modR = R % 2019
 
if R - L > 2019:
  print(0)
else:
  modlist = np.array([(L + i) % 2019 for i in range(min(2019, R-L+1))])
  modlist.argsort()
  print(modlist[0] * modlist[1])

Submission status: Wrong Answer

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

i = l
ans = 2018
while i < r:
    ans = min(ans, i*(i+1)%2019)
    i += 1

print(ans)

Submission status: Wrong Answer

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

ans = 2019*2019

if L // 2019 == R // 2019:

    if abs (L % 2019 - 1009) < abs(R % 2019 - 1009):
        ans = ((R % 2019) * ((R+1) % 2019)) % 2019

    elif abs (L % 2019 - 1009) == abs(R % 2019 - 1009):
        ans = ((L % 2019) * (R % 2019)) % 2019

    else:

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

else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

ans = 2018
for i in range(L, L + 2020):
    for j in range(L + 1, L + 2020):
        if (i > j) or (i > R):
            continue
        ans = min(ans, (i * j) % MOD)

print(ans)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
l1=l
l2=(l+1)
print((l1*l2)%2019)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

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

l = l%2019
r = r%2019
if l>r:
    r,l = l,r
temp = float('inf')
for i in range(l,r+1):
    for k in range(i+1,r+1):
        if i*k%2019 < temp:
            temp = (i*k)%2019
print(temp) if l != r else print(l*r%2019)

Submission status: Wrong Answer

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

P = 2019

def mul(a, b):
    return ((a % P) * (b % P)) % P

l = L//P
r = R/P

if r-(l+1)>0:
    print(0)
    
else:
    print(mul(L, L+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
flag = False
if R - L >= 2019:
    flag = True

for i in range(min(L,R),max(L,R)+1):
    for j in range(i,max(L,R)+1):
        if i != j:
            mod = i*j
            MIN = min(MIN,mod%2019)
if R == 0 or L == 0 or flag:
    print(0)
elif abs(R - L) == 1:
    print((R*L)%2019)
elif R == L:
    print((R*L)%2019)
else:
    print(MIN)

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
ans=2019
y=r
while l<r:
  while l<y:
    x=l*y
    x=x%2019
    if x<ans:
      ans=x
    if ans==0:
      break
    y=y-1
  if ans==0:
    break
  l=l+1
print(ans)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
diff = r - l
l = l % 2019
r = l + diff
a = 2019
for x in range(l, r):
  for y in range(x + 1, r):
    a = min(a, (x * y) % 2019)
    if a == 0:
      break
  else:
    continue
  break
print(a)

Submission status: Wrong Answer

Solution code:
"""
#include <stdio.h>
int main(){
  int l, r, ans=99999;
  int lst[99999];
  scanf("%d",&l);
  scanf("%d",&r);
  l %= 2019;
  r %= 2019;
  for(int i=l;i<r;i++){
    for(int j=i+1;j<r+1;j++){
      if(ans>(i*j)%2019){
        ans = (i*j)%2019;
        //printf("%d\n",ans);
      }
    }
  }
  printf("%d\n",ans);

}
/*"""
l, r = map(int, input().split())
l3 = l
l2 = 2019*(l//2019)
r -= l2
l %= 2019

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

#for i in range()

#lst = []
sum = 9999999999
#lm = 99999999999
#rm = 99999999999
#for 
#print(l%2019)
"""
for i in range(l,r):
  for j in range(i+1,r+1):
    #lst.append(i*j%2019)
    if sum > i*j%2019:
      sum = i*j%2019
print(sum)
"""
#*/

Submission status: Wrong Answer

Solution code:
import numpy as np
 
L, R = map(int, input().split())
modL = L % 2019
modR = R % 2019
 
if R - L > 2019:
  print(0)
else:
  modlist = [(L + i) % 2019 for i in range(min(2019, R-L+1))]
  min_ = modlist.pop(0)
  print(min_ * min(modlist))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = float('inf')
for i in range(L, L + 2020):
    for j in range(L + 1, L + 2020):
        if (i > j) or (i > R) or (j > R):
            continue
        ans = min(ans, (i * j) % MOD)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l,r=map(int,input().split())
l1=l%2019
l2=(l+1)%2019
print((l1*l2)%2019)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  7 20:52:12 2019

@author: YudNK
"""

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

if R - L >= 2019:
    print(0)
else:
    a = L%2019
    if a == 0:
        print(0)
    elif a + R - L >= 2019:
        print(0)
    else:
        l = [a + i for i in range(R - L + 1)]
        while len(l) > 1:
            m = 2018
            for i in range(len(l) - 1):
                b = (l[-1] * l[i]) % 2019
                if b < m:
                    m = b
            l.pop(-1)
        print(m)

Submission status: Wrong Answer

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

if R - L >= 2019:
    print(0)
    exit()
ans = (L * (L + 1)) % MOD
for i in range(L, L + 5000):
    for j in range(L + 1, L + 5000):
        if (i >= j) or (i > R) or (j > R):
            continue
        if (i * j) % MOD == 0:
            print(i, j)
        ans = min(ans, (i * j) % MOD)

print(ans)

Submission status: Wrong Answer

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

minimum=2019
z=1
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:
            z=1
            break
        if z==1:
            break
    
print(minimum)

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(min(L,R),max(L,R)+1):
    for j in range(i,max(L,R)+1):
        if i != j:
            mod = i*j
            MIN = min(MIN,mod%2019)
if R == 0 or L == 0:
    print(0)
elif abs(R - L) == 1:
    print((R*L)%2019)
elif R == L:
    print((R*L)%2019)
else:
    print(MIN)

Submission status: Wrong Answer

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

mod = 2019

l %= mod
r %= mod

if r <= l:
    r += 2019

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

if ans == 2020:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

st = l % 2019

if r - l >= 5000:
    print(0)

else:
    amari = []
    for i in range(r-l+1):
        amari.append((l+i) % 2019)
    amari.sort()
    print((amari[0] * amari[1]) % 2019)

Submission status: Wrong Answer

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

m1 = 2018
m2 = 2017
for i in range(L, R + 1):
    a = i % 2019
    if a < m1:
        m1 = a
    elif a < m2:
        m2 = a

an = m1 * m2
print(an % 2019)

Submission status: Wrong Answer

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if L == R:
    ans = L * R %2019
if l >= r:
    r += 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        temp = (i * j) % 2019
        if bool:
            min = temp
            ans = min
            bool = False
        elif min > temp:
            min = temp
            ans = min
print(ans)

Submission status: Wrong Answer

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


def main():
    ans = 2018
    l, r = list(map(int, input().split()))
    for i in range(l, min(l+2019, r)):
        for j in range(i, min(l+2019, r)+1):
            ans = min(ans, i*j % 2019)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# Setup
import sys
sys.setrecursionlimit(4100000)

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

l = l%2019
r = r%2019
if l>r:
    r,l = l,r
temp = float('inf')
for i in range(l,r+1):
    for k in range(i+1,r+1):
        if i*k%2019 < temp:
            temp = (i*k)%2019
print(temp) if l!=r else print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

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

    print(ans)

Submission status: Wrong Answer

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

st = l % 2019

if r - l >= 5000:
    print(0)

else:
    amari = []
    for i in range(r-l+1):
        amari.append((l+i) % 2019)

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

Submission status: Wrong Answer

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

#Rが2019以上は弾き出す
L-=2019*(L//2019)
R-=2019*(L//2019)
if R>=2019:
  print(0)
  exit() #脱出

#全探索(2019の二乗以下につきいける)
M=2019
for i in range(L, R+1):
  for j in range(i+1, R+1):
    M=min(M, (i*j)%2019)

print(M)

Submission status: Wrong Answer

Solution code:
def main():
  min_max=0
  f_1=2+10**9
  f_2=2+10**9
  min_d=2019
  min_d2=2019
  L,R=map(int,input().split())
  for i in range(L,R+1):
    a=i%2019
    if a<=min_d and a<=min_d2:
      min_d2=min_d
      min_d=a
      f_2=f_1
      f_1=i
    elif a<=min_d2:
      f_2=i
      min_d2=a
    if a==0:
      break
  print((min_d*min_d2)%2019)
  
main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

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

l = l%2019
r = r%2019
if l>r:
    r,l = l,r
temp = float('inf')
for i in range(l,r+1):
    for k in range(i+1,r+1):
        if i*k%2019 < temp:
            temp = (i*k)%2019
print(temp)

Submission status: Wrong Answer

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if l == r:
    r+=2019
if l > r:
    r += 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        temp = (i * j) % 2019
        if bool:
            min = temp
            ans = min
            bool = False
        elif min > temp:
            min = temp
            ans = min
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

    print(ans)

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
from itertools import combinations

mod = 2019
l, r = L % mod, R % mod
if l > r:
    r += mod

mini = l*r % mod
for i, j in combinations(range(l, r+1), 2):
    mini = min(mini, i*j % mod)
    if mini == 0:
        break
print(mini)

Submission status: Wrong Answer

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


def main():
    ans = 2018
    l, r = list(map(int, input().split()))
    for i in range(l, min(l+2019, r)+1):
        for j in range(l, min(l+2019, r)+1):
            ans = min(ans, i*j % 2019)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
i = 2018
j = 2018
for k in range(10 ** 5):
    if R - L + 1 >= 2019:
        i = 0
        j = 0
        break
    if L <= 2019 * k:    
        i = min(i,abs(2019 * k - L),abs(2019 * (k-1) - L))  
print((i%2019)*((i+1)%2019))

Submission status: Wrong Answer

Solution code:
#入力
I, J = map(int, input().split())
#前処理
if J - I >= 2019:
  print(0)
mod_I = I % 2019
 
  
pool = []
for i in range(J-I):
  mod_I = mod_I + i
  for j in range(J-I-i):
    mod_J = mod_I + i + j + 1
    pool.append((mod_I *mod_J) % 2019)      
print(min(pool))

Submission status: Wrong Answer

Solution code:
L,R = map(int, input().split())
baisuc = 1
count = 0

if R < 2019:
    print(L * (L + 1) % 2019)
    exit(0)

while True:
    r = int(L / 2019) * 2019
    for i in range(r if r != 0 else 2019, R+1, 2019):
        print(i)
        if L <= i + count <= R:
            print(count + 1)
            exit(0)

    count += 1

Submission status: Wrong Answer

Solution code:
l, r = list(map(int,input().split()))
Set = set([l%2019])
for i in range(r-l):
	Set.add((l+1+i)%2019)
List = list(Set)
answer = (l * r) % 2019
k = 0
for i in range(len(List)):
	for j in range(len(List)):
		if(i < j):
			if(k == 0 or (i >= 44 and j >= 46)):
				if(answer > (List[i] * List[j])% 2019):
					answer = (List[i] * List[j])% 2019
					k = 1
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

low = 2*1e+200

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

if(l*(l+1)%2019<low and l!=0):
    low = l*(l+1)%2019
print(low)

Submission status: Wrong Answer

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

print(doit(l, r))

Submission status: Wrong Answer

Solution code:
L, R = map(int, input().split())
from itertools import combinations

mod = 2019
l, r = L % mod, R % mod
if l > r:
    l, r = r, l

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

res=[]

l=l%MOD
r=r%MOD
l,r=min(l,r),max(l,r)

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

print(min(res))

Submission status: Wrong Answer

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

if r//mod - l//mod >= 1:
  print(0)
  exit()
  
l = l%mod
r = r%mod

if r < l:
  print(0)
  exit()

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

low = 2*1e+200

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

if(l*(l+1)%2019<low):
    low = l*(l+1)%2019
print(low)

Submission status: Wrong Answer

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if l > r:
    r += 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        temp = (i * j) % 2019
        if bool:
            min = temp
            ans = min
            bool = False
        elif min > temp:
            min = temp
            ans = min
print(ans)

Submission status: Wrong Answer

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

i = L
j = -1
if M<R:
    i = 0
else:
    if l<r:
        i = l
    else:
        j = 0
if -1==j:
    j = i+1
else:
    i = j-1
print((i*j)%2019)

Submission status: Wrong Answer

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

l=l%2019
r=r%2019

if l>r:
    print(0)
    exit()

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

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

Submission status: Wrong Answer

Solution code:
L, R = list(map(int, input().split()))
a = []
for i in range(R-L+1):
    #print(L+i)
    a.append((L+i)%2019)
a.sort()
print(a[0]*a[1])

Submission status: Wrong Answer

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

low = 2*1e+200

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

if(l*(l+1)%2019<low):
    low = l*(l-1)
print(low)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
L,R=map(int,input().split())
mod=2019
ans=[]
if R-L>2017:
    print(0)
elif L%mod>R%mod:
    print(0)
else:
    if R//673!=L//673:
        ans.append((L*(L+1)%mod))
        ans.append((((R//673)*673)*((R//673)*673-1))%mod)
        if R%673!=0:
            ans.append((((R//673)*673)*((R//673)*673+1))%mod)
        print(min(ans))
    else:
        print(L*(L+1)%mod)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
l,r = map(int,input().split(" "))

if r-l > 2019:
    print(0)
else:
    l2r = [[e%2019,e] for e in list(range(l,r+1,1))]
    if r-l > 4:
        if min([e%673 for e in list(range(l,r+1,1))]) == 0:
            print(0)
        else:
            l2r.sort(key=itemgetter(0))
            print((l2r[0][1] * l2r[1][1])%2019)
    else:
        l2r.sort(key=itemgetter(0))
        print((l2r[0][1] * l2r[1][1])%2019)

Submission status: Wrong Answer

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

mod = 2019
ans = int(2*1e9+7)
for i in range(L,L+2019):
  ans = min(ans, i*(i+1)%mod)
for i in range(R, R-2020, -1):
  ans = min(ans, i*(i-1)%mod)
print(ans)

Submission status: Wrong Answer

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

if R - L >= 2019:
    print(0)
    exit()
ans = (L * (L + 1)) % MOD
for i in range(L, L + 5000):
    for j in range(L + 1, L + 5000):
        if (i > R) or (j > R):
            continue
        ans = min(ans, (i * j) % MOD)

print(ans)

Submission status: Wrong Answer

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

low = 2*1e+200

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

if(l*(l-1)%2019<low):
    low = l*(l-1)
print(low)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

l,r = [int(i) for i in input().split()]
a = []
l = l%2019
r = r%2019
temp = float('inf')
for i in range(l,r+1):
    for k in range(i+1,r+1):
        if i*k%2019 < temp:
            temp = i*k%2019
print(temp)

Submission status: Wrong Answer

Solution code:
import sys

l,r = list(map(int, input().split()))
imin = 0

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

Submission status: Wrong Answer

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
if l >= r:
    r += 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        temp = (i * j) % 2019
        if bool:
            min = temp
            ans = min
            bool = False
        elif min > temp:
            min = temp
            ans = min
print(ans)

Submission status: Wrong Answer

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

rule = True
res=[]

l=l%MOD
r=r%MOD
l,r=min(l,r),max(l,r)

if l == r:
  rule = False

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

if rule:
  print(min(res))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
# Setup
import sys
sys.setrecursionlimit(4100000)

l,r = [int(i) for i in input().split()]
a = []
l = l%2019
r = r%2019
temp = float('inf')
for i in range(l,r+1):
    for k in range(i+1,r+1):
        print(i,k)
        if i*k%2019 < temp:
            temp = i*k%2019
print(temp)

Submission status: Wrong Answer

Solution code:
l, r = map(int, input().split())
if r-l>=2019:
    print(0)
    exit()
l, r = l%2019, r%2019
mi = 9999
l_, r_ = l, r
if (l/3).is_integer() and (r/673).is_integer():
    l_, r_ = l//3, r//673
if (l/673).is_integer() and (r/3).is_integer():
    l_, r_ = l//673, r//3
    
if r*(r-1)<2019:
    print(l*(l+1))
else:
    for i in range(l_, r_):
        for j in range(i+1, r_+1):
            print(mi)
            mi = min(mi, (i*j)%2019)
    print(mi)

Submission status: Wrong Answer

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

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

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

if sw > 0:
  print(0)

elif sw == 0:      
  j = L % 2019
  k = (L + 1) % 2019
  print(j * k)

Submission status: Wrong Answer

Solution code:
L,R= map(int,input().split())
#境界条件
bool = True
l = L % 2019
r = R % 2019
r += 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        temp = (i * j) % 2019
        if bool:
            min = temp
            ans = min
            bool = False
        elif min > temp:
            min = temp
            ans = min
print(ans)

Submission status: Wrong Answer

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

minv = 1145141919810931
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        if (i * j) % 2019 == 0:
            break
        minv = min(minv, (i * j) % 2019)

print(minv)

Submission status: Wrong Answer

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

print(min(a))