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

import sys
from operator import itemgetter
input = sys.stdin.readline

_n, _k = map(int, input().split())
_a = input()[:-1]
_f = input()[:-1]
alist = [item for item in map(int, _a.split())]
flist = [item for item in map(int, _f.split())]


def chker(costs, diffs, max_k):
    if sum(costs) <= max_k:
        print(0)
        return

    costs.sort()
    diffs.sort(reverse=True)
    sclist = sorted([[item1, item2, item1 * item2] for item1, item2 in zip(costs, diffs)], key=itemgetter(2), reverse=True)
    for k in range(max_k, 0, -1):
        sclist[0][0] = sclist[0][0] - 1
        if sclist[0][0] == 0:
            sclist = sclist[1:]
        else:
            sclist[0][2] = sclist[0][0] * sclist[0][1]
            sclist.sort(key=itemgetter(2), reverse=True)

    print(sclist[0][2])


chker(alist, flist, _k)


### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.readline

_n, _k = map(int, input().split())
alist = [int(item) for item in input().split()]
flist = [int(item) for item in input().split()]


def chker(costs, diffs, max_k):
	costs = np.sort(costs)[::-1]
	diffs = np.sort(diffs)
	
	_min, _max = 0, 10 ** 12
	while _min < _max:
		_mid = (_min + _max) // 2
		cnt = costs - _mid // diffs
		if cnt[cnt > 0].sum() <= max_k:
			_max = _mid
		else:
			_min = _mid + 1


	print(_min)


chker(alist, flist, _k)
### BUGGY CODE ###

N = int(input()) # 数字を変数に格納

result = 0

for i in range(N-1):
    result += (i+1)

print(result)

### FIXED CODE ###

N = int(input())

if N % 2 == 0:
    result = N // 2
    result = result * (N - 1)
elif N % 2 == 1:
    result = (N - 1) // 2
    result = result * N

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

import math
import random
import heapq
from collections import Counter, defaultdict
from decimal import Decimal, ROUND_HALF_UP, ROUND_CEILING
from functools import lru_cache, reduce
from itertools import combinations_with_replacement, product, combinations


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


# @lru_cache(size=None)
def slv(S, K):
    d = set([])
    for i in range(len(S)):
        for j in range(i + 1, len(S) + 1):
            d.add(S[i:j])
    return sorted(d)[K - 1]


def main():
    S = read_str()
    K = read_int()
    print(slv(S, K))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import math
import random
import heapq
from collections import Counter, defaultdict
from decimal import Decimal, ROUND_HALF_UP, ROUND_CEILING
from functools import lru_cache, reduce
from itertools import combinations_with_replacement, product, combinations


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def slv(S, K):
    d = set([])
    for i in range(len(S)):
        for j in range(i + 1, i + 1 + K):
            d.add(S[i:j])

    return sorted(d)[K - 1]


def main():
    S = read_str()
    K = read_int()
    # K = 3
    # S = ''.join([random.choice('abcdefghijklmnopqrstu') for _ in range(5000)])
    print(slv(S, K))


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

x = input()

l = len(x)
r = 0
while l != r:
    l = len(x)
    x = x.replace("ST", "")
    r = len(x)

print(r)

### FIXED CODE ###

x = input()

s = [""]
for xi in x:
    if xi == "S":
        s.append(xi)
    elif xi == "T":
        if s[-1] == "S":
            s.pop()
        else:
            s.append(xi)

print(len(s) - 1)
### BUGGY CODE ###

n = int(input())
light = 1
count = 0
a = []
his = []
for i in range(n):
    a.append(int(input()))
while light not in his:
    his.append(light)
    light = a[light-1]
    count += 1
    if light == 2:
        print(count)
        quit()
print(-1)


### FIXED CODE ###

n = int(input())
light = 1
count = 0
a = []
for i in range(n):
    a.append(int(input()))
while count < n:
    light = a[light-1]
    count += 1
    if light == 2:
        print(count)
        quit()
print(-1)
### BUGGY CODE ###

