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

n = int(input())
A = []
for _ in range(n):
    a = input()
    if a not in A:
        A.append(a)
    else:
        A.remove(a)
print(len(A))

### FIXED CODE ###

n = int(input())
A = [input() for _ in range(n)]
AS = set()
for i in A:
    if i not in AS:
        AS.add(i)
    else:
        AS.remove(i)
print(len(AS))
### BUGGY CODE ###

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

def Solve(N:int,S:str) -> int:
    total = Counter(S)
    counter1 = {"R":0,"G":0,"B":0}
    ans = 0

    for i in range(N-2):
        RGB = {"R","G","B"} - {S[i]}
        counter1[S[i]]+=1
        counter2 = {"R":0,"G":0,"B":0}
        for j in range(i+1,N-1):
            counter2[S[j]]+=1
            tmp = list(RGB - {S[j]})
            if len(tmp)==1:
                target = tmp[0]
                ans+=total[target]-counter1[target]-counter2[target]
                if((j - i)+ j <= N -1 and S[(j - i)+ j] == target):
                    ans-=1
    return ans

def main():
    N = int(input())
    S = input()
    print(Solve(N,S))

if __name__ == "__main__":
    main()




### FIXED CODE ###

from collections import Counter
N = int(input())
S = list(input())
dic = Counter(S)
dic2 = {"R":0,"G":0,"B":0}
ans = 0
for i in range(N-2):
    RGB = {"R","G","B"} - {S[i]}
    dic2[S[i]]+=1
    dic3 = {"R":0,"G":0,"B":0}
    for j in range(i+1,N-1):
        dic3[S[j]]+=1
        if len(RGB - {S[j]})!=1:
            continue
        else:
            target = list(RGB - {S[j]})[0]
            ans+=dic[target]-dic2[target]-dic3[target]
            if((j - i)+ j <= N -1):
                if(S[(j - i)+ j] == target):
                    ans-=1
print(ans)
### BUGGY CODE ###

n = int(input())
lst = list(map(int,input().split()))
res = 1
for i in lst:
    res *= i
if res > pow(10,18):
    print(-1)
else:
    print(res)


### FIXED CODE ###

def cal():
    n = int(input())
    lst = list(map(int,input().split()))
    if 0 in lst:
    	return 0
    else:
        prod = 1
        for a in lst:
            prod *= a
            if prod > 1000000000000000000:
                return -1
    return prod
print(cal())
### BUGGY CODE ###

N, K, Q = map(int, input().split(" "))
A = [int(input()) for i in range(Q)]

tmp = []
for i in range(N):
    tmp.append(A.count(i+1)) #正解数
# 得点は, 最初の点数 - 他人の正解数
# 他人の正解数は, 問題数 - 自分の正解数
# 得点は, 最初の点数 - 問題数 + 自分の正解数
# 得点 > 0 であれば, "Yes"
for i in range(N):
    if K - Q + tmp[i] > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N, K, Q = map(int, input().split(" "))    # N:人数, K:初期スコア, Q:問題数
A = [int(input()) for i in range(Q)]    # 正解者のリスト
B = [0 for i in range(N)]    # 正解数

for i in range(Q):
    num_ans_person = A[i] - 1
    B[num_ans_person] += 1

# 得点は, 最初の点数 - 他人の正解数
# 他人の正解数は, 問題数 - 自分の正解数
# 得点は, 最初の点数 - 問題数 + 自分の正解数
# 得点 > 0 であれば, "Yes"
for i in range(N):
    if K - Q + B[i] > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

n, m = map(int, input().split())
list_score = list(map(int, input().split()))
list_kard = [ list(map(int,input().split(" "))) for i in range(m)]

list_score_colume = list(set(list_score))

for i in range(len(list_score_colume)):
    k = [list_score.count(list_score_colume[i]), list_score_colume[i]]
    list_kard.append(k)


list_kard = sorted(list_kard, key=lambda x: x[1], reverse=True)


