Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

A,B,Q=map(int, input().split())
from bisect import bisect_left

S=[]
for i in range(A):
    s=int(input())
    S.append(s)
T=[]
for i in range(B):
    t=int(input())
    T.append(t)

for i in range(Q):
    x=int(input())
    sidx=bisect_left(S, x)
    tidx=bisect_left(T, x)
    if 0<=sidx<A and 0<=tidx<B:
        a1=max(S[sidx], T[tidx])-x
    else:
        a1=float("INF")
    if 0<=sidx-1<A and 0<=tidx-1<B:
        a2=max(x-S[sidx-1], x-T[tidx-1])
    else:
        a2=float("INF")
    if 0<=sidx<A and 0<=tidx-1<B:
        a3=S[sidx]-T[tidx-1]+min(S[sidx]-x, x-T[tidx-1])
    else:
        a3=float("INF")
    if 0<=sidx-1<A and 0<=tidx<B:
        a4=T[tidx]-S[sidx-1]+min(T[tidx]-x, x-S[sidx-1])
    else:
        a4=float("INF")
    #print(a1,a2,a3,a4)
    ans=min(a1,a2,a3,a4)
    print(ans)


### FIXED CODE ###

A,B,Q=map(int, input().split())
from bisect import bisect_left

S=[]
for i in range(A):
    s=int(input())
    S.append(s)
T=[]
for i in range(B):
    t=int(input())
    T.append(t)

for i in range(Q):
    x=int(input())
    sidx=bisect_left(S, x)
    tidx=bisect_left(T, x)
    if 0<=sidx<A and 0<=tidx<B:
        a1=max(S[sidx], T[tidx])-x
    else:
        a1=float("INF")
    if 0<=sidx-1<A and 0<=tidx-1<B:
        a2=max(x-S[sidx-1], x-T[tidx-1])
    else:
        a2=float("INF")
    if 0<=sidx<A and 0<=tidx-1<B:
        a3=S[sidx]-T[tidx-1]+min(S[sidx]-x, x-T[tidx-1])
    else:
        a3=float("INF")
    if 0<=sidx-1<A and 0<=tidx<B:
        a4=T[tidx]-S[sidx-1]+min(T[tidx]-x, x-S[sidx-1])
    else:
        a4=float("INF")
    #print(a1,a2,a3,a4)
    ans=min(a1,a2,a3,a4)
    print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
result = 1
 
for a in A:
  result *= a
  
if 0 in A:
  print(0)
elif result > 10**18:
  print(-1)
else:
  print(result)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
result = 1
 
if 0 in A:
  print(0)
  exit()

for a in A:
  result *= a
  if result > 10**18:
    print(-1)
    exit()

print(result)
### BUGGY CODE ###

def main():
    from sys import stdin
    input = stdin.readline
    N, M = map(int, input().split())
    SP = [tuple(input().split()) for i in range(M)]
    wa_num = 0
    wa_num_temp = {}
    ac_num = 0
    ansed = []
    ansed_append = ansed.append
    for sp in SP:
        if sp[0] in ansed:
            continue
        if sp[0] not in wa_num_temp:
            wa_num_temp[sp[0]] = 0
        if sp[1] == "WA" and sp[0] not in ansed:
            wa_num_temp[sp[0]] += 1
        elif sp[1] == "AC" and sp[0] not in ansed:
            ac_num += 1
            wa_num += wa_num_temp[sp[0]]
            ansed_append(sp[0])

    print(ac_num, wa_num)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    from sys import stdin
    input = stdin.readline
    N, M = map(int, input().split())
    SP = [list(input().split()) for i in range(M)]
    was = [0] * N
    acs = [0] * N
    penaltyCount = 0
    for sp in SP:
        if acs[int(sp[0])-1] == 1:
            continue
        if acs[int(sp[0])-1] == 0 and sp[1] == "WA":
            was[int(sp[0])-1] += 1
        elif acs[int(sp[0])-1] == 0 and sp[1] == "AC":
            acs[int(sp[0])-1] = 1
            penaltyCount += was[int(sp[0])-1]

    print(sum(acs), penaltyCount)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