n,m,q=map(int,input().split())
li=[list(map(int,input().split()))for _ in range(q)]

ans = 0
def dfs(i,A):
    #print(A)
    global ans 
    tmp = 0
    for a,b,c,d in li:
        if (A[b-1] - A[a-1]) == c:
            tmp += d
    ans = max(ans,tmp)
    if i == m:
        return
    for j in range(n):
        A_tmp = A[:]
        for k in range(1,j+2):
            A_tmp[-k] += 1
        dfs(i+1,A_tmp)
dfs(1,[1]*n)
print(ans)

### FIXED CODE ###

import itertools
n,m,q=map(int,input().split())
li=[list(map(int,input().split()))for _ in range(q)]

ans = 0
for A in itertools.combinations_with_replacement(range(1,m+1),n):
    tmp = 0
    for a,b,c,d in li:
        if A[b-1] - A[a-1] == c:
            tmp += d 
    ans = max(ans,tmp)
print(ans)
### BUGGY CODE ###

n=int(input())
l=[0]*10**5
A=map(int,input().split())

for a in A:
    l[a-1]+=1

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    tmp=l[b-1]
    l[b-1]=0
    l[c-1]+=tmp
    
    ans=0
    for j in range(10**5):
        ans+=l[j]*(j+1)
    print(ans)

### FIXED CODE ###

n=int(input())
l=[0]*10**5
A=list(map(int,input().split()))

for a in A:
    l[a-1]+=1

ans=sum(A)

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    tmp=l[b-1]
    l[b-1]=0
    l[c-1]+=tmp
    
    ans+=tmp*(c-b)
    
    print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = max(h)
for i in range(N-K+1):
    if max(h[i:i+K])-min(h[i:i+K]) < ans:
        ans = max(h[i:i+K])-min(h[i:i+K])
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
ans = max(h)
for i in range(N-K+1):
    if h[i+K-1]-h[i] < ans:
        ans = h[i+K-1]-h[i]
print(ans)
### BUGGY CODE ###

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

for i in range(1,N+1):
  print(A.count(i))


### FIXED CODE ###

from collections import Counter

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

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

input()
S = input()
cnt = 0
for i in range(0, 1000):
  c = (i//100, (i//10)%10, i%10)
  f = 0
  for s in S:
    if int(s) == c[f]:f += 1
    if f==3:break 
  if f==3:cnt += 1
print(cnt)
    


### FIXED CODE ###

input()
S = [int(i) for i in input()]
cnt = 0
for i in range(0, 1000):
  c = (i//100, (i//10)%10, i%10)
  f = 0
  for s in S:
    if s == c[f]:
      f += 1 
      if f==3:break 
  if f==3:cnt += 1
print(cnt)
### BUGGY CODE ###

import numpy as np
h, n = map(int, input().split())
dp = np.array([10**10]*(h+1))
dp[0] = 0
for _ in range(n):
    a, b = map(int, input().split())
    for start in range(h):
        end = min(start+a, h)
        dp[end] = min(dp[end], dp[start]+b)
print(dp[h])


### FIXED CODE ###

h, n = map(int, input().split())
dp = [10**10]*(h+1)
dp[0] = 0
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))

for a, b in ab:
    for start in range(h):
        end = min(start+a, h)
        dp[end] = min(dp[end], dp[start]+b)
print(dp[h])
### BUGGY CODE ###

n = int(input())
p = 1
for i in range(1, n + 1):
    p = p * i
print(p % 1000000007)


### FIXED CODE ###

import math

n = int(input())
print(math.factorial(n) % 1000000007)
### BUGGY CODE ###

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10 ** 9 + 7
dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N + 1):
    if i in a:
        dp[i] = -1
        continue
    if i == 1:
        if not i - 1 in a:
            dp[i] = 1
    else:    
        if dp[i - 1] != -1:
            dp[i] += dp[i - 1] % MOD
        if dp[i - 2] != -1:
            dp[i] += dp[i - 2] % MOD
print(dp[-1] % MOD)

