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

mi = lambda: map(int, input().split())
e = enumerate
n,k = mi()
a = list(mi())
g = [None]*n

d = dict()
for i,x in e(a):
  d[x] = i
for i,x in e(a):
  g[d[x]] = ((i+1)%n,int(d[x]>=i)+int(i+1==n))
  d[x] = i
db = [g]
for _ in range(40):
  old = db[-1]
  new = [None]*n
  for i in range(n):
    p,q = old[i]
    r,s = old[p]
    new[i] = (r,q+s)
  db.append(new)
cur = 0
st = 40
cs = 0
while st>=0:
  p,q = db[st][cur]
  if cs+q < k:
    cs += q
    cur = p
  else:
    st -= 1
q = list()
for x in a[cur:]:
  if x in q:
    t = x-1
    while t != x:
      t = q.pop()
  else:
    q.append(x)
print(' '.join(map(str,q)))

### FIXED CODE ###

mi = lambda: map(int, input().split())
e = enumerate
n,k = mi()
m = (n+k).bit_length()
a = list(mi())
g = [None]*n

d = dict()
for i,x in e(a):
  d[x] = i
for i,x in e(a):
  g[d[x]] = ((i+1)%n,int(d[x]>=i)+int(i+1==n))
  d[x] = i
db = [g]
for _ in range(m):
  old = db[-1]
  new = [None]*n
  for i in range(n):
    p,q = old[i]
    r,s = old[p]
    new[i] = (r,q+s)
  db.append(new)
cur = 0
st = m
cs = 0
while st>=0:
  p,q = db[st][cur]
  if cs+q < k:
    cs += q
    cur = p
  else:
    st -= 1
    
q = list()
while cur < n:
  if g[cur][1] == 0:
    cur = g[cur][0]
  elif g[cur] == (0,1):
    break
  else:
    q.append(a[cur])
    cur += 1
  
print(' '.join(map(str,q)))
### BUGGY CODE ###

S=input()
Q=int(input())
reverse=False
for _ in range(Q):
    T=input()
    if T[0]=="1":
        reverse=not reverse
    else:
        _,F,C=T.split()

        if ((not reverse) and F=="1") or (reverse and F=="2"):
            S=C+S
        else:
            S=S+C

if reverse:
    print(S[::-1])
else:
    print(S)


### FIXED CODE ###

from collections import deque
H=deque(input())
Q=int(input())
reverse=False

A,B="",""
for _ in range(Q):
    T=input()
    if T[0]=="1":
        reverse=not reverse
    else:
        _,F,C=T.split()

        if ((not reverse) and F=="1") or (reverse and F=="2"):
            H.appendleft(C)
        else:
            H.append(C)

if reverse:
    H.reverse()

for s in H:
    print(s,end="")
print()
### BUGGY CODE ###

from collections import deque

Y, X = map(int,input().split())
# sy, sx = map(int, input().split())
# gy, gx = map(int, input().split())
sy,sx = 1,1
gy,gx = Y,X
s = [["#"]*(X+2) for _ in range(Y+2)]
for y in range(Y):
    s[y+1] = list("#"+input()+"#")
inf = Y*X
c = [[inf]*X for _ in range(Y)]
c[sy-1][sx-1] = 0
drs = [[-1,0],[1,0],[0,0],[0,-1],[0,1]]
q = deque([(sy-1, sx-1)])

while q:
    y,x = q.popleft()
    cost = c[y][x]
    for dx,dy in drs:
        x2 = x+dx
        y2 = y+dy
        if s[y2+1][x2+1] == "." and c[y2][x2] > cost:
            c[y2][x2] = cost+1
            q.append((y2,x2))
if c[gy-1][gx-1] == inf:
    print("-1")
else:
    dots = 0
    for s1 in s:
        dots +=s1.count(".")
    print(dots-c[gy-1][gx-1]-1)

### FIXED CODE ###

H, W = map(int,input().split())
c = [["#"]*(W+2) for _ in range(H+2)]
dots = 0
for y in range(H):
    c[y+1] = "#",*list(input()),"#" 
    dots += c[y+1].count(".")
