Harryxun/stf_run huggingface dataset:
import numpy as np

N,M,X = map(int, input().split())

values = []
scores = []
greedy = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    values.append(tmp[0])
    scores.append(tmp[1:])
    greedy.append(np.sum(scores)/tmp[0])

values = np.array(values)
scores = np.array(scores)

selected = []
finished = []
finisheds = np.zeros(M)
ans = 0
while len(finished) != M and np.sum(greedy)!=0:
    arg = np.argmax(greedy)
    selected.append(arg)
    finisheds += scores[arg]
    ans += values[arg]
    scores[selected] = 0
    args = np.where(finisheds>=X)[0]
    finished.extend(list(args))
    finished = list(set(finished))
    for arg in args:
        scores[:, arg] = 0
    greedy = np.sum(scores, axis=1)/values
    for arg in finished:
        greedy[arg] = 0

if len(finished) == M:
    print(ans)
else:
    print(-1)



### FIXED CODE ###

import numpy as np

N,M,X = map(int, input().split())

values = []
scores = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    values.append(tmp[0])
    scores.append(tmp[1:])
scores = np.array(scores)
values = np.array(values)

def df(arg, score, tmp,args):
    tmps = []
    if arg==N:
        if len(np.where(score>=X)[0]) == M:
            return tmp
        else:
            return 0
    check = df(arg+1, score, tmp, args)
    if check:
        if type(check)==list:
            tmps.extend(check)
        else:
            tmps.append(check)
    check = df(arg+1, score+scores[arg], tmp+values[arg], args+[arg])
    if check:
        if type(check)==list:
            tmps.extend(check)
        else:
            tmps.append(check)
    if tmps == []:
        return 0
    else:
        return tmps

tmp = df(0, np.zeros(M), 0, [])
if tmp != 0:
    print(min(tmp))
else:
    print(-1)
import numpy as np
N = int(input())
W_list = [int(i) for i in input().split(" ")]
ans = np.abs(W_list[0] - np.sum(W_list[1:N]))
sum_list = np.sum(W_list)
sum_front = 0
for j in range(2, N):
  	sum_front += W_list[j]
    difference = np.abs(sum_list - 2 * sum_front)
    if difference < ans:
        ans = difference
    else:
        break
 
print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
W_list = [int(i) for i in input().split(" ")]
ans = np.abs(W_list[0] - np.sum(W_list[1:N]))
for j in range(2, N):
    difference = np.abs(np.sum(W_list[:j]) - np.sum(W_list[j:N]))
    if difference < ans:
        ans = difference
    else:
        break

print(ans)
from math import gcd
a,b,c,d = map(int, input().split())
c_n = b//c - (a-1)//c
d_n = b//d - (a-1)//d
l = (c*d)//gcd(c,d)
l_n = b//l - (a-1)//l
print(b - a - c_n - d_n + l_n + 1)

### FIXED CODE ###

from fractions import gcd
a,b,c,d = map(int, input().split())
c_n = b//c - (a-1)//c
d_n = b//d - (a-1)//d
l = (c*d)//gcd(c,d)
l_n = b//l - (a-1)//l
print(b - a - c_n - d_n + l_n + 1)
import sys
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
md=10**9+7

n,m=map(int,input().split())
s=[[0,0]]
if m==1:
  s.append([1,1])
for i in range(2,int(m**(0.5)+1)):
  k=0
  frag = 0
  if m%i!=0:
    frag = 1
  while m%i==0:
    m=int(m/i)
    k=k+1
  if frag == 0:
    s.append([i,k])
if m!=1:
  s.append([m,1])
q = [0]*(len(s)-1)
for i in range(1,len(s)):
  q[i-1] = s[i][1]

t = 1
for i in range(len(q)):
  c = cmb(n-1+q[i],q[i])
  t = t*(c%md)
  
print(t%md)

### FIXED CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    elif n<r: return 0
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
md=10**9+7

n,m=map(int,input().split())
s=[[0,0]]
for i in range(2,int(m**(0.5)+1)):
  k=0
  frag = 0
  if m%i!=0:
    frag = 1
  while m%i==0:
    m=int(m/i)
    k=k+1
  if frag == 0:
    s.append([i,k])
if m!=1:
  s.append([m,1])
q = [0]*(len(s)-1)
for i in range(1,len(s)):
  q[i-1] = s[i][1]

t = 1
for i in range(len(q)):
  c = cmb(n-1+q[i],q[i])
  t = t*(c%md)
  
