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

S = input()
p = 0
head = ''
end = ''
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        end += Qr[2]
      else:
        head = Qr[2]+head
    else:
      if p:
        head = Qr[2]+head
      else:
        end += Qr[2]
S = head + S + end
if p:
  print(S[::-1])
else:
  print(S)


### FIXED CODE ###

S = input()
p = 0
head = ''
end = ''
Q = int(input())
for _ in range(Q):
  Qr = list(input().split())
  if int(Qr[0])==1:
    p = not p
  else:
    if int(Qr[1])==1:
      if p:
        end += Qr[2]
      else:
        head = Qr[2]+head
    else:
      if p:
        head = Qr[2]+head
      else:
        end += Qr[2]
S = head + S + end
if p:
  print(S[::-1])
else:
  print(S)
### BUGGY CODE ###

n, m = map(lambda x: int(x), input().split(' '))
l = []
r = []
for i in range(m):
    l_tmp, r_tmp = map(lambda x: int(x), input().split(' '))
    l.append(l_tmp)
    r.append(r_tmp)

result = 0
card_id = l[0]
for j in range(n):
    for locked_l, locked_r in zip(l, r):
        if not (locked_l <= card_id + j <= locked_r):
            break
    else:   
        result += 1

print(result)


### FIXED CODE ###

n, m = map(lambda x: int(x), input().split(' '))
l = []
r = []
for i in range(m):
    l_tmp, r_tmp = map(lambda x: int(x), input().split(' '))
    l.append(l_tmp)
    r.append(r_tmp)

l_max = max(l)
r_min = min(r)

result = 0
if l_max <= r_min:
    result = r_min - l_max + 1
print(result)
### BUGGY CODE ###

import itertools

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

cnt = 0
for iter in itertools.combinations(range(0,N),2):
    if abs(iter[0] - iter[1]) == A[iter[0]] + A[iter[1]]:
        cnt += 1

print(cnt)


### FIXED CODE ###

from collections import Counter

def CHK():
    N = int(input())
    A = list(map(int,input().split()))
    L=[]
    R=[]
    cnt = 0
    for i in range(N):
        L.append(i + A[i])
    L_Cnt=Counter(L)

    for i in range(N):
        chk = i -A[i]
        cnt += L_Cnt[chk]
    print(cnt)

CHK()
### BUGGY CODE ###

# 2019/12/27

import sys
input=sys.stdin.readline

def main():
    h,w=map(int,input().split())
    s=[list('#'*(w+2))]
    for _ in range(h):
        s+=[list('#'+input()+'#')]
    s+=[list('#'*(w+2))]

    G=[]
    for i in range(h+2):
        g=[]
        for j in range(w+2):
            g.append([0,0,0,0])
        G.append(g)
    L,U,R,D=list(range(4))

    for i in range(1,h+1):
        for j in range(1,w+1):
            if s[i][j]=="#":continue
            G[i][j][L]=G[i][j-1][L]+1
            G[i][j][U]=G[i-1][j][U]+1
            
    ans=0

    for i in range(h,0,-1):
        for j in range(w,0,-1):
            if s[i][j]=="#":continue
            G[i][j][R]=G[i][j+1][R]+1
            G[i][j][D]=G[i+1][j][D]+1
            lit=G[i][j][L]+G[i][j][U]+G[i][j][R]+G[i][j][D]-3
            ans=max(ans,lit)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

# 2019/12/27

h,w=map(int,input().split())
s=[list('#'*(w+2))]
for _ in range(h):
    s+=[list('#'+input()+'#')]
s+=[list('#'*(w+2))]

L,U,R,D=[[[0]*(w+2) for _ in range(h+2)] for _ in range(4)]

for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=="#":continue
        L[i][j]=L[i][j-1]+1
        U[i][j]=U[i-1][j]+1

ans=0

