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

import sys 
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = list(map(int,readline().split()))
A = sorted(set(S))
q = deque(A)
ans = 0
while q:
  t = q.popleft()
  if t == 1:
    if S.count(1) == 1:
      print(1)
      sys.exit()
    else:
      print(0)
      sys.exit()
  if S.count(t) ==1:
    ans += 1
  count = 0
  for j in range(len(q)):
    if q[j] % t == 0:
      count +=1
      q.remove(q[j])
      q.appendleft(1)
  for i in range(count):
    q.remove(1)
print(ans)


### FIXED CODE ###

import sys 
import numpy as np
from numba import jit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


@jit(cache=True)
def solve(A):
  count = np.zeros(10**6+10)
  for x in A:
    if count[x] > 1:
      continue
    count[::x] += 1
  ans = 0
  for x in A:
    ans += count[x] == 1
  return ans

N = int(readline())
A = list(map(int,readline().split()))
A = np.array(A)
print(solve(A))
### BUGGY CODE ###

N = int(input())
S = list(map(int, input().split()))
Q = int(input())
T = list(map(int, input().split()))
ans = 0
for i in range(Q):
    OK = 0
    NG = N-1
    while abs(OK-NG)>0:
        mid = (OK+NG)//2
        if S[mid]==T[i]:
            ans += 1
            break
        elif S[mid]<T[i]:
            OK = mid
        else:
            NG = mid

print(ans)


### FIXED CODE ###

N = int(input())
S = list(set(map(int, input().split())))
S.sort()
Q = int(input())
T = list(map(int, input().split()))
ans = 0
for i in range(Q):
    OK = 0
    NG = len(S)
    while abs(OK-NG)>1:
        mid = (OK+NG)//2
        if S[mid]<=T[i]:
            OK = mid
        else:
            NG = mid
    if S[OK] == T[i]:
        ans += 1

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

n=int(input())
s=list(input())
q=int(input())
k=list(map(int,input().split()))
for i in range(q):
    p=s[:]
    h=0
    while p.count("D")!=0:
        f=p.index("D")
        p=p[f+1:]
        w=p[:]
        w=w[:k[i]-1]
        l=w.count("C")
        kl=w.count("M")
        if l!=0and kl!=0:
            for qp in range(kl):
                j=w.index("M")
                w=w[j+1:]
                h+=w.count("C")
    else:
        print(h)            

### FIXED CODE ###

n=int(input())
s=input()
q=int(input())
for i in list(map(int,input().split())):
    a=0
    v=[0,0,0]
    for j in range(n):
        if s[j]=="D":
            v[0]+=1
        elif s[j]=="M":
            v[1]+=1
            v[2]+=v[0]
        if j>=i:
            if s[j-i]=="D":
                v[0]-=1
                v[2]-=v[1]
            elif s[j-i]=="M":
                v[1]-=1
        if s[j]=="C":
            a+=v[2]
    print(a)
### BUGGY CODE ###

import math

def is_prime(n):
  if n == 2:
    return True

  if n < 2 or n % 2 == 0:
    return False

  i = 3
  while i <= math.sqrt(n):
    if n % i == 0:
      return False
    i += 2

  return True

while True:
  try:
    n = int(raw_input())
  except EOFError:
    break

  count = 0
  for x in range(2, n + 1):
    if is_prime(x):
      count += 1
  print count

### FIXED CODE ###

from bisect import bisect

def sieve(n):
  prime = [True] * n
  prime[0] = prime[1] = False
  for i in xrange(2, int(n ** 0.5) + 1):
    if prime[i]:
      for j in range(i ** 2, n, i):
        prime[j] = False
  return [i for i in xrange(2, n) if prime[i]]

primes = sieve(999999)
while True:
  try:
    print bisect(primes, input())
  except:
    break
### BUGGY CODE ###

N,Y = map(int,input().split())
a,b,c = N+1,N+1,N+1
dama = 0
count = 0

if Y // N == 10000:
    print(N,0,0)
elif Y // N == 5000:
    print(0,N,0)
elif Y // N == 1000:
    print(0,0,N)
else:
    stop = False
    for i in range(a):
        if stop:
            break
        b -= i
        for j in range(b):
            if stop:
                break
            c -= i+j
            for k in range(c):
                if i+j+k == N:
                    dama = 10000*i + 5000*j + 1000*k
                    if dama == Y:
                        print(i,j,k)
                        count += 1
                        stop = True
                        break
            c = N+1
        b = N+1
    if count == 0:
        print(-1,-1,-1)

