Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) 

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007


#n = int(input())


#a = [int(x) for x in input().split()]
l, r = map(int, input().split())
#print("sp", n, k, file=sys.stderr)

#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]


#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)


#s = input()


#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))



import re
import fractions

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)
  
def count(c):
  r = b // c - (a - 1) // c;
  print(c, r, file=sys.stderr)
  return r

print(l, r, file=sys.stderr)
l = l % 2019
#r = r % 2019
#if r < l:
#  r += 2019
#  if r < l:
#    r = r2
print(l, r, file=sys.stderr)

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




try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)


# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) 

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007


#n = int(input())


#a = [int(x) for x in input().split()]
l, r = map(int, input().split())
#print("sp", n, k, file=sys.stderr)

#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]


#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)


#s = input()


#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))



import re
import fractions

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)
  
def count(c):
  r = b // c - (a - 1) // c;
  print(c, r, file=sys.stderr)
  return r

def doit(l, r):
  #print(l, r, file=sys.stderr)
  l = l % 2019
  r = r % 2019
#  if r <= l:
  r += 2019
  #  if r < l:
  #    r = r2
  #print(l, r, file=sys.stderr)

  res = 2019
  for x in range(l, r):
    for y in range(l + 1, r + 1):
      #print(x, y, file=sys.stderr)
      res = min(res, (x * y) % 2019)
      if res == 0:
        return 0
  return res % 2019




try:
  print(doit(l, r))
except Exception as e:
  print("e", e, file=sys.stderr)


# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) 

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007


#n = int(input())


#a = [int(x) for x in input().split()]
l, r = map(int, input().split())
#print("sp", n, k, file=sys.stderr)

#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]


#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)


#s = input()


#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))



import re
import fractions

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)
  
def count(c):
  r = b // c - (a - 1) // c;
  print(c, r, file=sys.stderr)
  return r

print(l, r, file=sys.stderr)
l = l % 2019
r2 = r % 2019
if r2 < l:
  r2 += 2019
  if r2 < r:
    r = r2
print(l, r, file=sys.stderr)

def doit():
  res = 2019
  for x in range(l, r):
    for y in range(l + 1, r + 1):
      #print(x, y, file=sys.stderr)
      res = min(res, (x * y) % 2019)
  return res % 2019




try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)


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


l, r = map(int, input().split())
def doit(l, r):
  if r - l > 2019:
    return 0
  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))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted