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

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

A.sort()
ok = [False] * N

for i in range(N):
    for j in range(i+1, N):
        if ok[j]:
            continue

        if A[i] == A[j]:
            ok[i] = True
            ok[j] = True

        if A[j] % A[i] == 0:
            ok[j] = True

print(N-sum(ok))

### FIXED CODE ###

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

amax = max(A)
sieve = [False] * (amax+1)
exist = [0] * (amax+1)

for a in A:
    if exist[a] > 0:
        exist[a] += 1
        continue
    exist[a] += 1
    for i in range(a*2, amax+1, a):
        sieve[i] = True

ans = 0
for a in A:
    if not sieve[a] and exist[a] == 1:
        ans += 1

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

import math
q = int(input())
dp = [0]*(100001)
dp[0] = 1
dp[1] = 1
dp[2] = 1
for j in range(2,int(math.sqrt(100000)+1)):
  for k in range(j*2,100001,j):
    dp[k] = 1
    if k*2-1 <= 100000:
      dp[k*2-1] = 1
for i in range(q):
  l,r = map(int,input().split())
  ans = dp[l:r+1].count(0)
  print(ans)

### FIXED CODE ###

dp=[1]*(10**5+1)
dp[0],dp[1]=0,0
for i in range(2,10**5+1):
  if dp[i]==0:
    continue
  j=i
  while j+i<=10**5:
    j+=i
    if dp[j]==1:
      dp[j]-=1
      
ni=[0]*(10**5+1)
for i in range(2,10**5+1):
  if dp[i]==1 and dp[(i+1)//2]==1:
    ni[i]=1

ru=[0]*(10**5+1)
for i in range(1,10**5+1):
  ru[i]=ru[i-1]+ni[i]

q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(ru[r]-ru[l-1])
### BUGGY CODE ###

from collections import Counter, defaultdict

n, m = map(int, input().split())
an = list(map(int, input().split()))
ac = defaultdict(int, Counter(an))
ad = [0] * (n * 2)
for a, c in ac.items():
    for i in range(a - c, a):
        ad[i] += 1

for _ in range(m):
    x, y = map(int, input().split())
    ax = an[x - 1]
    ad[ax - ac[ax]] -= 1
    ac[ax] -= 1
    ac[y] += 1
    ad[y - ac[y]] += 1
    an[x - 1] = y
    print(ad[:n].count(0))


### FIXED CODE ###

from collections import Counter

n, m = map(int, input().split())
an = list(map(int, input().split()))
ac_ = Counter(an)
ac = {i: ac_[i] if i in ac_ else 0 for i in range(1, n + 1)}
ad = [0] * n
for a, c in ac.items():
    for i in range(max(0, a - c), a):
        ad[i] += 1
ans = ad.count(0)
anss = []

for x, y in (map(int, input().split()) for _ in range(m)):
    ax = an[x - 1]
    xdi = ax - ac[ax]
    if xdi >= 0:
        ad[xdi] -= 1
        if ad[xdi] == 0:
            ans += 1
    ac[ax] -= 1
    ac[y] += 1
    ydi = y - ac[y]
    if ydi >= 0:
        ad[ydi] += 1
        if ad[ydi] == 1:
            ans -= 1
    an[x - 1] = y
    anss.append(ans)
print('\n'.join(map(str, anss)))
### BUGGY CODE ###

N, M= (int(i) for i in input().split())
A = [int(i) for i in input().split()]
BC = [list(map(int, input().split())) for _ in range(M)]
count = 0

BC = sorted(BC, key=lambda x: x[1],reverse=True)
min_A = min(A)

for B,C in BC:
  if min_A >= C and count > N:
    break
  else:
    for i in range(B):
      if min_A >= C:
        break
      else:
        count+=1
        A.append(C)

A.sort()

ans = sum(A[count:len(A)])

print(ans)


### FIXED CODE ###

N, M= (int(i) for i in input().split())
A = [int(i) for i in input().split()]
BC = [list(map(int, input().split())) for _ in range(M)]
count = 0

BC = sorted(BC, key=lambda x: x[1],reverse=True)
min_A = min(A)

for B,C in BC:
  if min_A >= C and count > N:
    break
  else:
    l = min(B, N-count)
    for i in range(l):
      count+=1
      A.append(C)

A.sort()

ans = sum(A[count:len(A)])

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

N = int(input())
A = list(map(int,input().split()))
if A == sorted(A) and len(A) == len(set(A)):
  print(1)
  exit(0)

def check(X):
  idx = [0]
  ltr = [0]
  for a in A:
    if idx[-1] < a:
      idx.append(a)
      ltr.append(0)
    else:
      while True:
        while idx[-1] > a:
          idx.pop()
          ltr.pop()
        if idx[-1] != a:
          idx.append(a)
          ltr.append(0)
        if idx[-1] == 0:
          return False
        ltr[-1] += 1
        if ltr[-1] < X:
          break
        a = idx[-1] - 1
        idx.pop()
        ltr.pop()
  return ltr[0] == 0

ng, ok = 1, N
while ok - ng > 1:
  mid = (ok + ng) // 2
  if check(mid):
    ok = mid
  else:
    ng = mid
print(ok)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
if A == sorted(A) and len(A) == len(set(A)):
  print(1)
  exit(0)

def check(X):
  idx = [0]
  ltr = [0]
  for a in A:
    if idx[-1] < a:
      idx.append(a)
      ltr.append(0)
    else:
      while True:
        while idx[-1] > a:
          idx.pop()
          ltr.pop()
        if idx[-1] != a:
          idx.append(a)
          ltr.append(0)
        if idx[-1] == 0:
          return False
        ltr[-1] += 1
        if ltr[-1] < X:
          break
        a = idx[-1] - 1
        idx.pop()
        ltr.pop()
  return ltr[0] == 0

t = [1, N]
while t[1] - t[0] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(t[1])
### BUGGY CODE ###

import numpy as np
N, K = map(int, input().split())
# H = np.array([int(h) for h in input().split()])
H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)
k = np.array([i for i in range(1, K+1)])

