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

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

A = list(map(int,input().split()))
sum = 0
import collections

c = collections.Counter(A)
c = c.most_common()
for i in range(n):
  if len(c) > k:
    sum += c[-1][1]
    c = c[:-1]
  else:
    break
print(sum)

### FIXED CODE ###

import sys
import collections
input = sys.stdin.readline
n,k = map(int,input().split())

A = list(map(int,input().split()))
sum = 0
c = collections.Counter(A)
c = c.most_common()
if len(c) > k:
  a = len(c)-k
  c = c[-a:]
  for i in range(a):
    sum += c[i][1]
  print(sum)
else:
  print(0)
### BUGGY CODE ###

import bisect

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

for i in range(N):
    hoge = bisect.bisect_left(result,S[i])
    if hoge == 0:
        result = [S[i]] + result
    else:
        result[hoge - 1] = S[i]
print(len(result))

### FIXED CODE ###

import bisect

N = input()
N = int(N)
S = [-int(input()) for _ in range(N)]
result = []

for i in range(N):
    hoge = bisect.bisect(result,S[i])
    if hoge == len(result):
        result.append(S[i])
    else:
        result[hoge] = S[i]
print(len(result))
### BUGGY CODE ###

N = int(input())

# d = dict()


def make_divisors(n):
    divisors = []
    # res = 0
    # if n in d:
    #     return d
    for i in range(1, int(n ** 0.5) + 1):
        # if i in d:
        #     res += 1
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    # return res + len(divisors)
    return len(divisors)


ans = 0
for i in range(1, N + 1):
    ans += i * make_divisors(i)

print(ans)


### FIXED CODE ###

N = int(input())


def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1

    return table


# li = np.array(num_divisors_table(N))
# k = np.arange(N + 1)

li = num_divisors_table(N)

# print(sum(li * k))
ans = 0
for i in range(N + 1):
    ans += i * li[i]

print(ans)
### BUGGY CODE ###

 #ランレングス圧縮とは RLE(Run Length Encoding)とも言われます。
#連続したデータを、ひとつ分のデータと連続した長さで表現します。
def rle(s):
    tmp, count, ans = s[0], 1, []
    for i in range(1,len(s)):
        if tmp == s[i]:
            count += 1
        else:
            ans.append((tmp,count))
            tmp = s[i]
            count = 1
    ans.append((tmp,count))
    return ans

   # AAABBCCCCA ⇒ A3B2C4A1

# 初期入力
import sys
input = sys.stdin.readline
N,K = (int(x) for x in input().split())
S =input().strip()

#0と1が何回続くか
a =rle(S)
a_len =len(a)
count =[0]*a_len
ans =0

if K >= (a_len +1)//2:
    ans =N
else:
    for i in range(a_len):
        j =0
        count_0 =0
        while count_0 <K and i+j <a_len: #and j <a_len:
            count[i] +=a[i+j][1]
            if a[i+j][0]=="0":
                count_0 +=1
                if count_0 ==K and i+j+1 <a_len :
                    count[i] +=a[i+j+1][1]
            j +=1
    ans =max(count)
print(ans)

### FIXED CODE ###

 #ランレングス圧縮とは RLE(Run Length Encoding)とも言われます。
#連続したデータを、ひとつ分のデータと連続した長さで表現します。
def rle(s):
    tmp, count, ans_c,ans_n = int(s[0]),1,[] , []
    for i in range(1,len(s)):
        if tmp == int(s[i]):
            count += 1
        else:
            ans_c.append(tmp)
            ans_n.append(count)
            tmp = int(s[i])
            count = 1
    ans_c.append(tmp)
    ans_n.append(count)
    return ans_c,ans_n

# 初期入力
import sys
input = sys.stdin.readline
N,K = (int(x) for x in input().split())
S =input().strip()

#0と1が何回続くか
a_c,a_n =rle(S)
a_len =len(a_c)
a_n +=[0]
count =[0]*a_len
ans =0

#
if K >= (a_len +1)//2:
    ans =N