inf = H*W
m = [[inf]*W for _ in range(H)]
m[0][0] = 0
drs = [[-1,0],[1,0],[0,-1],[0,1]]

s = 0
yx = [[1, 1]]
notgoal = True
while notgoal and yx:
    yx2 = []
    s += 1
    for y,x in yx:
        for dy, dx in drs:
            x2 = x+dx
            y2 = y+dy
            if c[y2][x2] == "." and m[y2-1][x2-1] == inf:
                m[y2-1][x2-1] = s
                if (y2,x2) == (H,W):
                    notgoal = False
                else:
                    yx2.append([y2, x2])
    yx = yx2

if notgoal:
    print("-1")
else:
    print(dots-s-1)
### BUGGY CODE ###

import bisect

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

Color = []
for a in A:
  idx = bisect.bisect_left(Color,a)
  if idx == 0:
    Color.insert(0,a)
  else:
    Color[idx-1] = a
  #Color.sort()
  #print(Color)
print(len(Color))

### FIXED CODE ###

import sys
input = sys.stdin.readline
import bisect

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

Color = []
for a in A:
  idx = bisect.bisect_right(Color,a)
  if idx == len(Color):
    Color.append(a)
  else:
    Color[idx] = a
  #Color.sort()
  #print(Color)
print(len(Color))
### BUGGY CODE ###

import sys
input = sys.stdin.readline


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

    for _ in range(K):
        B = [0]*N
        for i, a in enumerate(A):
            bottom = i - a
            top = i + a + 1
            if bottom < 0:
                bottom = 0
            if top > N:
                top = N
            B[bottom:top] = list(map(lambda x: x+1, B[bottom:top]))
        if A == B:
            A = B
            break
        A = B[:]

    ans = ' '.join(list(map(str, A)))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from numba import jit
import sys
input = sys.stdin.readline


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

    for _ in range(K):
        B = [0]*(N+1)
        for i, a in enumerate(A):
            B[max(0, i-a)] += 1
            B[min(N, i+a+1)] -= 1
        for j in range(1, N):
            B[j] += B[j-1]
        if A == B[:-1]:
            A = B[:-1]
            break
        A = B[:-1]

    ans = ' '.join(list(map(str, A)))
    print(ans)


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

X,K,D = map(int, input().split())
place = X

for i in range(K):
    if place >= 0 and (place - D) >= 0:
        place -= D
    elif place >= 0 and (place - D) <= 0:
        place -= D
    else: place += D 

if place < 0:
    place = abs(place)
print(place) 

### FIXED CODE ###

import sys
X,K,D = map(int, input().split())
if X < 0: X = abs(X) #Xがマイナスならプラスに変換しておく

if X // D > K:
    X = X - (K * D)
    print(X)
    sys.exit() #ここはOK