for i in range(h,0,-1):
    for j in range(w,0,-1):
        if s[i][j]=="#":continue
        R[i][j]=R[i][j+1]+1
        D[i][j]=D[i+1][j]+1
        lit=L[i][j]+U[i][j]+R[i][j]+D[i][j]-3
        ans=max(ans,lit)
print(ans)
### BUGGY CODE ###

A,B,Q=map(int, input().split())
S=[int(input()) for _ in range(A)]
T=[int(input()) for _ in range(B)]
X=[int(input()) for _ in range(Q)]

import bisect
def solve(x):
    sr=bisect.bisect_right(S,x)
    tr=bisect.bisect_right(T,x)
    sl=sr-1
    tl=tr-1
    ret=10**12
    if sl>=0 and tl>=0:
        ret=min(ret,x-min(S[sl],T[tl]))
    if sr<A and tl>=0:
        ret=min(ret,S[sr]-T[tl]+min(S[sr]-x,x-T[tl]))
    if sl>=0 and tr<B:
        ret=min(ret,T[tr]-S[sl]+min(T[tr]-x,x-S[sl]))
    if sr<A and tr<B:
        ret=min(ret,max(S[sr],T[tr])-x)
    return ret

for x in X:
    print(solve(x))

### FIXED CODE ###

import sys
input = sys.stdin.readline
A,B,Q=map(int, input().split())
S=[int(input()) for _ in range(A)]
T=[int(input()) for _ in range(B)]
X=[int(input()) for _ in range(Q)]

import bisect
def solve(x):
    sr=bisect.bisect_right(S,x)
    tr=bisect.bisect_right(T,x)
    sl=sr-1
    tl=tr-1
    ret=10**12
    if sl>=0 and tl>=0:
        ret=min(ret,x-min(S[sl],T[tl]))
    if sr<A and tl>=0:
        ret=min(ret,S[sr]-T[tl]+min(S[sr]-x,x-T[tl]))
    if sl>=0 and tr<B:
        ret=min(ret,T[tr]-S[sl]+min(T[tr]-x,x-S[sl]))
    if sr<A and tr<B:
        ret=min(ret,max(S[sr],T[tr])-x)
    return ret

for x in X:
    print(solve(x))
### BUGGY CODE ###

S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
for x in query:
    if int(x[0]) == 1:
        S = S[::-1]
    elif int(x[0]) == 2:
        if int(x[1]) == 1:
            S = x[2] + S
        elif int(x[1]) == 2:
            S = S + x[2]
print(S)

### FIXED CODE ###

from collections import deque
S = input()
Q = int(input())
query = [list(input().split()) for _ in range(Q)]
reversecount = 0
d = deque(S)
for x in query:
    if int(x[0]) == 1:
        reversecount += 1
    else:
        if (int(x[1]) == 1 and (reversecount % 2 == 0)) or (int(x[1]) == 2 and (reversecount % 2 == 1)):
            d.appendleft(x[2])
        else:
            d.append(x[2])
if reversecount % 2 == 1:
    d.reverse()
print(*d, sep='')
### BUGGY CODE ###

import numpy as np
def main():
    h, w = map(int, input().split())
    s = np.array([list(input()) for _ in range(h)])
    t = np.zeros((h+2, w+2))
    t[1:-1, 1:-1][s == "."] = 1
    cost = np.zeros((h+2, w+2))
    for i in range(1, h+1):
        idx = np.where(t[i] == 0)
        for j in range(np.size(idx) - 1):
            L, R = idx[0][j], idx[0][j+1]
            cost[i][L+1:R] = np.add(cost[i][L+1:R], R-L-1)
    cost = cost.T
    t = t.T
    for i in range(1, w+1):
        idx = np.where(t[i] == 0)
        for j in range(np.size(idx) - 1):
            L, R = idx[0][j], idx[0][j+1]
            cost[i][L+1:R] = np.add(cost[i][L+1:R], R-L-1-1)
    print(int(np.max(cost)))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy as np
