Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
print(sum([n for n in range(1, int(inpt())) if (n%3!=0) and (n%5!=0)]))

Fixed submission:
n = int(input())

ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Buggy python submission (verdict: Runtime Error):
sum([n for n in range(1, int(inpt())) if (n%3!=0) and (n%5!=0)])

Fixed submission:
n = int(input())

ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
print(sum([n for n in range(1, N) if (n%3!=0) and (n%5!=0)]))

Fixed submission:
n = int(input())

ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
print(sum([n for n in range(1, N) if (n%3!=0) and (n%5!=0)]))

Fixed submission:
n = int(input())

ans = 0
for i in range(n+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(lambda x: int(x), input().split(" "))
if A=B and B=C:
  print("Yes")
else:
  print("No")

Fixed submission:
A, B, C = map(lambda x: int(x), input().split(" "))
if A is B and B is C:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = raw_input
ans = 0
for i in range(3):
    if s[i] == s[i+1]:
        ans = 1
if ans == 1:
    print "Bad"
else:
    print "Good"


Fixed submission:
S = raw_input()
arr = []

for i in range(4):
     if S[i] not in arr:
         arr.append(S[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if S[i] == arr[0]:
            a = a + 1
        elif S[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print"Yes"
    else:
        print "No"
Buggy python submission (verdict: Runtime Error):
H, W = map(int, raw_input().split())
h, w = map(int, raw_input().split())

sum = (H - h) * (W - w)
print sum
H, W = map(int, raw_input().split())
h, w = map(int, raw_input().split())

sum = (H - h) * (W - w)
print sum


Fixed submission:
H, W = map(int, raw_input().split())
h, w = map(int, raw_input().split())

sum = (H - h) * (W - w)
print sum
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
d = input()
if b - a < d and c - b < d:
    print "Yes"
else:
    print "No"


Fixed submission:
a, b, c, d = map(int,raw_input().split())
if abs(c-a) <= d or abs(a-b) <= d and abs(b-c) <= d:
    print "Yes"
else:
    print "No"
Buggy python submission (verdict: Runtime Error):
N, A = map(int, raw_input() .split())
print N * N - A


Fixed submission:
N = input()
A = input()
print N * N - A
Buggy python submission (verdict: Runtime Error):
a, b = map(int, raw_input() .split())
x = 0
y = 0
if a == 'H':
    x += 1
elif b == 'H':
    y += 1

if x == 1 and y == 1:
    print "H"
if x == 0 and y == 0:
    print "H"
if x == 1 and y == 0:
    print "D"
if x == 0 and y == 1:
    print "D"
    

Fixed submission:
a, b = map(str, raw_input() .split())
if a == 'H' and b == 'H':
    print "H"
elif a == 'H' and b == 'D':
    print "D"
elif a == "D" and b == "H":
    print "D"
else:
    print "H"
Buggy python submission (verdict: Runtime Error):
class atcorder:
    
    S=list(input())
    inv=list(reversed(S))
    i=0
    j=0
    if len(S)%2==0:
        pass
    else:
        if S==inv:
            i+=1
            N=int((len(S)-1)/2)
        for x in range(N-1):
            if S[x]==S[N-1-x] and inv[x]==inv[N-1-x]:
                pass
            else:
                j+=1
                
    if j==0 and i==1:
        print('yes')
    else:
        print('no')

Fixed submission:
class atcorder:
    
    S=list(input())
    inv=list(reversed(S))
    i=0
    j=0
    if S==inv:
        i+=1
        
    N=int((len(S)-1)/2)
    for x in range(N-1):
        if S[x]==S[N-1-x] and inv[x]==inv[N-1-x]:
            pass
        else:
            j+=1
                
    if j==0 and i==1:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
class atcorder:
    
    S=list(input())
    inv=list(reversed(S))
    i=0
    j=0
    if len(S)%2==0:
        pass
    else:
        if S==inv:
            i+=1
            N=int((len(S)-1)/2)
        for x in range(N-1):
            if S[x]==S[N-1-x] and inv[x]==inv[N-1-x]:
                pass
            else:
                j+=1
                
    if j==0 and i==1:
        print('yes')
    else:
        print('no')
            

Fixed submission:
class atcorder:
    
    S=list(input())
    inv=list(reversed(S))
    i=0
    j=0
    if S==inv:
        i+=1
        
    N=int((len(S)-1)/2)
    for x in range(N-1):
        if S[x]==S[N-1-x] and inv[x]==inv[N-1-x]:
            pass
        else:
            j+=1
                
    if j==0 and i==1:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K=map(int,input().split())
while(1):
    if K==0:
        break
    if A>0:
        if A<=K:
            K=K-A
            A=0
    else:
        if B>0 and B<=K:
            K=K-B
            B=0
        elif B>0 and B>=K:
            B=B-K
            K=0
        else:
            pass
print(A,B)

Fixed submission:
A,B,K=map(int,input().split())

if A>0:
    if A<=K:
        K=K-A
        A=0
    else:
        A=A-K
        K=0
if A<=0:
    if B>0 and B<=K:
        K=K-B
        B=0
    if B>0 and B>=K:
            B=B-K
            K=0
print(A,B)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N=int(input())
dic={}
ans=0
for i in range(N):
    s=list(input())
    s.sort()
    S=''.join(s)
    if S not in dic:
        dic[S]=1
    else:
        dic[S]+=1
for v in dic.values():
    if v>=2:
        ans+=int(comb(v,2))
print(ans)

Fixed submission:
N=int(input())
dic={}
ans=0
for i in range(N):
    s=list(input())
    s.sort()
    S=''.join(s)
    if S not in dic:
        dic[S]=1
    else:
        dic[S]+=1
for v in dic.values():
    if v>=2:
        ans+=v*(v-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N=int(input())
dic={}
ans=0
for i in range(N):
    s=list(input())
    s.sort()
    S=''.join(s)
    if S not in dic:
        dic[S]=1
    else:
        dic[S]+=1
for v in dic.values():
    if v>=2:
        ans+=int(comb(v,2))
print(dic)

Fixed submission:
N=int(input())
dic={}
ans=0
for i in range(N):
    s=list(input())
    s.sort()
    S=''.join(s)
    if S not in dic:
        dic[S]=1
    else:
        dic[S]+=1
for v in dic.values():
    if v>=2:
        ans+=v*(v-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
tmp=0    
for i in range(N):
    tmp=A[i]
    A[i]=0
    print(max(A))
    A[i]=tmp


Fixed submission:
N=int(input())
A=[int(input()) for i in range(N)] 
B=sorted(A)
for i in A:
    if i==B[-1]:
        print(B[-2])
    else:
        print(B[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            l = math.gcd(i,j)
            ans += math.gcd(l,k)
print(ans)


Fixed submission:
import math
K = int(input())
ans = 0
for i in range(1,K+1):
    ans -= i*2
    for j in range(i,K+1):
        l = math.gcd(i,j)
        ans -= l*3
        for k in range(j,K+1):
            ans += math.gcd(l,k)*6

for i in range(1,K+1):
    for j in range(i+1,K+1):
        ans -= math.gcd(i,j)*3

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [{0} for i in range(n)]

ans = [0] * n
a = 0
b = 0
sp = {i for i in range(n)}
for i in range(1,n):
    a,b = list(map(int,input().split()))
    ans[i] = min(sp-(s[a-1]|s[b-1]))

    s[a-1].add(ans[i])
    s[b-1].add(ans[i])

print(max(ans))
for i in range(1,n):
    print(ans[i])
    
    
   





Fixed submission:
S = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
s = input()
print(7 - S.index(s))

Buggy python submission (verdict: Runtime Error):
S = ["SUN","MON","TUE","WED","TUR","FRI","SAT"]
s = input()
print(7 - S.index(s))

Fixed submission:
S = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
s = input()
print(7 - S.index(s))
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a,a)

K = input()
K = int(K)
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(a,gcd(b,c))

print(ans)

Fixed submission:
def gcd(a,b):
    if a == 0:
        return b
    return gcd(b%a,a)

K = input()
K = int(K)
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd(a,gcd(b,c))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=list(input())
ans=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
  if s[i] =="R":
    s[i]=1
  elif s[i] =="G":
    s[i]=2
  elif s[i] =="B":
    s[i]=4
for i in range(n):
  for j in range(i+1,n):

    k=2*j-i
    if k>= n:
      continue
    if int(s[i])+int(s[j])+int(s[k])==7:
      ans -=1
print (ans)

Fixed submission:
n=int(input())
s=list(input())
ans=s.count('R')*s.count('G')*s.count('B')
for i in range(n):
  if s[i] =="R":
    s[i]=1
  elif s[i] =="G":
    s[i]=2
  elif s[i] =="B":
    s[i]=4
for i in range(n):
  for j in range(i+1,n):

    k=2*j-i
    if k>= n:
      continue
    if s[i]+s[j]+s[k]==7:
      ans -=1
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
N = 3
def common_divisor(num1,num2):
    max_n = max(num1,num2)
    min_n = min(num1,num2)
    temp = max_n%min_n
    while True:
        if temp:
            max_n = min_n
            min_n = temp
            temp = max_n%min_n
        else:
            return min_n

sum = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        temp = common_divisor(i,j)
        for m in range(1,K+1):
            sum = sum+common_divisor(m,temp)
print(sum)

Fixed submission:
import math
K = int(input())

sum = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        temp = math.gcd(i,j)
        for m in range(1,K+1):
            sum = sum+math.gcd(m,temp)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
N = 3
def common_divisor(num1,num2):
    if num1%num2==0:
        return num2
    elif num2%num1==0:
        return num1
    temp = max(num1,num2)%min(num1,num2)
    while True:
        if temp!=0:
            num1 = min(num1,num2)
            num2 = temp
            temp = num1%num2
        else:
            return num2

sum = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for m in range(1,K+1):
            sum = sum+common_divisor(common_divisor(i,j),m)

print(sum)

Fixed submission:
import math
K = int(input())

sum = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        temp = math.gcd(i,j)
        for m in range(1,K+1):
            sum = sum+math.gcd(m,temp)
print(sum)
Buggy python submission (verdict: Runtime Error):
if __name__=="__main__":
    l = list(input())
    N = len(l)
    if N==1:
        print(1)
        exit()
    results = []
    for i in range(0,N-1):
        if not l[i]==l[i+1]:
            results.append(max(i+1,N-i-1))
    print(min(results))

Fixed submission:
if __name__=="__main__":
    l = list(input())
    N = len(l)
    results = []
    for i in range(0,N-1):
        if not l[i]==l[i+1]:
            results.append(max(i+1,N-i-1))
    if len(results):
        print(min(results))
    else:
        print(N)

Buggy python submission (verdict: Runtime Error):
if __name__=="__main__":
    l = list(input())
    N = len(l)
    results = []
    for i in range(0,N-1):
        if not l[i]==l[i+1]:
            results.append(max(i+1,N-i-1))
    print(min(results))

Fixed submission:
if __name__=="__main__":
    l = list(input())
    N = len(l)
    results = []
    for i in range(0,N-1):
        if not l[i]==l[i+1]:
            results.append(max(i+1,N-i-1))
    if len(results):
        print(min(results))
    else:
        print(N)

Buggy python submission (verdict: Runtime Error):
if __name__=="__main__":
    l = list(input())
    N = len(l)
    pre = l[0]
    results = []
    for i in range(1,N):
        if not l[i]==pre:
            pre = l[i]
            results.append(max(i+1,N-i-1))
    print(min(results))

Fixed submission:
if __name__=="__main__":
    l = list(input())
    N = len(l)
    results = []
    for i in range(0,N-1):
        if not l[i]==l[i+1]:
            results.append(max(i+1,N-i-1))
    if len(results):
        print(min(results))
    else:
        print(N)
Buggy python submission (verdict: Runtime Error):
def main(S,target):
    dic_vector = [1,0]
    position = [0,0]
    x_path = abs(target[0])
    y_path = abs(target[1])
    if (S.count('F')-x_path-y_path)<0:
        print("No")
        exit()
    count = 0
    try:
        findPath(count,position,dic_vector)
    except Exception:
        print("No")


def findPath(index,position,dic_vector):
    if len(S) == index:
        if target == position:
            print("Yes")
            exit()
        return
    if S[index] == 'F':
        position = [position[0]+dic_vector[0],position[1]+dic_vector[1]]
        findPath(index+1,position,dic_vector)
    else:
        if dic_vector[0]:
            dic_vector = [0,1]
            findPath(index+1,position,dic_vector)
            dic_vector = [0,-1]
            findPath(index+1,position,dic_vector)
        else:
            dic_vector = [1,0]
            findPath(index+1,position,dic_vector)
            dic_vector = [-1,0]
            findPath(index+1,position,dic_vector)


if __name__=="__main__":
    S = list(input())
    target = list(map(int,input().split(" ")))
    main(S,target)

Fixed submission:
if __name__=="__main__":
    a = list(map(int,input().split(" ")))
    b = (a[0]+a[1])/2
    if b%1:
        print(int(b)+1)
    else:
        print(int(b))

Buggy python submission (verdict: Runtime Error):
import string
if __name__=="__main__":
    s = list(input())
    t = list(input())
    flag = False
    if s is t:
        print("No")
        exit()
    dic = string.ascii_lowercase
    c = 0
    for j in range(len(s)):
        if s[j] in t:
            c+=1
    if c==len(s) and c<len(t):
        print("Yes")
        exit()
    for i in range(len(dic)):
        if s.__contains__(dic[i]) and t.__contains__(dic[i]):
            flag = True
        if flag and s.__contains__(dic[i]) and not t.__contains__(dic[i]):
            for j in range(i+1,len(dic)):
                if t.__contains__(dic[j]):
                    print("Yes")
                    exit()
    print("No")


Fixed submission:
if __name__=="__main__":
    a = list(map(int,input().split(" ")))
    b = (a[0]+a[1])/2
    if b%1:
        print(int(b)+1)
    else:
        print(int(b))

Buggy python submission (verdict: Runtime Error):
import math
if __name__=="__main__":
    a = list(map(int,input()))
    b = (a[0]+a[1])/2
    if b-a[0]>a[1]-b:
        print(math.floor(b))
    else:
        print(math.floor(b)+1)

Fixed submission:
if __name__=="__main__":
    a = list(map(int,input().split(" ")))
    b = (a[0]+a[1])/2
    if b%1:
        print(int(b)+1)
    else:
        print(int(b))
Buggy python submission (verdict: Runtime Error):
if __name__=="__main__":
        l1 = list(map(int,input().split(" ")))
        l2 = list(map(int,input().split(" ")))
        l = {i:0 for i in range(200001)}
        N = l1[0]
        K = l1[1]
        for i in range(N):
            l[l2[i]]+=1
        dict = sorted(l.values())
        condition = lambda t:t!=0
        fliter_dict = list(filter(condition,dict))
        if len(fliter_dict)<=K:
            print(0)
        else:
            print(sum(fliter_dict[0:(len(fliter_dict)-K)]))

Fixed submission:
if __name__=="__main__":
    n = list(map(int,input()))
    print(n.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
if __name__=="__main__":
    count = 0
    idx = int(input())
    n = list(map(int,input().split(" ")))
    while True:
        for i in range(idx):
            if n[i]%2==1:
                print(count)
                break
        count+=1

Fixed submission:
if __name__=="__main__":
    count = 0
    idx = int(input())
    n = list(map(int,input().split(" ")))
    while True:
        for i in range(idx):
            if n[i]|1==n[i]:
                print(count)
                exit()
            else:
                n[i]=n[i]>>1
        count+=1

Buggy python submission (verdict: Time Limit Exceeded):
if __name__=="__main__":
    count = 0
    idx = int(input())
    n = list(map(int,input().split(" ")))
    while True:
        for i in range(idx):
            if n[i]|1 ==n[i]:
                print(count)
                exit()
        count+=1

Fixed submission:
if __name__=="__main__":
    count = 0
    idx = int(input())
    n = list(map(int,input().split(" ")))
    while True:
        for i in range(idx):
            if n[i]|1==n[i]:
                print(count)
                exit()
            else:
                n[i]=n[i]>>1
        count+=1
Buggy python submission (verdict: Runtime Error):
def main():
    rt = 0
    Q,H,S,D = map(int,input())
    N = float(input())
    count_1 = N//2
    count_2 = (N-count_1)//1
    count_3 = (N-count_1-count_2)*100//50
    count_4 = (((N-count_1-count_2)*100)-50*count_3)//25
    if count_1:
       rt+=count_1*min(2*S,D,4*H,8*Q)
    if count_2:
        rt+=count_2*min(S,2*H,4*Q)
    if count_3:
        rt+=min(2*H,Q)*count_3
    if count_4:
        rt+=Q*count_4
    print(rt)

if __name__=="__main__":
    main()

Fixed submission:
def main():
    rt = 0
    Q,H,S,D = map(int,input().split(" "))
    N = float(input())
    count_1 = N//2
    count_2 = (N-count_1*2)//1
    count_3 = (N-count_1*2-count_2)*100//50
    count_4 = (((N-count_1*2-count_2)*100)-50*count_3)//25
    if count_1:
        rt+=int(count_1)*min(2*S,D,4*H,8*Q)
    if count_2:
        rt+=int(count_2)*min(S,2*H,4*Q)
    if count_3:
        rt+=min(H,2*Q)*int(count_3)
    if count_4:
        rt+=Q*int(count_4)
    print(int(rt))

if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
     count = 1
     s = list(input())
     for i in range(1,len(s)):
         for j in range(0,len(s)-i):
             flag = check(s[j:j+i+1])
             if not flag:
                 count+=1
     print(count)

def check(s):
    i = 0
    while i <(len(s)>>1):
        if s[i]!=s[-i-1]:
            return False
        return True

if __name__=="__main__":
    main()

Fixed submission:
def main():
     s = list(input())
     count = int((len(s)*(len(s)-1))/2+1)
     dic = {}
     for i in range(len(s)):
         try:
             dic[s[i]].append(i)
         except Exception:
             dic[s[i]] = [i]

     for j in dic.values():
         count-=int((len(j)*(len(j)-1))/2)
     print(count)


if __name__=="__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
     s = list(input())
     results=[s]
     for i in range(1,len(s)):
         for j in range(0,len(s)-i):
             temp = s.copy()
             temp[j:j+i+1] = reversed(temp[j:j+i+1])
             if temp not in results:
                 results.append(temp)
     print(len(results))

if __name__=="__main__":
    main()

Fixed submission:
def main():
     s = list(input())
     count = int((len(s)*(len(s)-1))/2+1)
     dic = {}
     for i in range(len(s)):
         try:
             dic[s[i]].append(i)
         except Exception:
             dic[s[i]] = [i]

     for j in dic.values():
         count-=int((len(j)*(len(j)-1))/2)
     print(count)


if __name__=="__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from os import path
import sys
if(path.exists('C:/Users/prana/Desktop/sublime/input.txt')):
    sys.stdin = open("C:/Users/prana/Desktop/sublime/input.txt","r")
    sys.stdout = open("C:/Users/prana/Desktop/sublime/output.txt","w")

import math
def solve():
    ans = 0
    a = int(input()) 
    for i in range(a):
        for j in range(a):
            for k in range(a):
                ans += math.gcd(k+1,math.gcd(i+1,j+1))
    print(ans)

test_case = 1
while(test_case):
    solve()
    test_case -= 1

Fixed submission:
from os import path
if(path.exists('C:/Users/prana/Desktop/sublime/input.txt')):
    import sys
    sys.stdin = open("C:/Users/prana/Desktop/sublime/input.txt","r")
    sys.stdout = open("C:/Users/prana/Desktop/sublime/output.txt","w")

from math import gcd
def solve():
    ans = 0
    a = int(input()) 
    for i in range(a):
        for j in range(a):
            for k in range(a):
                ans += gcd(k+1,gcd(i+1,j+1))
    print(ans)

test_case = 1
while(test_case):
    solve()
    test_case -= 1
Buggy python submission (verdict: Time Limit Exceeded):
import math

def nyu():
    N,K= map(int,(input().split()))
    return K,N


def check(K,N ):
    min = 0
    abs_num = 0

    OLD_ABS =N
    NEW_ABS = abs(K-N)

    while NEW_ABS < OLD_ABS:
        OLD_ABS = N #OK
        N = NEW_ABS ##OK
        NEW_ABS =abs(K-N)
    #    print("N_NEW",NEW_ABS,"OLS_ABS",OLD_ABS,"N",N)
    print(N)

    

     
            
K,N = nyu()
check(K,N)
#print(S)



Fixed submission:
import math

def nyu():
    N,K= map(int,(input().split()))
    return K,N


def check(K,N ):
    min = 0
    abs_num = 0

    N = N%K

    OLD_ABS =N
    NEW_ABS = abs(K-N)

    while NEW_ABS < OLD_ABS:
        OLD_ABS = N #OK
        N = NEW_ABS ##OK
        NEW_ABS =abs(K-N)
    #    print("N_NEW",NEW_ABS,"OLS_ABS",OLD_ABS,"N",N)
    print(N)     
            
K,N = nyu()
check(K,N)
#print(S)
Buggy python submission (verdict: Time Limit Exceeded):
def nyu():
    L,R = map(int,input().split())
    return L,R


def convert(LL,LR):
    LL = LL % 2019
    LR = LR % 2019

    return LL,LR

def kansu(LL,LR):

    ans = 2020

    for ll in range(LL,LR):
        for lr in range(ll+1,LR+1):
    #        print(lr)
            tmp  = (ll * lr) % 2019
            if ans > tmp:
                ans = tmp

    print(ans)

ML,MR = nyu()
#ML,MR = convert(ML,MR)
kansu(ML,MR)


Fixed submission:
def nyu():
    L,R = map(int,input().split())
    return L,R


# def convert(LL,LR):
#     LL = LL % 2019
#     LR = LR % 2019

#     return LL,LR

def kansu(LL,LR):

    ans = 2020
    flg = False

    for ll in range(LL,LR):
        for lr in range(ll+1,LR+1):
            tmp  = (ll * lr) % 2019
            if ans > tmp:
                ans = tmp
                if ans == 0:
                    flg =True
                    break
        if flg == True:
            break

    print(ans)

ML,MR = nyu()
#ML,MR = convert(ML,MR)
kansu(ML,MR)