print(t%md)
n,a,b=map(int,input().split())
ans=0
for i in range(n+1):
    if a<=sum(list(map(int, sum(str(i)))))<=b:
        ans += i
print(ans)

### FIXED CODE ###

A,B,C,D =map(int,input().split())
if A+B>C+D:
  print("Left")
elif A+B==C+D:
  print("Balanced")
else:
  print("Right")
a, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)    

### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
  if a <= sum(list(map(int, list(str(i))))) <= b:
    ans += i
print(ans)
import collections
N, K, L = map(int, input().split())
road = [{"Connected":[],"set":0,"seen":False} for _ in range(N)]
rail = [{"Connected":[],"set":0,"seen":False} for _ in range(N)]

def dfs(graph, v, num): #深さ優先探索
    graph[v]["seen"] = True
    graph[v]["set"] = num
    for next_v in set(graph[v]["Connected"]):
        if graph[next_v]["seen"]:
            continue
        dfs(graph, next_v, num)

for X in ((road, K), (rail, L)): #結合を入力
    for _ in range(X[1]):
        p, q = map(int, input().split())
        X[0][p-1]["Connected"].append(q-1)
        X[0][q-1]["Connected"].append(p-1)

for X in [road, rail]: #探索して連結成分に分解
    set_index = 0
    for v in range(N):
        if X[v]["seen"]:
            continue
        dfs(X, v, set_index)
        set_index += 1
        

List = [(road[i]["set"],rail[i]["set"]) for i in range(N)]
counter = collections.Counter(List)
for A in List:
    print(counter[A],end=" ")
        


### FIXED CODE ###

N, K, L = map(int, input().split())

def fp(x, parentList): #findParent
    if parentList[x] == x:
        return x
    else:
        parentList[x] = fp(parentList[x], parentList)
        return parentList[x]

#各ノードのparentをリストで表現(連結前は自身がparent)
road = [i for i in range(N)]
rail = [i for i in range(N)]

for _ in range(K):
    p, q = map(int, input().split())
    par_p, par_q = fp(p-1, road), fp(q-1, road) #p, qのparent 
    #連結する際、若い番号をparentとする
    if par_p < par_q:
        road[par_q] = par_p
    else:
        road[par_p] = par_q

#railについても同様
for _ in range(L):
    s, t = map(int, input().split())
    par_s, par_t = fp(s-1, rail), fp(t-1, rail)
    if par_s < par_t:
        rail[par_t] = par_s
    else:
        rail[par_s] = par_t

#連結成分の要素をカウント
cnt = {}
for i in range(N):
    key = (fp(i,road),fp(i,rail))
    if key in cnt:
        cnt[key] += 1
    else:
        cnt[key] = 1
#出力
for i in range(N):
    key = (fp(i,road),fp(i,rail))
    ans = cnt[key]
    print(ans, end=" ")