### FIXED CODE ###

N,Y = map(int,input().split())
a,b,c = N+1,N+1,N+1
dama = 0
count = 0

if Y // N == 10000:
    print(N,0,0)
elif Y // N == 5000:
    print(0,N,0)
elif Y // N == 1000:
    print(0,0,N)
else:
    stop = False
    for i in range(a):
        if stop:
            break
        b -= i
        for j in range(b):
            if stop:
                break
            c -= i+j
            if i+j+c != N:
                pass
            else:
                dama = 10000*i + 5000*j + 1000*c
                if dama == Y:
                    print(i,j,c)
                    count += 1
                    stop = True
                    break
            c = N
        b = N+1
    if count == 0:
        print(-1,-1,-1)
### BUGGY CODE ###

n = input()
a = list(map(int, input().split()))
cut=0
 
while all(i%2==0 for i in a):
  list=[i/2 for i in a]
  cut+=1
print(cut)



### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)
### BUGGY CODE ###

n=int(input())
ans=0
for i in range(n):
  ans+=i
print(int(ans))

### FIXED CODE ###

n=int(input())
ans=n*(n-1)//2
print(ans)
### BUGGY CODE ###

import sys
input=sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

tk=UnionFind(n)

kk=[[False] * n for _ in range(n)]

for _ in range(m):
    a,b=map(int, input().split())
    kk[a-1][b-1]=True
    kk[b-1][a-1]=True
    tk.union(a-1, b-1)

for _ in range(k):
    c,d=map(int, input().split())
    kk[c-1][d-1]=True
    kk[d-1][c-1]=True

for i in range(n):
    tmp=tk.members(i)
    ans=-1
    for val in tmp:
        if not kk[i][val]:
            ans+=1
    print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

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

tk=UnionFind(n)

stk=[0 for _ in range(n)]
blk=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int, input().split())
    stk[a-1]+=1
    stk[b-1]+=1
    tk.union(a-1, b-1)

for _ in range(k):
    c,d=map(int, input().split())
    blk[c-1].append(d-1)
    blk[d-1].append(c-1)

for i in range(n):
    ans=tk.get_size(i)-1-stk[i]
    for j in blk[i]:
        if tk.is_same(i, j):
            ans-=1
    print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from bisect import bisect_left


def main():
    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()

    result = 0
    for c in C:
        index_c_b = bisect_left(B, c)
        for b in B[:index_c_b]:
            result += bisect_left(A, b)

    print(result)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from bisect import bisect_left, bisect_right


def main():
    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()

    result = 0
    for b in B:
        a = bisect_left(A, b)
        c = bisect_right(C, b)
        result += a * (N - c)

    print(result)


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

N=int(input())
L=list(map(int,input().split()))
L.append(0)
L.sort(reverse=True)
t=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]<L[j]+L[k]:
                t+=1
            else:
                break

print(t)


### FIXED CODE ###

from bisect import bisect_left

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

def main():
    from bisect import bisect_left as bl
    from itertools import accumulate as ac

    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    aa = [0]+list(ac(a))

    def b_search(ok, ng, value):
        while abs(ok-ng) > 1:
            mid = (ok+ng)//2
            if value(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def value(v):
        if sum([n-bl(a, v-a[i]) for i in range(n)]) >= m:
            return True
        else:
            return False

    b = b_search(0, 10**15, value)
    c = sum([n-bl(a, b-a[i]) for i in range(n)])-m
    ans = -c*b
    for i in range(n):
        d = bl(a, b-a[i])
        ans += aa[n]-aa[d]+(n-d)*a[i]
    print(ans)


main()


### FIXED CODE ###

def main():
    from bisect import bisect_left as bl
    from itertools import accumulate as ac

    n, m = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    aa = [0]+list(ac(a))
    an = aa[n]

    ok = 0
    ng = 10**10
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        q = 0
        for i in range(n):
            q += n-bl(a, mid-a[i])
        if q >= m:
            ok = mid
        else:
            ng = mid

    b = ok
    c = -m
    for i in range(n):
        c += n-bl(a, b-a[i])
    ans = -c*b
    for i in range(n):
        d = bl(a, b-a[i])
        ans += an-aa[d]+(n-d)*a[i]
    print(ans)


main()
### BUGGY CODE ###

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

import numpy as np
Nums.reverse()
cnt =0
d= np.array(Nums)

for i in range(N):
    P_i = d[0]
    d= np.delete(d,0)
    if (d>=P_i).prod() ==1:
        cnt +=1
    elif (d>=P_i).size ==0:
        cnt +=1

print(cnt)

### FIXED CODE ###

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

min_value=Nums[0]

cnt=0

for i in range(N):
    min_value = min(min_value,Nums[i])
    
    if Nums[i]<=min_value:
        cnt+=1
    
    

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

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

def z_algorithm(s):
    n = len(s)
    Z = [0]*n
    Z[0] = n
    i = 1
    j = 0
    while i < n:
        while i+j < n and s[j] == s[i+j]:
            j += 1
        Z[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i+k < n and k+Z[k] < j:
            Z[i+k] = Z[k]
            k += 1
        i += k
        j -= k
    return Z

ans = 0
for i in range(n):
    t = s[i:]
    z = z_algorithm(t)
    for j in range(len(z)):
        if z[j] <= j:
            ans = max(ans, z[j])
print(ans)


### FIXED CODE ###

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

dp = [[0]*(n+1) for i in range(n+1)]
#dp[n-1][n-1] = 1

for i in reversed(range(n)):
  for j in reversed(range(n)):
    if s[i] == s[j]:
      dp[i][j] = dp[i+1][j+1]+1

#print(dp)

ans = 0
for i in range(n-1):
  for j in range(i, n):
    ans = max(ans, min(dp[i][j], j-i))
    
print(ans)
### BUGGY CODE ###

s = input()
k = int(input())
ans = []
for i in range(len(s)):
  for j in range(i+1, len(s)+1):
    ans.append(s[i:j])
ans = sorted(list(set(ans)))
print(ans[k-1])

### FIXED CODE ###

s = input()
k = int(input())
ans = []
for i in range(len(s)):
  for j in range(i+1, len(s)+1):
    if j-i > k:break
    ans.append(s[i:j])
ans = sorted(list(set(ans)))
print(ans[k-1])
### BUGGY CODE ###

def resolve():
    s = input()
    c = 0
    while True:
        for i in range(len(s)-1):
            if s[i] != s[i+1]:
                s = s[:i] + s[i+2:]
                c += 2
                break
        if len(set(s)) == 0 or len(set(s)) == 1:
            break
    print(c)
resolve()

### FIXED CODE ###

def resolve():
    s = input()
    num_0 = s.count("0")
    num_1 = s.count("1")
    print(min(num_0, num_1)*2)
resolve()
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
N=int(input())
tree=np.array([[0]*N for i in range(N)])
for i in range(N-1):
    a,b,c=map(int,input().split(' '))
    tree[a-1][b-1] = c
    tree[b-1][a-1] = c
Q,K=map(int,input().split(' '))
ans = dijkstra(tree,indices=K-1)
for i in range(Q):
    s,e=map(int,input().split(' '))
    print(int(ans[s-1]+ans[e-1]))


### FIXED CODE ###

from collections import deque

N = int(input())
ABC=[map(int,input().split(' ')) for i in range(N-1)]
Q,K =  map(int,input().split(' '))
query = [map(int,input().split(' ')) for i in range(Q)]
tree = [[] for i in range(N+1)]
for a,b,c in ABC:
    tree[b].append((a,c))
    tree[a].append((b,c))
k_shortest = [0]*(N+1)
stack=deque([K])
while stack:
    k = stack.popleft()
    for v,d in tree[k]:
        if k_shortest[v] == 0:
            k_shortest[v] = k_shortest[k]+d
            stack.append(v)
for i,j in query:
    print(k_shortest[i]+k_shortest[j])
### BUGGY CODE ###

N, Y = map(int, input().split())

N_man_max = Y // 10000
N_gos_max = Y // 5000
N_sen_max = Y // 1000
flag = False
for i in range(N_man_max +1):
    if flag == True:
        break
    for j in range(N_gos_max +1 - i):
        for k in range(N_sen_max +1 - i - j):
            if 10000*i + 5000*j + 1000*k == Y and i+j+k == N:
                print(i,j,k)
                flag = True
if flag == False:
    print(-1, -1, -1)

### FIXED CODE ###

N, Y = map(int, input().split())
flag = False

for x in range(N+1):
    if flag == True:
        break
    for y in range(N-x+1):
        if 10000*x + 5000*y + 1000*(N-x-y) == Y:
            print(x, y, N-x-y)
            flag = True
            break

if flag == False:
    print(-1, -1, -1)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)

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

def condition(val):
    memo={}
    def dfs(num,count):
        if count>=val:
            return 0

        if (num,count) in memo:
            return memo[(num,count)]

        if num==N:
            memo[(num,count)]=int(val>count)
            return memo[(num,count)]

        ans=dfs(num+1,count+A[num])+dfs(num+1,count)
        memo[(num,count)]=ans
        return memo[(num,count)]

    return 2**(N-1)>dfs(0,0)-1

start=0
end=2000**2
while end-start>1:
    test=(start+end)//2
    if condition(test):
        start=test
    else:
        end=test

if condition(end):
    print(end)
else:
    print(start)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
S=sum(A)
if S%2==1:
    check=1
    for i in range(N):
        check=check|check<<A[i]
    for i in range(S//2+1,S+1):
        if check>>i &1==1:
            print(i)
            break
else:
    check=1
    for i in range(N):
        check=check|check<<A[i]

    for i in range(S//2,S+1):
        if check>>i &1==1:
            print(i)
            break
### BUGGY CODE ###

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

ans = -float('inf')

for i in range(n):
    now = i
    total = 0
    for j in range(1, k+1):
        now = pn[now]-1
        total += cn[now]
        ans = max(ans, total)
print(ans)

### FIXED CODE ###

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

ans = -float('inf')

for i in range(n): #start
    start = i
    now = start
    total = 0
    ls = [0]

    for j in range(1, k+1):
        now = pn[now]-1
        total += cn[now]
        ans = max(ans, total)
        ls.append(total)
        if now == start:
            rp = j
            break
    else:
        continue

    if total <= 0:
        continue
    else:
        if k % rp == 0:
            s = k % rp
            ans2 = total * (k // rp-1) + max(ls)
            ans = max(ans, ans2)
        else:
            s = k % rp
            ans2 = total * (k//rp) + max(ls[:s+1])
            ans = max(ans, ans2)
print(ans)
### BUGGY CODE ###

k, s = map(int, input().split())

ans = 0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            if sum([i, j, k]) == s:
                ans += 1
print(ans)


### FIXED CODE ###

k, s = map(int, input().split())

ans = 0
for x in range(k+1):
    for y in range(k+1):
        if x+y > s:
            continue
        if 0 <= s-x-y <= k:
            ans += 1

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


def main():
    N, K = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    count = 1
    num = 0
    dic = {}
    for a in A:
        if num == a:
            count += 1

        elif num > 0:
            dic.update({num:count})
            count = 1

        num = a

    dic.update({num:count})

    count = 0
    for i in range(len(dic.keys())-K):
        count += (sorted(dic.items(), key= lambda x:x[1])[i][1])

    print (count)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()



### FIXED CODE ###


def main():
    N, K = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    count = 1
    num = 0
    dic = {}
    for a in A:
        if num == a:
            count += 1

        elif num > 0:
            dic.update({num:count})
            count = 1

        num = a

    dic.update({num:count})

    sort_dic = sorted(dic.items(), key= lambda x:x[1])

    count = 0
    keys = len(dic.keys())
    for i in range(keys-K):
        count += sort_dic[i][1]

    print (count)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()
### BUGGY CODE ###

k,s = map(int,input().split())
count = 0
for l in range(k+1):
    for m in range(k+1):
        for n in range(k+1):
            if l + m + n == s:
                count += 1
print(count)

### FIXED CODE ###

k,s = map(int,input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
            count+=1
print(count)
### BUGGY CODE ###

import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, T = map(int, readline().split())

AB= list(map(int, read().split()))
A = AB[0::2]
B = AB[1::2]
ls = sorted(zip(A, B))
#ls = list(zip(A, B))
# 食べるのにかかる時間で昇順にソート
#ls.sort()
# 上の並び順において、ls[i:]の美味しさの最大値をdeli[i]とする
deli = [0]*N
deli[- 1] = ls[-1][- 1]
for i in range(N - 2, 0, - 1):
    deli[i] = max(deli[i + 1], ls[i][- 1])

res = 0
dp = np.zeros(T, np.int64)
for i in range(N - 1):
    for j in range(T - 1, - 1, - 1):
        if ls[i][0] <= j:
            dp[j] = max(dp[j], dp[j - ls[i][0]] + ls[i][1])
    res = max(res, dp[- 1] + deli[i + 1])
print(res)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, T = map(int, readline().split())

AB= list(map(int, read().split()))
A = AB[0::2]
B = AB[1::2]
ls = list(zip(A, B))
# 食べるのにかかる時間で昇順にソート
ls.sort()
# 上の並び順において、ls[i:]の美味しさの最大値をdeli[i]とする
deli = [0]*N
deli[- 1] = ls[-1][- 1]
for i in range(N - 2, - 1, - 1):
    deli[i] = max(deli[i - 1], ls[i][- 1])

res = 0
dp = [0]*T
for i in range(N - 1):
    for j in range(T - 1, - 1, - 1):
        if ls[i][0] <= j:
            dp[j] = max(dp[j], dp[j - ls[i][0]] + ls[i][1])
    res = max(res, dp[- 1] + deli[i + 1])
print(res)
### BUGGY CODE ###

def main():
    n, k = list(map(int, input().split()))
    p = list(map(int, input().split()))
    
    s = []
    for i, v in enumerate(p):
        if i + k > len(p):
            break
        #print(p[i:i+k])
        s.append((sum(p[i:i+k])+1*k)/2)    
    print(max(s))
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import itertools as iter

def main():
    n, k = list(map(int, input().split()))
    p = [0]
    p.extend(list(iter.accumulate([(1+int(x))/2 for x in input().split()])))
    #print(p)
    
    s = []
    for i in range(n-k+1):
        s.append(p[i+k]-p[i])
    #print(s)
    print(max(s))
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())

a = [int(input()) for i in range(n)]

for i in range(n):
    print(max(max(a[:i],a[i+1:])))

### FIXED CODE ###


n = int(input())
a = []
y = 0
for i in range(n):
    x = int(input())
    a.append(x)
    if y <= x:
        y = x
        m = i

a.sort(reverse = True)
a_1 = a[0]
a_2 = a[1]

if a_1 == a_2:
    for i in range(n):
        print(a_1)

else:
    for i in range(m):
        print(a_1)

    print(a_2)

    for j in range(m+1,n):
        print(a_1)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=[]
C=[]
for i in range(Q):
  b,c=map(int,input().split())
  B.append(b)
  C.append(c)

for i in range(Q):
  ans = 0
  for j in range(len(A)):
    if A[j] == B[i]:
      A[j]=C[i]
      ans += A[j]
    else:
      ans += A[j] 
  print(ans)

### FIXED CODE ###

import collections
n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
for val in arr:#あらかじめ各Aiの個数を数えておく
  cnt[val]+=1
sums=sum(arr) #あらかじめAiの総和を求めておく
q=int(input())
for _ in range(q):
  b,c=map(int,input().split())
  diff=(c-b)*(cnt[b])
  sums+=diff
  print(sums)
  cnt[c]+=cnt[b]#CiがBiに変更されたので、Biの数をCiの数に加える
  cnt[b]=0 #Biの数はゼロになる。
### BUGGY CODE ###

k,s=map(int,input().split())
L=[x+y+z for x in range(k+1) for y in range(k+1) for z in range(k+1)]
print(L.count(s))

### FIXED CODE ###

k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    if s-x-y>=0 and s-x-y<=k:
      ans+=1
print(ans)
### BUGGY CODE ###

def primes(n):
    res = [1]
    a = 2
    while n > 1 and a < (10**7):
        if n % a == 0:
            res.append(a)
            while n % a == 0:
                n //= a
        a += 1
    return set(res)


if __name__ == '__main__':
    a, b = map(int, input().split(' '))
    print(len(primes(a) & primes(b)))


### FIXED CODE ###

def primes(n):
    res = [1]
    a = 2
    while n > 1 and a < (10**6):
        if n % a == 0:
            res.append(a)
            while n % a == 0:
                n //= a
        a += 1
    if a == 10**6:
        res.append(n)
    return set(res)


if __name__ == '__main__':
    a, b = map(int, input().split(' '))
    print(len(primes(a) & primes(b)))