### FIXED CODE ###

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a.sort(reverse=True)
dp = [0] * (N + 1)
dp[0] = 1
if len(a) > 0:
    A = a.pop()
else:
    A = -1

if A == 1:
    dp[1] = 0
    if len(a) > 0:
        A = a.pop()
    if A == 2:
        dp[2] = 0
    else:
        dp[2] = 1
else:
    dp[1] = 1
for i in range(2, N + 1):
    if i == A:
        if len(a) > 0:
            A = a.pop()
        continue
    if dp[i - 1] != 0 and dp[i - 2] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2])  % 1000000007
    elif dp[i - 1] != 0:
        dp[i] = dp[i - 1]  % 1000000007
    elif dp[i - 2] != 0:
        dp[i] = dp[i - 2]  % 1000000007
    else:
        dp[i] = 0
print(dp[-1])
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk

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

length = N
i = [] #頂点(始点)
j = [] #頂点(終点)
d = [] #頂点間の距離
for _ in range(M):
    A,B = map(int,input().split())
    i.append(A-1)
    j.append(B-1)
    d.append(1)

graph = csr_matrix((d, (i, j)), shape=(N, N)) # 頂点i,jはゼロスタートである必要ある

#返り値は各頂点間の距離の値を含んだ隣接行列(float64型のnp.array)
dist,pred = dijkstra(graph, directed=False,indices=0,return_predecessors=True,unweighted=True,)
pred = pred + 1
print("Yes")
print(*pred[1:],sep="\n")


### FIXED CODE ###

# from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations,combinations,combinations_with_replacement
# from collections import deque,Counter
# import re
# from bisect import bisect_left
# from heapq import heappush,heappop
# from numba import njit,jit
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from fractions import gcd

# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
from networkx import Graph
from networkx.algorithms.traversal.breadth_first_search import bfs_predecessors
G = Graph()
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb,perm #permはnPk

# slist = "abcdefghijklmnopqrstuvwxyz"
N,M = map(int,input().split())
rows = [list(map(int,input().split())) for _ in range(M)]

G.add_edges_from(rows)

# shortestPath = shortest_path(G,target=1)
preds = bfs_predecessors(G,source=1)
# shortestPath = single_target_shortest_path(G,target=1)
# shortestPathLength,shortestPath = single_source_dijkstra(G,source=1)

preds = dict(preds)
if len(preds)+1 != N:
    print("No")
    exit()

print("Yes")
for i in range(2,N+1):
    print(preds[i])
### BUGGY CODE ###

#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    target = LI()

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += (target[i] * target[j]) % (10 ** 9 + 7)
            ans = ans % (10 ** 9 + 7)
    print(ans)


main()


### FIXED CODE ###

#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


MOD = 10 ** 9 + 7


def main():
    N = II()
    target = LI()

    ans = 0
    sums = [0] * N
    sum_all = target[0]
    sums[0] = target[0]
    for i in range(1, N):
        sum_all += target[i] % MOD
        sums[i] = sums[i-1] + target[i]

    for i in range(N):
        ans += target[i] * (sum_all - sums[i])
        ans = ans % MOD

    print(ans)


main()
### BUGGY CODE ###

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

A = sorted(A)