ans = 0
cnt = 0
for i in range(len(list_kard)):
    k = list_kard[i]
    if cnt + k[0] <= n:
        ans += k[0]*k[1]
        cnt += k[0]
    else:
        ans += k[1]*(n-cnt)
        break

print(ans)

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
list_score = list(map(int, input().split()))
list_kard = [list(map(int, input().split(" "))) for i in range(m)]

list_kard.sort(key=lambda x: x[1], reverse=True)
heapq.heapify(list_score)

for i in range(m):
    k = list_kard[i]
    for _ in range(k[0]):
        if list_score[0] < k[1]:
            heapq.heappop(list_score)
            heapq.heappush(list_score, k[1])
        else:
            break

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

N = int(input())
S = input()
S = [x for x in S]

s = len(S)
e = 0
while s != e:
  s = len(S)
  for i in range(len(S)-1):
    if i >= len(S)-1:break
    if S[i] == S[i+1]:
      S = S[:i] + S[i+1:]
    e = len(S)

print(len(S))

### FIXED CODE ###

N = int(input())
S = [x for x in input()]

def p(S):
  s = len(S)
  e = 0
  cnt = 0
  while s != e:
    cnt += 1
    if cnt > N:break
    s = len(S)
    for i in range(s-1):
      if i >= len(S)-1:break
      if S[i] == S[i+1]:S.pop(i)
      e = len(S)
  return len(S)

print(p(S))
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
mod = (10**9) + 7
t = 0
for i in range(n-1):
    for j in range(i+1,n):
        t += ((A[i]%mod) * (A[j]%mod))%mod
s = t%mod
print(s)

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
mod = (10**9) + 7
t = 0
sum = 0
for i in range(1,n):
    sum += A[i]
for i in range(n-1):
    t += (A[i]*sum)%mod
    sum -=  A[i+1]
t = t%mod
print(t)
### BUGGY CODE ###

S = input()

ls =[0 for i in range(2019)]
ls[0] += 1
p_amari = 0
kake = 1
ret = 0
for i in range(len(S)) :
	p_amari = ( int(S[len(S)-1-i]) * kake + p_amari ) % 2019
	ret += ls[p_amari]
	ls[p_amari] += 1
	kake *= 10
print(int(ret))

### FIXED CODE ###

S = input()

ls =[0 for i in range(2019)]
ls[0] += 1
p_amari = 0
ret = 0
len_s = len(S)
for i in range(len_s) :
	p_amari = ( int(S[len_s-1-i]) * pow(10, i, 2019) + p_amari ) % 2019
	ret += ls[p_amari]
	ls[p_amari] += 1
print(int(ret))
### BUGGY CODE ###

# coding: utf-8
# Your code here!
N=int(input())

P=list(map(float,input().split()))

dp=[0]*(N+1)
dp[0]=1

for p in P:
    temp=[0]*(N+1)
    for i in range(N):
        temp[i+1]+=dp[i]*p
        temp[i]+=dp[i]*(1-p)
    temp[N]+=dp[N]
    dp=temp[:]