elif a_len==2:
    ans =N
elif a_len ==3 and a_c[0]==1:
    ans=N
else:
    if a_c[0] ==1:
        i=2
        indx =i +2*K 
        count[0] =sum(a_n[:0 +2*K +1])
        while not(indx ==a_len+2 or indx ==a_len+1):
            count[i] =count[i-2] -a_n[i-2] -a_n[i-1] + a_n[indx-1] +a_n[indx]
            i +=2
            indx =i +2*K 
    else:
        count[0] =sum(a_n[:2*K])
        count[1] =sum(a_n[1: 1+2*K+1])
        i=3
        indx =i +2*K 
        while not(indx ==a_len+2 or indx ==a_len+1):
            count[i] =count[i-2] -a_n[i-2] -a_n[i-1] + a_n[indx-1] +a_n[indx]
            i +=2      
            indx =i +2*K 
    ans =max(count)
print(ans)
### BUGGY CODE ###

N = int(input())
s = [0]*N
p = [0]*N
for i in range(N):
    s[i] = "".join(sorted(input()))
    for j in range(i-1,-1,-1):
        if s[i] == s[j]:
            p[i] = p[j] + 1
            break

print(sum(p))

### FIXED CODE ###

N = int(input())
s = [0]*N
p = {}
ans = 0
for i in range(N):
    s[i] = "".join(sorted(input()))
    if s[i] in p:
        ans += p[s[i]]
        p[s[i]] += 1
    else:
        p[s[i]] = 1

print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

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

ans = 0
for i in range(n):
    tmp1 = a[i]
    for j in range(i+1, n):
        tmp2 = a[j]
        if tmp1 & tmp2 == 0:
            ans += 1
            # print(tmp1, tmp2)
            tmp1 = tmp1 ^ tmp2
        else:
            break
print(ans + n)


### FIXED CODE ###

#!/usr/bin/env python3

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

total = a[0]
xor = a[0]
ans = 0
l = 0
r = 0

while 1:
    if xor == total:
        ans += r-l+1
        r += 1
        if r == n:
            break
        total += a[r]
        xor ^= a[r]
    else:
        total -= a[l]
        xor ^= a[l]
        l += 1
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(a[0] // (2 ** m))
    exit()
a.sort()
while m > 0:
    while m > 0 and a[-1] >= a[-2]:
            m -= 1
            a[-1] //= 2
    a.sort()
# print(a)
print(sum(a))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    print(a[0] // (2 ** m))
    exit()
a = list(map(lambda x: x * (-1), a))
heapq.heapify(a)
while m > 0:
    m -= 1
    i = heapq.heappop(a) * (-1)
    i //= 2
    heapq.heappush(a, i * (-1))

print(sum(a) * (-1))
### BUGGY CODE ###

import collections
n = int(input())

dic = {}
for _ in range(n):
    s = input()
    dic[s] = dic.get(s, 0) + 1

print("\n".join(sorted([ k for k,v in dic.items() if v == max(dic.values()) ])))

### FIXED CODE ###

import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

u = max(c.values())
print("\n".join(sorted([ k for k,v in c.items() if v == u ])))
### BUGGY CODE ###

import math
N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))[::-1]
Cs = [a*b for a, b in zip(As, Bs)]
BCs = list(zip(Bs, Cs))

def func(target):
    return sum([math.ceil(max(0, c - target) / b) for b, c in BCs]) <= K

if __name__ == '__main__':
    min_i, max_i = 0, max(Cs)+1
    index = (max_i + min_i)//2
    while True:
        if not func(index):
            if func(index+1):
                print(index+1)
                break
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1


### FIXED CODE ###

import math
N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))[::-1]
Cs = [a*b for a, b in zip(As, Bs)]
BCs = list(zip(Bs, Cs))

def func(target):
    r = 0
    for b, c in BCs:
        r += math.ceil(max(0, c - target) / b)
    return r <= K

if __name__ == '__main__':
    min_i, max_i, index = 0, max(Cs)+1, 1
    while True:
        if func(index):
            index, max_i = (index-1 + min_i)//2, index-1
        else:
            index, min_i = (index+1 + max_i)//2, index+1
        if min_i > max_i:
            print(min_i)
            break
### BUGGY CODE ###

h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
f=1
for i in b1:
    for j in c1:
        if (i,j) not in d:
            f=0
print(bm+cm-f)

### FIXED CODE ###

h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
for i in b1:
    for j in c1:
        if (i,j) not in d:
            print(bm+cm)
            exit()
print(bm+cm-1)
### BUGGY CODE ###

import sys
from collections import deque
input = sys.stdin.readline

def solve_e(n, a_list):
    days = 0
    ind_list = [0] * n
    match_count = 0
    queue = list(range(n))
    stack = dict()
    while len(queue) > 0:
        days += 1
        new_queue = []
        for p in queue:
            if ind_list[p] < n - 1:
                q = a_list[p][ind_list[p]] - 1
                k = str(min(p, q)) + "_" + str(max(p, q))
                if k in stack.keys():
                    ind_list[p] += 1
                    ind_list[q] += 1
                    # print(days, p, q)
                    new_queue.append(p)
                    new_queue.append(q)
                    match_count += 1
                else:
                    stack[k] = 1
        queue = new_queue
    if match_count == n * (n - 1) // 2:
        return days - 1
    else:
        return -1


def test():
    N = 1000
    A_list = []
    for i in range(N):
        A_list.append(list(range(1, i + 1)) + list(range(i + 2, N + 1)))
    print(solve_e(N, A_list))


def main():
    N = int(input())
    A_list = []
    for _ in range(N):
        A_list.append(list(map(int, input().split())))
    print(solve_e(N, A_list))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def solve_e(n, a_list):
    days = 0
    ind_list = [0] * n
    match_count = 0
    queue = list(range(n))
    stack = dict()
    while len(queue) > 0:
        days += 1
        new_queue = []
        for p in queue:
            if ind_list[p] < n - 1:
                q = a_list[p][ind_list[p]] - 1
                k = str(min(p, q)) + "_" + str(max(p, q))
                if k in stack.keys():
                    ind_list[p] += 1
                    ind_list[q] += 1
                    # print(days, p, q)
                    new_queue.append(p)
                    new_queue.append(q)
                    match_count += 1
                else:
                    stack[k] = 1
        queue = new_queue
    if match_count == n * (n - 1) // 2:
        return days - 1
    else:
        return -1


def test():
    N = 1000
    A_list = []
    for i in range(N):
        A_list.append(list(range(1, i + 1)) + list(range(i + 2, N + 1)))
    print(solve_e(N, A_list))


def main():
    N = int(input())
    A_list = []
    for _ in range(N):
        A_list.append(list(map(int, input().split())))
    print(solve_e(N, A_list))


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

n = int(input())
a = []
count = 0
b = set([])
num = set(list(range(n)))
for _ in range(n):
    a.append(int(input()))
while len(b) < n:
    temp_num = min(num - b)
    temp = a[temp_num]
    b.add(temp_num)
    temp_list = sorted(list(num - b))
    for temp_i in temp_list:
        if a[temp_i] > temp:
            temp = a[temp_i]
            b.add(temp_i)
    count += 1
print(count)

### FIXED CODE ###

from bisect import bisect_right
n = int(input())
a_list = []
for i in range(n):
    a = int(input())
    a_list.append(a)
a_list.reverse()
l_list = [a_list[0]]
for i in range(1, n):
    a = a_list[i]
    if l_list[-1] <= a:
        l_list.append(a)
    else:
        index = bisect_right(l_list, a)
        l_list[index] = a
print(len(l_list))
### BUGGY CODE ###

K, N = map(int, input().split())
MOD = 998244353

P = N+K
fact = [1]*(P+1)
rfact = [1]*(P+1)
for i in range(P):
    fact[i+1] = r = ((i+1) * fact[i]) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

def comb(n, k):
    return fact[n] * rfact[k] * rfact[n-k] % MOD