for i in range(1, n+1):
    ans = 0
    for j in range(1, 15):
        for k in range(1, 15):
            for l in range(1, 15):
                if j ** 2 + k ** 2 + l ** 2 + j * k + k * l + l * j == i:
                    ans += 1
    print(ans)

### FIXED CODE ###

n = int(input())
ans = [0] * 10010
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            x = i * i + j * j + k * k + i * j + j * k + k * i
            if x <= n:
                ans[x] += 1
for i in range(1, n+1):
    print(ans[i])
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0


for i in range(n):
    if min(p[:i+1])>=p[i]:
        ans+=1
        
print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
ans = 0
ps=[]
p_min = p[0]
for i in p:
    if p_min>i:
        p_min=i
    
    if p_min>=i:
        ans+=1
print(ans)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def main():
    n=int(input())
    A=np.array([int(_) for _ in input().split()])
    B=np.zeros(n,dtype=int)
    while True:
        for i in range(1,n):
            B[i]=A[i-1]-B[i-1]
        B[1::]=A[:-1:]-B[:-1:]
        if B[0]==A[-1]-B[-1]:
            print(*[2*x for x in B])
            break
        B[0]+=1
    

if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()
### BUGGY CODE ###

import heapq

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
A.append(0)
S = []
heapq.heapify(S)
c = A[0]
cnt = 1
for i in range(1, N + 1):
    if A[i] == c:
       cnt += 1
    else:
        heapq.heappush(S, (A[i - 1], cnt))
        cnt = 1
        c = A[i]


for i in range(M):
    B, v = map(int, input().split())
    while len(S) > 0 and S[0][0] < v:
        x = heapq.heappop(S)
        if B <= x[1]:
            heapq.heappush(S, (v, B))
            if not B == x[1] : heapq.heappush(S, (x[0], x[1] - B))
            break
        else:
            B -= x[1]
            heapq.heappush(S, (v, x[1]))
sumS = 0
while len(S) > 0:
    x = heapq.heappop(S)
    sumS += x[0] * x[1]
print(sumS)

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
A.append(0)
S = []
heapq.heapify(S)
c = A[0]
cnt = 1
for i in range(1, N + 1):
    if A[i] == c:
       cnt += 1
    else:
        heapq.heappush(S, (A[i - 1], cnt))
        cnt = 1
        c = A[i]


for i in range(M):
    B, v = map(int, input().split())
    flag = False #Sからの取り出し比較を1度以上終えているか
    b = B # 残りカード
    while len(S) > 0 and S[0][0] < v:
        x = heapq.heappop(S)
        if b <= x[1]:
            heapq.heappush(S, (v, B))
            if not b == x[1] : heapq.heappush(S, (x[0], x[1] - b))
            flag = False
            break
        else:
            flag = True
            b -= x[1]

    if flag: #交換しきらないで、途中で終わっているのでこの分は挿入する
        heapq.heappush(S, (v, B - b))

sumS = 0
while len(S) > 0:
    x = heapq.heappop(S)
    sumS += x[0] * x[1]
print(sumS)
### BUGGY CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H,W,K = map(int, readline().split())
    S = [readline().strip() for j in range(H)]

    """
    white = []
    for line in S:
        white.append(line.count("1"))
    w = sum(white)

    if w <= K:
        print(0)
        exit()
    """

    ans = 10**5
    for i in range(2**(H-1)):
        ly = bin(i).count("1")
        x = 0
        y = [0]*(ly + 1)
        j = 0
        while j < W:
            m = 0
            for k in range(H):
                if S[k][j] == "1":
                    y[m] += 1
                    if y[m] > K:
                        x += 1
                        y = [0]*(ly + 1)
                        j -= 1
                        break
                if (i >> k) & 1:
                    m += 1
            j += 1

        ans = min(ans, x + ly)

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H,W,K = map(int, readline().split())
    S = [readline().strip() for j in range(H)]

    white = []
    for line in S:
        white.append(line.count("1"))
    white_total = sum(white)

    if white_total <= K:
        print(0)
        exit()

    ans = 10**5
    for i in range(2**(H-1)):
        impossible = False
        x = 0
        ly = bin(i).count("1")
        y_sum = [0]*(ly + 1)
        j = 0
        while j < W:
            m = 0
            y = [0]*(ly + 1)
            for k in range(H):
                if S[k][j] == "1":
                    y[m] += 1
                    if y[m] > K:
                        impossible = True
                        break
                    y_sum[m] += 1
                    if y_sum[m] > K:
                        x += 1
                        y_sum = [0]*(ly + 1)
                        j -= 1
                        break
                if (i >> k) & 1:
                    m += 1
            j += 1
            if impossible:
                x = 10**6
                break

        ans = min(ans, x + ly)

    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

