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

# from math import gcd
from fractions import gcd
from functools import reduce
 
n = int(input())
a = [int(x) for x in input().split()]
 
def lcm_list(numbers):
    return reduce(lambda x, y: (x * y) // gcd(x, y), numbers, 1)
 
lcm = lcm_list(a)
aa = []
for i in range(len(a)):
    aa.append(lcm // a[i])
ans = sum(aa) % 1000000007
print(ans)

### FIXED CODE ###

# from math import gcd
from fractions import gcd
from functools import reduce

def lcm_list(numbers):
    return reduce(lambda x, y: (x * y) // gcd(x, y), numbers, 1)

def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    lcm = lcm_list(a)
    aa = []
    for i in range(len(a)):
        aa.append(lcm // a[i])
    ans = sum(aa) % 1000000007
    print(ans)

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

import bisect
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


n = int(input())
ls = sorted(read_i(), reverse=True)
res = 0
for i, x in enumerate(ls):
    for j, y in enumerate(ls[i + 1:], i + 1):
        if 2 * y < x:
            break
        res += n - j - 1 - bisect.bisect(ls[j + 1:][::-1], x - y)
print(res)

### FIXED CODE ###

import bisect
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


n = int(input())
ls = sorted(read_i())
ls2 = ls[::-1]
res = 0
for i, x in enumerate(ls2):
    for j, y in enumerate(ls2[i + 1:], i + 1):
        if 2 * y < x:
            break
        res += n - j - 1 - bisect.bisect(ls[:-(j + 1)], x - y)
print(res)
### BUGGY CODE ###

import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
for _ in range(Q):
  l,r  = map(int,sys.stdin.readline().rstrip().split())
  print(S[l-1:r].count("AC"))
  del l
  del r

### FIXED CODE ###

import sys
N,Q = map(int,sys.stdin.readline().rstrip().split())
S = sys.stdin.readline().rstrip()
D = [0]
DD = 0
for i in range(1,len(S)):
  if S[i-1] + S[i] == "AC":
    DD += 1
  D.append(DD)
for _ in range(Q):
  l,r  = map(int,sys.stdin.readline().rstrip().split())
  print(D[r-1]- D[l-1])
  del l
  del r
### BUGGY CODE ###

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

b = set(a)

c = {}

for i in a:
    c[i] = c.get(i, 0) + 1

e = {}
for i in a:
    e[i] = c[i]*(c[i]-1)//2

d = {}

for k in a:
    if d.get(k, "hello") == "hello":
        ans = 0
        for i in b:
            if i != k:
                ans += e[i]
            else:
                ans += e[i]+1-c[i]
        d[k] = ans
    else:
        ans = d[k]
    print(ans)


### FIXED CODE ###

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

c = {}

for i in a:
    c[i] = c.get(i, 0) + 1

ways = 0
for i in c:
    ways += c[i]*(c[i]-1)//2

for k in a:
    ans = ways-c[k]+1
    print(ans)
### BUGGY CODE ###

N, M = map(int,input().split())
alist = list()
for _ in range(M):
    alist.append(int(input()))


li = {}
li[0] = 1

for i in range(1,N+1):
    if i in alist:
        li[i] = 0
    else:
        if i == 1:
            li[i] = 1
        else:
            li[i] = li[i-1] + li[i-2]
print(li[N]%(10**9+7))

### FIXED CODE ###

N, M = map(int,input().split())
alist = list()
for _ in range(M):
    alist.append(int(input()))


li = {}
li[0] = 1

for i in range(1,N+1):
    if len(alist)>=1 and i ==  alist[0]:
        li[i] = 0
        alist.pop(0)
    else:
        if i == 1:
            li[i] = 1
        else:
            li[i] = ((li[i-1] + li[i-2])%(10**9+7))
print(li[N]%(10**9+7))
### BUGGY CODE ###

import numpy as np

def imos(n,k,a):
    
    l=np.zeros((n+1),dtype=np.int64)
    for i in range(n):
        ai=a[i]
        start=max(0,i-ai) #StartIndex
        end=min(n,i+ai+1) #EndIndex + 1
        l[start]+=1
        l[end]-=1
    return np.cumsum(l)[:n]

if __name__=="__main__":
    n,k=map(int, input().split())
    a=list(map(int, input().split()))
    for _ in range(k):
        a=imos(n,k,a)
        if a.min()==n:
            break   
    
    print(*a)


### FIXED CODE ###

import numpy as np
from numba import njit

@njit #処理の並列化
def imos(n,k,a):
    
    l=np.zeros((n+1),dtype=np.int64)
    for i in range(n):
        ai=a[i]
        start=max(0,i-ai) #StartIndex
        end=min(n,i+ai+1) #EndIndex + 1
        l[start]+=1
        l[end]-=1
    return np.cumsum(l)[:n]

if __name__=="__main__":
    n,k=map(int, input().split())
    a=list(map(int, input().split()))
    for _ in range(k):
        a=imos(n,k,a)
        if a.min()==n:
            break   
    
    print(*a)
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC138 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,q = LI()
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
#オイラーツアー
def dfs(x,p):
    lst.append(x)
    for i in graph[x]:
        if i != p:
            dfs(i,x)
    lst.append(p)
lst = []
dfs(0,-1)
lst.pop()
left,right = [-1]*n,[-1]*n
for i in range(2*n-1):
    if left[lst[i]] < 0:
        left[lst[i]] = i
for i in range(2*n-1)[::-1]:
    if right[lst[i]] < 0:
        right[lst[i]] = i
cnt = [0]*(2*n)
for _ in range(q):
    p,x = LI()
    cnt[left[p-1]] += x
    cnt[right[p-1]+1] -= x
cnt = list(accumulate(cnt))
ans = [cnt[left[i]] for i in range(n)]
print(*ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC138 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,q = LI()
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    g[a-1].append(b-1)

ans = [0]*n
for _ in range(q):
    p,x = LI()
    ans[p-1] += x

que = deque()
que.append(0)
check = [True]*n
while que:
    v = que.popleft()
    for i in g[v]:
        if check[i]:
            check[i] = False
            que.append(i)
            ans[i] += ans[v]
print(*ans)
### BUGGY CODE ###

import numpy as np
n=int(input())

a=(input().split())
#print(a)
ans=1

for i in range(n):
    ans=ans*int(a[i])


if ans>10**18:
    ans=-1

print(ans)

### FIXED CODE ###

import numpy as np
n=int(input())
ans=1
a=input().split()
#print(a)
if '0' in a:
    ans=0
    print(ans)
if ans!=0:
    for i in a:
        ans=ans*int(i)
        if ans>10**18:
            ans=-1
            break
    print(ans)
### BUGGY CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
dp = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    e = x * 2
    while e <= 10 ** 6:
        dp[e] = False
        e += x
ret = 0
for x in a:
    if c[x] == 1 and dp[x] == True:
        ret += 1
print(ret)


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
dp = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    e = x * 2
    while e <= 10 ** 6:
        dp[e] = False
        e += x
ret = 0
for x in a:
    if c[x] == 1 and dp[x] == True:
        ret += 1
print(ret)
### BUGGY CODE ###

def solve(string):
    n = len(string)
    q_pos = [i for i in range(n) if string[n - i - 1] == "?"]
    table = [[0] * 13 for _ in range(len(q_pos) + 1)]
    table[0][int(string.replace("?", "0")) % 13] = 1
    for i in range(len(q_pos)):
        base = 10**q_pos[i] % 13
        for j in range(13):
            for k in range(10):
                table[i + 1][(j + k * base) % 13] += table[i][j]
    return str(table[-1][5] % (10**9 + 7))


if __name__ == '__main__':
    print(solve(input()))


### FIXED CODE ###

def solve(string):
    n = len(string)
    q_pos = [i for i in range(n) if string[n - i - 1] == "?"]
    table = [[0] * 13 for _ in range(2)]
    table[0][int(string.replace("?", "0")) % 13] = 1
    for i in range(len(q_pos)):
        base = pow(10, q_pos[i], 13)
        for j in range(13):
            for k in range(10):
                table[1][(j + k * base) % 13] += table[0][j]
        for j in range(13):
            table[1][j] %= (10**9 + 7)
        table[0] = table[1]
        table[1] = [0] * 13
    return str(table[0][5])


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

import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main(n):
  for s in range(1, n+1):
    ans = 0
    for i in range(1, 101):
        for j in range(1, 101):
            for k in range(1, 101):
                if i*i + j*j + k*k + i*j + j*k + k*i == s:
                    ans += 1
    print(ans)
    ans = 0
 
if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')
 
    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)
 
    main = cc_export(main, (i8, ))
    cc.compile()
 
from my_module import main
 
N = int(read())
main(N)

### FIXED CODE ###

n = int(input())

ans = [0 for _ in range(10001)]

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            s = x*x + y*y + z*z + x*y + y*z + z*x
            if s <= 10000:
                ans[s] += 1

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

n, q = map(int, input().split())
nei = {}
for _ in range(q):
  t, u, v = map(int, input().split())
  if t == 0:
    if u not in nei:
      nei[u] = set()
    if v not in nei:
      nei[v] = set()
    nei[u].add(v)
    nei[v].add(u)
  else:
    flag = False
    stack = set()
    visited = set()
    stack.add(u)
    while stack:
      node = stack.pop()
      if node in visited:
        continue
      if node == v:
        flag = True
        break
      visited.add(node)
      if not nei.get(node, None):
        continue
      for next_node in nei[node]:
        stack.add(next_node)
    if flag:
      print(1)
    else:
      print(0)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)
n, q = map(int, input().split())
un = UnionFind(n)
for _ in range(q):
  t, u, v = map(int, input().split())
  if t == 0:
    un.union(u, v)
  else:
    print(1 if un.same(u, v) else 0)
### BUGGY CODE ###

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

b = []

for i in a:
    b.append(i)
    b.reverse()
    
print(*b)

### FIXED CODE ###

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

b = []

b_odd = []
b_even = []

for i in range(len(a)):
    if i%2==0:b_even.append(a[i])
    else:b_odd.append(a[i])

if len(a)%2==0:
    b_odd.reverse()
    b_odd+=b_even
    print(*b_odd)
else:
    b_even.reverse()
    b_even+=b_odd
    print(*b_even)
### BUGGY CODE ###

a=input()
n=len(a)
s=[]
for i in range(n):
  s.append(a[i])
flag=1
cnt=0

while(flag==1):
  flag=0
  for i in range(n-1):
    if s[i]=="B" and s[i+1]=="W":
      s[i]="W"
      s[i+1]="B"
      i+=1
      flag=1
      cnt+=1
print(cnt)

### FIXED CODE ###

a=input()
n=len(a)
s=[]
sb=0

for i in range(n):
  s.append(a[i])
b=s.count("B")
w=n-b
fb=int((2*n-b-1)*b/2)

for i in range(n):
  if s[i]=="B":
    sb+=i

print(fb-sb)
### BUGGY CODE ###

n = int(input())
a = [0]
a += list(map(int,input().split()))
b = [0]*n
for i in range(n):
    print(a.count(i+1))


### FIXED CODE ###

n = int(input())
a = [0]
a += list(map(int,input().split()))
b = [0]*n
for i in range(n-1,0,-1):
    b[a[i]-1] += 1
for i in b:
    print(i)
### BUGGY CODE ###

# coding: utf-8
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import lil_matrix

N,M,L=map(int, input().split())
RG=lil_matrix((N,N))

for i in range(M):
    f,t,c = map(int, input().split())
    if c <= L:
        RG[(f-1,t-1)] = c
        RG[(t-1,f-1)] = c

Rd = floyd_warshall(RG, directed=False)

FG=lil_matrix((N,N))
FG[Rd <= L] = 1

Fd = floyd_warshall(FG, directed=False)

Q=int(input())
for i in range(Q):
    s, t = map(int, input().split())
    v = Fd[s-1][t-1]
    if s == t:
        print (str(0))
    if v == float('inf'):
        print (str(-1))
    else:
        print (str(int(v-1)))


### FIXED CODE ###

# coding: utf-8
from scipy.sparse.csgraph import floyd_warshall

N,M,L=map(int, input().split())
RG=[[0 for i in range(N)] for j in range(N)]

for i in range(M):
    f,t,c = map(int, input().split())
    if c <= L:
        RG[f-1][t-1] = c
        RG[t-1][f-1] = c

Rd = floyd_warshall(RG, directed=False)

FG=[[0 for i in range(N)] for j in range(N)]
for i in range(N):
    for j in range(i+1, N):
        if Rd[i][j] <= L:
            FG[i][j] = 1
            FG[j][i] = 1

Fd = floyd_warshall(FG, directed=False)

Q=int(input())
for i in range(Q):
    s, t = map(int, input().split())
    v = Fd[s-1][t-1]
    if s == t:
        print (str(0))
    if v == float('inf'):
        print (str(-1))
    else:
        print (str(int(v-1)))
### BUGGY CODE ###


def solve():
    i = L//2019
    ans = 0
    if L <= 2019*i <= R:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
            if ans == 0:
                break
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()


### FIXED CODE ###


def solve():
    i = (L//2019) + 1
    ans = 0
    if L <= 2019*i <= R:
        print(ans)
    else:
        ans = 2020
        for n in range(L,R):
            for m in range(n+1,R+1):
                ans = min(ans, (n*m)%2019)
            if ans == 0:
                break
        print(ans)

if __name__ == "__main__":
    L,R = list(map(int, input().split()))
    solve()
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
 
from bisect import bisect_left 
cnt = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    t = L[i]+L[j]
    idx = bisect_left(L,t,lo=j+1)
    cnt += max(0,idx-j-1)
print(cnt)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
 
from bisect import bisect_left 
cnt = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    t = L[i]+L[j]
    idx = bisect_left(L,t,j+1)
    cnt += max(0,idx-j-1)
print(cnt)
### BUGGY CODE ###

import functools

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

lst_2 = lst[:]
res = 0
for i in range(n):
    lst_2 = lst[:]
    lst_2.pop(i)
    res = max(res, functools.reduce(gcd, lst_2))
print(res)

### FIXED CODE ###

import functools
 
n = int(input())
lst = list(map(int, input().split()))
 
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
    
lst_forward = []
a = lst[0]
for i in lst:
    a = gcd(a, i)
    lst_forward.append(a)

lst_backward = []
a = lst[-1]
for i in lst[::-1]:
    a = gcd(a, i)
    lst_backward.append(a)
lst_backward = list(reversed(lst_backward))

s = max(lst_backward[1], lst_forward[-2])
for i in range(1, n-1):
    s = max(s, gcd(lst_forward[i-1], lst_backward[i+1]))
print(s)
### BUGGY CODE ###

N = int(input())

state = [[-1] * N for i in range(N)]
for index in range(N):
    Ai = int(input())
    for naka in range(Ai):
        x, y = map(int, input().split()) 
        state[index][x - 1] = y
        # state[index][naka] = [x, y]


# print(state)


maxx = 0
for index in range(2 ** N):
    # print(index)
    person = index
    tempM = 0
    Ai = 0
    ok = 1
    while person > 0:
        if person % 2 == 1:
            tempM += 1
            for i in range(N):
                if state[Ai][i] != -1:
                    # print(str(Ai) + " " + str(i))
                    # print(str(state[Ai][i]) + " " + str((index // (2 ** i)) % 2))
                    # print()
                    if state[Ai][i] != (index // (2 ** i)) % 2:
                        ok = 0
                
        
        person //= 2
        Ai += 1
    
    if ok == 1:
        maxx = max(maxx, tempM)

print(maxx)

### FIXED CODE ###

N = int(input())

state = [[-1] * N for i in range(N)]
for index in range(N):
    Ai = int(input())
    for naka in range(Ai):
        x, y = map(int, input().split()) 
        state[index][x - 1] = y
        # state[index][naka] = [x, y]


# print(state)


maxx = 0
for index in range(1, 2 ** N):
    # print(index)
    person = index
    tempM = 0
    Ai = 0
    ok = 1
    while person > 0:
        if ok == 0:
            break
        if person % 2 == 1:
            tempM += 1
            for i in range(N):
                if state[Ai][i] != -1:
                    # print(str(Ai) + " " + str(i))
                    # print(str(state[Ai][i]) + " " + str((index // (2 ** i)) % 2))
                    # print()
                    if state[Ai][i] != (index // (2 ** i)) % 2:
                        ok = 0
                        break
                
        
        person //= 2
        Ai += 1
    
    if ok == 1:
        maxx = max(maxx, tempM)

print(maxx)
### BUGGY CODE ###

import itertools
import math
k=int(input())
s=0
for a,b,c in itertools.product(range(1,k+1), repeat=3):
    g=math.gcd(math.gcd(a,b),c)
    s+=g
print(s)


### FIXED CODE ###

k=int(input())
s=0
import math
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            s+=math.gcd(math.gcd(a,b),c)
print(s)
### BUGGY CODE ###

# 解説YouTubeを参考（写経）
S = input()
N = 13
dp = [0 for _ in range(N)]
dp[0] = 1

mod = 1e9+7
mul = 1
for i in range(len(S)-1, -1, -1):
  nextDP = [0 for _ in range(N)]
  c = S[i]
  if c=="?":
    for k in range(10):
      for j in range(N):
        nextDP[(k*mul + j)%N] += dp[j]
        nextDP[(k*mul + j)%N] %= mod  
  else:
    k = int(c)
    for j in range(N):
      nextDP[(k*mul + j)%N] += dp[j]
      nextDP[(k*mul + j)%N] %= mod  
    
  mul *= 10
  mul %= N
  dp = nextDP
print(int(dp[5]))

### FIXED CODE ###

# 解説YouTubeを参考（写経）
S = input()
N = 13
dp = [0 for _ in range(N)]
dp[0] = 1

mod = 1e9+7
mul = 1
for i in range(len(S)-1, -1, -1):
  nextDP = [0 for _ in range(N)]
  c = S[i]
  if c=="?":
    for k in range(10):
      for j in range(N):
        nextDP[(k*mul + j)%N] += dp[j]
        nextDP[(k*mul + j)%N] %= mod  
  else:
    k = int(c)
    for j in range(N):
      nextDP[(k*mul + j)%N] += dp[j]
      nextDP[(k*mul + j)%N] %= mod  
    
  mul *= 10
  mul %= N
  dp = nextDP
print(int(dp[5]))
### BUGGY CODE ###

# 初期入力
import numpy as np 
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A.sort()
A_np =np.array(A,dtype=np.int64)
A_set =set(A)
count =set()
for i in range(N):
    if np.count_nonzero(A[i] %A_np[:i] ==0) >=1:
            count.add(A[i])
ans =len(A_set - count)
print(ans)

### FIXED CODE ###


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

	

from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)
### BUGGY CODE ###

def christmas_eve(n,k,h):
    _h = sorted(h)
    opt = 0
    ans = 10**9 + 1

    for i in range(n-(k-1)):
        l = _h[i:i+k]
        opt = max(l) - min(l)
        if ans > opt:
            ans = opt

    return ans
if __name__ == '__main__':
    n,k = map(int,raw_input().split())
    h = [int(raw_input()) for _ in range(n)]


    print christmas_eve(n,k,h)

### FIXED CODE ###

def christmas_eve(n,k,h):
    _h = sorted(h)
    opt = 0
    ans = 10**9 + 1
    _k = k - 1
    loop = n - _k
    for i in range(loop):
        opt = _h[i+_k] - _h[i]
        if ans >= opt:
            ans = opt

    return ans
if __name__ == '__main__':
    n,k = map(int,raw_input().split())
    h = [int(raw_input()) for _ in range(n)]

    print christmas_eve(n,k,h)
### BUGGY CODE ###

INF=10**18
N,M=map(int,input().split())

a,c=[],[]
for i in range(M):
    A,B=map(int,input().split())  
    C=list(map(int,input().split()))
    tmp=0
    for j in range(B):
      tmp+=1<<(C[j]-1)
    a.append(A)
    c.append(tmp)
    
dp=[[INF]*(1<<N) for i in range(M+1)]
dp[0][0]=0
for i in range(M):
    for j in range(1<<N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        o=(j | c[i])
        dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i])
ans=dp[M][2**N-1]
print(ans if ans!=INF else -1)

### FIXED CODE ###

INF=10**18
N,M=map(int,input().split())

a,c=[],[]
for i in range(M):
    A,B=map(int,input().split())  
    C=list(map(int,input().split()))
    tmp=0
    for j in range(B):
      tmp+=1<<(C[j]-1)
    a.append(A)
    c.append(tmp)
    
dp=[[INF]*(1<<N) for i in range(M+1)]
dp[0][0]=0
for i in range(M):
    for j in range(1<<N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        o=(j | c[i])
        dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i])
ans=dp[M][2**N-1]
print(ans if ans!=INF else -1)
### BUGGY CODE ###

def Count(n, lis):
    for i in lis:
        if lis.count(i) > 1:
            return 'NO'
    return 'YES'

num = int(input())
l = list(map(int,input().split()))
print(Count(num,l))
    

### FIXED CODE ###

num = int(input())
l = list(map(int,input().split()))
print('NO') if len(l) != len(set(l)) else print('YES')
### BUGGY CODE ###

N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
ans = [0]*(N-K+1)
score = 1
for i in range(K):
    score *= A[i]
for i in range(K, N):
    ans[i - K] = score
    score //= A[i - K]
    score *= A[i]
ans[-1] = score
print("\n".join(["Yes" if ans[i] > ans[i-1] else "No" for i in range(1,len(ans))]))

### FIXED CODE ###

N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
ans = ["Yes" if A[i] > A[i - K] else "No" for i in range(K,N)]
print("\n".join(ans))
### BUGGY CODE ###

from bisect import*
N,*L=map(int,open(0).read().split());L.sort()
a=0
for i,l in enumerate(L):
    for j,m in enumerate(L[i+1:],i+1):
      	a+=bisect_left(L,l+m,j+1)-bisect(L,abs(l-m),j+1)
print(a)

### FIXED CODE ###

from bisect import*
N,*L=map(int,open(0).read().split());L.sort()
a=0
l=[]
r=[]
for i in range(1001):
    l.append(bisect_left(L,i))
    r.append(bisect(L,i))
for p in L:
    for q in L:
        x=p+q
        y=abs(p-q)
        a+=(l[x]if x<1001else N)-(r[y]if 0<y<1001else(y>1000)*N)
for p in L:
    x=2*p
    a-=3*(l[x]if x<1001else N)
print((a+2*N)//6)