def main():
    h, w = map(int, input().split())
    s = np.array([list(input()) for _ in range(h)])
    t = np.zeros((h+2, w+2))
    t[1:-1, 1:-1][s == "."] = 1
    row = np.zeros((h+2, w+2))
    col = np.zeros((w+2, h+2))
    for i in range(1, h+1):
        idx = np.where(t[i] == 0)[0]
        dif = np.diff(idx)
        row[i, idx[:-1]+1] += dif-1
        row[i, idx[1:]] -= dif-1
        row[i] = np.cumsum(row[i])
    t = t.T
    for i in range(1, w+1):
        idx = np.where(t[i] == 0)[0]
        dif = np.diff(idx)
        col[i, idx[:-1]] += dif-2
        col[i, idx[1:]] -= dif-2
        col[i] = np.cumsum(col[i])
    col = col.T
    cost = np.add(row, col)
    print(int(np.max(cost)))

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

Row = int(input())
List = []
for i in range (Row):
  List.append(input())
mid = 0
s_l = set(List)
n = len(s_l)
for i in range(n):
  mid = max(mid,List.count(s_l.pop()))
s_l = set(List)
k=""
tryList = []
for i in range(n):
  k=s_l.pop()
  if List.count(k) == mid:
    tryList.append(k)
tryList.sort()
for element in tryList:
  print(element)

### FIXED CODE ###

Row = int(input())
dictA= {}
a = ""
mid = 0
for i in range (Row):
  a = input()
  dictA.setdefault(a,0) 
  dictA[a] += 1
  mid = max(mid, dictA[a])
sDict = sorted(dictA.items())
for i in range(len(dictA)):
  if sDict[i][1]== mid:
    print(sDict[i][0])
### BUGGY CODE ###

R,G,B,N = map(int,input().split())
ans = 0
for r in range(3001):
    for g in range(3001):
        remain = N - r*R - g*G
        if remain >= 0 and remain % B == 0:
            ans += 1
print(ans)

### FIXED CODE ###

R,G,B,N = map(int,input().split())
ans = 0
for r in range(3001):
    for g in range(3001):
        remain = N - r*R - g*G
        if remain >= 0 and remain % B == 0:
            ans += 1
print(ans)
### BUGGY CODE ###

from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
    
q = deque()
q.append(0)

ans = [-1 for _ in range(n)]
distance = [float('inf') for _ in range(n)]
distance[0] = 0
ans[0] = 0

visited = set({})

while q:
    start = q.popleft()
    visited.add(start)
    for i in graph[start]:
        distance[i] = min(distance[i], distance[start] + 1)
        if i not in visited:
            q.append(i)
            if (ans[i] == -1):
                ans[i] = start
                
if -1 not in ans:
    print('Yes')
    for i in range(1, n):
        print(ans[i] + 1)
else:
    print('No')

### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
    
q = deque()
q.append(0)

ans = [-1 for _ in range(n)]
ans[0] = 0

visited = set({})

while q:
    start = q.popleft()
    visited.add(start)
    for i in graph[start]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = start
                
if -1 not in ans:
    print('Yes')
    for i in range(1, n):
        print(ans[i] + 1)
else:
    print('No')
### BUGGY CODE ###

def main():
  n,m=map(int,input().split())
  a=list(map(int,input().split()))
  for i in range(m):
    a.sort(reverse=True)
    a[0]=a[0]//2
  print(sum(a))
main()


### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[-_ for _ in a]
import heapq
heapq.heapify(a)
for i in range(m):
  temp=-heapq.heappop(a)
  heapq.heappush(a,-(temp//2))
  
print(-sum(a))
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = list(reversed(sorted(a)))
b = list(reversed(sorted(b)))
c = list(reversed(sorted(c)))

ab = []
for i in range(min(len(a), k)):
    ax = a[i]
    for j in range(min(len(b), k)):
        bx = b[j]
        ab.append(ax+bx)
ab = list(reversed(sorted(ab)))

abc = []
for i in range(min(k, len(ab))):
    abx = ab[i]
    for j in range(min(k, len(c))):
        cx = c[j]
        abc.append(abx + cx)

abc = list(reversed(sorted(abc)))

for i in range(k):
    print(abc[i])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = list(reversed(sorted(a)))
b = list(reversed(sorted(b)))
c = list(reversed(sorted(c)))

abc = []
for p in range(x):
    for q in range(y):
        if (p+1) * (q+1) > k:
            break
        for r in range(z):
            if (p+1) * (q+1) * (r+1) > k:
                break
            abc.append(a[p]+ b[q] + c[r])

abc = list(reversed(sorted(abc)))

for i in range(k):
    print(abc[i])
### BUGGY CODE ###

import bisect as bi
n,m = map(int,input().split())
dic={}
P,Y = [],[]
for i in range(m):
  p,y = map(int,input().split())
  P.append(p)
  Y.append(y)
  target = dic.get(p) if dic.get(p)!=None else []
  target.append(y)
  dic[p] = target

def fill_zero(num):
  s = str(num)
  dif = 6-len(s)
  return '0'*dif+s
  
for i in range(m):
  li = sorted(dic[P[i]])
  #ord = li.index(Y[i])+1
  ord = bi.bisect_left(li, Y[i])+1
  print(fill_zero(P[i])+fill_zero(ord))
  

### FIXED CODE ###

N, M = map(int, input().split())
D = [[] for i in range(N)]
 
for i in range(M):
  p, y = map(int, input().split())
  D[p-1].append((y, i)) 

ans = [None]*M
 
for i, d in enumerate(D): 
  d.sort()
  for k, (y, j) in enumerate(d): 
    ans[j] = str(i+1).zfill(6) + str(k+1).zfill(6)
print(*ans, sep = '\n')
### BUGGY CODE ###

from operator import itemgetter

N, M = map(int, input().split())
pairs = [tuple(map(int, input().split())) for _ in range(N)]
pairs.sort(key = itemgetter(1), reverse = True)

A_max = M + 1
schedule = [0] * (M+1)
for A, B in pairs:
    if A_max == 1:
        break
    elif A < A_max:
        for i in range(A, A_max):
            if schedule[i] == 0:
                schedule[i] = B
                break
        else:
            A_max = A
    
print(sum(schedule))            


### FIXED CODE ###

from operator import itemgetter
import heapq

N, M = map(int, input().split())
pairs = [tuple(map(int, input().split())) for _ in range(N)]
pairs.sort(key = itemgetter(0))

heap = []
reward = 0
index_of_pairs = 0   
for i in range(1, M+1):
    while index_of_pairs < N and pairs[index_of_pairs][0] <= i:
        heapq.heappush(heap, -pairs[index_of_pairs][1])
        index_of_pairs += 1
    if heap:
        reward -= heapq.heappop(heap)

print(reward)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# D

# BFSで各点から到達可能な最も遠いところを探索する
# 1回探索はO(HW)なのでO(HHWW)?
# BFSなのでdeque / queue使う

# from collections import deque
import queue

H, W = map(int, input().split())

data = [None] * H
for i in range(H):
    data[i] = input()


def judge(h, w, dist):
    if (h >=0) and (h < H) and (w >= 0) and (w < W):
        if data[h][w] == '.' and dist[h][w] == -1:
            return True
        else:
            return False
    return False


def bfs(h, w):
    dist = [[-1] * W for i in range(H)]
    # q = deque()
    q = queue.Queue()

    max_dist = 0
    dist[h][w] = 0
    # q.append((h, w, 0))
    q.put((h, w, 0))

    # while len(q) > 0:
    while not q.empty():
        # h, w, val = q.popleft()
        h, w, val = q.get()
        dist[h][w] = val
        max_dist = max(max_dist, val)

        if judge(h+1, w, dist):
            q.put((h+1, w, val+1))
        if judge(h-1, w, dist):
            q.put((h-1, w, val+1))
        if judge(h, w+1, dist):
            q.put((h, w+1, val+1))
        if judge(h, w-1, dist):
            q.put((h, w-1, val+1))

    return max_dist


ans = 0
for h in range(H):
    for w in range(W):
        if data[h][w] == '.':
            res = bfs(h, w)
            # print(h, w, res)
            ans = max(ans, res)

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# D

# BFSで各点から到達可能な最も遠いところを探索する
# 1回探索はO(HW)なのでO(HHWW)
# BFSなのでdeque / queue使う・・・微妙に1つだけTLE残る

# 全ての地点から全ての地点への最短経路を求める

'''
3 5
...#.
.#.#.
.#...
'''

import sys
from collections import deque

stdin = sys.stdin

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

H, W = na()
# data = [ns() for _ in range(H)]

data = [list("#" * (W + 2))]
# 周りを'#'で埋めておく
for _ in range(H):
    data.append(["#"] + list(input()) + ["#"])
data += [list("#" * (W + 2))]


def bfs(h, w):
    dist = [[-1] * (W+2) for _ in range(H+2)]
    q = deque()

    max_dist = 0
    dist[h][w] = 0
    q.append((h, w, 0))

    # while len(q) > 0:
    while len(q) > 0:
        h, w, val = q.popleft()

        m = [(1, 0), (-1, 0), (0, 1), (0, -1)]
        for dx, dy in m:
            h_new, w_new = h + dx, w + dy
            if data[h_new][w_new] == '.' and dist[h_new][w_new] == -1:
                q.append((h_new, w_new, val+1))
                dist[h_new][w_new] = val + 1
                max_dist = max(max_dist, val + 1)

    return max_dist


ans = 0
for h in range(H+2):
    for w in range(W+2):
        if data[h][w] == '.':
            res = bfs(h, w)
            if ans < res:
                ans = res

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

n,c= [int(i) for i in input().split()]
t_tk_r=0
t_md_r=0
g_tk_r=0
g_md_r=0
t_tk=[]
t_md=[]
g_tk=[]
g_md=[]
a=[]
d1=0
for i in range(n):
  a.append([int(i) for i in input().split()])
for d0,v0 in a:
  t_tk_r+=v0-(d0-d1)
  t_md_r+=v0-(d0-d1)*2
  t_tk.append(t_tk_r)
  t_md.append(t_md_r)
  d1=d0
d1=0  
for d0,v0 in a[::-1]:
  g_tk_r+=v0-((c-d0)-d1)
  g_md_r+=v0-((c-d0)-d1)*2
  g_tk.append(g_tk_r)
  g_md.append(g_md_r)
  d1=(c-d0)
  
mx=max(max(t_tk),max(g_tk),0)
for i in range(1,n):
  mx=max(mx,max(t_tk[:i])+max(g_md[:n-i]),max(t_md[:i])+max(g_tk[:n-i]))
print(mx)

### FIXED CODE ###

n,c= [int(i) for i in input().split()]
t_tk_r=0
t_md_r=0
g_tk_r=0
g_md_r=0
t_tk_m=0
t_md_m=0
g_tk_m=0
g_md_m=0
t_tk=[]
t_md=[]
g_tk=[]
g_md=[]
a=[]
d1=0

for i in range(n):
  a.append([int(i) for i in input().split()])

for d0,v0 in a:
  t_tk_r += v0-(d0-d1)
  t_md_r += v0-(d0-d1)*2
  t_tk_m = max(t_tk_m,t_tk_r)
  t_md_m = max(t_md_m,t_md_r)
  t_tk.append(t_tk_m)
  t_md.append(t_md_m)
  d1=d0
  
d1=0  
for d0,v0 in a[::-1]:
  g_tk_r += v0-((c-d0)-d1)
  g_md_r += v0-((c-d0)-d1)*2
  g_tk_m = max(g_tk_m,g_tk_r)
  g_md_m = max(g_md_m,g_md_r)
  g_tk.append(g_tk_m)
  g_md.append(g_md_m)
  d1=(c-d0) 
mx=max(max(t_tk),max(g_tk),0)

for i in range(n-1):
  mx=max(mx,t_tk[i]+g_md[n-2-i],t_md[i]+g_tk[n-i-2])
print(mx)
### BUGGY CODE ###

n = int(input())
s = [input() for s in range(n)]
l = len(set(s))
tmp,ans,lans = [],[0]*l,[]
for i in range(n):
	if not s[i] in tmp:
		tmp.append(s[i])
		ans[tmp.index(s[i])] += 1
	else:
		ans[tmp.index(s[i])] += 1

for j in range(l):
	if ans[j] == max(ans):
		lans.append(tmp[j])
lans.sort()
for h in range(len(lans)):
	print(lans[h])

### FIXED CODE ###

n = int(input())
s = [input() for s in range(n)]
dic = {}

for i in range(n):
	if not s[i] in dic:
		dic[s[i]] = 1
	else:
		dic[s[i]] += 1

cnt_max = max(dic.values()) 
ans = []
for j in dic.keys():
	if dic[j] == cnt_max:
		ans.append(j)

ans.sort()

for h in range(len(ans)):
	print(ans[h])
### BUGGY CODE ###

n = int(input())
a = list(input().split())
for c in range(1,n+1):
    print(a.index(str(c))+1,end=" ")

### FIXED CODE ###

n = int(input())
student = {}
a = list(input().split())
for c in range(1,n+1):
    student[a[c-1]] = c
for c in range(1,n+1):
    print(student[str(c)],end=" ")
### BUGGY CODE ###

iteration = int(input())
array = []
for i in range(iteration):
    e = input()
    array.append(e)
ans = [e for e in set(array) if array.count(e) % 2 == 1]
print(len(ans))

### FIXED CODE ###

# Write and Erase
n = int(input())
a = {}
count = 0
for _ in range(n):
    elem = input()
    if elem not in a:
        a[elem] = 1
    else:
        a[elem] += 1
for i in a.values():
    count += i % 2
print(count)
### BUGGY CODE ###

N, W = [int(_) for _ in input().split()]
WV = [[int(_) for _ in input().split()] for _ in range(N)]
dp = {}
dp[0] = 0
for w, v in WV:
    dp_o = dp.copy()
    for k in dp_o:
        dp[k + v] = min(dp_o.get(k + v, float('inf')), dp_o[k] + w)
print(max([k for k, v in dp.items() if v <= W]))


### FIXED CODE ###

N, W = [int(_) for _ in input().split()]
WV = [[int(_) for _ in input().split()] for _ in range(N)]
dp = {}
dp[0] = 0
for w, v in WV:
    dp_o = dp.copy()
    for k in dp_o:
        dp[k + v] = min(dp_o.get(k + v, float('inf')), dp_o[k] + w)
print(max([k for k, v in dp.items() if v <= W]))
### BUGGY CODE ###

H, W, M = list(map(int, input().split()))
HW = list(tuple(int(x) - 1 for x in input().split()) for _ in range(M))
h = [0] * H
w = [0] * W
for hi, wi in HW:
	h[hi] += 1
	w[wi] += 1
hm = max(h)
wm = max(w)

hh = [i for i, v in enumerate(h) if v == hm]
ww = [i for i, v in enumerate(w) if v == wm]

ans = hm + wm - 1
for h in hh:
	for w in ww:
		if (h, w) not in HW:
			ans += 1
			break 	
	else:
		continue
	break
print(ans)


### FIXED CODE ###

H, W, M = list(map(int, input().split()))
HW = set(tuple(int(x) - 1 for x in input().split()) for _ in range(M))
h = [0] * H
w = [0] * W
for hi, wi in HW:
	h[hi] += 1
	w[wi] += 1
hm = max(h)
wm = max(w)

hh = [i for i, v in enumerate(h) if v == hm]
ww = [i for i, v in enumerate(w) if v == wm]

ans = hm + wm - 1
for h in hh:
	for w in ww:
		if (h, w) not in HW:
			ans += 1
			break 	
	else:
		continue
	break
print(ans)
### BUGGY CODE ###

a,b,k=map(int,input().split())
for i in range(k):
    if a>=1:
        a-=1
    elif b>=1:
        b-=1
print(a,b)

### FIXED CODE ###

a,b,k=map(int,input().split())
if a-k>=0:
    print(a-k,b)
else:
    if (a+b)>k:
        print(0,b-(k-a))
    else:
        print(0,0)
### BUGGY CODE ###

n = int(input())
listA = list(map(int,input().split()))
count = 0
l_count = []
ll =[]
m = len(l_count)
for k in range(n):
  a = listA[k]
  for z in range(m):
    ll.append(l_count[z][0])
  if a in ll:
    print(l_count[z][1])
  else:
      del listA[k]
      A = set(listA)
      for i in A:
        c = listA.count(i)
        count += int(c*(c-1)/2)
      print(count)
      listA.insert(k,a)
      l_count.append([a,count])
      count = 0

### FIXED CODE ###

from collections import Counter
n = int(input())
su = 0
l = list(map(int,input().split()))
l1 = Counter(l)
for k in l1.values():
  su += k*(k-1)//2
for t in l:
  a = l1[t]
  q = su-a*(a-1)//2+(a-1)*(a-2)//2
  print(q)
### BUGGY CODE ###


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


class unionFind:
    parent = []
    count = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.count = [1 for i in range(N)]

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.count[y] += self.count[x]
            self.count[x] = self.count[y]
            return

    def getCount(self, x):
        self.count[x] = self.count[self.root(x)]
        return(self.count[x])


N, M, K = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(M)]

CD = [tuple(map(int, input().split())) for i in range(K)]

G = unionFind(N)
for a, b in AB:
    G.unite(a, b)

for i in range(N):
    G.root(i)

ans = [G.getCount(i) - 1 for i in range(N)]
# print(ans)
# print(G.count)
for a, b in AB:
    ans[a-1] -= 1
    ans[b-1] -= 1

for c, d in CD:
    if G.same(c, d):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(*ans)


### FIXED CODE ###


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


class unionFind:
    parent = []
    count = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.count = [1 for i in range(N)]

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.count[y] += self.count[x]
            self.count[x] = self.count[y]
            return

    def getCount(self, x):
        self.count[x] = self.count[self.root(x)]
        return(self.count[x])


N, M, K = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(M)]

CD = [tuple(map(int, input().split())) for i in range(K)]

G = unionFind(N)
for a, b in AB:
    G.unite(a, b)

for i in range(N):
    G.root(i)

ans = [G.getCount(i) - 1 for i in range(N)]
# print(ans)
# print(G.count)
for a, b in AB:
    ans[a-1] -= 1
    ans[b-1] -= 1

for c, d in CD:
    if G.same(c, d):
        ans[c-1] -= 1
        ans[d-1] -= 1

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

#!/usr/bin/env python3

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

count = 0

for i in range(N):
    for j in range(N):
        if i == j:
            continue

        if A[i] % A[j] == 0:
            break

    else:
        count += 1

print(count)


### FIXED CODE ###

#!/usr/bin/env python3

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

A.sort()
A_max = A[-1]
table = [0] * (A_max + 1)

for x in A:
    table[x] += 1
    for y in range(x * 2, A_max + 1, x):
        table[y] += 1

result = sum([1 for x in A if table[x] == 1])
print(result)