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

import sys
from array import array
from itertools import islice

sys.setrecursionlimit(5001)
MOD = 10 ** 9 + 7

n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    links[x].add(y)
    links[y].add(x)

double_factorial_odd = array('q', [0] * (n // 2))
prev = 1
for i in range(n // 2):
    prev = double_factorial_odd[i] = (2 * i + 1) * prev % MOD


def dfs(v, p):
    ret = array('q', [0, 1])
    for u in links[v]:
        if u == p:
            continue
        res = dfs(u, v)
        lt, ls = len(ret), len(res)
        mrg = array('q', [0] * (lt + ls - 1))
        for i, c in islice(enumerate(ret), 1 - lt % 2, None, 2):
            for j, d in islice(enumerate(res), 1 - ls % 2, None, 2):
                mrg[i + j] = (mrg[i + j] + c * d) % MOD
        ret = mrg

    if len(ret) % 2 == 1:
        ret[0] = -sum(pattern * df % MOD for pattern, df in zip(ret[2::2], double_factorial_odd)) % MOD

    return ret


print(MOD - dfs(0, -1)[0])


### FIXED CODE ###

import sys

sys.setrecursionlimit(5001)
MOD = 10 ** 9 + 7

n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    links[x].add(y)
    links[y].add(x)

double_factorial_odd = [0] * (n // 2)
prev = 1
for i in range(n // 2):
    prev = double_factorial_odd[i] = (2 * i + 1) * prev % MOD


def dfs(v, p):
    ret = [0, 1]
    for u in links[v]:
        if u == p:
            continue
        res = dfs(u, v)
        lt, ls = len(ret), len(res)
        mrg = [0] * (lt + ls - 1)
        for i in range(1 - lt % 2, lt, 2):
            c = ret[i]
            for j in range(1 - ls % 2, ls, 2):
                mrg[i + j] = (mrg[i + j] + c * res[j]) % MOD
        ret = mrg

    if len(ret) % 2 == 1:
        ret[0] = -sum(pattern * df % MOD for pattern, df in zip(ret[2::2], double_factorial_odd)) % MOD

    return ret


print(MOD - dfs(0, -1)[0])
### BUGGY CODE ###

#coding:utf-8
N = int(input())
trees = [list(input().split()) for i in range(N)]

class BinaryTree:
    def __init__(self,key,p=None,l=None,r=None):
        self.key = key
        self.p = p
        self.l = l
        self.r = r

def Insert(root,z):
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.l
        else:
            x = x.r
    z.p = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.l = z
    else:
        y.r = z
    return root

def preOrder(x):
    if x == None:
        return
    global preList
    preList.append(x.key)
    
    preOrder(x.l)
    preOrder(x.r)

def inOrder(x):
    if x == None:
        return
    inOrder(x.l)

    global inList
    inList.append(x.key)
    
    inOrder(x.r)

def Find(x,target):
    if x == None:
        return 
    if x.key == target:
        global yes
        yes = True
        return True
    Find(x.l,target)
    Find(x.r,target)

root = None
for data in trees:
    if data[0] == "insert":
        z = BinaryTree(int(data[1]))
        root = Insert(root,z)
    if data[0] == "find":
        yes = False
        a = Find(root, int(data[1]))
        if yes:
            print("yes")
        else:
            print("no")
        
    if data[0] == "print":
        inList = []
        preList = []
        inOrder(root)
        a = " " + " ".join([str(num) for num in inList])
        print(a)

        preOrder(root)
        a = " " + " ".join([str(num) for num in preList])
        print(a)


### FIXED CODE ###

#coding:utf-8
N = int(input())
trees = [list(input().split()) for i in range(N)]

class BinaryTree:
    def __init__(self,key,p=None,l=None,r=None):
        self.key = key
        self.p = p
        self.l = l
        self.r = r

def Insert(root,z):
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.l
        else:
            x = x.r
    z.p = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.l = z
    else:
        y.r = z
    return root

def preOrder(x):
    if x == None:
        return
    global preList
    preList.append(x.key)
    
    preOrder(x.l)
    preOrder(x.r)

def inOrder(x):
    if x == None:
        return
    inOrder(x.l)

    global inList
    inList.append(x.key)
    
    inOrder(x.r)

def Find(x,target):
    while x != None:
        y = x
        if target < x.key:
            x = x.l
        elif target > x.key:
            x = x.r
        else:
            print("yes")
            return
    print("no")

root = None
for data in trees:
    if data[0] == "insert":
        z = BinaryTree(int(data[1]))
        root = Insert(root,z)
    if data[0] == "find":
        Find(root, int(data[1]))
      
    if data[0] == "print":
        inList = []
        preList = []
        inOrder(root)
        a = " " + " ".join([str(num) for num in inList])
        print(a)

        preOrder(root)
        a = " " + " ".join([str(num) for num in preList])
        print(a)
### BUGGY CODE ###

from operator import add


class SegTree():
    def __init__(self, N, e=float("inf"), operator_func=min):
        self.e = e
        self.size = N
        self.node = [self.e] * (2*N)
        self.op = operator_func

    def set_list(self, l):
        for i in range(self.size):
            self.node[i+self.size-1] = l[i]
        for i in range(self.size-1)[::-1]:
            self.node[i] = self.op(self.node[2*i+1], self.node[2*i+2])
    
    def update(self, k, x):
        k += self.size - 1
        self.node[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.node[k] = self.op(self.node[2*k+1], self.node[2*k+2])

    def get(self, l, r):
        x = self.e
        l += self.size; r += self.size
        a, b = [], []

        while l<r:
            if l&1:
                a += [l-1]; l += 1
            if r&1:
                r -= 1; b += [r-1]
            l >>= 1; r >>= 1

        for i in a+(b[::-1]):
            x = self.op(x, self.node[i])
        return x


def solve():
    N, Q = map(int, input().split())
    *c, = map(int, input().split())
    tree = SegTree(N+1, 0, add)
    m = [tuple(map(int, input().split())) for i in range(Q)]
    idxs = sorted(range(Q), key=lambda i: m[i][1])

    right = 0
    pos = [None] * (N+1)
    ans = [None] * (Q)

    for idx in idxs:
        l, r = m[idx]
        for i in range(right, r):
            if pos[c[i]]:
                tree.update(pos[c[i]], 0)
            pos[c[i]] = i+1
            tree.update(i+1, 1)
        ans[idx] = tree.get(l, r+1)
        right = r
    print(*ans, sep="\n")


solve()


### FIXED CODE ###

class FenwickTree:
    def __init__(self, size):
        self.size = size
        self.array = [0]*size
 
    def add(self, index, value):
        while index < self.size:
            self.array[index] += value
            index += index&(-index)
 
    def sum(self, index):
        answer = 0
        while index > 0:
            answer += self.array[index]
            index -= index&(-index)
        return answer
 
    def rangesum(self, start, end):
        return self.sum(end)-self.sum(start-1)


def solve():
    N, Q = map(int, input().split())
    *c, = map(int, input().split())
    tree2 = FenwickTree(N+1)
    m = [list(map(int, input().split())) for _ in range(Q)]
    idxs = sorted(list(range(Q)), key=lambda i: m[i][1])

    right = 0
    pos = [-1] * (N+1)
    ans = [-1] * (Q)

    for idx in idxs:
        l, r = m[idx]
        for i in range(right, r):
            x = pos[c[i]]
            if x != -1:
                tree2.add(x, -1)
            pos[c[i]] = i+1
            tree2.add(i+1, 1)
        ans[idx] = tree2.rangesum(l, r)
        right = r
    print(*ans, sep="\n")


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

k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                cnt += 1
print(cnt)

### FIXED CODE ###

k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0<=z<=k:
            cnt += 1
print(cnt)
### BUGGY CODE ###

n = int(input())
s = input()
q = int(input())
k = list(map(int, input().split()))
d = {"D":0, "M":1, "C":2}
ss = [-1]*n
for i in range(n):
    if s[i] in d:
        ss[i] = d[s[i]]
for ki in k:
    D=M=DM=C=0
    for i, c in enumerate(ss):
        if c == 0:
            D += 1
        elif c == 1:
            M += 1
            DM += D
        elif c == 2:
            C += DM
        if i >= ki-1:
            j = i-ki+1
            if ss[j] == 0:
                D -= 1
                DM -= M
            elif ss[j] == 1:
                M -= 1
    print(C)

### FIXED CODE ###

# コピペ https://atcoder.jp/contests/dwacon5th-prelims/submissions/7670569
# 自分の https://atcoder.jp/contests/dwacon5th-prelims/submissions/7822126
# とほぼ変わらないのに自分のものはTLEするので検証
n=int(input())
s=input()
q=int(input())
for i in list(map(int,input().split())):
    a=0
    v=[0,0,0]
    for j in range(n):
        if s[j]=="D":
            v[0]+=1
        elif s[j]=="M":
            v[1]+=1
            v[2]+=v[0]
        if j>=i:
            if s[j-i]=="D":
                v[0]-=1
                v[2]-=v[1]
            elif s[j-i]=="M":
                v[1]-=1
        if s[j]=="C":
            a+=v[2]
    print(a)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
A = list(map(int, input().split()))
#B = [0] * M
#C = [0] * M

for i in range(M):
	b, c = map(int, input().split())
	A.extend([c]*b)
A.sort(reverse=True)

print(sum(A[0:N]))


### FIXED CODE ###

import sys, heapq
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, M = map(int, input().split())
A = list(map(int, input().split()))
a = [(-i, 1) for i in A]
heapq.heapify(a)

for i in range(M):
	b, c = map(int, input().split())
	heapq.heappush(a, (-c, b))
	
ans = 0

for i in range(N):
	pop = heapq.heappop(a)
	ans += pop[0]
	if pop[1] != 1:
		heapq.heappush(a, (pop[0], pop[1] - 1))

ans *= -1
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
i_list = [0] * (N+1)
cnt = 0

for k in range(K, N+1):
    A_sum = A[cnt]
    for i in range(cnt, K+cnt-1):
        if A[i+1] == 0:
            A_sum = 0
            break
        else:
            A_sum = A_sum * A[i+1]
    i_list[k] = A_sum
    A_sum = 0
    cnt = cnt + 1

for k in range(K, N):
    if i_list[k] < i_list[k+1]:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
i_list = [0] * N

for i in range(K, N):
    if A[i-K] < A[i]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

h, w = map(int, input().split())
lis = []
num = [[0] * w for i in range(h)]
s = [str(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            lis.append([i,j])
            num[i][j] = 1
cnt = -1
while lis != []:
    cnt += 1
    tmp = []
    for x,y in lis:
        if x > 0:
            if num[x-1][y] == 0:
                num[x-1][y] = 1
                tmp.append([x-1,y])
        if x < h-1:
            if num[x+1][y] == 0:
                num[x+1][y] = 1
                tmp.append([x+1,y])
        if y > 0:
            if num[x][y-1] == 0:
                num[x][y-1] = 1
                tmp.append([x,y-1])
        if y < w-1:
            if num[x][y+1] == 0:
                num[x][y+1] = 1
                tmp.append([x,y+1])
    lis = tmp
print(cnt)

### FIXED CODE ###

import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  M = [['#' == x for x in input()] for _ in range(H)]

  black = deque([(i, j) for i in range(H) for j in range(W) if M[i][j]])

  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not M[bi - 1][bj]:
        M[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not M[bi][bj - 1]:
        M[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not M[bi + 1][bj]:
        M[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not M[bi][bj + 1]:
        M[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()
### BUGGY CODE ###

import bisect
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        A = list(map(int, input().split()))

        A.sort()
        for _ in range(M):
            bisect.insort(A, A.pop() // 2)

        print(sum(A))


# Run main
if __name__ == '__main__':
    AtCoder().main()


### FIXED CODE ###

import bisect
import heapq
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        hq = []
        for c in input().split():
            heapq.heappush(hq, -1 * int(c))

        for _ in range(M):
            heapq.heappush(hq, int(heapq.heappop(hq) / 2))

        print(-1 * sum(hq))


# Run main
if __name__ == '__main__':
    AtCoder().main()
### BUGGY CODE ###

N, M = map(int, input().split())
base = [[int(l) for l in input().split()] for i in range(M)]
sort_target = sorted(base) 
  
prefecture_index = sort_target[0][0]
i=0
result = []
for target in sort_target:
  i = i + 1 if prefecture_index == target[0] else 1
  prefecture_index = target[0]
  result.append([base.index(target), target[0], i])

sorted_result = sorted(result) 
for result in sorted_result:
  print("{:0=6}{:0=6}".format(result[1], result[2]))

### FIXED CODE ###

N, M = map(int, input().split())
base = []
for i in range(M):
  (a, b) = map(int, input().split())
  base.append((a, b, i))
sorted_target = sorted(base) 

prefecture_index = sorted_target[0][0]

i=0
result = {}

for target in sorted_target:
  if prefecture_index == target[0]:
    i+=1
  else:
    prefecture_index = target[0]
    i = 1
  result[target[2]] = [prefecture_index, i]

for i in range(M):
  print("{:0=6}{:0=6}".format(result[i][0], result[i][1]))
### BUGGY CODE ###

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

def j(a,b,c):
  if a<b+c and c<b+a and b<a+c:
    return True
  else:
    return False

cnt = 0
l = list(itertools.combinations(range(N),3))
for i1,i2,i3 in l:
  a,b,c = L[i1],L[i2],L[i3]
  if j(a,b,c):
    cnt += 1
print(cnt)

### FIXED CODE ###

import bisect
N =int(input())
L = sorted(list(map(int,input().split())))

cnt = 0

for i in range(N):
  for j in range(i+1,N):
    cnt += bisect.bisect_left(L,L[i]+L[j]) - (j+1)
print(cnt)
### BUGGY CODE ###

k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                ans += 1
print(ans)


### FIXED CODE ###

k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0 <= z <= k and x+y+z == s:
            ans += 1
print(ans)
### BUGGY CODE ###

N=int(raw_input())
a=[-1]
for _ in range(N):
    a.append(int(raw_input()))


if not 2 in a:
    print -1
else:
    alr=[]
    i=1
    c=1
    while(1):
        if a[i]==2:
            print c
            break
        elif i in alr:
            print -1
            break
        else:
            alr.append(i)
            i=a[i]
            c+=1
            
        

### FIXED CODE ###

N=int(raw_input())
a=[-1]
for _ in range(N):
    a.append(int(raw_input()))
 
 
i=1
c=0
while(1):
    if i==2:
        print c
        break
    elif c>=N:
        print -1
        break
    c+=1
    i=a[i]
### BUGGY CODE ###

# -*- coding: utf-8 -*-

from collections import deque
import copy

class Puzzle(list):
    def __init__(self):
        list.__init__(self)
        self.space = None
        self.path = ""
    
    def __hash__(self):
        return hash(str(self[:]))

if __name__ == '__main__':
    
    N = 3
    N2 = 9
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    d = ["u", "l", "d", "r"]

    p = Puzzle()
    for i in range(N):
        p += [int(x) for x in input().split()]
    for i in range(N2):
        if p[i] == 0:
            p[i] = N2
            p.space = i
    target = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    def isTarget(p):
        return p[:] == target[:]

    def bfs(s):
        Q = deque()
        V = set()
        Q.append(s)
        V.add(s)
        while Q:
            u = Q.popleft()
            if isTarget(u):
                return u.path
            sx = u.space // N
            sy = u.space % N
            for r in range(4):
                tx = sx + dx[r]
                ty = sy + dy[r]
                if not (0<= tx < N and 0 <= ty < N):
                    continue
                v = copy.copy(u)
                v[u.space], v[tx * N + ty] = v[tx * N + ty], v[u.space]
                v.space = tx * N + ty
                if not v in V:
                    V.add(v)
                    v.path += d[r]
                    Q.append(v)

        return "unsolvable"

    ans = bfs(p)
    print(len(ans))





### FIXED CODE ###

# -*- coding: utf-8 -*-

from collections import deque
import copy

class Puzzle(list):
    def __init__(self):
        list.__init__(self)
        self.space = None
        self.path = ""
    
    def __hash__(self):
        return hash(str(self[:]))

if __name__ == '__main__':
    
    N = 3
    N2 = 9
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    d = ["u", "l", "d", "r"]

    p = Puzzle()
    for i in range(N):
        p += [int(x) for x in input().split()]
    for i in range(N2):
        if p[i] == 0:
            p[i] = N2
            p.space = i
    target = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    def isTarget(p):
        return p[:] == target[:]

    def bfs(s):
        Q = deque()
        V = set()
        Q.append(s)
        V.add(s)
        while Q:
            u = Q.popleft()
            if isTarget(u):
                return u.path
            sx = u.space // N
            sy = u.space % N
            for r in range(4):
                tx = sx + dx[r]
                ty = sy + dy[r]
                if not (0<= tx < N and 0 <= ty < N):
                    continue
                v = Puzzle()
                v[:] = u[:]
                v.path = u.path
                change = tx * N + ty
                v[u.space], v[change] = v[change], v[u.space]
                v.space = change
                if not v in V:
                    V.add(v)
                    v.path += d[r]
                    Q.append(v)

        return "unsolvable"

    ans = bfs(p)
    print(len(ans))
### BUGGY CODE ###



N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]

memo = [1e12] * (N + 1)
memo[0] = 0

for i in range(N - 1):
    for j in range(1, K + 1):
        if i + j >= N: break
        memo[i + j] = min(abs(H[i] - H[i + j]) + memo[i], memo[i + j])
print(memo[N - 1])


### FIXED CODE ###



N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]

memo = [1e12] * (N + 1)
memo[0] = 0

for i in range(N - 1):
    for j in range(1, K + 1):
        if i + j >= N: break
        memo[i + j] = min(abs(H[i] - H[i + j]) + memo[i], memo[i + j])
print(memo[N - 1])
### BUGGY CODE ###

def main():
    n = int(input())
    ans = 1
    mod = 10**9 + 7
    for i in range(1,n+1):
        ans *= i
    print(ans%mod)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math

def main():
    n = int(input())
    mod = 10**9 + 7
    print(math.factorial(n)%mod)


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

n, x, y = map(int, input().split())


arr = [[10**4] * n for i in range(n)]
for i in range(n-1):
        arr[i][i+1] = 1
        arr[i+1][i] = 1
arr[x-1][y-1] = 1
arr[y-1][x-1] = 1

def dk(s,n,w,cost):
    d = [10**4] * n
    us = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        for i in range(n):
            if (not us[i]) and v == -1:
               v = i
            elif (not us[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        us[v] = True
               
        for x in range(n):
               d[x] = min(d[x],d[v]+cost[v][x])
    return d

ans = [0] * (n-1)
for i in range(n):
    dist = dk(i,n,n,arr)
    for j in range(len(dist)):
        ans[dist[j]] += 1

for i in range(1,len(ans)):
    print(ans[i] // 2)
print(0)


### FIXED CODE ###

n, x, y = map(int, input().split())


min_dist = [0] * n

for i in range(n):
    for j in range(i+1,n):
        dist = min(abs(j-i), abs(j-(y-1)) + 1 +abs((x-1)-i))
        min_dist[dist] += 1

for i in range(1,n):
    print(min_dist[i])
### BUGGY CODE ###

N,M,K = map(int,input().split())
fr = [[] for i in range(N+1)]
bl = [[] for i in range(N+1)]
for _ in range(M):
    A,B = map(int, input().split())
    fr[A].append(B)
    fr[B].append(A)
for _ in range(K):
    C,D = map(int, input().split())
    bl[C].append(D)
    bl[D].append(C)

leader = [0]*(N+1)
d = {}
for root in range(1,N+1):
    if leader[root]!=0:
        continue
    d[root] = set([root])
    stack = [root]
    while stack:
        start = stack.pop()
        leader[start] = root
        for v in fr[start]:
            if leader[v]!=0:
                continue
            d[root].add(v)
            stack.append(v)

ans = [0]*(N+1)
for i in range(1,N+1):
    cluster = d[leader[i]]
    ans[i] = len(cluster) - len(fr[i]) - 1
    for b in bl[i]:
        if b in cluster:
            ans[i] -= 1
print(*ans[1:])

### FIXED CODE ###

N,M,K = map(int,input().split())
fr = [[] for i in range(N+1)]
bl = [[] for i in range(N+1)]
for _ in range(M):
    A,B = map(int, input().split())
    fr[A].append(B)
    fr[B].append(A)
for _ in range(K):
    C,D = map(int, input().split())
    bl[C].append(D)
    bl[D].append(C)

leader = [0]*(N+1)
d = {}
for root in range(1,N+1):
    if leader[root]!=0:
        continue
    d[root] = set([root])
    stack = [root]
    while stack:
        start = stack.pop()
        leader[start] = root
        for v in fr[start]:
            if leader[v]!=0:
                continue
            d[root].add(v)
            stack.append(v)

ans = [0]*(N+1)
for i in range(1,N+1):
    cluster = d[leader[i]]
    ans[i] = len(cluster) - len(fr[i]) - 1
    for b in bl[i]:
        if b in cluster:
            ans[i] -= 1
print(*ans[1:])
### BUGGY CODE ###

import sys
N=int(input())
ans=1
numbers=input().split()
for j in range(N):
  num=int(numbers[j])
  ans=ans*num
  if ans==0:
    print(0)
    sys.exit()
if ans>1000000000000000000:
  print(-1)
  sys.exit()
print(ans)

### FIXED CODE ###

import sys
N=int(input())
ans=1
numbers=input().split()
zero="0" in numbers
if zero:
  print(0)
  sys.exit()
for j in range(N):
  num=int(numbers[j])
  ans=ans*num
  if ans>1000000000000000000:
    print(-1)
    sys.exit()
print(ans)
### BUGGY CODE ###

n = int(input())
s = 0
su = 0

for i in range(len(str(n))):
    s = s + int(str(n)[i])

for i in range(len(str(s))):
    su = su + int(str(s)[i])

if su % 9 == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
if n % 9 == 0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

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

ans = 2200
for i in range(l, r):
    for j in range(l+1, r+1):
        if i == j:
            continue
        else:
            tmpans = (i * j) % 2019
        ans = min(ans, tmpans)

print(ans)

### FIXED CODE ###

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

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        ans = 0
        break
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                ans = 0
                break
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)