from math import gcd
import numpy as np

def setwise_coprime_check_fun(A_list):
    gcd_all = A_list[0]
    for i in range(N - 1):
        gcd_all = gcd(gcd_all, A_list[i + 1])
    return gcd_all

def preprocess_fun(A_max):
    p_flg = [1] * (A_max + 1)
    D = [0] * (A_max + 1)
    p_flg[0] = 0
    p_flg[1] = 0
    for i in range(2, A_max + 1, 1):
        if p_flg[i]:
            for j in range(i, A_max + 1, i):
                p_flg[j] = 0
                D[j] = i
    return D

def pairwise_coprime_check(A_list, D):
    p_count = [0] * (max(A_list) + 1)
    p_count_temp = [0] * (max(A_list) + 1)
    for A in A_list:
        temp = A
        while temp != 1:
            if p_count[D[temp]] == 1:
                return 0
            else:
                p_count_temp[D[temp]] = 1
            temp = temp // D[temp]
        p_count = list(np.array(p_count) + np.array(p_count_temp))
        p_count_temp = [0] * (max(A_list) + 1)
    return 1

# 標準入力
N = int(input())
A_list = list(map(int, input().split(" ")))

# 整数の最大値を取得
A_max = max(A_list)

# 本体
if(setwise_coprime_check_fun(A_list) != 1):
    print("not coprime")
else:
    D = preprocess_fun(A_max)
    if pairwise_coprime_check(A_list, D) == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")

### FIXED CODE ###

from math import gcd
import numpy as np

def setwise_coprime_check_fun(A_list, N):
    gcd_all = A_list[0]
    for i in range(N - 1):
        gcd_all = gcd(gcd_all, A_list[i + 1])
        if gcd_all == 1:
            break
    return gcd_all

def preprocess_fun(A_max):
    p_flg = [True] * (A_max + 1)
    D = [0] * (A_max + 1)
    p_flg[0] = False
    p_flg[1] = False
    for i in range(2, A_max + 1, 1):
        if p_flg[i]:
            for j in range(i, A_max + 1, i):
                p_flg[j] = False
                D[j] = i
    return D

def pairwise_coprime_check(A_list, D):
    p_count = [0] * (max(A_list) + 1)
    for A in A_list:
        temp = A
        d = 0
        while temp != 1:
            if p_count[D[temp]] == 1 and d != D[temp]:
                return 0
            p_count[D[temp]] = 1
            d = D[temp]
            temp = temp // D[temp]
    return 1

## 標準入力
N = int(input())
A_list = list(map(int, input().split(" ")))

# 整数の最大値を取得
A_max = max(A_list)

# 本体
if(setwise_coprime_check_fun(A_list, N) != 1):
    print("not coprime")
else:
    D = preprocess_fun(A_max)
    if pairwise_coprime_check(A_list, D) == 1:
        print("pairwise coprime")
    else:
        print("setwise coprime")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
n, q = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]
d = [[] for i in range(n)]
for i in range(n-1):
    ai, bi = map(int,input().split())
    ab[ai-1][bi-1] = 1
    ab[bi-1][ai-1] = 1
    d[ai-1].append(bi-1)
    d[bi-1].append(ai-1)




#point
px = [0 for i in range(n)]
for i in range(q):
    pi,xi = map(int,input().split())
    px[pi-1] +=xi
sp = [float("inf") for i in range(n)]
sp[0] = px[0]

#訪問済
x = [0 for i in range(n)]
def f(v,p):
    x[v] = 1
    sp[v] = p + px[v]
    for di in d[v]:
        if x[di] == 0:
            f(di,sp[v])
f(0,0)
for i in range(n):
    print(sp[i])

### FIXED CODE ###