for n in range(1, N):
    start = np.maximum(n-k, 0)
    if n < K:
        dp[n] = np.amin(dp[start] + np.abs(H[n]-H[start]))
    else:
        dp[n] = np.min(dp[n - k] + np.abs(H[n] - H[n - k]))


print(dp[N-1])

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
# H = np.array([int(h) for h in input().split()])
H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)
k = np.array([i for i in range(1, K+1)])

for n in range(1, N):
    start = max(n-K, 0)
    #if n < K:
    #   dp[n] = np.amin(dp[start] + np.abs(H[n]-H[start]))
    #else:
    #   dp[n] = np.min(dp[n - k] + np.abs(H[n] - H[n - k]))
    dp[n] = np.min(dp[start:n] + np.abs(H[n]-H[start:n]))

print(dp[N-1])
### BUGGY CODE ###

import math

n = int(input())

def calc(l):
    if l <= 5:
        return 0

    ans = 0
    m = math.floor(math.sqrt(n/6))
    M = math.floor(math.sqrt(n/6))
    MM = math.floor(math.sqrt(n-2))
    for i in range(1, m+2):
        for k in range(max(1, M-1), MM+2):
            for j in range(i, k+1):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == l:
                    d = len(set([i, j, k]))
                    if d == 3:
                        ans += 6
                    elif d == 2:
                        ans += 3
                    elif d == 1:
                        ans += 1
    
    return ans

for p in range(1, n+1):
    print(calc(p))

### FIXED CODE ###

n = int(input())
N = 10 ** 4

l = [0 for _ in range(N + 1)]

for i in range(1, 42):
    for k in range(1, 99):
        for j in range(i, k+1):
            s = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if s > N:
                continue
            d = len(set([i, j, k]))
            if d == 3:
                l[s] += 6
            elif d == 2:
                l[s] += 3
            elif d == 1:
                l[s] += 1

for i in range(1, n+1):
    print(l[i])
### BUGGY CODE ###

N = int(input())
alist = [int(input()) for i in range(N)]
### 三角形が成立しない場合を数える
MOD = 998244353
asum = [0]
for i in range(N):
    asum += [asum[-1] + alist[i]]
S = asum[-1]
Sharf = S / 2