def calc(A):
    M = A//2
    r = 0
    if A % 2:
        p = K - 2*M + N - 2
        for m in range(max(0, 2*M+2-K), min(M, N)+1):
            if 2*M+2-K <= m < N:
                r += pow(2, m, MOD) * comb(M, m) * (comb(p, N-m) + comb(p-1, N-m-1)) % MOD
            elif 2*M+2-K <= m == N:
                r += pow(2, m, MOD) * comb(M, m) * comb(p, N-m) % MOD
    else:
        p = K - 2*M + N - 1
        for m in range(max(0, 2*M+1-K), min(N, M)+1):
            r += pow(2, m, MOD) * comb(M, m) * comb(p, N-m) % MOD
    return r % MOD
ans = []
for i in range(2, 2*K+1):
    if i <= K:
        ans.append(calc(i - 1))
    else:
        ans.append(calc(2*K - i + 1))
print(*ans, sep='\n')

### FIXED CODE ###

K, N = map(int, input().split())
MOD = 998244353

P = N+K
fact = [1]*(P+1)
rfact = [1]*(P+1)
for i in range(P):
    fact[i+1] = r = ((i+1) * fact[i]) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

def comb(n, k):
    return fact[n] * rfact[k] * rfact[n-k] % MOD

def h(n, k):
    if n < 0 or k < 0:
        return 0
    return comb(n+k, k)

def calc(A):
    M = A//2
    r = 0
    if A % 2:
        p = K - 2*M + N - 2
        for m in range(M+1):
            if K-2*M-2+m < 0 or N-m < 0:
                continue
            r += pow(2, m, MOD) * comb(M, m) * (h(K-2*M-2+m, N-m) + h(K-2*M-2+m, N-m-1)) % MOD
    else:
        p = K - 2*M + N - 1
        for m in range(M+1):
            if K-2*M-1+m < 0 or N-m < 0:
                continue
            r += pow(2, m, MOD) * comb(M, m) * h(K-2*M-1+m, N-m) % MOD
    return r % MOD
ans = []
for i in range(2, 2*K+1):
    if i <= K:
        ans.append(calc(i - 1))
    else:
        ans.append(calc(2*K - i + 1))
print(*ans, sep='\n')
### BUGGY CODE ###

H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7


# modしながらコンビネーションを求める
def mod_cmb(n, r, mod):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * mod_inverse(q, mod) % mod