from collections import deque
n, q = map(int,input().split())
d = [[] for i in range(n)]
for i in range(n-1):
    ai, bi = map(int,input().split())
    d[ai-1].append(bi-1)
    d[bi-1].append(ai-1)
#point
px = [0 for i in range(n)]
for i in range(q):
    pi,xi = map(int,input().split())
    px[pi-1] += xi
sp = [0 for i in range(n)]
s = deque()
s.append(0)
visited = [False for i in range(n)]
while len(s) > 0:
    x = s.popleft()
    visited[x] = True
    sp[x] += px[x]
    for xc in d[x]:
        if not visited[xc]:
            s.append(xc)
            sp[xc] += sp[x]
for i in range(n):
    print(sp[i])
### BUGGY CODE ###

#13:27
s = input()
l = len(s)
s = 'F' + s
x,y = map(int,input().split())
raw = [1]
for i in range(1,l+1):
  if s[i] == 'F':
    if s[i-1] == 'F':
      raw[-1] += 1
    else:
      raw.append(1)
  if s[i] == 'T':
    if s[i-1] == 'T':
      raw.append(0)
l2 = len(raw)
a = []
b = []
for i in range(l2):
  if i == 0:
    x -= raw[i]-1
  elif i % 2 == 0:
    a.append(raw[i])
  else:
    b.append(raw[i])
#print(raw)
#print(a,x)
#print(b,y)
nowa = [0 for _ in range(16001)]
nowa[8000] = 1
for aa in a:
  lasta = nowa
  nowa = [0 for _ in range(16001)]
  for i in range(16001):
    if lasta[i] == 1:
      nowa[i+aa] = 1
      nowa[i-aa] = 1
nowb = [0 for _ in range(16001)]
nowb[8000] = 1
for bb in b:
  lastb = nowb
  nowb = [0 for _ in range(16001)]
  for i in range(16001):
    if lastb[i] == 1:
      nowb[i+bb] = 1
      nowb[i-bb] = 1
if nowa[8000+x] * nowb[8000+y] == 1:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = input()
l = len(s)
s = 'F' + s
x,y = map(int,input().split())
raw = [1]
for i in range(1,l+1):
  if s[i] == 'F':
    if s[i-1] == 'F':
      raw[-1] += 1
    else:
      raw.append(1)
  if s[i] == 'T':
    if s[i-1] == 'T':
      raw.append(0)
l2 = len(raw)
a = []
b = []
for i in range(l2):
  if i == 0:
    x -= raw[i]-1
  elif i % 2 == 0:
    a.append(raw[i])
  else:
    b.append(raw[i])
#print(raw)
#print(a,x)
#print(b,y)
nowa = {0}
for aa in a:
  lasta = nowa
  nowa = set()
  for aaa in lasta:
    nowa.add(aaa+aa)
    nowa.add(aaa-aa)
nowb = {0}
for bb in b:
  lastb = nowb
  nowb = set()
  for bbb in lastb:
    nowb.add(bbb+bb)
    nowb.add(bbb-bb)
#print(nowa,nowb)
#print(x,y)
if x in nowa and y in nowb:
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


N = int(input())
seq = list(map(int, input().split()))
ans = 0
for i in range(N -1):
    for j in range(i+1, N):
        tmp = (seq[i] * seq[j])
        ans += tmp
print(ans%(10**9+7))



### FIXED CODE ###

#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


N = int(input())
seq = list(map(int, input().split()))

s = 0
for i in range(N):
    s += seq[i]

s2 =0
for i in range(N):
    s2 += seq[i]**2


s0 = (s**2 -s2)//2

print(s0%(10**9+7))
### BUGGY CODE ###

N=int(input())
ans = 0

for i in range(1, N+1):
    tmp = i
    while(tmp <= N):
        ans += tmp
        tmp += i

print(ans)

### FIXED CODE ###

N=int(input())
ans = 0
 
for i in range(1, N+1):
    num = N // i
    if num == 1:
        ans += i
    else:
        ans += num * (i + num * i) / 2
 
print(int(ans))
### BUGGY CODE ###

N = int(input())
inputs = [int(input()) for _ in range(N)]

for i in range(N):
    sorted_inputs = sorted(inputs, reverse=True)
    if sorted_inputs[0] == inputs[i]:
        print(sorted_inputs[1])
    else:
        print(sorted_inputs[0])