tbsize = int(Sharf//1)+1
#dptableA[i番目までは振り分けた][Rの合計] -> そこからR>=S/2となる数
dptableA = [[0 for j  in range(tbsize)] for k in range(N)]
#dptableB[i番目までは振り分けた][Rの合計] -> そこからR=G=S/2, B=0となる数
dptableB = [[0 for j  in range(tbsize)] for k in range(N)]
dpflag = [[False for j  in range(tbsize)] for k in range(N)]

def ddp(cur_N, R): #(retA: R>=S/2となる数, retB: R=G=S/2,B=0の数)を返す
    if cur_N == N: #末端
        retA = 1 if R >= Sharf else 0
        retB = 1 if R == Sharf else 0
        return retA, retB
    if R >= Sharf: #R>=S/2はこれ以降のパターン全てR>=S/2
        #となるので残りの要素をRGBどこに割り振っても良い
        retA = pow(3, N-cur_N, MOD)
        retB = 1 if R == Sharf else 0 #特にR=S/2の時はR=G=S/2にできる
        return retA, retB
    if asum[cur_N] - R > Sharf: #Rに入れないものがS/2を超える
        return 0, 0 #どう頑張ってもR >= S/2を実現できない
    if dpflag[cur_N][R]: #DPテーブルにある
        return dptableA[cur_N][R], dptableB[cur_N][R]
    
    #そうではない場合は計算が必要
    ai = alist[cur_N]
    #aiをRGBのどれかに振り分ける
    retA_R, retB_R = ddp(cur_N+1, R+ai) #Rに振り分けた場合
    retA_GB, retB_GB = ddp(cur_N+1,R) #Rに入れなかった場合
    retA_GB = retA_GB * 2 %MOD #GBで2通りあるので2倍
    retA = (retA_R + retA_GB) % MOD
    retB = (retB_R + retB_GB) % MOD
    dpflag[cur_N][R] = True
    dptableA[cur_N][R] = retA
    dptableB[cur_N][R] = retB
    return retA, retB

retA, retB = ddp(0,0)
#全体 - (ある辺がS/2以上) + (2辺がS/2)
ans = (pow(3, N, MOD) - retA*3 + retB*3) % MOD
print(ans)

### FIXED CODE ###

N = int(input())
alist = [int(input()) for i in range(N)]
import numpy as np
### 三角形が成立しない場合を数える
alist.sort(reverse=False) #大きい方からチェックするとS/2に早く到達しやすい
MOD = 998244353
asum = [0]
for i in range(N):
    asum += [asum[-1] + alist[i]]
S = asum[-1]
Sharf = S / 2

#dptableA[i番目までは振り分けた][Rの合計] -> そこからR>=S/2となる数
dptableA = np.zeros((N+1, S+1), dtype=np.int) #[[0 for i in range(S+1)] for j in range(N+1)]
dptableA[N, int(np.ceil(Sharf)):] = 1
#dptableB[i番目までは振り分けた][Rの合計] -> そこからR=G=S/2, B=0となる数
dptableB = np.zeros((N+1, S+1), dtype=np.int) #[[0 for i in range(S+1)] for j in range(N+1)]
if S %2 == 0:
    dptableB[N, int(Sharf)] = 1 

#dpの計算をまとめて行う
for i in range(N, 0, -1): #後ろから見ていく
    n = i - 1
    an = alist[n]
    asn = asum[n]
    dptableA[n, 0:asn+1] = (2*dptableA[n+1, 0:asn+1] + dptableA[n+1, an:an+asn+1])%MOD
    #dptableA[n] = [(2*dptableA[n+1][k]+dptableA[n+1][k+alist[n]]) % MOD for k in range(asum[n]+1)]
    dptableB[n, 0:asn+1] = (dptableB[n+1, 0:asn+1] + dptableB[n+1, an:an+asn+1])%MOD
    #dptableB[n] = [(dptableB[n+1][k]+dptableB[n+1][k+alist[n]]) %MOD for k in range(asum[n]+1)]
retA, retB = dptableA[0,0], dptableB[0,0]
#全体 - (ある辺がS/2以上) + (2辺がS/2)
ans = (pow(3, N, MOD) - retA*3 + retB*3) % MOD
print(ans)
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 1
flag = True
for i in range(1, N):
    for j in range(i-1, -1, -1):
        if P[j] < P[i]:
            flag = False

    if not flag:
        flag = True
    else:
        ans += 1 
print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 0
mi = N
for i in range(N):
    mi = min(mi, P[i])
    if mi == P[i]: ans += 1

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


num=int(input())

def lucas(n):
    if n>1:
        return lucas(n-1)+lucas(n-2)
    elif n==1:
        return 1
    elif n==0:
        return 2

print(lucas(num))

### FIXED CODE ###


num=int(input())

def lucas(n):
    lus = [2, 1]
    for idx in range(n+1):
        if idx > 1:
            lus.append(lus[-2]+lus[-1])
    return lus[-1]
            
print(lucas(num))
### BUGGY CODE ###

import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x * -1, A))