# modしたa^bを求める
def mod_pow(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 1:
        return a * mod_pow(a, p - 1, mod)
    else:
        return (mod_pow(a, p // 2, mod) % mod) ** 2 % mod


# aで割りたいときはa^(p-2)をかければよい（pは素数かつmodで使うやつ）
def mod_inverse(a, mod):
    return mod_pow(a, (mod - 2), mod)


n1 = B + H - A - 1
r1 = H - A - 1
n2 = W + A - B - 2
r2 = A - 1
temp = mod_cmb(n1, r1, MOD) * mod_cmb(n2, r2, MOD) % MOD
ans = temp
for _ in range(1, W - B):
    temp = temp * (n1 + 1) * mod_inverse(n1 + 1 - r1, MOD) % MOD
    temp = temp * (n2 - r2) * mod_inverse(n2, MOD) % MOD
    n1 += 1
    n2 -= 1
    ans = (ans + temp) % MOD

print(ans)

### FIXED CODE ###

H, W, A, B = map(int, input().split())
MOD = 10 ** 9 + 7
limit = 2 * 10 ** 5


# modしながらコンビネーションを求める
def mod_cmb(n, r, mod):
    x = fact[n] * fact_inverse[r] % mod
    x = x * fact_inverse[n - r] % mod
    return x


def d_cmb(n, r, mod):
    return mod_cmb(n + r - 1, r, mod)


# modしたa^bを求める
def mod_pow(a, p, mod):
    if p == 0:
        return 1
    elif p % 2 == 1:
        return a * mod_pow(a, p - 1, mod)
    else:
        return (mod_pow(a, p // 2, mod) % mod) ** 2 % mod


fact = [1] * (limit + 1)
fact_inverse = [1] * (limit + 1)

for i in range(1, limit + 1):
    fact[i] = fact[i - 1] * i % MOD

fact_inverse[limit] = mod_pow(fact[limit], MOD - 2, MOD)
for i in reversed(range(1, limit + 1)):
    fact_inverse[i - 1] = fact_inverse[i] * i % MOD

n1 = W
r1 = H - A - 1
n2 = 1
r2 = A - 1
ans = 0
for i in range(W - B):
    ans += d_cmb(n1 - i, r1, MOD) * d_cmb(n2 + i, r2, MOD)
    ans %= MOD

print(ans)
### BUGGY CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,a=LI()
  l=LI()

  dp=[[[0]*51 for _ in range(2501)] for __ in range(n+1)]
  dp[0][0][0]=1
  for i in range(n):
    nd=l[i]
    for j in range(2500):
      for k in range(50):
        ni=i+1
        nj=j
        nk=k

        dp[ni][nj][nk]+=dp[i][j][k]

        nj+=nd
        nk+=1

        if nj>2500:
          continue

        dp[ni][nj][nk]+=dp[i][j][k]

  # print(dp[2][9][1])
  # print(dp[3][9][1])
  # print(dp[4][9][1])

  ans=0
  for j in range(2500):
    for k in range(1,50):
      if j%k!=0:
        continue
      if j//k==a and dp[n][j][k]>0:
        ans+=dp[n][j][k]

  return ans

# main()
print(main())


### FIXED CODE ###

import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,a=LI()
  l=LI()

  dp=[[[0]*51 for _ in range(2501)] for __ in range(n+1)]
  dp[0][0][0]=1
  for i in range(n):
    nd=l[i]
    for j in range(2500):
      for k in range(50):
        ni=i+1
        nj=j
        nk=k

        dp[ni][nj][nk]+=dp[i][j][k]

        nj+=nd
        nk+=1

        if nj>2500:
          continue

        dp[ni][nj][nk]+=dp[i][j][k]

  # print(dp[2][9][1])
  # print(dp[3][9][1])
  # print(dp[4][9][1])

  ans=0
  for j in range(2501):
    for k in range(1,51):
      if j%k!=0:
        continue
      if j//k==a and dp[n][j][k]>0:
        ans+=dp[n][j][k]

  return ans

# main()
print(main())
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a)
b = sorted(b)
c = sorted(c, reverse=True)
count = 0
a_count = 0
for i in range(n):
    b_select = b[i]
    a_count = 0
    for j in a:
        if j < b_select:
            a_count += 1
        else:
            break
             
    c_count = 0
    for k in c:
        if k > b_select:
            c_count += 1
        else:
            break
    count += a_count * c_count
print(count)

### FIXED CODE ###

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

a = sorted(a)
b = sorted(b)
c = sorted(c)

import bisect
count = 0
for i in b:
    a_count = bisect.bisect_left(a, i)
    c_count = n - bisect.bisect_right(c, i)
    count += a_count * c_count
    
print(count)
### BUGGY CODE ###

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

### FIXED CODE ###

from collections import deque
n = int(input())
a = list(map(int,input().split()))
b = deque()
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n%2==1:
    b.reverse()

print(*b)
### BUGGY CODE ###

import sys
import copy

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

def main():
    N,K = LI()[:]
    A = LI()
    #print(N,K)
    #print(A)

    for _ in range(K):
        B = [0]*N
        for i, a in enumerate(A):
            #print(i, a)
            if a == 0:
                B[i] += 1
            else:
                # i-(a+0.5) ~ i+(a+0.5)
                # i: 整数、a: ＋整数　なので +0.5 は切り捨てられる。
                #　影響範囲は、 i-a ~ i+a
                for p in range(i-a,i+a+1):
                    #print("p:",p)
                    if p >=0 and p < N:
                        B[p] += 1
                #print(B)
        A = copy.deepcopy(B)

    print(" ".join(map(str,A)))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import numpy as np
from numba import njit
 
readline = sys.stdin.readline
 
@njit('i8,i8,i8[::1]',cache=True)
def loop(n,k,a):
    for j in range(k):
        b = np.zeros(n+1, dtype=np.int64)
        for i in range(n):
            b[max(i-a[i], 0)] += 1
            b[min(i+a[i]+1, n)] -= 1
        a = np.cumsum(b)[:-1]
        if np.all(a==n):
            return(a)
            break
    else:
        return(a)
 
 
n, k = map(int, readline().split())
a = np.array(readline().split(), dtype=np.int64)
 
ans = loop(n,k,a)
print(*ans)
### BUGGY CODE ###


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

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

N = int(input())
A = list(map(int, input().split()))
l = A[0]
for a in A:
    l = lcm(l, a)
ans = 0
mod = int(1e9+7)
for a in A:
    ans += (l * pow(a, mod-2, mod))%mod
    ans %= mod
print(ans)


### FIXED CODE ###


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

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

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    l = A[0]
    for a in A:
        l = lcm(l, a)
    ans = 0
    mod = int(1e9+7)
    for a in A:
        ans += (l * pow(a, mod-2, mod))%mod
        ans %= mod
    print(ans)
### BUGGY CODE ###

import copy
N,W=map(int,input().split())
dp_1=[0]*(W+1)
dp_2=[0]*(W+1)

for i in range(1,N+1):
    w,v=map(int,input().split())
    #dp_2=[0]*(W+1)
    for j in range(1,W+1):
        if j-w>=0:
            dp_2[j]=max(dp_1[j],dp_1[j-w]+v)
        else:
            dp_1[j]=dp_2[j]
    dp_1=copy.copy(dp_2)
print(dp_2[-1])

### FIXED CODE ###

N,W=map(int,input().split())
dp=[[0 for i in range(W+1)] for j in range(N+1)]

for i in range(1,N+1):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j-w>=0:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])
### BUGGY CODE ###

N=int(input())
S=input()

ans=float('inf')
for i in range(N):
  cnt=0
  S1=S[:i]
  S2=S[i+1:]
  cnt+=S1.count('W')+S2.count('E')
  ans=min(ans,cnt)
print(ans)

### FIXED CODE ###

N=int(input())
S=input()

acc_e=[0]
acc_w=[0]
for i in S:
  acc_e.append(acc_e[-1])
  acc_w.append(acc_w[-1])
  if i=='E':
    acc_e[-1]+=1
  else:
    acc_w[-1]+=1

ans=N
for i in range(N):
  turn=acc_w[i]+acc_e[-1]-acc_e[i+1]
  ans=min(ans,turn)
print(ans)
### BUGGY CODE ###

import sys

input = sys.stdin.readline


def main():
    K, Q = map(int, input().split())
    D = list(map(int, input().split()))

    for _ in range(Q):
        n, x, m = map(int, input().split())
        md = [D[i] % m for i in range(K)]
        smda = 0
        mda0 = 0
        for i in range((n - 1) % K):
            if md[i] == 0:
                mda0 += 1
            smda += md[i]
        roop = (n - 1) // K
        res = n - 1 - (x % m + sum(md) * roop + smda) // m - md.count(0) * roop - mda0
        print(res)


main()


### FIXED CODE ###

import sys

input = sys.stdin.readline


def main():
    K, Q = map(int, input().split())
    D = list(map(int, input().split()))

    for _ in range(Q):
        n, x, m = map(int, input().split())
        md = [D[i] % m for i in range(K)]
        smda = 0
        mda0 = 0
        for i in range((n - 1) % K):
            if md[i] == 0:
                mda0 += 1
            smda += md[i]
        smd = smda
        md0 = mda0
        for i in range((n - 1) % K, K):
            if md[i] == 0:
                md0 += 1
            smd += md[i]
        roop = (n - 1) // K
        res = n - 1 - (x % m + smd * roop + smda) // m - md0 * roop - mda0
        print(res)


main()