### FIXED CODE ###

N = int(input())
inputs = [int(input()) for _ in range(N)]

sorted_inputs = sorted(inputs, reverse=True)
for i in range(N):
    if sorted_inputs[0] == inputs[i]:
        print(sorted_inputs[1])
    else:
        print(sorted_inputs[0])
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))

i = 0
ans = 1
while i < N-1:
    for j in range(N-i-1):
        if a[i] == a[i+j+1]:
            ans = 0
            break
    if ans == 0:
        break
    i +=1
    
if ans == 1:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

from collections import Counter

N = int(input())
a = list(map(int,input().split()))
c=Counter(a)
ans = max(c.values())
    
if ans == 1:
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

def resolve():
    (N, M) = list(map(int, input().split(" ")))
    As = [int(input()) for i in range(M)]

    cnts = [False] * (N+1)
    for i in range(N+1):
        c = 0
        if i in As:
            c = 0
        elif i == 0:
            c = 1
        elif i == 1:
            c = 1
        elif i == 2:
            c = 2 if 1 not in As else 1
        else:
            c = (cnts[i-2] + cnts[i-1])%1000000007
        cnts[i] = c

    print(cnts[N])

if '__main__' == __name__:
    resolve()

### FIXED CODE ###

def resolve():
    (N, M) = list(map(int, input().split(" ")))
    As = [int(input()) for i in range(M)]
    As.sort()

    cnts = [False] * (N+1)
    ptr = 0
    for i in range(N+1):
        c = 0
        if ptr < len(As) and i == As[ptr]:
            c = 0
            ptr = ptr + 1
        elif i == 0:
            c = 1
        elif i == 1:
            c = 1
        elif i == 2:
            c = 2 if 1 not in As else 1
        else:
            c = (cnts[i-2] + cnts[i-1])%1000000007
        cnts[i] = c

    print(cnts[N])

if '__main__' == __name__:
    resolve()
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    XY = [tuple(map(int, input().split())) for _ in range(N)]
    # XY = [list(map(int, input().split())) for _ in range(N)]
    XY.sort()

    def count(x_min, x_max, y_min, y_max, i, j):
        OK = 0
        NG = 0
        a = j - i + 1 - K
        for m in range(i, j + 1):
            if y_min <= XY[m][1] <= y_max:
                OK += 1
            else:
                NG += 1
            if OK >= K:
                return True
            if NG > a:
                return False

    ans = 10 ** 20
    for i in range(N - 1):
        for j in range(i + K - 1, N):
            for k in range(N):
                for l in range(N):
                    if XY[k][1] < XY[l][1]:
                        if count(XY[i][0], XY[j][0], XY[k][1], XY[l][1], i, j):
                            # print ('A')
                            ans = min(ans, (XY[j][0] - XY[i][0]) * (XY[l][1] - XY[k][1]))
    print (ans)
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#PythonだとTLEする
N, K = map(int, input().split())
X = [0] * N
Y = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    X[i] = x
    Y[i] = y

def count(x_min, x_max, y_min, y_max):
    cnt = 0
    for i in range(N):
        if x_min <= X[i] <= x_max and y_min <= Y[i] <= y_max:
            cnt += 1
    return cnt

ans = 10 ** 20
for i in range(N):
    for j in range(N):
        for k in range(N):
            for l in range(N):
                # print ('i, j , k, l = ', i, j, k, l)
                if X[i] < X[j] and Y[k] < Y[l]:
                    if count(X[i], X[j], Y[k], Y[l]) >= K:
                        # print ('A')
                        ans = min(ans, (X[j] - X[i]) * (Y[l] - Y[k]))
print (ans)
### BUGGY CODE ###

import bisect
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
b=sorted(list(map(int,input().split())))
ma=a[0]*b[-1]
mi=0
if sum(a)<k+1:
  ma=0
for i in range(n):
  a[i]=a[i]*b[i]