heapq.heapify(A)

for _ in range(M):
    b, c = map(int, input().split())
    for _ in range(b):
        heapq.heappush(A, -c)

ans = 0
for _ in range(N):
    ans += -1 * (heapq.heappop(A))

print(ans)


### FIXED CODE ###

import sys
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
origin = sum(A)
heapq.heapify(A)

BC = [list(map(int, input().split())) for _ in range(M)]
BC = sorted(BC, reverse=True, key=lambda x: x[1])

count = 0

for i in range(M):
    b = BC[i][0]
    c = BC[i][1]
    for _ in range(b):
        smallest = heapq.heappop(A)
        tmp = c - smallest
        if tmp <= 0:
            heapq.heappush(A, smallest)
            break
        else:
            heapq.heappush(A, c)
            origin += tmp
            count += 1
            if count >= N:
                print(origin)
                sys.exit()

print(origin)
### BUGGY CODE ###

S=list(input())
Q=int(input())
R_count=0
for i in range(Q):
  Query=list(input().split())
  if Query[0]=="1":
    R_count+=1
  else:
    if Query[1]=="1":
      if R_count%2==0:
        S.insert(0,Query[2])
      else:
        S.append(Query[2])
    else:
      if R_count%2==0:
        S.append(Query[2])
      else:
        S.insert(0,Query[2])
print("".join(S) if R_count%2==0 else "".join(S[::-1]))


### FIXED CODE ###

from collections import deque

S=input()
Q=int(input())
r_flag=False
ans=deque((S))
for i in range(Q):
  Qu=input().split()
  if Qu[0]=="1":
    r_flag=not r_flag
  else:
    if Qu[1]=="1":
      if r_flag==True:
        ans.append(Qu[2])
      else:
        ans.appendleft(Qu[2])
    else:
      if r_flag==True:
        ans.appendleft(Qu[2])
      else:
        ans.append(Qu[2])
ans=list(ans)
print("".join(ans) if r_flag==False else "".join(ans[::-1]))
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
d = {i:0 for i in range(N+1)}