num = 1
num1 = 0
N = input()
H = list(map(int, input().split())
for i in range(1,N) :
  if H[i] >= H[i-1] :
    num += 1
  else :
    num1 += 1
print(a)

### FIXED CODE ###

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

cnt = 0
for i in range(len(H)):
    if (max(H[0:i+1]) == H[i]):
        cnt += 1

print(cnt)
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[i]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(min(K,50)):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[x]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

threshhold = int(sum(A)/(4 * M))

##print(threshhold)

c = 0
for val in A:
  if val > threshhold:
    ##print(val)
    c += 1

if M > c:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

i = input()
l = i.split()
print(l[2] + ' ' + l[0] + ' ' + l[1])
a = int(input())
b = int(input())

print(a*b)
print(2a + 2b)


### FIXED CODE ###

a,b = map(int,input().split())
print(a * b,(a + b) * 2)
def swap(A,i,j):
    A[i],A[j] = A[j],A[i]
    return A

def mincost(A):
    B = sorted(A)
    cost = 0
    
    for i, bi in enumerate(B):
        t = 0
        j = A.index(bi)
        tmp_cost = 0
        
        # swap in a cyclic group
        while j != i:
            t += 1
            bj = B[j]
            k = A.index(bj)
            tmp_cost += bi + bj
            swap(A,j,k)
            j = k
        
        # diff. to swap with min(B)
        dec = t * (bj - B[0])
        inc = 2 * (bj + B[0])
        
        if dec < inc:
            cost += tmp_cost
        else:
            cost += tmp_cost - dec + inc
    return cost

if __name__ == "__main__":
    input()
    A = list(map(int, input().strip().split()))
    cost = mincost(A)
    print(cost)

### FIXED CODE ###

def swap(A,i,j):
    A[i],A[j] = A[j],A[i]
    return A

def mincost(A):
    B = sorted(A)
    cost = 0
    b0 = B[0]
    
    for i, bi in enumerate(B):
        t = 0
        j = A.index(bi)
        tmp_cost = 0
        
        # swap in a cyclic group
        while j != i:
            t += 1
            bj = B[j]
            k = A.index(bj)
            tmp_cost += bi + bj
            swap(A,j,k)
            j = k
        
        # diff. to swap with min(B)
        dec = t * (bi - b0)
        inc = 2 * (bi + b0)
        
        if dec < inc:
            cost += tmp_cost
        else:
            cost += tmp_cost - dec + inc
    return cost

if __name__ == "__main__":
    input()
    A = list(map(int, input().strip().split()))
    cost = mincost(A)
    print(cost)
n = int(input())
s = input()
out = 0

def rgb (tmpstr, j, i, s):
    if s[j] != s[i]:
        tmpstr = s[j + 1 :  n]
        remain = "RGB".replace(s[j],"").replace(s[i],"")
        num = tmpstr.count(remain) 
        if (j + (j - i)) < len(s):
            if  s[j + (j - i)]  == remain:
                num = num - 1
        return num
    else:
        return 0
    
    
out = sum([sum([rgb(s[j + 1 :  n], j, i, s) for j in range(i+1, n-1)]) for i in range(n-2)])
#for i in range(n-2):
#    out += sum([rgb(s[j + 1 :  n], j, i, s) for j in range(i+1, n-1)])
print(out)



### FIXED CODE ###

s = input()
if s.find("7") != -1:
    print ("Yes")
else:
    print ("No")
import math
N=int(input())
A=list(map(int,input().strip().split(' ')))



GG=[0]*N
GG[0]=A[0]
for i in range(1,N):
    GG[i]=math.gcd(GG[i-1],A[i])

GG2=[0]*N
GG2[-1]=A[-1]

for i in range(2,N+1):
    GG2[-i]=math.gcd(GG2[-(i-1)],A[-i])

ans=[0]*N

ans[0]=GG2[1]
ans[-1]=GG[N-2]
#print(GG)
#print(GG2)
#print(ans)


temp=ans[0]
for i in range(1,N-1):
    ans[i]=math.gcd(GG[i-1],GG2[i+1])
    if ans[i]>temp:
        temp=ans[i]
if ans[-1]>temp:
    temp=ans[-1]


print(temp)    

### FIXED CODE ###

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

def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
  

GG=[0]*N
GG[0]=A[0]
for i in range(1,N):
    GG[i]=gcd(GG[i-1],A[i])

GG2=[0]*N
GG2[-1]=A[-1]

for i in range(2,N+1):
    GG2[-i]=gcd(GG2[-(i-1)],A[-i])

ans=[0]*N

ans[0]=GG2[1]
ans[-1]=GG[N-2]
#print(GG)
#print(GG2)
#print(ans)


temp=ans[0]
for i in range(1,N-1):
    ans[i]=gcd(GG[i-1],GG2[i+1])
    if ans[i]>temp:
        temp=ans[i]
if ans[-1]>temp:
    temp=ans[-1]


print(temp)
from math import ceil
def gcd(a,b):
  while b:
    a,b = b,a%b  
  return a

def lcm(a,b):
  return a*b//gcd(a,b)  
  
n,m = map(int,input().split())
A = list(map(int,input().split()))

A = [a//2 for a in A]

pre = None
for a in A:
  c = 0
  while a % 2 ==0:
    a //= 2 
    c += 1    
  if pre is None:    
    pre = c
  elif pre != c:
    print(0)
    exit()
  
ans = lcm(A[0],A[1])  
for i in range(n-2):  
  if ans > m:
    ans = 0
    break
  for i in range(len(A)-2):
    ans = lcm(ans,A[i+2])  

print(ceil((m//ans)/2))  

### FIXED CODE ###

from math import ceil
def gcd(a,b):
  while b:
    a,b = b,a%b  
  return a

def lcm(a,b):
  return a*b//gcd(a,b)  
  
n,m = map(int,input().split())
A = list(map(int,input().split()))

A = [a//2 for a in A]

pre = None
for a in A:
  c = 0
  while a % 2 ==0:
    a //= 2 
    c += 1    
  if pre is None:    
    pre = c
  elif pre != c:
    print(0)
    exit()

if n == 1:
  ans = A[0]
else:
  ans = lcm(A[0],A[1])  
  for i in range(n-2):  
    if ans > m:
      print(0)
      exit()
    ans = lcm(ans,A[i+2])  

print(ceil((m//ans)/2))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def dfs(x, y, symbol,land):
    if land[y][x] != '.':
        return ([land[y][x]] if not str(land[y][x]).isnumeric() else False), 0
    land[y][x] = symbol
    count = 1
    dxdy = [(1,0),(-1,0),(0,1),(0,-1)]

    owner_list = []
    for dx,dy in dxdy:
        if 0 <= x + dx < len(land[0]) and 0 <= y + dy < len(land):
            ret,c = dfs(x + dx, y + dy, symbol,land)
            count += c

            if ret is not False:
                owner_list += ret
    return (list(set(owner_list)), count)

while True:
    w,h = map(int,input().split())
    if w == 0 and h == 0:
        break
    land = [list(input()) for i in range(0,h)]

    symbol = 0
    count_dict = {'W' :0, 'B' :0}

    for y in range(h):
        for x in range(w):
            if land[y][x] == '.':
                ret, count = dfs(x,y,symbol,land)
                if len(ret) == 1:
                    count_dict[ret[0]] += count
                symbol += 1
    print(count_dict['B'],count_dict['W'])

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def dfs(x, y, symbol,land):
    if land[y][x] != '.':
        return ([land[y][x]] if not str(land[y][x]).isnumeric() else False), 0
    land[y][x] = symbol
    count = 1
    dxdy = [(1,0),(-1,0),(0,1),(0,-1)]

    owner_list = []
    for dx,dy in dxdy:
        if 0 <= x + dx < len(land[0]) and 0 <= y + dy < len(land):
            ret,c = dfs(x + dx, y + dy, symbol,land)
            count += c

            if ret is not False:
                owner_list += ret
    return (list(set(owner_list)), count)

while True:
    w,h = map(int,input().split())
    if w == 0 and h == 0:
        break
    land = [list(input()) for i in range(0,h)]

    symbol = 0
    count_dict = {'W' :0, 'B' :0}

    for y in range(h):
        for x in range(w):
            if land[y][x] == '.':
                ret, count = dfs(x,y,symbol,land)
                if len(ret) == 1:
                    count_dict[ret[0]] += count
                symbol += 1
    print(count_dict['B'],count_dict['W'])
N,L=list(map(int,input().split()))
taste=[]
taste1=[]
memo=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    if L+i<0:
        memo.append(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
memo=sorted(memo)
pie=(sum-memo[-1])
print(pie)

### FIXED CODE ###

N,L=list(map(int,input().split()))
taste=[]
taste1=[]
memo=[]
sum=0
for i in range(N):
    tasty=abs(L+i)
    if L+i<=0:
        memo.append(L+i)
    taste.append(tasty)
    taste1.append(L+i)
    sum+=taste1[i]
tasteab=sorted(taste)
memo=sorted(memo)
if memo!=[]:
    pie=(sum-memo[-1])
else:
    pie=(sum-tasteab[0])
print(pie)
H = int(input())
W = int(input())

if H % 2 ==0:
  N = H * W / 2

else:
  N = int(H * W / 2) + 1

print(N)

### FIXED CODE ###

H , W = map(int, input() .split())

if W == 1:
    N = 1

elif H == 1:
    N = 1

else:   
    if H % 2 ==0:
        N = H * W / 2
        
            
    elif H % 2 ==1:
        if W % 2 ==0:
            N = H * W / 2
        else:
            N = int(H * W / 2) + 1

print(int(N))
n,k=map(int,input().split())
A=[]
for i in range(n):
  A.append(int(input())-k)
AA,BB=[0]*(n+1),[0]*(n+1)
AA[-2]=A[-1]
BB[-2]=A[-1]
for i in reversed(range(n-1)):
  AA[i]=AA[i+1]+A[i]
  BB[i]=BB[i+1]+A[i]
BB.sort()
cur=1
D=dict()
D[BB[0]]=cur
for i in range(1,n+1):
  if BB[i]==BB[i-1]:
    continue
  else:
    cur+=1
    D[BB[i]]=cur
AAA=[0]*(n+1)
for i in range(n+1):
  AAA[i]=D[AA[i]]

import math
n_max=2*10**5
nn=int(math.log2(n_max))+1
BIT=[0]*(2**nn)
BIT.insert(0,0)
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s
def bitadd(BIT,i,x):
  while i<=2**nn:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

ans=0
for i in range(n+1):
  ans+=i-bitsum(BIT,AAA[i]-1)
  bitadd(BIT,AAA[i],1)
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
A=[]
for i in range(n):
  A.append(int(input())-k)
AA,BB=[0]*(n+1),[0]*(n+1)
AA[-2]=A[-1]
BB[-2]=A[-1]
for i in reversed(range(n-1)):
  AA[i]=AA[i+1]+A[i]
  BB[i]=BB[i+1]+A[i]
BB.sort()
cur=1
D=dict()
D[BB[0]]=cur
for i in range(1,n+1):
  if BB[i]==BB[i-1]:
    continue
  else:
    cur+=1
    D[BB[i]]=cur
AAA=[0]*(n+1)
for i in range(n+1):
  AAA[i]=D[AA[i]]

nn=18
BIT=[0]*(2**nn)
BIT.insert(0,0)
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s
def bitadd(BIT,i,x):
  while i<=2**nn:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

ans=0
for i in range(n+1):
  ans+=i-bitsum(BIT,AAA[i]-1)
  bitadd(BIT,AAA[i],1)
print(ans)
a,b=map(int(input().split()))
print(a*b)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
w, h, x, y = [int(i) for i in input().split(' ')]

m_x, m_y = w / 2, h / 2

a = (x - m_x) / (y - m_y)

print(w * h / 2, 1 if x == m_x and y == m_y else 0)

### FIXED CODE ###

w, h, x, y = [int(i) for i in input().split(' ')]

m_x, m_y = w / 2, h / 2

print(w * h / 2, 1 if x == m_x and y == m_y else 0)
n,k=map(int,input().split())
v=list(map(int,input().split()))
a=[[v[:k],[]]]
for i in range(1,min(n,k)):
     l=v[:k-i]
     r=v[-i:][::-1]
     a.append([l,r])
a.append([[],v[-min(n,k):][::-1]])
ma=0
for a_ in a:
     l=a_[0]
     r=a_[1]
     su=sum(l)+sum(r)
     for i in range(k//2):
          if len(r)==0:
               l_=l.pop()
               su-=l_
               mi=min(l)
               l.remove(mi)
               su-=mi
               ma=max(ma,su)
          elif len(l)==0:
               r_=r.pop()
               su-=r_
               mi=min(r)
               r.remove(mi)
               su-=mi
               ma=max(ma,su)
          else:
               l_=l.pop()
               r_=r.pop()
               try:
                    l_mi=min(l)
               except:
                    l_mi=10**7+1
               try:
                    r_mi=min(r)
               except:
                    r_mi=10**7+1
               if l_mi>r_mi:
                    if r_mi<0:
                         r.remove(r_mi)
                         su-=r_mi
               else:
                    if l_mi<0:
                         l.remove(l_mi)
                         su-=l_mi
               if l_>r_:
                    l.append(l_)
                    su-=r_
               else:
                    r.append(r_)
                    su-=l_
               ma=max(ma,su)
print(ma)

### FIXED CODE ###

n,k=map(int,input().split())
v=list(map(int,input().split()))
ma=0
for i in range(k//2+1):
     pick=min(k-i,n)
     for j in range(pick+1):
          if j==0:
               l=v[:pick]
               al=l
          elif j==pick:
               r=v[-pick:]
               al=r
          else:
               l=v[:pick-j]
               r=v[-j:]
               al=l+r
          for rem in range(i):
               if len(al)>0:
                    mi=min(al)
                    if mi<0:
                         al.remove(mi)
                    else:
                         break
               else:
                    break
          if len(al)>0:
               ma=max(ma,sum(al))
print(ma)
N,A,B = map(int,input().split())
if (B-A)%2==0:
    print(str(int(B-(B+A)/2)))
else:
    if B-A==1:
        if N-A>B-1:
            print(B-1)
        else:
            rint(N-A)
    else:
        if N-A>B-1:
            print(A+(A-B)/2)
        else:
            print(B+(B-A)/2)


### FIXED CODE ###

N,A,B = map(int,input().split())
if (B-A)%2==0:
    print(str(int(B-(B+A)//2)))
else:
    if N-B>A-1:
        print(str(int(A+(B-A-1)//2)))
    else:
        print(str(int(N-B+1+(B-A-1)//2)))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


mod = 1e9 + 7
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) / gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek / a[i]
print(int(s % mod))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)


def gcd(aa, b):
    if b == 0:
        return aa
    return gcd(b, aa % b)


mod = int(1e9 + 7)
n = int(input())
a = [int(i) for i in input().split()]
kek = 1
for i in range(n):
    kek = (kek * a[i]) // gcd(kek, a[i])
s = 0
for i in range(n):
    s += kek // a[i]
print(int(s % mod))
from collections import defaultdict
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
result = {}
md = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            p = di[i][0] - di[j][0]
            q = di[i][1] - di[j][1]
            result[(p,q)] = result.get((p,q), 0)+1
            md[(p,q)] += 1
#print(result)
print(n - max(result.values()))
#print(md)
#print(n - max(md.values()))

### FIXED CODE ###

#from collections import defaultdict
n = int(input())
di = [list(map(int, input().split(' '))) for _ in range(n)]
result = {0:0}
#md = defaultdict(int)
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            p = di[i][0] - di[j][0]
            q = di[i][1] - di[j][1]
            result[(p,q)] = result.get((p,q), 0)+1
            #md[(p,q)] += 1
#print(result)
print(n - max(result.values()))
#print(md)
#print(n - max(md.values()))
nk=input().split()
n=int(nk[0])
k=int(nk[1])
data=list(map(int,input().split()))
data2=data.sort()
s=0
for i in range(k):
    s += data2[i]
print(s)

### FIXED CODE ###

nk=input().split()
n=int(nk[0])
k=int(nk[1])
data=list(map(int,input().split()))
data.sort()
s=0
for i in range(k):
    s += data[i]
print(s)
H, W = [int(i) for i in input().split()]
N = int(input())
a = [int(i) for i in input().split()]
c = [[0 for j in range(W)] for i in range(H)]
w = 0
h = 0
for i in range(N):
    for j in range(a[i]):
        c[h][w] = i+1
        if h%2 == 0:
            if w < W - 1:
                w += 1
            else:
                h += 1
        else:
            if w > 0:
                w -= 1
            else:
                h += 1
for i in range(H):
    print(*c[i]

### FIXED CODE ###

H, W = [int(i) for i in input().split()]
N = int(input())
a = [int(i) for i in input().split()]
c = [[0 for j in range(W)] for i in range(H)]
w = 0
h = 0
for i in range(N):
    for j in range(a[i]):
        c[h][w] = i+1
        if h%2 == 0:
            if w < W - 1:
                w += 1
            else:
                h += 1
        else:
            if w > 0:
                w -= 1
            else:
                h += 1
for i in range(H):
    print(*c[i])
s = input()
 
for i in range(len(s))
	if i%2==0 and s(i)=='R':
    print('No')
    exit()
    elif i%2==1 and s(i)=='L':
    print('No')
    exit()

print('Yes')

### FIXED CODE ###

s = input()
 
for i in range(len(s)):
	if i%2==1 and s[i]=='R':
		print('No')
		exit()
	elif i%2==0 and s[i]=='L':
		print('No')
		exit()
 
print('Yes')
def inpl(): return list(map(int,input().split()))
 
N, W = inpl()
dp = [[0]*W for _ in range(N+1)]
for n in range(1,N+1):
  w, v = inpl()
  for x in range(W+1):
    if x < w:
      dp[n][x] = dp[n-1][x]
    else:
      dp[n][x] = max(dp[n-1][x], dp[n-1][x-w] + v)
print(dp[-1][-1])


### FIXED CODE ###

def inpl(): return list(map(int,input().split()))
 
N, W = inpl()
dp = [[0]*(W+1) for _ in range(N+1)]
for n in range(1,N+1):
  w, v = inpl()
  for x in range(W+1):
    if x < w:
      dp[n][x] = dp[n-1][x]
    else:
      dp[n][x] = max(dp[n-1][x], dp[n-1][x-w] + v)
print(dp[-1][-1])
# -*- coding: utf-8 -*-

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

for i in range(a, b+1):
    if i // 10000 == i % 10 and (i // 1000) % 10 == (i % 100) // 10:
        n += 1

print(n)


### FIXED CODE ###

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

print(input()[0] + input()[1] + input()[2])