for i in range(50):
  now=0
  for i in range(n):
    now+=max(0,(a[i]-(mi+ma)//2+b[i]-1)//b[i])
  if now>k:
    mi=(ma+mi)//2
  else:
    ma=(ma+mi)//2
print(ma)

### FIXED CODE ###

import bisect
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
b=sorted(list(map(int,input().split())))
ma=a[0]*b[-1]
mi=0
if sum(a)<k+1:
  ma=0
for i in range(n):
  a[i]=a[i]*b[i]
while abs(ma-mi)>1:
  now=0
  for i in range(n):
    now+=max(0,(a[i]-(mi+ma)//2+b[i]-1)//b[i])
  if now>k:
    mi=(ma+mi)//2
  else:
    ma=(ma+mi)//2
print(ma)
### BUGGY CODE ###

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

B=[]
for i in range(N):
    if i%2==0:
        B.append(A[i])
    else:
        B.insert(0,A[i])

if N%2==0:
    print(*B)
else:
    print(*B[::-1])

### FIXED CODE ###

from collections import deque

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

B=deque([])
for i in range(N):
    if i%2==0:
        B.append(A[i])
    else:
        B.appendleft(A[i])

if N%2==0:
    print(*list(B))
else:
    print(*list(B)[::-1])
### BUGGY CODE ###

import math

input1 = input().split()
A = int(input1[0])
B = int(input1[1])
N = int(input1[2])

output = 0
result = 0
for x in range(N):
    result = (math.floor(A*(x+1) / B)) - A*(math.floor((x+1)/B))
    if result > output:
        output = result
    if result < output:
        break

print(output)

### FIXED CODE ###

import math

input1 = input().split()
A = int(input1[0])
B = int(input1[1])
N = int(input1[2])

x = 0
result = 0
if N >= B-1:
    x = B-1
    result = (A*(x%B) - (A*x)%B)/B
elif N < B-1:
    x = N
    result = (A*(x%B) - (A*x)%B)/B

print(int(result))
### BUGGY CODE ###

import numpy as np
from itertools import product

X, Y = map(int, input().split())
flag = 0

for x in product('24', repeat=X):
    a = np.array(list(map(int, x)))
    if a.sum() == Y:
        flag = 1
        break
if flag == 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import numpy as np
from itertools import combinations_with_replacement

X, Y = map(int, input().split())
flag = 0

for x in combinations_with_replacement('24', X):
    a = np.array(list(map(int, x)))
    if a.sum() == Y:
        flag = 1
        break
if flag == 1:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [list(input()) for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if A[i][j] == 'S':
        break
Q = collections.deque([[i, j, K]])
hmin = hmax = i
wmin = wmax = j
while Q:
    h, w, res = Q.popleft()
    A[h][w] = '#'
    hmin = min(hmin, h)
    hmax = max(hmax, h)
    wmin = min(wmin, w)
    wmax = max(wmax, w)
    if res:
        res -= 1
        if h and A[h - 1][w] == '.':
            Q += [[h - 1, w, res]]
        if h < H - 1 and A[h + 1][w] == '.':
            Q += [[h + 1, w, res]]
        if w and A[h][w - 1] == '.':
            Q += [[h, w - 1, res]]
        if w < W - 1 and A[h][w + 1] == '.':
            Q += [[h, w + 1, res]]
print(1 +
      min([math.ceil(_ / K)
           for _ in (hmin, H - 1 - hmax, wmin, W - 1 - wmax)]))


### FIXED CODE ###

import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]
for h in range(H):
    if 'S' in A[h]:
        w = A[h].index('S')
        break
visited = [[False] * W for _ in range(H)]
ans = min([h, H - 1 - h, w, W - 1 - w])
res = K - 1
Q = collections.deque([[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                       [h, w + 1, res]])
while Q:
    h, w, res = Q.popleft()
    if 0 <= h < H and 0 <= w < W and A[h][w] == '.' and not visited[h][w]:
        visited[h][w] = True
        ans = min([ans, h, H - 1 - h, w, W - 1 - w])
        if res:
            res -= 1
            Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                  [h, w + 1, res]]
print(1 + math.ceil(ans / K))
### BUGGY CODE ###

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

for i in range(L, R+1):
	if (i % 2019 == 0):
		min = 0
		break
	for j in range(i+1, R+1):
		num = i * j % 2019
		if j > i and num < min:
			min = num

print(min)

### FIXED CODE ###

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

if R -L >= 2019:
	min = 0
else:

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

print(min)