print(sum(dp[N//2+1:]))



### FIXED CODE ###

# coding: utf-8
# Your code here!
N=int(input())
P=list(map(float,input().split()))

dp=[[0]*(N+1) for i in range(N+1)]

dp[0][0]=1
for n in range(N):
    for i in range(n+1):
        j=n-i
        dp[j][i+1]+=dp[j][i]*P[n]
        dp[j+1][i]+=dp[j][i]*(1-P[n])

ans=0
for i in range((N+1)//2):
    ans+=dp[i][-i-1]

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

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

ans = 0
for i in range(N):
  isOK = True
  for j in range(i):
    if P[i] > P[j]:
      isOK = False
      break
  if isOK:
    ans += 1

print(ans)

### FIXED CODE ###

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

ans = 1
tempmin = P[0]
for i in range(1,N):
  if tempmin >= P[i]:
    tempmin = P[i]
    ans += 1

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

a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
  ans = ans ^ i
print(ans)
  

### FIXED CODE ###

a,b = map(int,input().split())
def xor(X):
  if X%2== 0:
    i = 0 if (X//2)%2==0 else 1
    return X ^ i
  else:
    i = 0 if ((X+1)//2)%2==0 else 1
    return i
A = xor(a-1)
B = xor(b)
print(A ^ B)
### BUGGY CODE ###

import queue 
N = int(input())
tree = [[]for _ in range(N+1)]
for i in range(1,N):
    a,b = map(int,input().split())
    tree[a].append( [b,i])
    tree[b].append([a,i])
 
que = queue.Queue()
node = [-1]*(N+1)
edge = [-1]*N
que.put(1)
node[1] = 1
maxi = 1
color = [[] for _ in range(N+1)]
while(True):
    if que.empty():
        break
    start = que.get()
    for i in tree[start]:
        
        
        col = 1
        if edge[i[1]] == -1:
            que.put(i[0])
            while(True):
               
                if col in (color[i[0]] + color[start]):
                    col +=1
                    if col > maxi:
                        maxi = col
                else :
                    break
            edge[i[1]] = col
            color[i[0]].append(col)
            color[start].append(col)
print(maxi)
for i in edge[1:]:
    print(i)

### FIXED CODE ###

import queue 
N = int(input())
tree = [[]for _ in range(N+1)]
for i in range(1,N):
    a,b = map(int,input().split())
    tree[a].append( [b,i])
    tree[b].append([a,i])
 
que = queue.Queue()
node = [-1]*(N+1)
edge = [-1]*N
que.put(1)
node[1] = 1
maxi = 1
start = 0
color = [[] for _ in range(N+1)]
node[1] = 0
while(True):
    if que.empty():
        break
    before = start
    start = que.get()
    col =1
    for i in tree[start]:
        
        if node[i[0]] == -1 :
            que.put(i[0])
        if edge[i[1]] == -1:
            if col == node[start]:
                col += 1
            edge[i[1]] = col
            node[i[0]] = col
            if col > maxi:
                maxi = col
            col +=1
            
print(maxi)
for i in edge[1:]:
    print(i)
### BUGGY CODE ###

def func(n, W, w):
    # ナップザック問題
    # 残り荷物 iつで,残り容量jの場合の最大価値
    dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
    for i in range(1, len(dp)):
        for j in range(len(dp[0])):
            if j-w[-i][0] >= 0:
                dp[i][j] = max(dp[i-1][j-w[-i][0]] + w[-i][1], dp[i-1][j])
            else:
                dp[i][j] = dp[i-1][j]
    # for i in range(len(dp)):
        # print(dp[i])
    return dp[n][W]
n, W = [int(i) for i in input().split()]
w = [[0, 0] for _ in range(n)]
for i in range(n):
    w[i] = [int(i) for i in input().split()]
print(func(n, W, w))
"""
# print("print(\" vs \" + str(func({}, {}, {})))".format(n, W, w))
print("11 vs " + str(func(4, 6, [[2, 1], [3, 4], [4, 10], [3, 4]])))
print("13 vs " + str(func(4, 6, [[2, 1], [3, 7], [4, 10], [3, 6]])))
print("400 vs " + str(func(4, 10, [[1, 100], [1, 100], [1, 100], [1, 100]])))
print("0 vs " + str(func(4, 1, [[10, 100], [10, 100], [10, 100], [10, 100]])))
"""


### FIXED CODE ###

def func(n, W, w):  # ナップザック問題の亜種
    _max = 0
    weights = [[] for _ in range(4)]
    for i in range(n):
        weights[w[i][0]-w[0][0]].append(w[i][1])
    for i in range(len(weights)):
        weights[i].sort()
        weights[i].append(0)
        weights[i].reverse()
        for j in range(1, len(weights[i])):
            weights[i][j] += weights[i][j-1]
    # print(weights)
    for i in range(len(weights[0])):
        # print("i:{}".format(i))
        for j in range(len(weights[1])):
            # print("j:{}".format(j))
            for k in range(len(weights[2])):
                for l in range(len(weights[3])):
                    # 「i+j+k+l < n」つ選ぶ
                    if w[0][0]*i\
                            + (w[0][0]+1)*j\
                            + (w[0][0]+2)*k\
                            + (w[0][0]+3)*l <= W:
                        # print("i:{} j:{} k:{} l:{} score:{}".format(i, j, k, l, weights[0][i]+weights[1][
                        # j]+weights[2][k]+weights[3][l]))
                        _max = max(_max, weights[0][i]+weights[1][j]+weights[2][k]+weights[3][l])
    return _max


n, W = [int(i) for i in input().split()]
w = [[0, 0] for _ in range(n)]
for i in range(n):
    w[i] = [int(i) for i in input().split()]
print(func(n, W, w))
"""
# print("print(\" vs \" + str(func({}, {}, {})))".format(n, W, w))
print("11 vs " + str(func(4, 6, [[2, 1], [3, 4], [4, 10], [3, 4]])))
print("13 vs " + str(func(4, 6, [[2, 1], [3, 7], [4, 10], [3, 6]])))
print("400 vs " + str(func(4, 10, [[1, 100], [1, 100], [1, 100], [1, 100]])))
print("0 vs " + str(func(4, 1, [[10, 100], [10, 100], [10, 100], [10, 100]])))
"""
### BUGGY CODE ###

from pprint import pprint
def uragaesi(x,y):
    global arr
    arr[x][y] = 0 if arr[x][y] else 1 
    arr[x-1][y] = 0 if arr[x-1][y] else 1 
    arr[x][y-1] = 0 if arr[x][y-1] else 1 
    arr[x-1][y-1] = 0 if arr[x-1][y-1] else 1 
    arr[x+1][y] = 0 if arr[x+1][y] else 1 
    arr[x][y+1] = 0 if arr[x][y+1] else 1 
    arr[x+1][y+1] = 0 if arr[x+1][y+1] else 1
    
def main():
    N,M =list(map( int,input().split()))
    arr = [[1 for i in range(N+2)] for j in range(M+3)]
    ans = 0
    
    for y in range(1,N+1):
        for x in range(1,M+1):
                arr[x][y] = 0 if arr[x][y] else 1 
                arr[x-1][y] = 0 if arr[x-1][y] else 1 
                arr[x][y-1] = 0 if arr[x][y-1] else 1 
                arr[x-1][y-1] = 0 if arr[x-1][y-1] else 1 
                arr[x+1][y] = 0 if arr[x+1][y] else 1 
                arr[x][y+1] = 0 if arr[x][y+1] else 1 
                arr[x+1][y+1] = 0 if arr[x+1][y+1] else 1
                arr[x+1][y-1] = 0 if arr[x+1][y-1] else 1
                arr[x-1][y+1] = 0 if arr[x-1][y+1] else 1
                
    
    for y in range(1,N+1):
        for x in range(1,M+1):
            if arr[x][y] == 0:
                ans = ans + 1

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

N,M = list(map(int,input().split()))
ans = (N-2)*(M-2)
if N == 1 and M == 1:
    ans = 1
elif M == 1:
    ans = abs(N - 2)
print(abs(ans))
### BUGGY CODE ###

#!/usr/bin/env python3
s = input()
t = input()
dp = [[0]*(1+len(t)) for _ in range(1+len(s))]
def match(s_,t_,i,j):
    if s_[i] == t_[j]:
        return 1
    else: return 0
#　配列アラインメントの感じでマッチしたら+1 そうでなかったら+0を返す
# traceback関数を作って戻る必要がある
# 漸化式 dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+match())
# traceback[i+1][j+1] = 0 だったら上、1なら左、2なら斜め
traceback =[[-1]*(1+len(t)) for _ in range(1+len(s))]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
            traceback[i+1][j+1] = 3
        elif dp[i][j+1] >= dp[i+1][j]:
            dp[i+1][j+1] = dp[i][j+1]
            traceback[i+1][j+1] = 1
        else:
            dp[i+1][j+1] = dp[i+1][j]
            traceback[i+1][j+1] = 2
        
# traceback時の初期値がx = len(s),y = len(t)
# tracebackの挙動を見ながらx,y を更新する
#　終了条件はx,y == 0,0 になったとき
# traceback[x][y] % 2 == 1 の時、s[x-1]を出力する。
x,y = len(s),len(t)
"""for i in range(1+len(s)):
    #print(dp[i])
    print(traceback[i])
"""
output = []
while True:
    if traceback[x][y] == 3:
        output.append(s[x-1])
        #print()
    x_ = x
    y_ = y
    x -= traceback[x_][y_] % 2 
    y -= traceback[x_][y_] // 2
    #print(x,y)
    if x == 1 and y == 1:
        if traceback[x][y] == 3:
            output.append(s[x-1])
        break
    if x == 0 or y == 0:
        break
for i in range(len(output)-1,-1,-1):
    print(output[i],end="")
print()

    

### FIXED CODE ###

#!/usr/bin/env python3
s = input()
t = input()
dp = [[0]*(1+len(t)) for _ in range(1+len(s))]
def match(s_,t_,i,j):
    if s_[i] == t_[j]:
        return 1
    else: return 0
#　配列アラインメントの感じでマッチしたら+1 そうでなかったら+0を返す
# traceback関数を作って戻る必要がある
# 漸化式 dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j],dp[i][j]+match())
# traceback[i+1][j+1] = 0 だったら上、1なら左、2なら斜め
traceback =[[-1]*(1+len(t)) for _ in range(1+len(s))]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
            traceback[i+1][j+1] = 3
        elif dp[i][j+1] >= dp[i+1][j]:
            dp[i+1][j+1] = dp[i][j+1]
            traceback[i+1][j+1] = 1
        else:
            dp[i+1][j+1] = dp[i+1][j]
            traceback[i+1][j+1] = 2
        
# traceback時の初期値がx = len(s),y = len(t)
# tracebackの挙動を見ながらx,y を更新する
#　終了条件はx,y == 0,0 になったとき
# traceback[x][y] % 2 == 1 の時、s[x-1]を出力する。
x,y = len(s),len(t)
"""for i in range(1+len(s)):
    #print(dp[i])
    print(traceback[i])
"""
output = []
while True:
    if traceback[x][y] == 3:
        output.append(s[x-1])
        #print()
    x_ = x
    y_ = y
    x -= traceback[x_][y_] % 2 
    y -= traceback[x_][y_] // 2
    #print(x,y)
    if x == 1 and y == 1:
        if traceback[x][y] == 3:
            output.append(s[x-1])
        break
    if x == 0 or y == 0:
        break
for i in range(len(output)-1,-1,-1):
    print(output[i],end="")
print()
### BUGGY CODE ###

N = int(input())
S = []
Y = set()
c = 0
for i in range(N):
  s = input()
  t = [s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]]
  t.sort()
  u = t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+t[7]+t[8]+t[9]
  if u in Y:
    c += S.count(u)
  S.append(u)
  Y.add(u)

print(c)


### FIXED CODE ###

N = int(input())
S = []
Y = {}
c = 0
for i in range(N):
  s = input()
  t = [s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9]]
  t.sort()
  u = t[0]+t[1]+t[2]+t[3]+t[4]+t[5]+t[6]+t[7]+t[8]+t[9]
  if u not in Y:
    Y[u] = 1
  else :
    c += Y[u]
    Y[u] += 1
    


print(c)
### BUGGY CODE ###

n = int(input())
ans = 1
for i in range(1, n+1):
    ans *= i
ans = ans % (10**9 + 7)
print(ans)


### FIXED CODE ###

n = int(input())
ans = 1
for i in range(1, n+1):
    ans *= i
    ans = ans % (10**9 + 7)
ans = ans % (10**9 + 7)
print(ans)
### BUGGY CODE ###

S = list(input())
ans = S.count('0')
num = 0
for i in range(len(S)):
  for j in range(i+3,len(S)):
    num = ''.join(map(str,S[i:j+1]))
    if int(num) % 2019 == 0:
      ans += 1
print(ans)

### FIXED CODE ###

S = list(str(input()))
S.reverse()
mod = 2019
rem = [0]*mod
num = 0
rem[num] += 1
d = 1
ans = 0
for s in S:
  num += int(s) * d
  num %= mod
  d *= 10
  d %= mod
  rem[num] += 1
for r in rem:
  ans += r*(r-1)//2
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

# from typing import Optional
from typing import List

# from typing import Dict
from typing import Tuple
from typing import Set

# from typing import Sequence

Cod = Tuple[int, int]


def main():
    args = input().split()
    H = int(args[0])
    W = int(args[1])
    M = int(args[2])

    codList: Set[Cod] = []
    columnSumList: List[int] = [0] * W
    rowSumList: List[int] = [0] * H
    for i in range(M):
        h, w = map(lambda x: int(x), input().split())
        item = (h, w)
        codList.append(item)
        columnSumList[w - 1] += 1
        rowSumList[h - 1] += 1

    maxColumnSum = max(columnSumList)
    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]
    maxRowSum = max(rowSumList)
    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]

    result = maxColumnSum + maxRowSum
    for row in maxRowIndexList:
        for column in maxColumIndexList:
            if (row + 1, column + 1) in codList:
                continue
            else:
                print(result)
                return

    print(result - 1)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

# from typing import Optional
from typing import List

# from typing import Dict
from typing import Tuple
from typing import Set

# from typing import Sequence

Cod = Tuple[int, int]


def main():
    args = input().split()
    H = int(args[0])
    W = int(args[1])
    M = int(args[2])

    codList = {}
    columnSumList: List[int] = [0] * W
    rowSumList: List[int] = [0] * H
    for i in range(M):
        h, w = map(lambda x: int(x), input().split())
        item = (h, w)
        codList.setdefault(h, {})
        codList[h][w] = item
        columnSumList[w - 1] += 1
        rowSumList[h - 1] += 1

    maxColumnSum = max(columnSumList)
    maxColumIndexList = [i for i, x in enumerate(columnSumList) if x == maxColumnSum]
    maxRowSum = max(rowSumList)
    maxRowIndexList = [i for i, x in enumerate(rowSumList) if x == maxRowSum]

    result = maxColumnSum + maxRowSum
    for row in maxRowIndexList:
        for column in maxColumIndexList:
            if row + 1 in codList and column + 1 in codList[row + 1]:
                continue
            else:
                print(result)
                return

    print(result - 1)


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

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

mod = 10**9+7

cnt = [0]*60
bt = [0]*60

for a in A:
    for i in range(60):
        cnt[i] += (a>>i)&1

for i in range(60):
    x = cnt[i]
    bt[i] += x*(N-x)%mod

ans = 0
for i in range(60):
    ans += bt[i]*2**i
    ans %= mod

print(ans)

### FIXED CODE ###

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

mod = 10**9+7

cnt = [0]*60
bt = [0]*60

for a in A:
    for i in range(60):
        cnt[i] += (a>>i)&1

ans = 0
for i in range(60):
    x = cnt[i]
    y = x*(N-x)%mod
    ans += y*2**i
    ans %= mod

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

N,W = map(int, input().split())
ws = []
vs = []
for i in range(N):
    w,v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ws_m = [w-ws[0] for w in ws]
# ws_m = [w-min(ws) for w in ws]
"""
i番目まで見て、n個選んでいて、重さがwのときのvの最大値
ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする
dp[i][n][w] 
"""
dp = [[[0]*(3*N+1) for i in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):
    for n in range(N):
        for j in range(3*N):
            # もらうDP
            # j-wなら、新しくwをナップサックに入れて価値が増えるか見る
            if j-w >= 0:
                dp[i+1][n+1][j] = max(dp[i][n+1][j], dp[i][n][j-w]+v)
            # 追加できない場合は以前の情報を更新
            else:
                dp[i+1][n+1][j] = dp[i][n+1][j]

ans= 0
for i,As in enumerate(dp[N]):
    w = W - i*ws[0]
    if w > 0:
        ans = max(ans,max(As[:w+1]))
print(ans)   

### FIXED CODE ###

N,W = map(int, input().split())
ws = []
vs = []
for i in range(N):
    w,v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ws_m = [w-ws[0] for w in ws]

"""
i番目まで見て、n個選んでいて、重さがwのときのvの最大値
ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする
dp[i][n][w] 
"""
dp = [[[-1]*(3*N+10) for i in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):
    for n in range(i+1):
        for j in range(3*N):
            dp[i+1][n][j] = max(dp[i+1][n][j], dp[i][n][j])
            # if dp[i][n][j] == -1: continue
            if j + (n+1)*ws[0] + w <= W:
                dp[i+1][n+1][j+w] = max(dp[i][n][j+w], dp[i][n][j] + v)

ans= 0
for i,As in enumerate(dp[N]):
    w = min(W - i*ws[0], sum(ws_m))
    if w >= 0:
        ans = max(ans,max(As[:w+1]))
print(ans)
### BUGGY CODE ###

import bisect

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

count = 0
lenB = len(B)
lenC = len(C)
for a in A:
  for i in range(bisect.bisect_right(B, a), lenB):
    count += lenC - bisect.bisect_right(C, B[i])
print(count)


### FIXED CODE ###

import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
count = 0
lenA = len(A)
lenB = len(B)
lenC = len(C)
for b in B:
  count += (bisect.bisect_left(A, b))*(lenC-bisect.bisect_right(C, b))
print(count)
### BUGGY CODE ###

N = int(input().strip())
A = [int(v) for v in input().strip().split(" ")]

A = sorted(A)
visited = {}
for i in range(N):
    visited[A[i]] = 0

counter = 0
for i in range(N):
    count_flag = True
    mark = 0
    if visited[A[i]] == 1:
        continue

    for j in range(N):
        if i == j:
            continue
        if A[i] < A[j]:
            break
        if A[i] % A[j] == 0:
            count_flag = False
            mark = j
            break
    if count_flag:
        counter += 1

    for j in range(mark, N):
        if A[i] % A[j] == 0:
            visited[A[j]] = 1

print(counter)

### FIXED CODE ###

N = int(input().strip())
A = [int(v) for v in input().strip().split(" ")]

exist_in_input = [0 for _ in range(10**6 + 1)]
if_can_divide = [0 for _ in range(10**6 + 1)]

for a in A:
    exist_in_input[a] += 1

counter = 0
for i in range(1, 10**6+1):
    if if_can_divide[i] == 1 or exist_in_input[i] == 0:
        continue

    if exist_in_input[i] == 1:
        counter += 1

    for j in range(0, 10**6+1, i):
        if_can_divide[j] = 1

print(counter)
### BUGGY CODE ###

n=int(input())
s=0
for i in range(n):
    a=int(input())
    c=0
    if a==2:
        s+=1
    else:
        for j in range(2,a,1):
     #  i print(j)
            if a%j==0:
                break
            else:
                if j==a-1:
                    s+=1
print(s)

### FIXED CODE ###

import math
n=int(input())
s=0
for i in range(n):
    a=int(input())
    b=math.ceil(a**0.5)
    if a==2:
        s+=1
    elif a%2==0 or a < 2:
        continue
    else:
        c=0
        for j in range(3,b+1,2):
            if a%j==0:
                c+=1
                break
        if c==0:
            s+=1
print(s)