def cmb(m, n):
    if m - n < n:
        n = m - n
    if n == 0:
        return 1
    if n == 1:
        return m
    
    numerator = [m - n + k + 1 for k in range(n)]
    denominator = [k + 1 for k in range(n)]

    for p in range(2, n+1):
        pivot = denominator[p-1]
        if pivot > 1:
            offset = (m-n) % p
            for k in range(p-1, n, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    
    result = 1
    for k in range(n):
        if numerator[k] > 1:
            result *= int(numerator[k])
            
            # mod(10**9+7)
            # result = result % (10**9+7)

    return result

ans = 0
for i in range(n):
    if n-i-1 < k-1:
        pass
    else:
        ans -= A[i] * cmb(n-i-1, k-1)
    if i < k-1:
        pass
    else:
        ans += A[i] * cmb(i, k-1)

ans = ans % (10**9 + 7)
print(ans)

### FIXED CODE ###

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

mod = 10**9 + 7

# factorial
factorial = [1,1]
# factorial inverse
factorial_inverse = [1,1]
# inverse for calculation
inverse = [0,1]

for i in range(2, n+1):
    factorial.append((factorial[-1]*i) % mod)
    inverse.append((- inverse[mod % i] * (mod//i)) % mod)
    factorial_inverse.append(factorial_inverse[-1] * inverse[-1] % mod)

def Binominal_theorem(n, k, mod):
    if n < k:
        return 0
    if (n < 0) or (k < 0):
        return 0
    return factorial[n] * factorial_inverse[k] * factorial_inverse[n-k] % mod

ans_min = 0
for i in range(n-k+1):
    ans_min += (A[i] * Binominal_theorem(n-i-1, k-1, mod)) % mod

A = A[::-1]
ans_max = 0
for i in range(n-k+1):
    ans_max += (A[i] * Binominal_theorem(n-i-1, k-1, mod)) % mod

ans = (ans_max - ans_min) % mod
print(ans)
### BUGGY CODE ###

S = list(input())
n = 0
i = 0
while i < len(S):
    # print(S)
    if len(set(S[i:i+2])) == 2:
        S = S[:i]+S[i+2:]
        n += 2
        if i != 0:
            i -= 1
    else:
        i += 1
print(n)

### FIXED CODE ###

S = input()
n = 0
i = 0
while i < len(S):
    # print(S)
    if len(set(S[i:i+2])) == 2:
        S = S[:i]+S[i+2:]
        n += 2
        if i != 0:
            i -= 1
    else:
        i += 1
print(n)
### BUGGY CODE ###

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

for i in range(M):
    A[A.index(max(A))] //= 2

print(sum(A))


### FIXED CODE ###

import heapq
from math import ceil

N, M = map(int, input().split())
A = [(-1)*int(x) for x in input().split()]

if len(A) == 1:
    for i in range(M):
        A[0] = ceil(A[0]/2)
    A[0] = -A[0]
    print(A[0])
else:
    count = 0
    heapq.heapify(A)
    a = heapq.heappop(A)
    b = heapq.heappop(A)
    while count < M:
        while a <= b:
            a = ceil(a/2)
            count += 1
            if count == M:
                break
        if count == M:
            break
        heapq.heappush(A,a)
        a = b
        b = heapq.heappop(A)
    heapq.heappush(A,a)
    heapq.heappush(A,b)
    ans = (-1)*sum(A)
    print(ans)
### BUGGY CODE ###

def snuke_festival(N,arr):
    n_pair = 0
    for i in range(N):
        for j in range(N):
            if arr[0][i] < arr[1][j]:
                for k in range(N):
                    if arr[1][j] < arr[2][k]:
                        n_pair += 1
    return n_pair

if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    arr_sorted = []
    for j in range(3):
        arr_sorted.append(arr[j].sort())
    print(snuke_festival(N,arr))

### FIXED CODE ###

import bisect

def snuke_festival(N,arr):
    n_pair = 0
    for item in arr[1]:
        up_pair = bisect.bisect_left(arr[0],item)
        down_pair = bisect.bisect_right(arr[2],item)
        n_pair += up_pair*(N-down_pair)
    return n_pair


if __name__ == "__main__":
    N  =int(input())
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    arr_sorted = []
    for j in range(3):
        arr_sorted.append(arr[j].sort())
    print(snuke_festival(N,arr))
### BUGGY CODE ###

A, B = [int(x) for x in input().split()]
tmp = 0
for i in range(A, B+1):
    if i == 0:
        tmp += i
    else:
        tmp = tmp ^ i
print(tmp)



### FIXED CODE ###

a, b = [int(x) for x in input().split()]


def xor(x):
    tmp = (x + 1) % 4
    if tmp == 0:
        return 0
    elif tmp == 1:
        return x
    elif tmp == 2:
        return 1
    else:
        return 1 ^ x


print(xor(a - 1) ^ xor(b))
### BUGGY CODE ###

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

### FIXED CODE ###

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

N, X, M = map(int, input().split())
A = [X]
a = X
s = X
r = 0
r0 = 0
l = 0
amari = 0

for i in range(M+1):
  a = a ** 2 % M
  if A.count(a) >= 1:
    r0 = A.index(a)
    l = len(A[r0:])
    r = (N - i - 1) // l
    amari = (N - i - 1) % l
    s = s + sum(A[r0:])*r + sum(A[r0:r0+amari])
    break
  A.append(a)
  s += A[-1]

print(s)

### FIXED CODE ###

N, X, M = map(int, input().split())
A = [X]
A_dict = {X}
a = X
s = X
r = 0
r0 = 0
l = 0
amari = 0

for i in range(M+1):
  a = a ** 2 % M
  if a in A_dict:
    r0 = A.index(a)
    l = len(A[r0:])
    r = (N - i - 1) // l
    amari = (N - i - 1) % l
    s = s + sum(A[r0:])*r + sum(A[r0:r0+amari])
    break
  A.append(a)
  A_dict.add(a)
  s += A[-1]

print(s)
### BUGGY CODE ###

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

### FIXED CODE ###

n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    print(0)
    quit()
for x in ls:
    res *= x
    if res > 10**18:
        print(-1)
        quit()
print(res)
### BUGGY CODE ###

n = int(input())
c = list(input())
cnt = 0

for i in range(n):
    if c[i] == 'W':
        for j in range(n-1,0,-1 ):
            if i > j:
                break
            if c[j] == 'R':
                if i < j:
                    c[i] = 'R'
                    c[j] = 'W'
                    cnt += 1
                break
print(cnt)

### FIXED CODE ###

n = int(input())
c = input()
cnt = 0
ans = 0

for i in range(n):
    if c[i] == 'R':
        cnt += 1
    
for j in range(cnt):
    if c[j] == 'W':
        ans += 1
        
print(ans)
### BUGGY CODE ###

mod = 10**9+7

# N = 15
N = int(input())
xx = list(map(int, input().split()))

a = 1
for i in range(2,N):
    a *= i
    # a %= mod

aa = [a]
for i in range(N-2):
    aa.append((aa[-1]+a//(i+2))%mod)


dx = [xx[i]-xx[i-1] for i in range(1,N)]

ans = 0
for a,d in zip(aa,dx):
    ans += a*d
    ans %= mod

print(ans%mod)


### FIXED CODE ###

mod = 10**9+7

# N = 15
N = int(input())
xx = list(map(int, input().split()))

a = 1
for i in range(2,N):
    a *= i
    a %= mod

aa = [a]
for i in range(N-2):
    aa.append((aa[-1]+a*pow(i+2,mod-2,mod))%mod)


dx = [xx[i]-xx[i-1] for i in range(1,N)]

ans = 0
for a,d in zip(aa,dx):
    ans += a*d
    ans %= mod

print(ans%mod)
### BUGGY CODE ###

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

if N < M:
    print('NO')
else:
    F = True
    for t in T:
        if (t in D) == False:
            F = False
            break
        else:
            del D[D.index(t)]
    if F:
        print('YES')
    else:
        print('NO')


### FIXED CODE ###

import collections


N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

d = collections.Counter(D)
t = collections.Counter(T)

F  = True
dk = d.keys()

for tk in t.keys():
    if tk in dk == False:
        F = False
        break
    elif d[tk] < t[tk]:
        F = False
        break

if F:
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

import fractions
n = int(input())
mod = 10**9 + 7
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
b = []
for i in range(n):
    an = ans // a[i]
    b.append(an)

print(sum(b) % mod)

### FIXED CODE ###

import fractions
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
b = []
b_sum = 0
mod = 10**9+7
for i in range(n):
    b_sum += (ans // a[i])

print(b_sum % mod)
### BUGGY CODE ###

from sys import stdin, stdout, exit
  
def max_heapify(a, i):
    heap_size = a[0]
  
    L = 2*i
    R = 2*i + 1
    if L <= heap_size and a[L] > a[i]:
        largest = L
    else:
        largest = i
    if R <= heap_size and a[R] > a[largest]:
        largest = R
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        max_heapify(a, largest)
  
  
def main():
    ret = []
    heap = [-1] * 2000001
    heap[0] = 1
    for cmd in stdin:
        if cmd[0] == 'i':
            heap[0] += 1
            i = heap[0]
            heap[i] = int(cmd[7:])
  
            half = i // 2
            while i > 1 and heap[half] < heap[i]:
                heap[i], heap[half] = heap[half], heap[i]
                i //= 2
                half = i // 2
        elif cmd[1] == 'x':
            ret.append(heap[1])
            heap[1] = heap[heap[0]]
            heap[0] -= 1
            max_heapify(heap, 1)
        elif cmd[1] == 'n':
            stdout.writelines("\n".join([str(s) for s in ret]))
            print()
            exit(0)
  
  
main()

### FIXED CODE ###

import heapq
import sys

h = []

for com in sys.stdin.readlines():
    if com[0] == "i":
        heapq.heappush(h, -int(com[7:]))
    elif com[1] == "x":
        print(-heapq.heappop(h))
### BUGGY CODE ###

h,w,m=list(map(int, input("").split()))
hb= [i for i in range(h)]
wb=[i for i in range(w)]
bo=[]
hb=[0]*h
wb=[0]*w
for i in range(m):
    a,b=list(map(int, input("").split()))
    #各行列に爆弾いくつあるか
    hb[a-1]+=1
    wb[b-1]+=1
    #爆弾の座標
    bo.append([a,b])
#ソート
mwb=[]
mhb=[]
#爆弾数が最大の行と列番号をメモ
hmax=max(hb)
wmax=max(wb)
for i in range(h):
    if hb[i]==hmax:
        mhb.append(i+1)
for i in range(w):
    if wb[i]==wmax:
        mwb.append(i+1)
c=0
#最大の爆弾数の行と列に含まれる爆弾数=cの確認
for h,w in bo:
    if h in mhb and w in mwb:
        c+=1
#行と列の最大爆弾数の和
out=hmax+wmax
#行と列の最大数の積がcと一致するなら必ず重複があるので－1
if c==len(mwb)*len(mhb):
    out-=1
print(out)

### FIXED CODE ###

h,w,m=list(map(int, input("").split()))
bo=[]
hb=[0]*h
wb=[0]*w
for i in range(m):
    a,b=list(map(int, input("").split()))
    #各行列に爆弾いくつあるか
    hb[a-1]+=1
    wb[b-1]+=1
    #爆弾の座標
    bo.append([a,b])
#ソート
mwb=[]
mhb=[]
#爆弾数が最大の行と列番号をメモ
hmax=max(hb)
wmax=max(wb)
for i in range(h):
    if hb[i]==hmax:
        mhb.append(i)
for i in range(w):
    if wb[i]==wmax:
        mwb.append(i)
c=0
#最大の爆弾数の行と列に含まれる爆弾数=cの確認
for h,w in bo:
     #h in mhb and w in mwb
    if(hb[h-1] == hmax and wb[w-1] == wmax):
        c+=1
#行と列の最大爆弾数の和
out=hmax+wmax
#行と列の最大数の積がcと一致するなら必ず重複があるので－1
if c==len(mwb)*len(mhb):
    out-=1
print(out)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
 
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a, b):
    return (a * b)//gcd(a,b)

lcm_a = 1
 
for i in range(N):
    lcm_a = lcm(lcm_a,A[i])
    
ans = 0
mod = int(1e9+7)
for i in range(N):
    ans += (lcm_a//A[i])%mod
    
print(ans%mod)

### FIXED CODE ###

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a, b):
    return (a * b)//gcd(a,b)

lcm_a = 1

for i in range(N):
    lcm_a = lcm(lcm_a,A[i])

ans = 0
for i in range(N):
    ans += lcm_a//A[i]

mod = int(1e9+7)

print(ans%mod)