for i in range((N//G)+1):
    for j in range((N//B)+1):
        if i*G+j*B<=N:
            d[i*G+j*B] += 1

ans = 0
for i in range((N//R)+1):
    ans += d[N-(R*i)]
print(ans)

### FIXED CODE ###

from collections import defaultdict

R, G, B, N = map(int, input().split())
d = defaultdict(int)

for i in range((N//G)+1):
    for j in range((N//B)+1):
        d[i*G+j*B] += 1

ans = 0
for i in range((N//R)+1):
    ans += d[N-(R*i)]
print(ans)
### BUGGY CODE ###

import sys
for line in sys.stdin:
    n = int(line)
    count = 0
    for i in range(2,n+1):
        k = 2
        flag = True
        while k**2 <= i:
            if i%k == 0:
                flag = False
                break
            k += 1
        if flag:
            count += 1
    print (count)

### FIXED CODE ###

import sys
prime = [0]
isPrime = [1 for i in range(1000000)]
isPrime[0] = 0
isPrime[1] = 0
for i in sys.stdin:
    n = int(i)
    if prime[len(prime)-1] < n:
        for i in range(prime[len(prime)-1]+1,n+1):
            if isPrime[i] == 1:
                prime.append(i)
                for j in range(i*2, 1000000, i):
                    isPrime[j] = 0
    print(sum(isPrime[:n+1]))
### BUGGY CODE ###

import math
def main():
  from builtins import input, int, map
  N = int(input())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  A.sort()
  C.sort()
  n = int(math.log(N,2))+1

  ans = 0

  for i in range(N):
    if A[0] >= B[i]:
      continue
    if A[N-1] < B[i]:
      a = N
    else:
      left = 0
      right = N-1
      for _ in range(n):
        if right - left <= 1:
          break
        mid = (left + right) // 2
        if  B[i]> A[mid]:
          left = mid
        else:
          right = mid
      a = left + 1
    if C[N-1] <= B[i]:
      continue
    if C[0] > B[i]:
      c = N
    else:      
      left = 0
      right = N-1
      for _ in range(n):
        if right - left <= 1:
          break
        mid = (left + right) // 2
        if B[i]>= C[mid]:
          left = mid
        else:
          right = mid
      c = len(C[right:])
    ans += a*c
  print(ans)
main()

### FIXED CODE ###

import bisect as bi
def main():
  from builtins import input, int, map
  N = int(input())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  A.sort()
  C.sort()

  ans = 0

  for i in range(N):
    a = bi.bisect_left(A,B[i])
    c = N-bi.bisect_right(C,B[i])
    ans += a*c
  print(ans)
main()
### BUGGY CODE ###

from collections import Counter
N = int(input())
src = list(map(int,input().split()))

ctr1 = Counter()
ctr2 = Counter()

ans = []
for i in range(N):
    ctr1.update([src[i]])
    ctr2.update([src[-i-1]])
    if ctr1 == ctr2:
        ans.append(i+1)
        ctr1 = Counter()
        ctr2 = Counter()

print(*sorted(ans))



### FIXED CODE ###

# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from bisect import bisect_left, insort

N = int(input())
src = list(map(int,input().split()))
ans = []
A, B = [], []

for i in range(N):
    a, b = src[i], src[-i-1]
    addA = False
    addB = False

    if a != b:
        j = bisect_left(B, a)
        if j != len(B) and B[j] == a:
            del B[j]
        else:
            addA = True

        j = bisect_left(A, b)
        if j != len(A) and A[j] == b:
            del A[j]
        else:
            insort(B, b)

        if addA:
            insort(A, a)

    if len(A) == len(B) == 0:
        ans.append(i+1)

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

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

Edges=sorted(Edges)
cnt =0
# for i in c:
#     e1=(i[1] + i[2])
#     e2=(i[0] + i[2])
#     e3=(i[0] + i[1])

#     if i[0] < e1 and i[1] < e2 and i[2] < e3:
#         cnt+=1

for a in range(N-2):
    for b in range(a+1,N-1):
        ab = Edges[a] + Edges[b]

        list_ab = list(filter(lambda x : x > Edges[b] and x < ab ,Edges))
        cnt += max(0,len(list_ab))


print(cnt)

### FIXED CODE ###

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

Edges=sorted(Edges)
cnt =0
# for i in c:
#     e1=(i[1] + i[2])
#     e2=(i[0] + i[2])
#     e3=(i[0] + i[1])

#     if i[0] < e1 and i[1] < e2 and i[2] < e3:
#         cnt+=1


import bisect

for a in range(N-2):
    for b in range(a+1,N-1):
        ab = Edges[a] + Edges[b]

        idx = bisect.bisect_left(Edges,ab)

        cnt += max(0,idx-b-1)


print(cnt)
### BUGGY CODE ###

N = int(input())
List = list(map(int,input().split()))
num = 1
for i in List:
  num *= i
if num <= 10**18:
  print(num)
else:
  print(-1)

### FIXED CODE ###

N = int(input())
List = list(map(int,input().split()))
import math
def seki(L):
  num = 1
  for i in L:
    num *= i
  return num
def Seki(L):
  if len(L) <= int(math.sqrt(N)):
    return seki(L)
  else:
    return Seki(L[:len(L)//2]) * Seki(L[len(L)//2:])
if Seki(List) <= 10**18:
  print(Seki(List))
else:
  print(-1)
### BUGGY CODE ###

# Your code here!
h,w,d = map(int,input().split())

dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
for i in range(q):
    ans = 0
    l,r = map(int,input().split())
    current = l
    current_m = dic[l]
    while current < r:
        current += d
        next_m = dic[current]
        ans += abs(next_m[0]-current_m[0])+abs(next_m[1]-current_m[1])
        current_m = next_m
        
    
    print(ans)

### FIXED CODE ###

h,w,d = map(int,input().split())
 
dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
c = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    pi,pj = dic[i]; qi,qj = dic[i-d]
    c[i] = c[i-d] + abs(pi-qi) + abs(pj-qj)
    
for i in range(q):
    l,r = map(int,input().split())
    print(c[r]-c[l])
### BUGGY CODE ###

N = int(input())
S = []
kaisuu = []
solution = []
index = 0

for i in range(N):
  tmp = input()
  
  if (tmp in S) == False:
    S.append(tmp)
    kaisuu.append(1)
    index += 1
  
  if (tmp in S) == True:
    index_tmp = S.index(tmp)
    kaisuu[index_tmp] += 1
  
max_ = max(kaisuu)

for i, k in enumerate(kaisuu):
  if k == max_:
    solution.append(S[i])
    
solution.sort()

for i in solution:
  print(i)

### FIXED CODE ###

import collections

N = int(input())
solution = []
S = []

for i in range(N):
  tmp = input()
  S.append(tmp)
  
c = collections.Counter(S)

d = c.most_common()

max_ = d[0][1]

for i,k in enumerate(d):
  if d[i][1] == max_:
    solution.append(d[i][0])
    
solution.sort()

for i in solution:
  print(i)
### BUGGY CODE ###

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

a.sort(reverse=True)
b.sort(reverse=True)

def count(n):
    damage=0
    cnt=0
    for i in range(n):
        cnt+=1
        damage+=b[i]
        if damage>=H:
            return cnt
    
    cnt -= (-(H-damage))//a[0]
    return cnt

ans=float("inf")
for i in range(N+1):
    cnt=count(i)
    if cnt<=ans:
        ans=cnt
    else:
        print(ans)
        exit()
print(ans)

### FIXED CODE ###

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

a.sort(reverse=True)
b.sort(reverse=True)

def count(n):
    damage=0
    cnt=0
    for i in range(n):
        cnt+=1
        damage+=b[i]
        if damage>=H:
            return cnt
    
    cnt -= (-(H-damage))//a[0]
    return cnt

for i in range(N):
    if b[i]>a[0]:
        continue
    else:
        print(count(i))
        exit()
print(count(N))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
n = len(A)
z = 10 ** 9 + 7
ans = 0
x = 0
y = 0
for i in range(n - 1):
    B = A[i + 1:n]
    x = sum(B)
    y = (A[i] * x) % z
    ans = (ans + y) % z

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
n = len(A)
z = 10 ** 9 + 7
ans = 0

x = sum(A)
x = x ** 2
for i in A:
    y = i * i
    x -= y

x = x // 2
x = x % z
print(x)
### BUGGY CODE ###

import numpy as np
INF = 2**60 # 無限大を表す値
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]
W = H + max(A for (A, B) in AB)
dp = np.full((N+1, W+1), INF, dtype = np.int64)
dp[0][0] = 0
for i, (A, B) in enumerate(AB):
    for j in range(W+1):
        dp[i+1][j] = np.minimum(dp[i+1][j], dp[i][j])
        if j-A >= 0:
            dp[i+1][j] = np.minimum(dp[i+1][j], dp[i+1][j-A] + B)
print(np.min(dp[N][H:W+1]))

### FIXED CODE ###

INF = 2**60 # 無限大を表す値
H, N = map(int, input().split())
AB = [map(int, input().split()) for i in range(N)]
dp = [INF] * (H + 1)
dp[0] = 0
for A, B in AB:
    for j in range(H+1):
        dp[j] = min(dp[j], dp[max(j-A, 0)] + B)
print(dp[H])
### BUGGY CODE ###

N = int(input())
num = input()
X = int(num,2)
c = num.count('1')
def A(s):
    if s == 0:
        return 1
    else:
        return A(s%(str(bin(s)).count('1'))) + 1
amari1 = X%(c+1)
if c != 1:
    amari2 = X%(c-1)
    for i in range(N):
        if num[i] == '1':
            ans = A((amari2-2**(N-1-i))%(c-1))
            print(ans)
        else:
            ans = A((amari1+2**(N-1-i))%(c+1))
            print(ans)
else:
    for i in range(N):
        if num[i] == '1':
            print(0)
        else:
            ans = A((amari1+2**(N-1-i))%(c+1))
            print(ans)

### FIXED CODE ###

N=int(input())
X=input()
Y=int(X,2)
Z=Y
C=X.count('1')
if C==1:
  for i in range(N):
    if X[i]=='1':
      print(0)
    elif i==N-1:
      print(2)
    else:
      print(1)
  exit()
Y,Z=Y%(C+1),Z%(C-1)
def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))
 
for i in range(N):
  if X[i]=='1':
    print(1+f((Z-pow(2,N-i-1,C-1))%(C-1)))
  else:
    print(1+f((Y+pow(2,N-i-1,C+1))%(C+1)))
### BUGGY CODE ###

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

ans=set()
for i in range(n-1):
    i_set=set(s[i+1:])

    for j in i_set:
        j_ind=s.index(j)
        s_i=s[i+1:]
        j_set=set(s_i[s_i.index(j)+1:])
        [ans.add(s[i]+j+k) for k in j_set]

print(len(ans))

### FIXED CODE ###

n = int(input())

s = input()

ans = set()
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j), a+1)
        if b == -1:
            continue
        for k in range(10):
            if s.find(str(k), b+1) != -1:
                ans.add(str(i)+str(j)+str(k))
print(len(ans))