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

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

for i in range(m):
    a[a.index(max(a))]=max(a)//2

print(sum(a))


### FIXED CODE ###

import heapq
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)

for i in range(m):
    max=heapq.heappop(a)
    heapq.heappush(a,(max*(-1)//2)*(-1))

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

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M=map(int, input().split())
B=[tuple(map(int, input().split())) for _ in range(M)]

P=list(range(N+1))
C=[1 for _ in range(N+1)]
C[0] = 0

def root(x):
    if P[x]==x: return x
    P[x] = root(P[x])
    return P[x]

def unite(a,b):
    ra = root(a)
    rb = root(b)
    C[ra] += C[rb]
    C[rb] = 0
    P[rb] = ra

def same(a,b):
    return root(a) == root(b)

def count(x):
    return C[root(x)]

ans=[0]*(M+1)
ans[M] = N * (N-1)

for i in range(M-1,-1,-1):
    a,b = B[i]
    if same(a,b):
        ans[i] = ans[i+1]
        continue
    ans[i] = ans[i+1] - count(a) * count(b)
    unite(a,b)

for i in range(1,M+1):
    print(ans[i] - ans[0])

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,M=map(int, input().split())
B=[tuple(map(int, input().split())) for _ in range(M)]

P=list(range(N+1))
C=[1 for _ in range(N+1)]
C[0] = 0

def root(x):
    if P[x]==x: return x
    P[x] = root(P[x])
    return P[x]

def unite(a,b):
    ra = root(a)
    rb = root(b)
    C[ra] += C[rb]
    C[rb] = 0
    P[rb] = ra

def same(a,b):
    return root(a) == root(b)

def count(x):
    return C[root(x)]

ans=[0]*(M+1)
ans[M] = N * (N-1)

for i in range(M-1,-1,-1):
    a,b = B[i]
    if same(a,b):
        ans[i] = ans[i+1]
        continue
    ans[i] = ans[i+1] - count(a) * count(b)
    unite(a,b)

for i in range(1,M+1):
    print(ans[i] - ans[0])
### BUGGY 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 False

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

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

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
    
  def all_group_numbers(self):
    return sum([-x*(-x-1)//2 for x in self.parents if x < -1])

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
uf=UnionFind(N)
ans=[]
ANS=N*(N-1)//2
flg=True
for i in range(M-1,-1,-1):
  if flg:
    ans.append(ANS-uf.all_group_numbers())
  else:
    ans.append(ans[-1])
  
  flg=uf.union(AB[i][0]-1,AB[i][1]-1)
for i in range(len(ans)-1,-1,-1):
  print(ans[i])

### 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 False,0,0

    if self.parents[x] > self.parents[y]:
      x, y = y, x
    nx=self.size(x)
    ny=self.size(y)
    self.parents[x] += self.parents[y]
    self.parents[y] = x
    
    return True,nx,ny

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]
    
  def all_group_numbers(self):
    return [-x for x in self.parents if x < -1]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
uf=UnionFind(N)
ans=[0]*(M+1)
ans[M]=N*(N-1)//2
i=M-1
for a,b in AB[::-1]:
  flg,na,nb=uf.union(a-1,b-1)
  if flg:
    ans[i]=ans[i+1]-na*nb
  else:
    ans[i]=ans[i+1]
  i-=1
for a in ans[1:]:
  print(a)
### BUGGY CODE ###

n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      break
    a = a * 10 + 7

### FIXED CODE ###

n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
  if b == 0:
    print(-1)
### BUGGY CODE ###

import random
import numpy as np

def is_prime(q,k=50):
    # q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return 1
    if q < 2 or q&1 == 0: return 0

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return 0
    return 1
  
chk = np.array([0]*10**5)
for i in range(10**5):
  chk[i] = is_prime(i+1,20)
  
ans = np.array([0]*10**5)
for i in range(2,10**5):
  ans[i] = chk[i]&chk[(i+1)//2]
np.cumsum(ans,out=ans)

q = int(input())
for i in range(q):
  l,s = map(int,input().split())
  print(ans[s-1]-ans[max(0,l-2)])

### FIXED CODE ###

import random
import numpy as np

def is_prime(q,k=50):
    # q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return 1
    if q < 2 or q&1 == 0: return 0

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return 0
    return 1
  
chk = np.array([0]*10**5)
for i in range(10**5):
  chk[i] = is_prime(i+1,15)
  
ans = np.array([0]*10**5)
for i in range(2,10**5):
  ans[i] = chk[i]&chk[(i+1)//2]
np.cumsum(ans,out=ans)

import sys
input = sys.stdin.readline
q = int(input())
for i in range(q):
  l,s = map(int,input().split())
  print(ans[s-1]-ans[max(0,l-2)])
### BUGGY CODE ###

D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())

min_solved = 1000

def dfs(depth, solve_num, point, sum_solved):
    global min_solved

    point += (depth+1) * 100 * solve_num
    if solve_num == p[depth]:
        point += c[depth]
    
    if point >= G:
        if sum_solved < min_solved:
            min_solved = sum_solved
        return 0

    if depth == len(p) - 1:
        return 0

    for i in range(p[depth+1]+1):
        dfs(depth+1, i, point, sum_solved + i)

    return 0

for i in range(p[0]+1):
    dfs(0, i, 0, i)

print(min_solved)
print("\n")

### FIXED CODE ###

import math

D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())
# 各配点について全問解いた時のポイント
fsp = [p[i]*100*(i+1)+c[i] for i in range(D)]

# print(fsp)

min_pro = 100000000

def dfs(solve):
    global min_pro
    max_rest = -1
    if len(solve) == D:
        sum_point = 0
        sum_pro = 0
        for i in range(D):
            if solve[i] == "1":
                sum_point += fsp[i]
                sum_pro += p[i]
            else:
                max_rest = i
        #print(solve, sum_point, max_rest,math.ceil((G - sum_point) / ((max_rest+1)*100)))
        if sum_point < G:
            if math.ceil((G - sum_point) / ((max_rest+1)*100)) < p[max_rest]:
                sum_pro += math.ceil((G - sum_point) / ((max_rest+1)*100))
            else:
                sum_pro += 100000
        if min_pro > sum_pro:
            min_pro = sum_pro


        #pps[counter] = [sum_point, sum_pro, solve]
        #counter += 1
        return 0

    dfs(solve+"0")
    dfs(solve+"1")
    return 0

dfs("0")
dfs("1")

print(min_pro)
print("\n")
### BUGGY CODE ###

H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A+=[a]
  B+=[b]
dp=[[float('inf') for i in range(H+1)]for i in range(N+1)]#i番めの魔法までを使って体力j減らすのに必要な魔力の最小値
dp[0][0]=0
for i in range(1,N+1):
  for j in range(H+1):
    if j>=A[i-1]:
      Ai=A[i-1]
      Bi=B[i-1]
      dp[i][j]=min(dp[i][j-Ai]+Bi,dp[i-1][j])
    else:
      dp[i][j]=min(dp[i-1][j],B[i-1])
ans=dp[N][H]
print(ans)

### FIXED CODE ###

H,N=map(int,input().split())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A+=[a]
  B+=[b]
dp=[[float('inf') for i in range(H+1)]for i in range(N+1)]#i番めの魔法までを使って体力j減らすのに必要な魔力の最小値
dp[0][0]=0
for i in range(1,N+1):
  for j in range(H+1):
    if j>=A[i-1]:
      Ai=A[i-1]
      Bi=B[i-1]
      dp[i][j]=min(dp[i][j-Ai]+Bi,dp[i-1][j])
    else:
      dp[i][j]=min(dp[i-1][j],B[i-1])
ans=dp[N][H]
print(ans)
### BUGGY CODE ###

def main():
  n,a,*x=map(int,open(0).read().split())
  x=[0]+x
  dp=[[[0]*(50*n+1)for j in range(n+1)]for i in range(n+1)]
  dp[0][0][0]=1
  for i in range(1,n+1):
    dp[i][0]=dp[i-1][0]
    for j in range(1,n+1):
      for k in range(1,50*n+1):
        dp[i][j][k]=dp[i-1][j][k]
        if k-x[i]>=0:
          dp[i][j][k]+=dp[i-1][j-1][k-x[i]]
  ans=0
  for i in range(1,n+1):
    j=i*a
    if j<50*n+2:
      ans+=dp[-1][i][j]
  print(ans)
if __name__=='__main__':
  main()

### FIXED CODE ###

n,a,*x=map(int,open(0).read().split())
x=[0]+x
dp=[[[0]*(50*n+1)for j in range(n+1)]for i in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  dp[i][0]=dp[i-1][0]
  for j in range(1,n+1):
    for k in range(1,50*n+1):
      dp[i][j][k]=dp[i-1][j][k]
      if k-x[i]>=0:
        dp[i][j][k]+=dp[i-1][j-1][k-x[i]]
ans=0
for i in range(1,n+1):
  j=i*a
  if j<50*n+2:
    ans+=dp[-1][i][j]
print(ans)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()

for _ in range(Q):
    l, r = map(int, input().split())
    s = S[l-1:r]
    ans = 0

    print(s.count('AC'))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

t = [0] * (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())

a = [1] * N
for gate in range(M):
    for id in range(1, N+1):
        if id < L[gate] or R[gate] < id:
            a[id-1] = 0

print(sum(a))


### FIXED CODE ###

N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(lambda x: int(x)-1, input().split())

sum = 0
maxl = max(L)
minr = min(R)
for id in range(N):
    if maxl <= id and id <= minr:
        sum += 1

print(sum)
### BUGGY CODE ###

import math
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
a.reverse()
f.sort()
totalnum=sum(a)
maxproduct=0
for i in range(n):
  maxproduct=max(f[i]*a[i],maxproduct)
l1=0
r1=maxproduct
while True:
  l2=l1
  r2=(l1+r1)//2
  if l2==r2:
    break
  counter=0
  for i in range(n):
    c=math.floor(r2/f[i])
    while (c+1)*f[i]<=r2:
      c+=1
    counter+=max(0,a[i]-c)
  if counter<=k:
    r1=r2
  else:
    l1=r2
if l1==r1:
  print(r2)
else:
  counter=0
  r2=l1
  for i in range(n):
    c=math.floor(r2/f[i])
    while (c+1)*f[i]<=r2:
      c+=1
    counter+=max(0,a[i]-c)
  if counter<=k:
    print(l1)
  else:
    print(r1)

### FIXED CODE ###

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
a.reverse()
f.sort()
maxproduct=0
for i in range(n):
  maxproduct=max(f[i]*a[i],maxproduct)
l1=0
r1=maxproduct
while True:
  l2=l1
  r2=(l1+r1)//2
  if l2==r2:
    break
  counter=0
  for i in range(n):
    c=r2//f[i]
    while (c+1)*f[i]<=r2:
      c+=1
    counter+=max(0,a[i]-c)
  if counter<=k:
    r1=r2
  else:
    l1=r2
if l1==r1:
  print(r2)
else:
  counter=0
  r2=l1
  for i in range(n):
    c=r2//f[i]
    while (c+1)*f[i]<=r2:
      c+=1
    counter+=max(0,a[i]-c)
  if counter<=k:
    print(l1)
  else:
    print(r1)
### BUGGY CODE ###

import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
a = na()

def calc_lux(a):
    res = [0 for _ in range(len(a))]
    for i in range(len(a)):
        light = a[i]
        for j in range(max(0, i-light), min(n-1, i+light)+1, 1):
            res[j] += 1
    return res

for _ in range(k):
    # calc lux from a
    lux = calc_lux(a)

    if a==lux:
        a = lux
        break

    # overwrite a
    a = lux
    # print(lux)

print(" ".join([str(i) for i in a]))

### FIXED CODE ###

import sys
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
a = na()

def calc_lux(a):
    imosu = [0 for _ in range(len(a))]
    res = [0 for _ in range(len(a))]
    cnt = 0
    for i in range(len(a)):
        light = a[i]
        le = max(0, i-light)
        imosu[le] += 1
        if i+light < n-1:
            imosu[i+light+1] -= 1

    tmp = 0
    for i in range(len(res)):
        tmp += imosu[i]
        res[i] += tmp
    return res

for _ in range(k):
    # calc lux from a
    lux = calc_lux(a)

    if a==lux:
        a = lux
        break

    # overwrite a
    a = lux
    # print(lux)

print(" ".join([str(i) for i in a]))
### BUGGY CODE ###

from itertools import accumulate

N, K, *A = map(int, open(0).read().split())

for _ in range(min(K, 41)):
    B = [0] * N
    for x, d in enumerate(A):
        B[x - d if x > d else 0] += 1
        if (x := x + d + 1) < N:
            B[x] -= 1
    A = list(accumulate(B))

print(*A)

### FIXED CODE ###

from itertools import accumulate

N, K, *A = map(int, open(0).read().split())

for _ in range(min(K, 41)):
    B = [0] * (N + 1)
    for x, d in enumerate(A):
        B[max(0, x - d)] += 1
        B[min(N, x + d + 1)] -= 1
    A = list(accumulate(B))

print(*A[:-1])
### BUGGY CODE ###

n, k, q = list(map(int, input().split()))
b = []

for _ in range(n):
    b.append(k)

for i in range(q):
    a = int(input())
    b[a-1] += 1
    b = list(map(lambda x: x-1, b))

for i in range(len(b)):
    if b[i] > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

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

b = [k]*n

for i in range(q):
    a = int(input())
    b[a-1] += 1

b = list(map(lambda x: x-q, b))

for i in range(len(b)):
    if b[i] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math


#N,K=map(int,input().split())
N=int(input())
S=input()
Q=int(input())
Query=[input().split() for i in range(Q)]


def segfunc(x,y):
    return (x|y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])

def update(k,b):
    k += num-1
    if seg[k]==set([b]):
        return ()
    seg[k] = set([b])
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

ide_ele =set()

#num:n以上の最小の2のべき乗
n=N
num =2**(n-1).bit_length()
seg=[set() for i in range(2*num)]

for i in range(N):
    update(i,S[i])

for type,i,c in Query:

    if type=="1":
        update(int(i)-1,c)
    else:
        print(len(query(int(i)-1,int(c))))
    #print(seg)


### FIXED CODE ###

from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math


#N,K=map(int,input().split())
N=int(input())
S=input()
Q=int(input())
Query=[input().split() for i in range(Q)]

def segfunc(x,y):
    return (x|y)

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=seg[2*i+1]|seg[2*i+2]

def update(k,b):
    k += num-1
    if seg[k]=={b}:
        return ()
    seg[k] = {b}
    while k:
        k = (k-1)>>1
        seg[k] = seg[k*2+1]|seg[k*2+2]

def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=set()
    while q-p>1:
        if p&1 == 0:
            res = res|seg[p]
        if q&1 == 1:
            res = res|seg[q]
            q -= 1
        p = p>>1
        q = (q-1)>>1
    if p == q:
        res = res|seg[p]
    else:
        res = res|seg[p]|seg[q]
    return res

#num:n以上の最小の2のべき乗
n=N
num =2**(n-1).bit_length()
seg=[set()] * (2*num)

for i in range(N):
    seg[i+num-1]={ord(S[i])}
for k in range(num-2,-1,-1):
    seg[k] = seg[k*2+1]|seg[k*2+2]
for type, i, c in Query:
    if type=="1":
        update(int(i)-1,ord(c))
    else:
        print(len(query(int(i)-1,int(c))))
    #print(seg)
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
ans=[]
k=0
for i in range(0,n):
  for j in range(0,n):
    if(i != j and l[i] %l[j] ==0):
      k=0
      break
    else:k=1
  
  if(k==1):ans.append(i)
    
print(len(set(ans)))
     

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
l.sort();

ans = [0]*(l[n-1]+1)
p=0

while(p<n):
     
    for i in range(l[p],l[n-1]+1,l[p]):
        ans[i]+=1
    p+=1
   
    

c=0
#print(ans)
for i in l:
    if(ans[i]==1):
        c+=1
print(c)
### BUGGY CODE ###

import sys
import heapq
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    H,N = LI()
    M = []
    for i in range(N):
        M.append(LI())

    dp = {0:H}
    h = []
    heapq.heappush(h,0)
    nxt = -1

    for i in range(10**9):
        if dp.get(i,-1) == -1:
            continue
        if dp[i] == 0:
            print(i)
            return
        for j in range(N):
            dp[i+M[j][1]] = min(dp.get(i+M[j][1],H),max(0,dp[i]-M[j][0]))

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import heapq
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    H,N = LI()
    M = []
    for i in range(N):
        M.append(LI())

    dp = [10**10] * (H+1)
    dp[0] = 0

    for i in range(H):
        for j in range(N):
            HP = min(H,i+M[j][0])
            dp[HP] = min(dp[HP],dp[i]+M[j][1])
    print(dp[H])

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

n = int(input())
ls = [int(input()) for _ in range(n)]

def judge(n):
    if n == 2 or n == 3:
        return 1
    div = 3
    while div < n:
        if n%2 == 0 or n%div == 0:
            return 0
        else:  
            div += 2
    return 1

print(sum(map(judge, ls)))


### FIXED CODE ###

n = int(input())
ls = [int(input()) for _ in range(n)]


def judge(n):
    if n == 2 or n == 3:
        return 1
    if n % 2 == 0:
        return 0
    i = 3
    while i <= n/i:
        if n%i == 0:
            return 0
        else:  
            i += 2
    return 1

print(sum(map(judge, ls)))
### BUGGY CODE ###


import sys
from itertools import accumulate
N, = [int(i) for i in input().split(' ')]
As = [int(i) for i in input().split(' ')]
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def fractional(N):
    if N == 0:
        return 1
    else:
        return mul(N, fractional(N-1))

T = fractional(N)
fracs = list(accumulate([0] + [div(T, (i+1)) for i in range(N)]))


result = 0
for i in range(N):
    i = i+1
    x = mul(As[i-1], fracs[N-i+1] + (fracs[i] - fracs[1]))
    result = (result + x) % mod 
print(result)


### FIXED CODE ###


import sys
from itertools import accumulate
mod = pow(10, 9) + 7
N, = [int(i) for i in input().split(' ')]
As = [int(i) for i in input().split(' ')]
sys.setrecursionlimit(pow(10, 8))

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod

NNN = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def fractional(N):
    if N == 0:
        return 1
    else:
        return mul(N, fractional(N-1))

T = g1[N]
fracs = list(accumulate([0] + [mul(T, inverse[(i+1)]) for i in range(N)]))


result = 0
for i in range(N):
    i = i+1
    x = mul(As[i-1], fracs[N-i+1] + (fracs[i] - fracs[1]))
    result = (result + x) % mod 
print(result)
### BUGGY CODE ###

s=input()
k=int(input())

sl=[]
l=len(s)
for i in range(l):
    for j in range(i+1):
        sl.append(s[j:i+1])
              
li=[]
for i in sl:
    if i not in li:
        li.append(i)
        
li.sort()

print(li[k-1])

### FIXED CODE ###

s=input()
k=int(input())

l=list(s)

import collections
c=collections.Counter(l)
li=c.most_common()
from operator import itemgetter
li.sort(key=itemgetter(0))

co=0
p=[]
for i in range(min(5,len(li))):
    for j in range(len(s)):
        if l[j]==li[i][0]:
            for e in range(min(len(s)-j,k)):
                co+=1
                p.append(s[j:j+e+1])

q=collections.Counter(p)
ans=q.most_common()
ans.sort(key=itemgetter(0))   

print(ans[k-1][0])