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

from collections import deque
from numba import njit, b1, i4, i8, f8
import numpy as np
import sys

read = sys.stdin.read
readline = sys.stdin.readline

@njit((i8,i8,i8,i8,i8,i8,b1[:, :]), cache=True)
def solve(H,W,C_h,C_w,D_h,D_w,S):
  INF = int(1e7)
  dist = [[INF]*(W) for _ in range(H)]
  dist[C_h][C_w] = 0
  isinque = [[False]*(W) for _ in range(H)]
  que1 = [(C_h,C_w)]
  que2 = []
  i,j = 0,0

  move_a = [(1,0),(0,1),(-1,0),(0,-1)]
  move_b = [(-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2),(-1,-2),(-1,-1),(-1,1),(-1,2),(0,-2),(0,2),(1,-2),(1,-1),(1,1),(1,2),(2,-2),(2,-1),(2,0),(2,1),(2,2)]

  while True:
    if i==len(que1) and j==len(que2):
      break;
    while i<len(que1):
      h,w = que1[i]
      i += 1
      isinque[h][w] = False
      for dh,dw in move_a:
        nh,nw = h+dh,w+dw
        if 0<=nh<H and 0<=nw<W and S[nh][nw] and dist[nh][nw] > dist[h][w]:
          dist[nh][nw] = dist[h][w]
          if isinque[nh][nw]==False:
            que1.append((nh,nw))
            isinque[nh][nw] = True
      for dh,dw in move_b:
        nh,nw = h+dh,w+dw
        if 0<=nh<H and 0<=nw<W and S[nh][nw] and dist[nh][nw] > dist[h][w]+1:
          dist[nh][nw] = dist[h][w]+1
          if isinque[nh][nw]==False:
            que2.append((nh,nw))
            isinque[nh][nw] = True
    while j<len(que2):
      h,w = que2[j]
      j += 1
      isinque[h][w] = False
      for dh,dw in move_a:
        nh,nw = h+dh,w+dw
        if 0<=nh<H and 0<=nw<W and S[nh][nw] and dist[nh][nw] > dist[h][w]:
          dist[nh][nw] = dist[h][w]
          if isinque[nh][nw]==False:
            que1.append((nh,nw))
            isinque[nh][nw] = True
      for dh,dw in move_b:
        nh,nw = h+dh,w+dw
        if 0<=nh<H and 0<=nw<W and S[nh][nw] and dist[nh][nw] > dist[h][w]+1:
          dist[nh][nw] = dist[h][w]+1
          if isinque[nh][nw]==False:
            que2.append((nh,nw))
            isinque[nh][nw] = True
  print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)

H,W = map(int,readline().split())
C_h,C_w = map(lambda x:int(x)-1,readline().split())
D_h,D_w = map(lambda x:int(x)-1,readline().split())
S = np.array([[c=='.' for c in readline()] for _ in range(H)])
solve(H,W,C_h,C_w,D_h,D_w,S)

### FIXED CODE ###

from collections import deque

H,W = map(int,input().split())
C_h,C_w = map(lambda x:int(x)-1,input().split())
D_h,D_w = map(lambda x:int(x)-1,input().split())
S = [input() for _ in range(H)]

INF = int(1e10)
dist = [[INF]*(W) for _ in range(H)]
deq = deque()
deq.append((C_h,C_w,0))

move_a = [(1,0),(0,1),(-1,0),(0,-1)]
move_b = [(i,j)for i in range(-2,2+1) for j in range(-2,2+1) if abs(i)+abs(j)>=2]

while len(deq):
  h,w,c = deq.popleft()
  if dist[h][w] <= c:
    continue
  dist[h][w] = c
  for dh,dw in move_a:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c:
      deq.appendleft((nh,nw,c))
  for dh,dw in move_b:
    nh,nw = h+dh,w+dw
    if nh<0 or nw<0 or nh>=H or nw>=W:
      continue
    if S[nh][nw] == '#':
      continue
    if dist[nh][nw] > c+1:
      deq.append((nh,nw,c+1))
  
