Harryxun/stf_run huggingface dataset:
import collections
def main():
    N, M = map(int, input().split())
    bridges = []
    for _ in range(M):
        a, b = map(int, input().split())
        bridges.append([a-1, b-1])
    bridges = bridges[::-1]
    parent = [i for i in range(N)]
    count = dict()
    for i in range(N): count[i] = 1

    def find(i):
        if parent[i] != i:
            parent[i] = find(parent[i])
        return parent[i]

    def union(i, j):
        pi, pj = find(i), find(j)
        df = 0
        if pi != pj:
            parent[pj] = pi
            df += count[pi] * count[pj]
            count[pi] += count[pj]
            del count[pj]
        return df

    ans = [N*(N-1)//2]
    for a, b in bridges[:-1]:
        d = union(a, b)
        ans.append(ans[-1] - d)
    return ans[::-1]

if __name__ == '__main__':
    output = main()
    for v in output:
        print(v)

### FIXED CODE ###

import collections
def main():
    N, M = map(int, input().split())
    bridges = []
    for _ in range(M):
        a, b = map(int, input().split())
        bridges.append([a, b])
    bridges = bridges[::-1]
    parent = [i for i in range(N+1)]
    count = dict()
    for i in range(N+1): count[i] = 1

    def find(i):
        if parent[i] != i:
            parent[i] = find(parent[i])
        return parent[i]

    def union(i, j):
        pi, pj = find(i), find(j)
        df = 0
        if pi != pj:
            if count[pi] > count[pj]:
                parent[pj] = pi
                df += count[pi] * count[pj]
                count[pi] += count[pj]
                del count[pj]
            else:
                parent[pi] = pj
                df += count[pi] * count[pj]
                count[pj] += count[pi]
                del count[pi]                
        return df

    ans = [N*(N-1)//2]
    for a, b in bridges[:-1]:
        d = union(a, b)
        ans.append(ans[-1]-d)
    return ans[::-1]

if __name__ == '__main__':
    output = main()
    for v in output:
        print(v)
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
print(str(c11) + str(c22) + str(c33))

### FIXED CODE ###

c1 = input()
c2 = input()
c3 = input()
print(c1[0] + c2[1] + c3[2])
N, K = map(int, input().split())
D = list(map(int, input().split()))
shiharai=N
l = [int(x) for x in list(str(N))]
c=len(l)
for i in range(len(l)):
    while l[i] in D:
        shiharai+=1
        l = [int(x) for x in list(str(shiharai))]
if len(l)!=c:
    for i in range(len(l)):
        while l[i] in D:
            shiharai+=1
            l = [int(x) for x in list(str(shiharai))]
print(shiharai)

### FIXED CODE ###

A, B, C= map(int, input().split())
if (A!=5 and A!=7) or (B!=5 and B!=7) or (C!=5 and C!=7):
    print("NO")
elif A==5:
    if (B==5 and C==7) or (B==7 and C==5):
        print ("YES")
    else:
        print("NO")
elif (B==5 and C==5):
    print("YES")
else:
    print("NO")
a,b=input().split()
if a>=13:
  print(b)
elif 6<=a<=12 :
  print(b/2)
else :
  print(0)

### FIXED CODE ###

i=list(map(int,input().split()))
if i[0]>=13:
  print(i[1])
elif 6<=i[0]<=12:
  print(int(i[1]/2))
else :
  print(0)
while True:
    s = input()
    if s == "":
        break
    joi = 0
    ioi = 0
    s_list = [s[i:i+3] for i in range(len(s) - 2)]
    for i in s_list:
        if i == "JOI":
            joi += 1
        if i == "IOI":
            ioi += 1
    print(joi)
    print(ioi)

### FIXED CODE ###

while True:
    try:
        s = input()
    except:
        break
    joi = 0
    ioi = 0
    for i in range(len(s) - 2):
        x = s[i] + s[i + 1] + s[i + 2]
        if x == "JOI":
            joi += 1
        if x == "IOI":
            ioi += 1
    print(joi)
    print(ioi)
import numpy as np

b = list(map(int, input().split()))
def task(b):
    return abs(b[1] - b[0]) + abs(b[2] - b[1])
a = np.array(a)
p = np.array([[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]) - 1
Min = np.inf
for i in range(6):
    Min = min(Min, task(a[p[i,:]]))
print(Min)


### FIXED CODE ###

import numpy as np

a = list(map(int, input().split()))
def task(b):
    return abs(b[1] - b[0]) + abs(b[2] - b[1])
a = np.array(a)
p = np.array([[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]) - 1
Min = np.inf
for i in range(6):
    Min = min(Min, task(a[p[i,:]]))
print(Min)
while True:
    a = map(str, raw_input().split())
    if a[0] != 0:
        print sorted(a)
    else: break

### FIXED CODE ###

while 1:
    a, b = sorted(map(int, raw_input().split()))
    if a + b == 0:
        break
    else:
        print a, b
n=int(input())

a=n//10
if a==3:
 print("bon")
elif a==0 or a==6 or a==8 or a==1
 print("pon")
else
 print("hon")

### FIXED CODE ###

n=int(input())
 
a=n%10
if a==3:
 print("bon")
elif a==0 or a==6 or a==8 or a==1:
 print("pon")
else:
 print("hon")
N = int(input())
p_list = list(map(float, input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for j in range(N+1):
        dp[i][j] += dp[i-1][j] * (1-p_list[i-1])
        if j > 0:
            dp[i][j] += dp[i-1][j-1] * p_list[i-1]
            
start = N//2 + 1
for p in dp[N][start:]:
    ans += p
print(ans)

### FIXED CODE ###

N = int(input())
p = list(map(float, input().split()))

dp = [[0.] * (N+1) for _ in range(N+1)]
dp[0][0] = 1.

for i in range(1, N+1):
    for j in range(i+1):
        prob = dp[i-1][j-1]*p[i-1]
        if i > 0:
            prob += dp[i-1][j]*(1.-p[i-1])
        dp[i][j] = max(dp[i][j], prob)
print(sum(dp[-1][N//2+1:]))
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
minus = []
for i in range(N):
  if A[i] < 0:
    minus.append(A[i])
abs_A = (abs(i) for i in A)
if len(minus) % 2 == 0:
  print(sum(abs_A))
else:
  print(sum(abs_A)-min(abs_A)*2)

### FIXED CODE ###

from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
minus = []
for i in range(N):
  if A[i] < 0:
    minus.append(A[i])
abs_A = [abs(i) for i in A]
if len(minus) % 2 == 0:
  print(sum(abs_A))
else:
  print(sum(abs_A)-min(abs_A)*2)
s=input()
i=0
j=len(s)-1
ans=0
while i!=j:

    while s[i]=="x":
        i+=1
        ans+=1
    if i==j:
        break
    while s[j]=="x":
        j-=1
        ans+=1
    if s[i]!=s[j]:
        ans=-1
        break
    if i==j:
        break
    i+=1
    j-=1
print(ans)

### FIXED CODE ###

s=input()
i=0
j=len(s)-1
ans=0
while i<j:
    while s[i]==s[j]=="x":
        i+=1
        j-=1
        if i>j:break
    if i>j:break    
    while s[i]=="x":
        i+=1
        ans+=1
        if i>j:break
    if i>j:break
    while s[j]=="x":
        j-=1
        ans+=1
        if i>j:break
    if i>j:break
    if s[i]!=s[j]:
        ans=-1
        break
    i+=1
    j-=1
    if i>j:break
print(ans)
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if n >= m:
    print(0)
    exit()

cost = []
for i in range(m-1):
    cost.append(x[i] - x[i+1])

l = sorted(cost)
ind = [0]
for i in range(n-1):
    ind.append(cost.index(l[i]) + 1)
ind.append(m)
ind.sort()

X = []
for i in range(n):
    X.append(x[ind[i]:ind[i+1]])

ans = 0
for i in X:
    ans += i[-1] - i[0]
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if n >= m:
    print(0)
    exit()

cost = []
for i in range(m-1):
    cost.append(x[i+1] - x[i])

cost.sort()
ans = 0
for i in range(m-n):
    ans += cost[i]
print(ans)
s = input()
n = len(s)
x, y = map(int, input().split())
dx = []
dy = []
xy = 0
cnt =0
for i in s:
    if i == 'F':
        cnt += 1
    else:
        xy += 1
        xy %= 2
        if xy:
            dx.append(cnt)
        else:
            dy.append(cnt)
        cnt = 0
if cnt != 0:
    if xy:
        dy.append(cnt)
    else:
        dx.append(cnt)
sum_x = sum(dx) + 2
sum_y = sum(dy) + 2
dpx = [[0] * sum_x for i in range(len(dx))]
dpy = [[0] * sum_y for i in range(len(dy))]

if dx:
    dpx[0][dx[0]] = True
if dy:
    dpy[0][dy[0]] = True
    dpy[0][-dy[0]] = True
for i in range(1, len(dx)):
    for j in range(0, sum_x):
        dpx[i][j] = dpx[i-1][j-dx[i]] or dpx[i-1][(j+dx[i])%sum_x]
for i in range(1, len(dy)):
    for j in range(0, sum_y):
        dpy[i][j] = dpy[i-1][j-dy[i]] or dpy[i-1][(j+dy[i])%sum_y]
print('Yes' if dpx[-1][x] and dpy[-1][y] else 'No')



### FIXED CODE ###

s = input() + 'T'
n = len(s)
x, y = map(int, input().split())
X = [[], [0]]
xy = 0
cnt =0
for i in s:
    if i == 'F':
        cnt += 1
    else:
        X[xy].append(cnt)
        xy = 1 - xy
        cnt = 0

def f(l):
    if len(l) == 0:
        return [0]
    post = [l[0]]
    for i in range(1, len(l)):
        if l[i]:
            pre = sorted(post)
            post = []
            for j in range(len(pre)):
                if j == 0 or pre[j] != pre[j-1]:
                    post.append(pre[j]+l[i])
                    post.append(pre[j]-l[i])
    return post

print('Yes' if x in f(X[0]) and y in f(X[1]) else 'No')
a,b,c = map(int,input().split())
coutn5 = [x for x in [a,b,c] if x==5]
coutn7 = [x for x in [a,b,c] if x==7]

if len(count5)==2 and len(count7)==1:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

a,b,c = map(int,input().split())

count5 = len([x for x in [a,b,c] if x==5])
count7 = len([x for x in [a,b,c] if x==7])

if count5==2 and count7==1:
  print('YES')
else:
  print('NO')
K = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[K])

### FIXED CODE ###

K = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[K-1])
n,k = map(int,input().split)
 
s = input().rstrip().split(' ')
st = []
 
for i in range(0,n):
  a = int(s[i]) 
  st.append(a)

new_st = sorted(st)
sum = 0
for j in range(0,k):
  sum += new_st[j]
  
print(sum)
    

### FIXED CODE ###

n,k = map(int,input().split())
 
s = input().rstrip().split(' ')
st = []
 
for i in range(0,n):
  a = int(s[i]) 
  st.append(a)
 
new_st = sorted(st)
sum = 0
for j in range(0,k):
  sum += new_st[j]
  
print(sum)
# -*- coding: utf-8 -*-
import sys

A, B = map(int, input().split())

C = A + B

if A%3 == 0:
    print('Possible')
else if B%3 == 0:
    print('Possible')
else if C%3 == 0:
    print('Possible')
else:
    print('Impossible')

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

A, B = map(int, input().split())

C = A + B

if A%3 == 0:
    print('Possible')
elif B%3 == 0:
    print('Possible')
elif C%3 == 0:
    print('Possible')
else:
    print('Impossible')
N,K = map(int,input().split())
R,S,P  =  map(int,input().split())
S = input()
ans = 0
for i in range(K):
    if S[i] == “r”:
        ans += P
    elif S[i] == “s”:
        ans += R
    else:
        ans += S
T = []
for i in range(K,N):
    if S[i] ==“r”:
        if S[i-K] == “r”:
            if i in T:
                ans += P
            else:
                T.append(i)
        else:
             ans += P
    elif S[i] == “s”:
        if S[i-K] == “s”:
            if i in T:
                ans += R
            else:
                T.append(i)
        else:
             ans += R
       else:
            if S[i-K] == “p”:
                if i in T:
                    ans += S
                else:
                    T.append(i)
            else:
                ans +=S
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
R,S,P  =  map(int,input().split())
t = input()
s = []
for i in range(N):
    s.append(t[i])
ans = 0
for i in range(K):
    if s[i] == 'r':
        ans += P
        s[i] = 'a'
    elif s[i] == 's':
        ans += R
        s[i] = 'b'
    else:
        ans += S
        s[i] = 'c'
T = []
for i in range(K,N):
    if s[i] == 'r':
        if s[i-K] != 'a':
            ans += P
            s[i] = 'a'
    elif s[i] == 's':
        if s[i-K] != 'b':
            ans += R
            s[i] = 'b'
    else:
        if s[i-K] != 'c':
            ans += S
            s[i] = 'c'
print(ans)
n=int(input())
x=[int(i) for i in input().split()]
a=[]
p=0
for i in range(1,max(x)):
  for j in range(n):
    p+=(x[j]-i)**2
  a.append(p)
  p=0
print(min(a))

### FIXED CODE ###

n=int(input())
x=[int(i) for i in input().split()]
a=[]
p=0
for i in range(1,max(x)+1):
  for j in range(n):
    p+=(x[j]-i)**2
  a.append(p)
  p=0
print(min(a))
printf((3A + P)/2)

### FIXED CODE ###

a, p = map(int, input().split())
c = int((3*a+p) / 2)
print("{}".format(c))
n=int(input())
for i in range(7):
  print(i) if 2**i <= n < 2++(i+1)

### FIXED CODE ###

n=int(input())
for i in range(7):
  if 2**i<=n<2**(i+1):
    print(2**i)
n,k=map(int,input().split())
h=list(map(int,input().split()))
cnt=0
for i in h:
  if h<k:
    cnt+=1
    
print(cnt)

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
cnt=0
for i in h:
  if i>=k:
    cnt+=1
    
print(cnt)
def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    ans = 0
    i = 0
    j = 0
    T.sort()
    if len(T) == 1:
        ans = 1
        return(ans)

    while True:
        if T[j] + K >= T[i+1]:
            i = i + 1
            if i == N-1:
                ans += 1
                return (ans)
            for h in range(C-2):
                if T[j] + K >= T[i+1]:
                    if h == C-3:
                        ans += 1
                        i += 2
                        j = i
                        if j >= N-1:
                            return(ans)
                        break
                    else:
                        i += 1
                        if (i+1) == N-1:
                            ans += 1
                            return(ans)  
                        continue
                elif T[j] + K < T[i + 1]:
                    j = i + 1
                    i = i + 1
                    ans += 1
                    if j == N-1:
                        ans += 1
                        return(ans)
                    break

        elif T[j] + K < T[i+1]:
            ans += 1
            i += 1
            j = i
            if j == N-1:
                ans += 1
                return(ans)

print(main())


### FIXED CODE ###

def main():
    N, C, K = map(int, input().split())
    T = list(int(input()) for _ in range(N))

    T.sort()

    ans = 0
    temp = T[0]
    cnt = 1

    for i in range(1,N):
        if temp + K < T[i] or C == cnt:
            ans += 1
            temp = T[i]
            cnt = 1
        else:
            cnt += 1

    ans += 1
    return (ans)

print(main())
import math
num = int(input().replace(" ",""))
// 平方根にしたものを二倍して一致するかどうかで確認が可能
print("Yes" if num == round(math.sqrt(num)) ** 2 else "No")

### FIXED CODE ###

import math
num = int(input().replace(" ",""))
# nの平方根を二乗して一致するなら平方根
print("Yes" if num == round(math.sqrt(num)) ** 2 else "No")
A=input() 
B=input() 
C=input() 

i=0
j=0
k=0
c=0

while(True):
    if(c==0):
        if(i>=(len(A)+1)):
            print("A")
            exit()
        if(A[i]=="a"):
            i+=1
            c=0
        elif(A[i]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2

    elif(c==1):
        if(j>=(len(B)+1)):
            print("B")
            exit()
        if(B[j]=="a"):
            i+=1
            c=0
        elif(B[j]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2
    else:
        if(k>=(len(C)+1)):
            print("C")
            exit()
        if(C[k]=="a"):
            i+=1
            c=0
        elif(C[k]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2


    



### FIXED CODE ###

A=input() 
B=input() 
C=input() 

i=0
j=-1
k=-1
c=0

while(True):
    if(c==0):
        if(i>=(len(A))):
            print("A")
            exit()
        if(A[i]=="a"):
            i+=1
            c=0
        elif(A[i]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2

    elif(c==1):
        if(j>=(len(B))):
            print("B")
            exit()
        if(B[j]=="a"):
            i+=1
            c=0
        elif(B[j]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2
    else:
        if(k>=(len(C))):
            print("C")
            exit()
        if(C[k]=="a"):
            i+=1
            c=0
        elif(C[k]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2
n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>1000000000000000000:
            s=-1
            break
            
     print(s)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
if min(l)== 0:
    print(0)
else:    
    s=1
    for x in l:
        s *= x
        if s>10**18:
            s=-1
            break
    print(s)
List=[int(i) for i in input().split()]
if List.count(5) == 2 and List.cout(7) == 1:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

List=[int(i) for i in input().split()]
if List.count(5) == 2 and List.count(7) == 1:
  print("YES")
else:
  print("NO")
def search(n):
    res = 0
    while n:
        n %= bin(n).count("1")
        res += 1
    return res


def main():
    n = int(input())
    x = list(map(int, list(input())))
    first_mod = x_decimal = 0
    diff = pow(2, n - 1)
    for i in range(n):
        if x[i]:
            first_mod += 1
            x_decimal += diff
        diff //= 2
    increase_base = x_decimal % (first_mod + 1)  # 反転させる桁が元々0だった場合
    decrease_base = x_decimal % (first_mod - 1)  # 反転させる桁が元々1だった場合
    diff = pow(2, n - 1)
    for i in range(n):
        cnt = 0
        if x[i] == 1 and first_mod > 1:
            cnt = 1 + search((decrease_base - diff % (first_mod - 1)) % (first_mod - 1))
        elif x[i] == 0:
            cnt = 1 + search((increase_base + diff % (first_mod + 1)) % (first_mod + 1))
        diff //= 2
        print(cnt)


if __name__ == '__main__':
    main()



### FIXED CODE ###

def search(n):
    res = 0
    while n:
        n %= bin(n).count("1")
        res += 1
    return res


def main():
    n = int(input())
    x = list(input())
    x_decimal = int("".join(map(str, x)), 2)
    first_mod = sum(map(int, list(x)))
    increase_mod = first_mod + 1
    increase_base = x_decimal % increase_mod  # 反転させる桁が元々0だった場合
    decrease_mod = first_mod - 1
    if decrease_mod:
        decrease_base = x_decimal % decrease_mod  # 反転させる桁が元々1だった場合
    for i in range(n):
        cnt = 0
        if x[i] == "1" and decrease_mod:
            cnt = 1 + search((decrease_base - pow(2, n - i - 1, decrease_mod)) % decrease_mod)
        elif x[i] == "0":
            cnt = 1 + search((increase_base + pow(2, n - i - 1, increase_mod)) % increase_mod)
        print(cnt)


if __name__ == '__main__':
    main()
R = int(input())
G = int(input())

print(2G-R)



### FIXED CODE ###

R = int(input())
G = int(input())

print(2*G-R)
import copy

n = int(input())
A = list(map(int, input().split()))
B = copy.deepcopy(A)
results = [''] * n
maxvalue = max(A)
maxvalue2 = max(A)
targetValue = ''
while maxvalue > 0:
    mod = 0
    maxvalue = maxvalue >> 1
    for idx, a in enumerate(A):
        mod += a % 2
        A[idx] = a >> 1
    targetValue = str(mod % 2) + targetValue
for i in range(n):
    maxvalue2 = max(B)
    tmpValue = int(targetValue, 2)
    while maxvalue2 > 0:
        results[i] = str((tmpValue % 2 + B[i] % 2) % 2) + results[i]
        tmpValue = tmpValue >> 1
        B[i] = B[i] >> 1
        maxvalue2 = maxvalue2 >> 1
answers = [''] * n
for idx, res in enumerate(results):
    answers[idx] = str(int(res, 2))
print(" ".join(answers))


### FIXED CODE ###

import copy

n = int(input())
A = list(map(int, input().split()))

target = 0
for i in range(n):
    target ^= A[i]

results = [''] * n

for i in range(n):
    results[i] = str(target ^ A[i])

print(" ".join(results))
import sys
sys.setrecursionlimit(10000)

def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)

    n = int(input())
    tree = [[] for _ in range(n + 1)]
    depth = [0] * (n * 2)
    for _ in range(1, n):
        a, b, c = map(int, input().split())
        tree[a].append((b, c))
        tree[b].append((a, c))

    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])


ans()

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
 
def ans():
    def dfs(v, p, d):
        depth[v] = d
        for e, cost in tree[v]:
            if e == p:
                continue
            dfs(e, v, d + cost)
 
    n = int(input())
    tree = [[] for _ in range(n + 1)]
    depth = [0] * (n * 2)
    for _ in range(1, n):
        a, b, c = map(int, input().split())
        tree[a].append((b, c))
        tree[b].append((a, c))
 
    q, k = map(int, input().split())
    dfs(k, -1, 0)
    for _ in range(q):
        x, y = map(int, input().split())
        print(depth[x] + depth[y])
 
 
ans()
nput()
B=input()
C=input()
D=input()
a=int(A)
b=int(B)
c=int(C)
d=int(D)

max=0
min=0

if a < c :
    max=c
else :
    max=a
    
if b > d :
    min=d
else :
    min=b
if ( min - max ) > 0 :
    print( min - max )
else :
    print(0)



### FIXED CODE ###



a,b,c,d=[int(i) for i in input().strip().split(' ')]

'''
入力は他の人のを見た
'''

max=0
min=0

if a < c :
    max=c
else :
    max=a
    
if b > d :
    min=d
else :
    min=b
if ( min - max ) > 0 :
    print( min - max )
else :
    print(0)
l,r=map(int,input().split())
if r-l>=2019:
  print(0)
else:
  a=2019
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min((i%2019)*(j%2019)%2019,a)
print(a)


### FIXED CODE ###

l,r=map(int,input().split())
if r-l>=2019:
  print(0)
else:
  a=2019
  for i in range(l,r):
    for j in range(i+1,r+1):
      a=min((i%2019)*(j%2019)%2019,a)
  print(a)
a,b= int(input()).split()

count=0
while a >0:
	a -= b
	count+=1
print(count)

### FIXED CODE ###


a,b=map(int, input().split())

count=0
while a >0:
	a -= b
	count+=1
print(count)
n=int(input())
print(r*r)

### FIXED CODE ###

n=int(input())
print(n*n)
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc125_c
import fractions, functools, itertools

# input
n = int(input())
A = [int(s) for s in input().split()]
# get ans
x = A[0]
y = A[1]
def divisors(n):
     for i in range(2, n):
        if n%i == 0:
            yield i
ds = set(divisors(x)) + set(divisors(y))
def condition(d):
    not_div = (a%d != 0 for a in A)
    not_div = (1 if b else 0 for b in not_div)
    return sum(not_div) <= 1
ans = max(filter(condition, ds))
# output
print(ans)



### FIXED CODE ###

#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc125_c
import fractions, functools, itertools

# input
n = int(input())
A = [int(s) for s in input().split()]
# get ans
gcd = fractions.gcd
L = list(itertools.accumulate(A, gcd))
R = list(itertools.accumulate(A[::-1], gcd))
R = R[::-1]
L.append(0)
R.append(0)
gs = [gcd(L[i-1], R[i+1]) for i in range(n)]
ans = max(gs)
# output
print(ans)
import itertools
N,K = map(int,input().split())
D = list(map(int,input().split()))

#使用可能数字の取り出し
Num = [1]*10 #index = num, 使用可能: 1,使用不可: 0
Num1 = [] #使用可能数字格納
for i in range(K):
  Num[D[i]] = 0
for i in range(10):
  if(Num[i] == 1):Num1.append(i)
 
#組み合わせ
Comb = []
n = len(str(N))
for i in range(n):
  Comb.append(Num1)
Comb = list(itertools.product(*Comb))

for i in range(len(Comb)):
  tmp = Comb[i]
  tmp_num = ''
  for j in range(n): tmp_num += str(tmp[j])
  tmp_num = int(tmp_num)
  if(N <= tmp_num):
    ans = tmp_num
    break
    
print(ans)

### FIXED CODE ###

import itertools
N,K = map(int,input().split())
D = list(map(int,input().split()))

#使用可能数字の取り出し
Num1 = []
for i in range(10):
  if(i in D): continue
  else: Num1.append(i)
 
#組み合わせ
Comb = []
n = len(str(N))
for i in range(n+1):
  Comb.append(Num1)
Comb = list(itertools.product(*Comb))

ans = -1
for i in range(len(Comb)):
  tmp = Comb[i]
  tmp_num = ''
  for j in range(n): tmp_num += str(tmp[j])
  tmp_num = int(tmp_num)
  if(N <= tmp_num):
    ans = tmp_num
    break
    
if(ans == -1):
  for i in range(len(Comb)):
   tmp = Comb[i]
   tmp_num = ''
   for j in range(n+1): tmp_num += str(tmp[j])
   tmp_num = int(tmp_num)
   if(N <= tmp_num):
     ans = tmp_num
     break
print(ans)