if (X // D) <= K:
    if X % D >= abs((X % D)-D):
        if (K - (X // D)) % 2 == 1:
            print(abs((X % D)-D))
            sys.exit()
        else:
            print(X % D)
            sys.exit()
    else:
        if (K - (X // D)) % 2 == 1:
            print(abs((X % D)-D))
            sys.exit()
        else:
            print(X % D)
            sys.exit()
### BUGGY CODE ###

# coding: utf-8
import sys
from collections import deque
from numba import jit

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

@jit
def main():
    N = ir()
    P = lr()
    P = [((p-1)//N, (p-1)%N) for p in P]
    dp = [[min(i, N-1-i, j, N-1-j) for j in range(N)] for i in range(N)]
    people = [[True] * N for i in range(N)]

    answer = 0
    for i, j in P:
        answer += dp[i][j]
        people[i][j] = False
        que = deque([(i, j, dp[i][j])])
        popleft = que.popleft; append = que.append
        while que:
            y, x, cur = popleft()
            cur += people[y][x]
            if x > 0:
                if dp[y][x-1] > cur:
                    dp[y][x-1] = cur
                    append((y, x-1, cur))
            if x < N-1:
                if dp[y][x+1] > cur:
                    dp[y][x+1] = cur
                    append((y, x+1, cur))
            if y > 0:
                if dp[y-1][x] > cur:
                    dp[y-1][x] = cur
                    append((y-1, x, cur))
            if y < N-1:
                if dp[y+1][x] > cur:
                    dp[y+1][x] = cur
                    append((y+1, x, cur))

    print(answer)
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

# coding: utf-8
import sys
from collections import deque

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def main():
    N = ir()
    P = lr()
    P = [((p-1)//N, (p-1)%N) for p in P]
    dp = [[min(i, N-1-i, j, N-1-j) for j in range(N)] for i in range(N)]
    people = [[True] * N for i in range(N)]

    answer = 0
    for i, j in P:
        answer += dp[i][j]
        people[i][j] = False
        que = deque([(i, j, dp[i][j])])
        popleft = que.popleft; append = que.append
        while que:
            y, x, cur = popleft()
            cur += people[y][x]
            if x > 0:
                if dp[y][x-1] > cur:
                    dp[y][x-1] = cur
                    append((y, x-1, cur))
            if x < N-1:
                if dp[y][x+1] > cur:
                    dp[y][x+1] = cur
                    append((y, x+1, cur))
            if y > 0:
                if dp[y-1][x] > cur:
                    dp[y-1][x] = cur
                    append((y-1, x, cur))
            if y < N-1:
                if dp[y+1][x] > cur:
                    dp[y+1][x] = cur
                    append((y+1, x, cur))

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

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
for i in range(M):
    A[-1] //= 2
    A = sorted(A)
print(sum(A))


### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = [-i for i in list(map(int, input().split()))]
heapq.heapify(A)
for m in range(M):
    A_max = -heapq.heappop(A)  # Aの最大値を削除して取り出す
    heapq.heappush(A, -(A_max // 2))
print(-sum(A))
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline
N, C = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [[0] * (C + 1) for _ in range(N)]
mod = 10 ** 9 + 7
for i in range(N):
  for j in range(C + 1):
    for k in range(a[i], b[i] + 1):
      c[i][j] += (k ** j) % mod
      c[i][j] %= mod
dpx = [0] * (C + 1)
dpy = [0] * (C + 1)
dpx[0] = 1
for i in range(N):
  if i % 2:
    dpx = [0] * (C + 1)
  else:
    dpy = [0] * (C + 1)
  for j in range(C + 1):
    for k in range(j, C + 1):
      if i % 2:
        dpx[k] += dpy[j] * c[i][k - j]
        dpx[k] %= mod
      else:
        dpy[k] += dpx[j] * c[i][k - j]
        dpy[k] %= mod
if N % 2:
  print(dpy[-1] % mod)
else:
  print(dpx[-1] % mod)

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
N, C = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * (N * (C + 1))
mod = 10 ** 9 + 7
for i in range(N):
  c[i * (C + 1)] = b[i] - a[i] + 1
for i in range(N):
  for k in range(a[i], b[i] + 1):
    t = 1
    for j in range(C):
      t *= k
      t %= mod 
      c[i * (C + 1) + j + 1] += t
      c[i * (C + 1) + j + 1] %= mod
dpx = [0] * (C + 1)
dpy = [0] * (C + 1)
dpx[0] = 1
for i in range(N):
  if i % 2:
    dpx = [0] * (C + 1)
  else:
    dpy = [0] * (C + 1)
  for j in range(C + 1):
    for k in range(j, C + 1):
      if i % 2:
        dpx[k] += dpy[j] * c[i * (C + 1) + k - j]
        dpx[k] %= mod
      else:
        dpy[k] += dpx[j] * c[i * (C + 1) + k - j]
        dpy[k] %= mod
if N % 2:
  print(dpy[-1] % mod)
else:
  print(dpx[-1] % mod)
### BUGGY CODE ###

import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7
P = 2 ** 127 - 1

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

pow2 = [1] * (N + 10)
for n in range(1, N + 10):
    pow2[n] = pow2[n - 1] * 2 % MOD

def inv_mod(a):
    b = P
    u, v = 1, 0
    while a:
        q, r = divmod(b, a)
        a, b = r, a
        u, v = v - q * u, u
    if b < 0:
        v = -v
    if v < 0:
        v += P
    return v

def to_key(a, b):
    if a == 0:
        return -1
    x = inv_mod(a) * b % P
    return x

def pair_key(key):
    if key == -1:
        return 0
    if key == 0:
        return -1
    return P - inv_mod(key)
  
counter = defaultdict(int)
origin = 0
for a, b in zip(A, B):
    if a == b == 0:
        origin += 1
        continue
    key = to_key(a, b)
    counter[key] += 1

answer = origin
k = 1
for key, cnt in counter.items():
    key1 = pair_key(key)
    if key1 not in counter:
        k *= pow2[cnt]
    elif key < key1:
        x, y = cnt, counter[key1]
        k *= pow2[x] + pow2[y] - 1
    k %= MOD
answer += k - 1
answer %= MOD
print(answer)


### FIXED CODE ###

import sys
from collections import defaultdict
from math import gcd

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

pow2 = [1] * (N + 10)
for n in range(1, N + 10):
    pow2[n] = pow2[n - 1] * 2 % MOD

def to_standard_form(a, b):
    if a == 0:
        return (0, 1)
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        return (-a, -b)
    return (a, b)

counter0 = defaultdict(int)
counter1 = defaultdict(int)
origin = 0
for a, b in zip(A, B):
    if a == b == 0:
        origin += 1
        continue
    a, b = to_standard_form(a, b)
    if b <= 0:
        counter0[(a, b)] += 1
    else:
        counter1[(b, -a)] += 1
        counter0[(b, -a)] += 0

answer = origin
k = 1
for key, cnt0 in counter0.items():
    cnt1 = counter1[key]
    x = pow2[cnt0] + pow2[cnt1]
    k = k * (x - 1) % MOD

answer += k - 1
answer %= MOD
print(answer)
### BUGGY CODE ###

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

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

B = []
C = []

for j in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
    
candidate = []
candidate.extend(A)

for i, b in enumerate(B):
    for j in range(b):
        candidate.append(C[i])
        
sorted_candidate = sorted(candidate, reverse=True)

print(sum(sorted_candidate[:N]))

### FIXED CODE ###

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

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

BC = []

for j in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
    
sorted_BC = sorted(BC, reverse=True, key=lambda item: item[1])

candidate = []
count = N
for bc in sorted_BC:
    b = bc[0]
    c = bc[1]
    if count >= 0:
        candidate.extend([c] * b)
        count = count - b
    else:
        break
    
candidate.extend(A)

print(sum(sorted(candidate, reverse=True)[:N]))
### BUGGY CODE ###

n,k=map(int,input().split())
li=[[0,0] for i in range(n)]
for i in range(n):
    li[i][0],li[i][1]=map(int,input().split())

li.sort(reverse=True,key=lambda x:x[1])

def find_num_neta(choice,li):
    k=[]
    for i in choice:
        k.append(li[i][0])
    return len(set(k))

#-----------------------------------------
best_list=[]
best_list_neta=[]
not_best_list=[]

for i in li:
    if i[0] in best_list_neta:
        not_best_list.append(i)
    else:
        best_list.append(i)
        best_list_neta.append(i[0])


s2=min(find_num_neta(list(range(n)),li),k)
s1=find_num_neta(list(range(k)),li)


score=-1
for i in range(s1,s2+1):
    oishisa=0
    for j in range(i):
        oishisa+=best_list[j][1]
    for j in range(k-i):
        oishisa+=not_best_list[j][1]
    
    new_score=i**2+oishisa

    if score<new_score:
        score=new_score
        
    
print(score)

### FIXED CODE ###

n,k=map(int,input().split())
li=[[0,0] for i in range(n)]
for i in range(n):
    li[i][0],li[i][1]=map(int,input().split())



def find_num_neta(choice,li):
    k=[]
    for i in choice:
        k.append(li[i][0])
    return len(set(k))
#-----------------------------------------

li.sort(reverse=True,key=lambda x:x[1])
s2=min(find_num_neta(list(range(n)),li),k)
s1=find_num_neta(list(range(k)),li)
oishisa=sum([li[i][1] for i in range(k)])
score=oishisa+s1**2

#-----------------------------------------
li.sort(key=lambda x:x[0])
best_list=[]
not_best_list=[]


m=-1
for i in li:
    if m==i[0]:
        not_best_list.append(i)
    else:
        best_list.append(i)
        m=i[0]
        
not_best_list.sort(reverse=True,key=lambda x:x[1])
best_list.sort(reverse=True,key=lambda x:x[1])



 
 
for i in range(s1+1,s2+1):
    oishisa=oishisa+best_list[i-1][1]-not_best_list[k-i][1]
    
    new_score=i**2+oishisa
    
    if score<new_score:
        score=new_score
        
    
print(score)
### BUGGY CODE ###

#!/usr/bin/env python3

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

for _ in range(M):
    max_diff = -float("inf")
    max_index = 0
    for i, a in enumerate(a_list):
        if a - (a // 2) > max_diff:
            max_diff = a - (a // 2)
            max_a = a // 2
            max_index = i
    a_list[max_index] = max_a

ans = sum(a_list)
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import heapq

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

# Pythonのheapqは最小値しかとれないので、負の値に変換して扱う
a_list = list(map(lambda x: x * (-1), a_list))
heapq.heapify(a_list)

for _ in range(M):
    max_value = -heapq.heappop(a_list)
    heapq.heappush(a_list, -(max_value // 2))

ans = -sum(a_list)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

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

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

        if x == y:
            return

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

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

    def 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_members(self):
        return {r: self.members(r) for r in self.roots()}

def main():
    h, w = map(int, input().split())
    tizu = [input().strip() for _ in range(h)]
    
    directions = [[1, 0], [0, 1]]
    UF = UnionFind(h * w)
    for i in range(h):
        for j in range(w):
            for dy, dx in directions:
                ny = i + dy
                nx = j + dx
                if ny == h or nx == w:
                    continue
                if tizu[i][j] != tizu[ny][nx]:
                    UF.union(i * w + j, ny * w + nx)
    
    ans = 0
    for _, lst in UF.all_group_members().items():
        b_cnt = 0
        w_cnt = 0
        for num in lst:
            i = num // w
            j = num % w
            if tizu[i][j] == "#":
                b_cnt += 1
            else:
                w_cnt += 1
        ans += b_cnt * w_cnt
    print(ans)

main()

### FIXED CODE ###

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

def main():
    h, w = map(int, input().split())
    tizu = [input().strip() for _ in range(h)]
    directions = [[-1, 0], [1, 0], [0, -1], [0, 1]]
    used = [[False for _ in range(w)] for _ in range(h)]
    
    ans = 0
    for i in range(h):
        for j in range(w):
            if used[i][j]:
                continue
            used[i][j] = True
            queue = deque()
            queue.append([i, j])
            queue.append(tizu[i][j])
            b_cnt = 0
            w_cnt = 0
            while queue:
                pos = queue.popleft()
                bw = queue.popleft()
                if bw == "#":
                    b_cnt += 1
                else:
                    w_cnt += 1
                for dy, dx in directions:
                    ny = dy + pos[0]
                    nx = dx + pos[1]
                    if ny == -1 or ny == h or nx == -1 or nx == w:
                        continue
                    if used[ny][nx]:
                        continue
                    bw2 = tizu[ny][nx]
                    if bw == bw2:
                        continue
                    used[ny][nx] = True
                    queue.append([ny, nx])
                    queue.append(bw2)
            ans += b_cnt * w_cnt
    print(ans)

main()
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
# import numpy as np

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
A = LI()

"""
明るさが一定値を超えると計算しなくて良い
一定？d > math.floort(N/2)
"""

# lamps = [[0] * N] * (K + 1)
lamps = [[0 for i in range(N)] for j in range(K + 1)]
lamps[0] = A

# lamps = np.array(lamps)

if K > 40:
    b = [str(N)] * N
    print(" ".join(b))
    sys.exit()

for i in range(K):
    tmps = [0 for i in range(N)]
    for j in range(N):
        w = lamps[i][j]
        tmps[max(0, j - w)] += 1
        r = min(N-1, j + w)
        if r + 1 < N:
            tmps[r + 1] -= 1
    hoge = 0
    for j in range(N):
        hoge += tmps[j]
        lamps[i + 1][j] = hoge
ans = lamps[-1]
ans = map(str, ans)
print(" ".join(ans))


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
A = LI()

"""
明るさが一定値を超えると計算しなくて良い
一定？d > math.floort(N/2)
"""
if K > 50:
    b = [str(N)] * N
    print(" ".join(b))
    sys.exit()

lamps = [[0 for i in range(N)] for j in range(K + 1)]
lamps[0] = A

"""
累積和〜
"""
for i in range(K):
    if lamps[i] == [N for i in range(N)]:
        ans = [str(N) for i in range(N)]
        print(" ".join(ans))
    tmps = [0 for i in range(N)]
    for j in range(N):
        w = lamps[i][j]
        tmps[max(0, j - w)] += 1
        r = min(N-1, j + w)
        if r + 1 < N:
            tmps[r + 1] -= 1
    hoge = 0
    for j in range(N):
        hoge += tmps[j]
        lamps[i + 1][j] = hoge
ans = lamps[-1]
ans = map(str, ans)
print(" ".join(ans))
### BUGGY CODE ###

import sys
import heapq
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = [[0 for i in range(3 * n)] for j in range(3 * n)]
for i in range(m):
    u, v = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    graph[u][n+v] = 1
    graph[u+n][2*n+v] = 1
    graph[u + 2 * n][v] = 1
s, t = [int(i) for i in sys.stdin.readline().split()]
s -= 1
t -= 1

def dijkstra(graph, s, g):
    que = [(0,s)]
    already = set()
    flg = False
    while que:
        cost, cur = heapq.heappop(que)
        already.add(cur)
        if cur == g:
            flg = True
            break
        for i, _next in enumerate(graph[cur]):
            if _next == 0:
                continue
            if i in already:
                continue
            heapq.heappush(que, (cost + 1, i))
    if not flg:
        cost = -1
        return cost
    return cost // 3

res = dijkstra(graph, s, t)
print(res)

### FIXED CODE ###

import sys
INF = 10 ** 9
n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {j:[] for j in range(3 * n)}
for i in range(m):
    u, v = [int(i) for i in sys.stdin.readline().split()]
    u -= 1
    v -= 1
    graph[u].append(n+v)
    graph[u+n].append(2*n+v)
    graph[u + 2 * n].append(v)
s, t = [int(i) for i in sys.stdin.readline().split()]
s -= 1
t -= 1

que = [s]
flg = False
already = set()
dist = [INF for i in range(3 * n)]
dist[s] = 0
while que:
    cur= que[0]
    que.pop(0)
    for i in graph[cur]:
        if i not in already:
            if i == t:
                res = dist[cur] + 1
                que.clear()
                flg = True
                break
            que.append(i)
            dist[i] = dist[cur] + 1
            already.add(i)
if not flg:
    res = -1
else:
    res //= 3

print(res)
### BUGGY CODE ###

def solve(i,j,a):
    k=False
    sc=0
    for c in a:
        if c>j:
            break
        elif c>j//2 and c<j:
            continue
        elif c==j:
            sc+=1
            if sc>=2:
                k=True
                break
        else:
            if j%c==0:
                k=True
                break
    return k

n=int(input())
a=sorted(list(map(int,input().split())))
ans=0
for i,j in enumerate(a):
    if solve(i,j,a):
        continue
    else:
        ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=max(a)
cnt=[0 for _ in range(m+1)]
ans=0
for i in a:
    if cnt[i]>=1:
        cnt[i]+=1
        continue
    for j in range(2*i,m+1,i):
        cnt[j]+=1
    cnt[i]=1
for i in range(n):
    if cnt[a[i]]==1:
        ans+=1
print(ans)