print(dist[D_h][D_w] if dist[D_h][D_w]<INF else -1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
a = int(input())
count = 0
first = 2
def num_div(num):
  a = 2
  while num!=1:
    if num % a == 0:
      while True:
        if num % a ==0:
          num /= a
        elif num == 1:
          return 0
        else:
          return -1
    a += 1

#print(num_div(2))
#sys.exit(0)

while a!=1:
  #素因数は一つ？
  if num_div(first) == -1:
    first += 1
    continue
  if a % first == 0:
    a /= first
    first += 1
    count += 1
print(count)

### FIXED CODE ###

from collections import Counter

def prime_factor(num):
  factor_list = []
  while num % 2 == 0:
    factor_list.append(2)
    num /= 2
  f = 3
  while f * f <= num:
    if num % f == 0:
      factor_list.append(f)
      num /= f
    else:
      f += 2
  if num!=1:
    factor_list.append(num)
  return factor_list

def get_count(c):
  ans = 0
  _max = c
  for i in range(1,c+1):
    if i <= _max:
      ans += 1
      _max -= i
    else:
      break
  return ans
a = int(input())
counter = Counter(prime_factor(a))
ans = 0
for i in counter:
  ans += get_count(counter[i])
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
from collections import defaultdict
X = defaultdict(set)
Y = defaultdict(set)
N = int(input())
xy = set()
for _ in range(N):
    x, y = inpl()
    xy.add((x,y))
    X[y].add(x)
    Y[x].add(y)
ans = 0
while True:
    newxy = set()
    for x, y in xy:
        for newx in X[y]:
            for newy in Y[x]:
                if not newx in X[newy]:
                    newxy.add((newx,newy))
                    X[newy].add(newx)
                    Y[newx].add(newy)
                    ans += 1
    if len(newxy) == 0:
        break
    else:
        xy = set()
        for x,y in newxy:
            for xp in X[y]:
                xy.add((xp,y))
            for yp in Y[x]:
                xy.add((x,yp))
        xy = newxy | xy
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
from collections import defaultdict

class UnionFind:
    def __init__(self, N=None):
        if N is None or N < 1:
            self.parent = defaultdict(lambda: -1)
        else:
            self.parent = [-1]*int(N)

    def root(self, n):
        if self.parent[n] < 0:
            return n
        else:
            m = self.root(self.parent[n])
            self.parent[n] = m
            return m

    def merge(self, m, n):
        rm = self.root(m)
        rn = self.root(n)
        if rm != rn:
            if -self.parent[rm] < -self.parent[rn]:
                rm, rn = rn, rm
            self.parent[rm] += self.parent[rn]
            self.parent[rn] = rm

    def size(self, n):
        return -self.parent[self.root(n)]
    
    def connected(self, m, n):
        return self.root(m) == self.root(n)
    
    def groups(self):
        if isinstance(self.parent,list):
            return list(map(lambda x: x<0, self.parent)).count(True)
        else: # self.parent: defaultdict
            return list(map(lambda x: x<0, self.parent.values())).count(True) 

class CountUp:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

Xi = defaultdict(CountUp())
Yi = defaultdict(CountUp())
N = int(input())
xy = []
for _ in range(N):
    x, y = inpl()
    xi = Xi[x]
    yi = Yi[y]
    xy.append((xi,yi))
Nx = len(Xi)
Ny = len(Yi)
Nxy = Nx + Ny
uf = UnionFind(Nx+Ny)
for xi, yi in xy:
    uf.merge(xi,yi+Nx)

gi = defaultdict(CountUp())
Ng = uf.groups()
edges = [0]*Ng
nx = [0]*Ng
ny = [0]*Ng
for i in range(Nx):
    nx[gi[uf.root(i)]] += 1
for i in range(Nx,Nxy):
    ny[gi[uf.root(i)]] += 1
for xi, yi in xy:
    edges[gi[uf.root(xi)]] += 1

ans = 0
for g in range(Ng):
    ans += nx[g]*ny[g] - edges[g]
print(ans)
### BUGGY CODE ###

import random
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
numans=0
s=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s.append(list(map(int,input().split())))
    for j in range(26):
        num5=s[i-1][j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    numans+=num2+s[i-1][num1-1]
    num[num1-1]=i
def sco(n1,n2,n3):
    n0=0
    n01=[0]*26
    old=ans[n1]
    ans[n1]=n2
    for k in range(n3):
        n0+=s[k][ans[k]-1]
        n01[ans[k]-1]=k+1
        for l in range(26):
            n0-=(k+1-n01[l])*c[l]
    return n0
for i in range(500):
    for j in range(d):
        num6=random.randint(1,26)
        num100=sco(j,num6,d)
        if num100>numans:
            ans[j]=num6
for i in range(d):
    print(ans[i])


### FIXED CODE ###

d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s=list(map(int,input().split()))
    for j in range(26):
        num5=s[j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    num[num1-1]=i
for i in range(d):
    print(ans[i])
### BUGGY CODE ###

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

n = max(a, b)

for i in range(n):
    if abs(a-i) == abs(i-b):
        print(i)
        exit()

print('IMPOSSIBLE')


### FIXED CODE ###

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

n = (a+b) % 2
if n == 0:
    print((a+b) // 2)
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

n,*bb = map(int, open(0).read().split())

ans = []

while bb:
    for i,v in zip(range(len(bb),0,-1),bb[::-1]):
#         print(i,v)
        if i==v:
            ans.append(v)
            del bb[i-1]
            break

for a in ans[::-1]:
    print(a)

### FIXED CODE ###

n,*bb = map(int, open(0).read().split())

ans = []

while bb:
    imp = True
    for i,v in zip(range(len(bb),0,-1),bb[::-1]):
#         print(i,v)
        if i==v:
            ans.append(v)
            del bb[i-1]
            imp = False
            break
    if imp:
        ans = [-1]
        break

for a in ans[::-1]:
    print(a)
### BUGGY CODE ###

N = int(input())
line = input().split()
str_ = []
flag = 0 if (N % 2 != 0) else 1
for index, s in enumerate(line):
    if (flag):
        str_ += [s]
    else:
        str_ = [s] + str_
    flag ^= 1
print(' '.join(str_))

### FIXED CODE ###

from collections import deque
N = int(input())
line = input().split()
Q = deque([])

flag = 0 if (N % 2 != 0) else 1
for i in range(N):
    if (i % 2 == 0):
        if (flag):
            Q.append(line[i])
        else:
            Q.appendleft(line[i])
    else:
        if (flag):
            Q.appendleft(line[i])
        else:
            Q.append(line[i])

print(' '.join(Q))
### BUGGY CODE ###

N,M = input().split()
N,M = int(N),int(M)
f_start = [0 for i in range(N)]
A,B = [],[]
import heapq
for i in range(N):
    a,b = input().split()
    a,b = int(a),int(b)
    A.append(a)
    B.append(-b)
    
def add(q_,add_):
    for i in range(len(add_)):
        heapq.heappush(q_,add_[i])

def kouho(A,B,m):
    kouho_list = []
    for i in range(len(B)):
        if(A[i]==m):
            kouho_list.append(B[i])
    return kouho_list

q = []
heapq.heapify(q)
sum_money = 0

for m in range(1,M+1):
    kouho_list = kouho(A,B,m)
    add(q,kouho_list)
    #print(q)
    if(len(q)>0):
        sum_money += -heapq.heappop(q)
print(sum_money)

### FIXED CODE ###

N,M = input().split()
N,M = int(N),int(M)
f_start = [0 for i in range(N)]
A,B = [],[]
import heapq
for i in range(N):
    a,b = input().split()
    a,b = int(a),int(b)
    A.append(a)
    B.append(-b)
    
def add(q_,add_):
    for i in range(len(add_)):
        heapq.heappush(q_,add_[i])

def kouho(A,B,M):
    kouho_list = [[] for i in range(M+1)]
    for i in range(len(A)):
        if(A[i]<=M):
            kouho_list[A[i]].append(B[i])
    return kouho_list

q = []
heapq.heapify(q)
sum_money = 0

kouho_list = kouho(A,B,M)
for m in range(1,M+1):
    kouho_ = kouho_list[m]
    add(q,kouho_)
    #print(q)
    if(len(q)>0):
        sum_money += -heapq.heappop(q)
print(sum_money)
### BUGGY CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()
A.sort()

def cmb(n, r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

max = max(A)
index = bisect_left(A, max / 2)
if cmb(max, A[index]) > cmb(max, A[index - 1]):
    ans = [max, A[index]]
else:
    ans = [max, A[index - 1]]
print(*ans)

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
A = getList()
A.sort()

max = max(A)
index = bisect_left(A, max / 2)
if abs((max / 2) - A[index]) < abs((max / 2) - A[index - 1]):
    ans = [max, A[index]]
else:
    ans = [max, A[index - 1]]
print(*ans)
### BUGGY CODE ###

n = int(input())
s = input()
ans = []
for i in range(n):
    grp1 = s[:i]
    grp2 = s[i+1:]
    cnt = grp1.count('W') + grp2.count('E')
    ans.append(cnt)
print(min(ans))

### FIXED CODE ###

n = int(input())
s = input()

w_num = [0] * (n+1)
e_num = [0] * (n+1)
e = s.count('E')

for i in range(n):
    if s[i] == 'W':
        w_num[i+1] = w_num[i] + 1
    else:
        w_num[i+1] = w_num[i]
        
    if s[i] == 'E':
        e_num[i+1] = e_num[i] + 1
    else:
        e_num[i+1] = e_num[i]


ans = n

for i in range(n):
    cnt = w_num[i] + (e - e_num[i+1])
    if cnt < ans:
        ans = cnt

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

import copy
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(len(A)):
  a = copy.deepcopy(A)
  a.pop(i)
  print(max(a))

### FIXED CODE ###

import numpy as np

N = int(input())
A = [int(input()) for i in range(N)]
A = np.array(A)
first = max(A)
arg = A.argsort()
first_idx = arg[-1]
second_idx = arg[-2]
second = A[second_idx]
for i in range(len(A)):
  if i==first_idx:
    print(second)
  else:
    print(first)
### BUGGY CODE ###

P=1000000007
def gcd(x,y):
  return (y if x%y==0 else gcd(y,x%y))
N=int(input())
A=list(map(int,input().split()))
l=1
for a in A:
  l=a*l//gcd(a,l)
ans=0
for a in A:
  ans+=l//a
print(ans%P)



### FIXED CODE ###

P=1000000007
def power(x,p):
  if(p==0):
    return 1;
  if(p%2):
    return power(x,p-1)*x%P;
  a=power(x,p//2);
  return a*a%P;
def inv(x):
  return power(x,P-2);
N=int(input());A=list(map(int,input().split()));
#N=10000;A=[1000000 for i in range(N)];
L=[0 for i in range(max(A)+1)]
for a in A:
  t=a;i=2;
  while(i**2<=a):
    c=0;
    while(t%i==0):
      t//=i;c+=1;
    L[i]=max(L[i],c)
    i+=1;
  if(t!=1):
    L[t]=max(L[t],1)
    
l=1;
for i in range(2,len(L)):
  l=l*power(i,L[i])%P;
b=0;
for a in A:
  b=(b+inv(a))%P
print(l*b%P)
### BUGGY CODE ###

H, W, N = map(int, input().split())
S = set()
toCheck = set()
rs = [0] * 10
for _ in range(N):
    a, b = map(int, input().split())
    S.add((a, b))
    for i in range(3):
        for j in range(3):
            toCheck.add((a - i, b - j))

for a, b in toCheck:
    if a + 2 > H or b + 2 > W or b < 1 or a < 1:
        continue
    cnt = 0
    for i in range(3):
        for j in range(3):
            na, nb = a + i, b + j
            if (na, nb) in S:
                cnt += 1
    rs[cnt] += 1

total = max(0, H - 2) * max(0, W - 2)
rs[0] = total - sum(rs[1:])
for it in rs:
    print(it)




### FIXED CODE ###

H, W, N = map(int, input().split())
S = set()
toCheck = set()
rs = [0] * 10
for _ in range(N):
    a, b = map(int, input().split())
    S.add((a, b))
    for i in range(3):
        for j in range(3):
            toCheck.add((a - i, b - j))

for a, b in toCheck:
    if a + 2 > H or b + 2 > W or b < 1 or a < 1:
        continue
    cnt = 0
    for i in range(3):
        for j in range(3):
            na, nb = a + i, b + j
            if (na, nb) in S:
                cnt += 1
    rs[cnt] += 1

total = max(0, H - 2) * max(0, W - 2)
rs[0] = total - sum(rs[1:])
for it in rs:
    print(it)
### BUGGY CODE ###

n=int(input())
arr=[int(input()) for _ in range(n)]
ans=[-1]*(n+1)
num=1
ans[0]=arr[0]
for i in range(1,n):
  for j in range(num):
    if ans[j]<arr[i]:
      ans[j]=arr[i]
      break
  else:
    ans[num]=arr[i]
    num+=1
print(num)

### FIXED CODE ###

#quoted LIS from https://qiita.com/python_walker/items/d1e2be789f6e7a0851e5
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS=[arr[0]]
for i in range(1,n):
  if arr[i]>=LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_right(LIS,arr[i])]=arr[i]
print(len(LIS))
### BUGGY CODE ###

input()
da = list(map(int,input().split()))
da.insert(0,0)
al = 0
for k in range(1,len(da)):
  da[k] += da[k-1]
  if da[k]== 0:
        al += 1
for i in range(1,len(da)):
    for j in range(1,len(da)-i):
      if da[i+j] - da[i] == 0:
        al += 1
print(al)

### FIXED CODE ###

from collections import defaultdict
 
n = int(input())
a = [int(i) for i in input().split()]
 
s = 0
d = defaultdict(int)
ans = 0
d[0] = 1
 
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
 
print(ans)
### BUGGY CODE ###

N = int(input())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

A = A[::-1]
B = B[::-1]
R = [0 for _ in range(N)]
for i, (a, b) in enumerate(zip(A, B)):
    r = a % b
    if r > 0:
        r = b - r
    R[i] = r

ans = 0
for i in range(0, N):
    r = R[i]
    ans += r
    for j in range(i + 1, N):
        rj = R[j]
        rj -= r
        R[j] = rj % B[j]

print(ans)


### FIXED CODE ###

N = int(input())
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

A = A[::-1]
B = B[::-1]
R = [0 for _ in range(N)]
for i, (a, b) in enumerate(zip(A, B)):
    r = a % b
    if r > 0:
        r = b - r
    R[i] = r

ans = R[0]
for i in range(1, N):
    r = R[i]
    r = r - ans
    r = r % B[i]
    ans += r

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

import copy
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    b = copy.deepcopy(a)
    del b[i]
    b.sort()
    print(b[-1])

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 1e18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    if a[i] == 0:
        print(0)
        exit()
for i in range(n):
    ans *= a[i]
    if ans > 1e18:
        print(-1)
        exit()
if ans > 1e18:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

from decimal import *
getcontext().prec = 40000
a, b, c = map(int, input().split())
#print(a **.5, b**.5,c**.5)
#print(a **.5+ b**.5,c**.5)
#print(Decimal(a).sqrt() , Decimal(b).sqrt() , Decimal(c).sqrt())
if Decimal(a).sqrt() + Decimal(b).sqrt() >= Decimal(c).sqrt():
#if a **.5 + b**.5 < c**.5:
    print('No')
else:
    print('Yes')
    

### FIXED CODE ###

from decimal import *
getcontext().prec = 30000
a, b, c = map(int, input().split())
#print(a **.5, b**.5,c**.5)
#print(a **.5+ b**.5,c**.5)
#print(Decimal(a).sqrt() , Decimal(b).sqrt() , Decimal(c).sqrt())
#if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
if 2 * Decimal(a * b).sqrt() + Decimal(b) + Decimal(a) < Decimal(c):
#if a **.5 + b**.5 < c**.5:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
for i in range(n-1):
    cnt = 10**9
    for j in range(k):
        if i-j < 0: continue
        cnt = min(dp[-1-j] + abs(h[i-j]-h[i+1]), cnt)
        #print("i =",i,"j =",j,"i-j =",i-j,"i+j =",i+j,"cnt =",cnt)
    dp += [cnt]
print(dp[-1])

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]
for i in range(n-1):
    cnt = float("inf")
    for j in range(k):
        if i-j < 0: continue
        cnt = min(dp[-1-j] + abs(h[i-j]-h[i+1]), cnt)
        #print("i =",i,"j =",j,"i-j =",i-j,"i+j =",i+j,"cnt =",cnt)
    dp.append(cnt)
print(dp[-1])
### BUGGY CODE ###

# 入力
N = int(input())
c = [0]*4
for a in input().split():
    c[int(a)] += 1

# DPテーブルを初期化
dp = [[[-1 for k in range(310)] for j in range(310)] for i in range(310)]
dp[0][0][0] = 0


for k in range(0, c[3] + 1):
    for j in range(0, c[2]+c[3]-k + 1):
        for i in range(0, c[1]+c[2]+c[3]-j-k + 1):
            if i == j == k == 0:
                continue
            temp = N
            if i != 0:
                temp += i*dp[i - 1][j][k]
            if j != 0:
                temp += j*dp[i + 1][j - 1][k]
            if k != 0:
                temp += k*dp[i][j + 1][k - 1]
            dp[i][j][k] = temp / (i + j + k)


# 答えを得て出力
print(dp[c[1]][c[2]][c[3]])


### FIXED CODE ###

import collections

# 入力
N = int(input())
c = collections.Counter(list(map(int, input().split())))

# DPテーブルを初期化
dp = [[[0.0 for k in range(310)] for j in range(310)] for i in range(310)]


for k in range(0, c[3] + 1):
    for j in range(0, c[2]+c[3]-k + 1):
        for i in range(0, c[1]+c[2]+c[3]-j-k + 1):
            if i == j == k == 0:
                continue
            dp[i][j][k] = (N+i*dp[i - 1][j][k]+j *
                           dp[i + 1][j - 1][k]+k*dp[i][j + 1][k - 1])/(i+j+k)


# 答えを得て出力
print(dp[c[1]][c[2]][c[3]])
### BUGGY CODE ###

import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt=0
for i in range(N-1,1,-1):
    for j in range(i-1,0,-1):
        b = bisect.bisect_right(L[:j],L[i]-L[j])
        cnt+=j-b
print(cnt)

### FIXED CODE ###

import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        b = bisect.bisect_left(L,L[i]+L[j])
        cnt += b-j-1
print(cnt)
### BUGGY CODE ###

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)

### FIXED CODE ###

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

ans = 1
for i in a:
    if i == 0:
      	ans = 0

if ans != 0:
	for i in a:
		ans = ans*i
		if ans > 1000000000000000000:
			break

if ans <= 1000000000000000000:
	print(ans)
else:
  	print(-1)
### BUGGY CODE ###

import sys
from collections import defaultdict

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():

    N = in_n()
    A = list(in_nn())

    d = defaultdict(lambda: 0)
    for i in range(N):
        d[A[i]] += 1

    ans = 0
    for i in range(N):
        for num in make_divisors(A[i]):
            #print(A[i], num)
            if num == A[i]:
                if d[num] >= 2:
                    break
            else:
                if d[num] >= 1:
                    break
        else:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = sorted(list(in_nn()))

    maxA = max(A)
    ans = [True] * (maxA + 1)
    d = set()

    for i in range(N):
        if A[i] in d:
            ans[A[i]] = False
        for j in range(A[i] * 2, maxA + 1, A[i]):
            if not j:
                break
            else:
                ans[j] = False
        d |= {A[i]}

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

    print(count)


if __name__ == '__main__':
    main()