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

def main():
    N = int(input())
    a = [list(map(int, input().split())) for i in range(N)]

    now = [0] * N
    day = 0
    while True:
        had_game = False
        all_finish = True
        can_game = [True] * N
        for i in range(N):
            if now[i] < N-1 and can_game[i]:
                all_finish = False
                want = a[i][now[i]] - 1
                if can_game[want]:
                    if a[want][now[want]] - 1 == i:# 相手の試合相手が自分
                        now[want] += 1
                        now[i] += 1
                        can_game[i] = False
                        can_game[want] = False
                        had_game = True
                        # print(day+1, i+1, want+1)
        if all_finish:
            if had_game:
                print(day+1)
            else:
                print(day)
            break
        if not had_game:
            print(-1)
            break
        day += 1
    # print(now)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import time
def main():
    N = int(input())
    a = [list(map(int, input().split())) for i in range(N)]
    start = time.time()
    now = [0] * N
    day = 0
    gamed_day = [-1] * N
    finished = 0
    while True:
        if time.time() - start > 1.6:
            print((N*(N-1))//2)
            break
        had_game = False
        all_finish = True
        for i in range(N-1, -1, -1):
            if now[i] < N-1 and gamed_day[i] != day:
                all_finish = False
                want = a[i][now[i]] - 1
                if gamed_day[want] != day:# 今日試合していない
                    if a[want][now[want]] - 1 == i:# 相手の試合相手が自分
                        now[want] += 1
                        now[i] += 1
                        if now[want] >= N-1:
                            finished += 1
                        if now[i] >= N-1:
                            finished += 1
                        gamed_day[i] = day
                        gamed_day[want] = day
                        had_game = True
                        # print(day+1, i+1, want+1)
        if all_finish or finished == N:
            if had_game:
                print(day+1)
            else:
                print(day)
            break
        if not had_game:
            print(-1)
            break
        day += 1
    # print(now)

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

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

q = m // n
for i in range(q):
    p = q - i
    r = m % p
    if r == 0:
        print(p)
        exit()


### FIXED CODE ###

import math

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

q = m // n

ret = 0
for i in range(1, int(math.sqrt(m))+1):
    if m % i == 0:
        if i <= q and ret < i:
            ret = i
        p = m//i
        if m//i <= q and ret < p:
            ret = p
print(ret)
### BUGGY CODE ###

from heapq import heappop, heappush

X, Y, Z, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
h = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            heappush(h, -(A[i] + B[j] + C[k]))
for _ in range(K):
    print(-heappop(h))


### FIXED CODE ###

from heapq import heappop, heappush

X, Y, Z, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
C = [int(s) for s in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
counted = set()
h = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
for _ in range(K):
    s, i, j, k = heappop(h)
    print(-s)
    if X > i+1 and (i+1, j, k) not in counted:
        heappush(h, (-(A[i+1] + B[j] + C[k]), i+1, j, k))
        counted.add((i+1, j, k))
    if Y > j+1 and (i, j+1, k) not in counted:
        heappush(h, (-(A[i] + B[j+1] + C[k]), i, j+1, k))
        counted.add((i, j+1, k))
    if Z > k+1 and (i, j, k+1) not in counted:
        heappush(h, (-(A[i] + B[j] + C[k+1]), i, j, k+1))
        counted.add((i, j, k+1))
### BUGGY CODE ###

import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

N = readInt()
S = readChar()
rgb = {"R":[],"G":[],"B":[]}
for i in range(N):
	rgb[S[i]].append(i)

c=s=0
for r in rgb["R"]:
	for g in rgb["G"]:
		for b in rgb["B"]:
			a = sorted([r,g,b])
			if a[2]-a[1]!=a[1]-a[0]:
				c+=1


print(c)


### FIXED CODE ###

import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def binary_search(li,item):#二分探索
	left,right = 0, len(li)
	while left<=right:
		mid = (left+right)//2
		if li[mid]==item:
			return mid
		elif li[mid]<item:
			left = mid+1
		else:
			right = mid-1
	return -1

N = readInt()
S = readChar()
rgb = {"R":[],"G":[],"B":[]}
for i in range(N):
	rgb[S[i]].append(i)

c=s=0
c=len(rgb["R"])*len(rgb["G"])*len(rgb["B"])
for i in range(N):
	for j in range(i+1,N):
		k = 2*j-i
		if k>=N:
			continue
		if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
			s+=1

ans=c-s
print(ans)
### BUGGY CODE ###

from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
answer = 0
for i in range(N):
    for j in range(i+1, N):
        answer += bisect_left(L[j+1:], L[i]+L[j])
print(answer)


### FIXED CODE ###

from bisect import bisect_left

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

from collections import deque

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

checked = [-1 for _ in range(N)]
checked[0] = 0
d = deque([0])
while d:
    now = d.popleft()
    for i in range(M):
        if (L[i][0] - 1 == now and checked[L[i][1]-1] == -1):
            checked[L[i][1]-1] = now + 1
            d.append(L[i][1]-1)

        if (L[i][1] - 1 == now and checked[L[i][0]-1] == -1):
            checked[L[i][0]-1] = now + 1
            d.append(L[i][0]-1)


flag = False
for i in range(1, N):
    if checked[i] == -1:
        flag = True
        break

if flag:
    print('No')
else:
    print('Yes')
    for i in range(1, N):
        print(checked[i])

### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]
link = [[] for _ in range(N)]

for i in range(M):
    link[L[i][0]-1].append(L[i][1]-1)
    link[L[i][1]-1].append(L[i][0]-1)

checked = [-1 for _ in range(N)]
checked[0] = 0
d = deque([0])
while d:
    now = d.popleft()
    for i in range(len(link[now])):
        if checked[link[now][i]] == -1:
            checked[link[now][i]] = now + 1
            d.append(link[now][i])


flag = False
for i in range(1, N):
    if checked[i] == -1:
        flag = True
        break

if flag:
    print('No')
else:
    print('Yes')
    for i in range(1, N):
        print(checked[i])
### BUGGY CODE ###

# coding: utf-8

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


ans = [float("inf")]*(n)

ans[0] = 0
ans[1] = abs(h_list[1]-h_list[0])

for i in range(n):
    for j in range(1,k+1):
        if i+j > n-1:
            break
        ans[i+j] = min(ans[i+j], ans[i]+abs(h_list[i+j]-h_list[i]))
        
# print(ans)
print(ans[-1])

### FIXED CODE ###

# coding: utf-8
import numpy as np

n, k = map(int, input().split())
h_list = np.array([int(x) for x in input().split()])

ans = np.zeros(n, dtype=int)

for i in range(1, n):
    start = max(i-k, 0)
    ans[i] = np.min(ans[start:i] + np.abs(h_list[start:i] - h_list[i]))
        
# print(ans)
print(ans[-1])
### BUGGY CODE ###

from collections import deque
S = deque([s for s in input()])
Q = int(input())
for i in range(Q):
    query = input().split()
    t = int(query[0])
    if t == 1:
        S.reverse()
    else:
        f = int(query[1])
        c = query[2]
        if f == 1:
            S.appendleft(c)
        else:
            S.append(c)
print(''.join(S))


### FIXED CODE ###

from collections import deque
def main():
    S = deque([s for s in input()])
    Q = int(input())
    order = True
    for i in range(Q):
        query = input().split()
        t = int(query[0])
        if t == 1:
            order = not order
        else:
            f = int(query[1])
            c = query[2]
            left = True
            if f == 1:
                if order:
                    left = True
                else:
                    left = False
            else:
                if order:
                    left = False
                else:
                    left = True
            if left:
                S.appendleft(c)
            else:
                S.append(c)
    if not order:
        S.reverse()
    print(''.join(S))

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

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

s = list(input())
q = int(input())

for i in range(q):
    query = input()
    if query == "1":
        s = s[::-1]
    else:
        x, q2_1, q2_2 = query.split()
        if q2_1 == "1":
            a = deque(s)
            a.appendleft(q2_2)
            s = list(a)
        else:
            s.append(q2_2)
print("".join(s))

### FIXED CODE ###

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

s = list(input())
q = int(input())

a = deque(s)
reverse = False

for i in range(q):
    query = input()
    if query == "1":
        if reverse:
            reverse = False
        else:
            reverse = True
    else:
        x, q2_1, q2_2 = query.split()
        if q2_1 == "1":
            if reverse:
                a.append(q2_2)
            else:
                a.appendleft(q2_2)
        else:
            if reverse:
                a.appendleft(q2_2)
            else:
                a.append(q2_2)

s = list(a)
if reverse:
    s = s[::-1]
    print("".join(s))
else:
    print("".join(s))
### BUGGY CODE ###

def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

start = 0
end = 0
ans = 0
l.sort(key=lambda x: x[1])
#print(l)
while(len(l) > 0):
    ans += 1
    start = l[0][0]
    end = l[0][1]
    l = l[1:]
    if len(l) < 1:
        break
    remove_ind = []
    for ind, i in enumerate(l):
        if i[0] > end:
            start = i[0]
            end = i[1]
            remove_ind .append(ind)
    l = [l[i] for i in range(len(l)) if i not in remove_ind]
print(ans)


### FIXED CODE ###

def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n, c = LI()
l = []
for i in range(n):
    l.append(LI())

#チャンネル見る必要がある
#同じチャンネルで連続しているものはくっつける
la = [[[], []] for i in range(c)]
for i in l:
    la[i[2] - 1][0].append(i[0])
    la[i[2] - 1][1].append(i[1])

starts = []
ends = []
for s, e in la:
    wa = set(s).union(set(e))
    seki = set(s).intersection(set(e))
    a = list(wa.difference(seki))
    a.sort()
    for i, j in zip(a[0::2], a[1::2]):
        starts.append(i)
        ends.append(j)

s = min(starts)
e = max(ends)

imos = [0 for i in range(s,e + 2)]
for i, j in zip(starts, ends):
    imos[i - s] += 1
    imos[j - s + 1] -= 1
for i in range(len(imos) - 1):
    imos[i + 1] += imos[i]

print(max(imos))
### BUGGY CODE ###


def main():
  _n = int(input())
  ans = 1
  for num in map(int, input().split()):
    ans *= num

  print(ans if ans <= 10**18 else -1)

main()


### FIXED CODE ###


def main():
  _n = int(input())
  ans = 1
  for num in map(int, input().split()):
    if num == 0:
      print(0)
      return

    if ans <= 10**18:
      ans *= num

  print(ans if ans <= 10**18 else -1)

main()
### BUGGY CODE ###

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

for i in range(10**9):
    if abs(A-i) == abs(B-i):
        print(i)
        break
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

A, B = map(int, input().split())
ans = (A+B) / 2
if str(ans)[-1] == "0":
    print(int(ans))
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

from statistics import median
N = int(input())
X = [int(i) for i in input().split()]
for n in range(N):
    temp = X[:n] + X[n+1:]
    print(median(temp))

### FIXED CODE ###

from statistics import median
N = int(input())
X = [int(i) for i in input().split()]
sort_X = sorted(X)
sort_X = sort_X[N//2-1:N//2+1]
for x in X:
    if sort_X[0] >= x:
        print(sort_X[1])
    else:
        print(sort_X[0])
### BUGGY CODE ###

N,C = map(int,input().split())
ld = [[]]
for i in range(C):
  ld.append([0]+list(map(int,input().split())))
lc = [[]]  
for i in range(N):
  lc.append([0]+list(map(int,input().split())))

#こたえ作り
lans = []
for i in range(1,C+1):
  for j in range(i+1,C+1):
    for k in range(j+1,C+1):
      for cc in [[i,j,k],[i,k,j],[j,i,k],[j,k,i],[k,i,j],[k,j,i]]:
        ans = 0
        for p in range(1,N+1):
          for q in range(1,N+1):
            X = lc[p][q]
            Y = cc[(p+q)%3]
            ans += ld[X][Y]
        lans.append(ans)
print(min(lans))

### FIXED CODE ###

#然列挙では間に合わない
N,C = map(int,input().split())
ld = [[]]
for i in range(C):
  ld.append([0]+list(map(int,input().split())))
lc = [[]]  
for i in range(N):
  lc.append([0]+list(map(int,input().split())))

#前処理
lmae = [[0 for i in range(C+1)] for j in range(3)]
for p in range(1,N+1):
  for q in range(1,N+1):
    for i in range(1,C+1):
      X = lc[p][q]
      Y = i
      lmae[(p+q)%3][i] += ld[X][Y]

#こたえ作り
lans = []
for i in range(1,C+1):
  for j in range(i+1,C+1):
    for k in range(j+1,C+1):
      for cc in [[0,1,2],[0,2,1],[1,0,2],[1,2,0],[2,0,1],[2,1,0]]:
        ans = lmae[cc[0]][i]+lmae[cc[1]][j]+lmae[cc[2]][k]
        lans.append(ans)
print(min(lans))
### BUGGY CODE ###

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

	divisors.sort()
	return divisors

x = int(input())

l = make_divisors(x)

for i in range(max(len(l)//2,1)):
	a = -10**4+l[i]
	b = -10**4
	#print(a,b)
	while True:
		num = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
		if num == l[-i-1]:
			print(a,b)
			#print('Yes!')
			break
		if a == 10**6:
			break
		#print(l[-i-1],num)
		a += 1
		b += 1



### FIXED CODE ###

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

	divisors.sort()
	return divisors

x = int(input())

l = make_divisors(x)

for i in range(max(len(l)//2,1)):
	a = -10**3+l[i]
	b = -10**3
	#print(a,b)
	while True:
		num = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
		if num == l[-i-1]:
			print(a,b)
			#print('Yes!')
			break
		if b == 10**3:
			break
		#print(l[-i-1],num)
		a += 1
		b += 1
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
n = 0
can = True

while can:
    for i in range(N):
        if A[i]%2 != 0:
            break

        if A[i]%2 == 0:         
            A[i] = A[i] // 2
            n += 1
        else:
            can = False
            break

print(n)

### FIXED CODE ###

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

while 1:
    #すべてが偶数か確認
    for i in range(N):
        if A[i] % 2 == 0:
            continue
        else:
            F = 1
    
    if F == 1 : break 

    for i in range(N):
        A[i] = A[i]/2
    n += 1


print(n)
### BUGGY CODE ###

def binary_search(ls, val):
    ls_norm = len(ls)

    if ls_norm == 0:
        return -1

    mid = int(ls_norm / 2)

    if ls[mid] == val:
        return mid
    elif ls[mid] > val:
        return binary_search(ls[0: mid], val)
    else:
        return binary_search(ls[mid + 1:], val)

n = int(input())
S = [int(i) for i in input().split(' ')]

q = int(input())
T = [int(i) for i in input().split(' ')]

result = 0
for t in T:
    if binary_search(S, t) != -1:
        result += 1

print(result)


### FIXED CODE ###

def binary_search(S, key):
    S_len = len(S)

    if S_len == 0:
        return -1

    mid = S_len // 2

    if S[mid] == key:
        return 1

    if S[mid] >= key:
        return binary_search(S[:mid], key)
    else:
        return binary_search(S[mid + 1:], key)

n = int(input())
S = [int(i) for i in input().split(' ')]

q = int(input())
T = [int(i) for i in input().split(' ')]

result = 0

for t in T:
    left, right = 0, n
    while left < right:
        mid = (right + left) // 2
        if S[mid] == t:
            result += 1
            break

        if S[mid] > t:
            right = mid
        else:
            left = mid + 1

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

def popcount(n):
    cnt = 0
    for i in range(n):
        if ((n >> i) & 1):
            cnt +=1
    return cnt

def f(n):
    cnt = 0
    while True:
        if n == 0:
            break
        n = n % popcount(n)
        cnt += 1
    return cnt

def numChange(list, i):
    num = 0
    j = 0
    while True:
        if i < 0:
            break
        num += int(list[i]) * pow_r(2, j)
        i -= 1
        j += 1
    return num

def pow_r(x, n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return pow_r(x ** 2, n // 2)
    else:
        return x * pow_r(x ** 2, (n - 1) // 2)

if __name__ == "__main__":
    n = int(input())
    xList = list(input())
    k = len(xList) - 1
    for i in range(n):
        if xList[i] == '0':
            xList[i] = '1'
        else:
            xList[i] = '0'
        xNum = numChange(xList, k)
        print(f(xNum))
        if xList[i] == '0':
            xList[i] = '1'
        else:
            xList[i] = '0'


### FIXED CODE ###

def f(n):
    cnt = 1
    while n > 0:
        n  %= bin(n).count('1')
        cnt += 1
    return cnt

if __name__ == "__main__":
    n = int(input())
    x = input()
    d = x.count('1')
    if d == 1:
        for i in x[:-1]:
            if i == '0':
                print(1)
            else:
                print(0)
        if x[-1] == '1':
            print(0)
        else:
            print(2)
        exit()

    ans = []
    M = 0
    for i in x:
        M <<= 1
        if i == '1':
            M += 1
    p = M % (d + 1)
    m = M % (d - 1)
    for i in range(n):
        if x[i] == '0':
            ans.append(f((p + pow(2, n - i - 1, d + 1)) % (d + 1)))
        else:
            ans.append(f((m - pow(2, n - i - 1, d - 1)) % (d - 1)))
    print(*ans, sep='\n')
### BUGGY CODE ###

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

dp = [0]*(10**6)

for i in a:
  m = 2
  while i*m <= 10**6:
    dp[i*m-1] = 1
    m += 1
ans = 0
for i in a:
  if a.count(i) == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
 
dp = [0]*(10**6)
count = [0]*(10**6)

for i in a:
  count[i-1] += 1
 
b = list(set(a))
for i in b:
  for j in range(i*2, 10**6+1, i):
    dp[j-1] = 1
    
ans = 0
for i in a:
  if count[i-1] == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
lr = [range(l, r+1) for l, r in lr]

ans = set(range(1, n+1))
for i in range(m):
    ans = ans & set(lr[i])
print(len(ans))

### FIXED CODE ###

from sys import stdin
n, m = map(int, stdin.readline().split())
mn = 1
mx = n

for i in range(m):
    l, r = map(int, stdin.readline().split())
    mn = max(mn, l)
    mx = min(mx, r)
print(max(0, mx-mn+1))
### BUGGY CODE ###

import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n,r):
    return P(n, r)//math.factorial(r)

n, a, b = map(int,input().split())
num = 10**9+7
ans = 2**n - 1
ans -= C(n, a)
ans -= C(n, b)
print(ans%num)

### FIXED CODE ###

n, a, b = map(int, input().split())
MOD = 10**9+7

len_inv = 2*(10**5) + 10
inv = [1]*(len_inv)

for i in range(2, len_inv):
    inv[i] = inv[MOD%i] * (MOD - MOD//i) % MOD

def comb(n, k, MOD):
    x = 1
    for i in range(k):
        x *= (n-i)
        x *= inv[i+1]
        x %= MOD
    return x

ans = pow(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)
ans += MOD
ans %= MOD
print(ans)
### BUGGY CODE ###

import itertools 

N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()
C=list(itertools.combinations(S,3))
count=0
for i in C:
    if i[0]<i[1]+i[2]:
        count+=1
print(count)

### FIXED CODE ###



N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()

count=0
le=len(S)
S.append(-100000)
for i in range(le-2):
    for j in range(i+1,le-1):
        if S[i]<S[j]+S[j+1]:
            left=j+1
            right=le
            while left<=right:
                mid=(left+right)//2
                if S[i]<S[j]+S[mid] and S[i]>=S[j]+S[mid+1]:
                    count+= mid-(j+1)+1
                    
                    break
                elif S[i]<S[j]+S[mid]:
                    left=mid+1
                elif S[i]>=S[j]+S[mid]:
                    right=mid-1
                else:
                    print("イレギュラーな例につかまりました")
                    exit()
                
print(count)
### BUGGY CODE ###

import sys

x, y = map(int, input().split())
cnt = 0
if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    while x <= 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        x += 1
        cnt += 1
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
else:
    while x >= 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        x += 1
        cnt += 1
    if x == y:
        print(cnt)
    else:
        print(cnt+1)

### FIXED CODE ###

import sys

x, y = map(int, input().split())
cnt = 0
if abs(x) == abs(y):
    print(1)
elif abs(x) < abs(y):
    while x < 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(y) - abs(x)
        x += abs(y) - abs(x)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
else:
    while x > 0:
        x *= -1
        cnt += 1
    while abs(x) != abs(y):
        cnt += abs(x) - abs(y)
        x += abs(x) - abs(y)
    if x == y:
        print(cnt)
    else:
        print(cnt+1)
### BUGGY CODE ###

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

MAX=10**6+1

n=ni()
a=nl()

s = [0]*(MAX)

for ai in a:
  if s[ai]==2:
    continue
  for i in range(ai,MAX,ai):
    s[i]+=1

cnt=0
for ai in a:
  if s[ai]==1:
    cnt+=1

print(cnt)

### FIXED CODE ###

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

MAX=10**6+1

n=ni()
a=nl()

s = [0]*(MAX)

for ai in a:
  if s[ai]!=0:
    s[ai]=2
    continue
  for i in range(ai,MAX,ai):
    s[i]+=1

cnt=0
for ai in a:
  if s[ai]==1:
    cnt+=1

print(cnt)