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

import itertools
from sys import stdin
N=list(map(int,stdin.readline().strip().split()))[0]
st=list(stdin.readline().strip())
count=0
stt=set(st)
stt=list(stt)
num=["0","1","2","3","4","5","6","7","8","9"]
num = [s for s in num if s in stt ]
num_list= ["".join(i) for i in itertools.product(num,repeat=3)]

for number in num_list:
    cnt = 0
    for i in range(N):
        if number[cnt]==st[i]:
            cnt+=1
            if cnt==3:
                count += 1
                break


print(count)

### FIXED CODE ###

def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()
### BUGGY CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import *

def f(a,b,k): #k桁目のxor
    p1 = 1<<k
    p2 = 2*p1
    p3 = 3*p1
    a = [i&(p2-1) for i in a]
    b = [i&(p2-1) for i in b]
    b.sort()
    
    res = 0
    for ai in a:
        j1 = bisect_left(b,p1-ai)
        j2 = bisect_left(b,p2-ai)
        j3 = bisect_left(b,p3-ai)
        res += j2-j1+n-j3
    return res%2

ans = 0
for k in range(28,-1,-1):
    ans |= f(a,b,k)*(1<<k)

print(ans)    




### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



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

import queue
def main():
    h,w=map(int,input().split())
    maze=[]
    for i in range(h):
        row=input()
        maze.append(row)
    #print(maze)
    root=[[-1 for i in range(h*w)] for i in range(h*w)]
    for i in range(h):
        for j in range(w):
        # print(maze[i][j])
            if maze[i][j]==".":
                now=w*i+j
                hidari=w*i+j-1
                migi=w*i+j+1
                ue=w*(i-1)+j
                sita=w*(i+1)+j
                if j>0:
                    if maze[i][j-1]!="#":
                        root[now][hidari]=0
                if i+1<h:
                    if maze[i+1][j]!="#":
                        root[now][sita]=0
                if j+1<w:
                    if maze[i][j+1]!="#":
                        root[now][migi]=0
                if 0<i:
                    if maze[i-1][j]!="#":
                        root[now][ue]=0
            else:
                now=w*i+j
                now=w*i+j
                hidari=w*i+j-1
                migi=w*i+j+1
                ue=w*(i-1)+j
                sita=w*(i+1)+j
                if j>0:
                    root[now][hidari]=-1
                if i+1<h:
                    root[now][sita]=-1
                if j+1<w:
                    root[now][migi]=-1
                if 0<i:
                    root[now][ue]=-1
    #print(root)
    max=0
    for start in range(h*w):
        dist=[-1]*(h*w)
        now=start
        dist[start]=0
        visted=[0]*(h*w)
        toVis=queue.Queue()
        visted[now]=1
        for i in range(h*w):
            if root[now][i]!=-1:
                toVis.put(i)
                dist[i]=dist[now]+1
        while toVis.empty()!=True:
            now=toVis.get()
            visted[now]=1
            for i in range(h*w):
                if root[now][i]!=-1 and visted[i]!=1:
                    toVis.put(i)
                    dist[i]=dist[now]+1
        #print("s:",start,"g:",goal,"len",dist[goal])
        farest=dist[now]
        if max<farest:
            max=farest
    print(max)
            
if __name__=="__main__":
    main()


    

### FIXED CODE ###

h,w=map(int,input().split())
n=h*w
inf=10**6
field=[]
for i in range(h):
    field.append(input())
dist=[[inf]*n for i in range(n)]
for i in range(h):
    for j in range(w):
        if field[i][j]=="#":continue
        if j+1<w and field[i][j+1]!="#":
            dist[i*w+j][i*w+j+1]=1
            dist[i*w+j+1][i*w+j]=1
        if i+1<h and field[i+1][j]!="#":
            dist[i*w+j][(i+1)*w+j]=1
            dist[(i+1)*w+j][i*w+j]=1
for i in range(n):
    for j in range(n):
        for k in range(n):
            dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k])
ans=0
for i in range(n):
    for j in range(n):
        if i==j:
            continue
        if dist[i][j]==inf:
            continue
        ans=max(ans,dist[i][j])
print(ans)
### BUGGY CODE ###

import math
from collections import deque

import time

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

graph = []

for i in range(m):
  a, b = map(int, input().split())
  graph.append([a, b])
  
dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

guidepost = [-1] * (n+1)

while d:
  v = d.popleft()
  for i, j in graph:
    if dist[i] != -1 and dist[j] != -1:
      continue
    elif i == v:
      dist[j] = 1
      d.append(j)
      if guidepost[j] != -1:
        print("No")
        exit()
      else:
        guidepost[j] = v
    elif j == v:
      dist[i] = 1
      d.append(i)
      if guidepost[i] != -1:
        print("No")
        exit()
      else:
        guidepost[i] = v
  
for i in range(2, n+1):
  if guidepost[i] == -1:
    print("No")
    exit()

print("Yes")
for i in range(2, n+1):
  print(guidepost[i])

### FIXED CODE ###

import math
from collections import deque

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

graph = [[] for _ in range(n+1)]

for i in range(m):
  a, b = map(int, input().split())
  graph[a].append(b)
  graph[b].append(a)

flag = [0] * (n+1)
flag[0] = 1
flag[1] = 1

d = deque()
d.append(1)

guidepost = [-1] * (n+1)

while d:
  v = d.popleft()
  for i in graph[v]:
    if flag[i] != 0:
      continue
    flag[i] = 1
    d.append(i)
    if guidepost[i] != -1:
      print("No")
      exit()
    else:
      guidepost[i] = v
  
if not all(guidepost):
  print("No")
  exit()

ans = guidepost[2:]    

print("Yes")
print(*ans, sep="\n")
### BUGGY CODE ###

from collections import Counter


N = int(input())
A = [input() for i in range(N)]
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)

ans=0
for i in range(N):
    for j in range(i+1,N):
#         print(i,j)
#         print(verify_anagrams(A[i],A[j]))
        if verify_anagrams(A[i],A[j]):
            ans+=1
print(ans)

### FIXED CODE ###

N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)
### BUGGY CODE ###

A,B,N=map(int,input().split())
C=A%B
ans=0
for i in range(1,min(B,N+1)):
    b=i
    ans=max(ans, (A*b-C*b%B)//B)
print(ans)

### FIXED CODE ###

A,B,N=map(int,input().split())
C=A%B
ans=0
b=min(B-1,N)
ans=(A*b-C*b%B)//B
print(ans)
### BUGGY CODE ###

import numpy as np

n,m=map(int,input().split())
e = []

for _ in range(1,m+1):
    a,b=map(int,input().split())
    e.append((a,b))

q = int(input())
cs = [0] * (q+1)
dp = np.zeros((n+1, 11), int)
for i in range(1, q+1):
    v,d,c=map(int,input().split())
    cs[i] = c
    dp[v,d] = i

for d in range(9, -1, -1):
    for i in range(1,n+1):
        dp[i,d] = max(dp[i,d], dp[i,d+1])
    for a,b in e:
        dp[a,d] = max(dp[a,d], dp[b,d+1])
        dp[b,d] = max(dp[b,d], dp[a,d+1])

for i in range(1, n+1):
    print(cs[dp[i,0]])

### FIXED CODE ###

n,m=map(int,input().split())
e = []

for _ in range(1,m+1):
    a,b=map(int,input().split())
    e.append((a,b))

q = int(input())
cs = [0] * (q+1)
dp = [[0]*11 for _ in range(n+1)]
for i in range(1, q+1):
    v,d,c=map(int,input().split())
    cs[i] = c
    dp[v][d] = i

for d in range(9, -1, -1):
    for i in range(1,n+1):
        dp[i][d] = max(dp[i][d], dp[i][d+1])
    for a,b in e:
        dp[a][d] = max(dp[a][d], dp[b][d+1])
        dp[b][d] = max(dp[b][d], dp[a][d+1])

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

# D
n = int(input())
y = list(map(int, input().split()))
ans = [0 for i in range(n)]
for i in range(n):
    count=0
    for j in range(i,n+i):
        if (j-i) % 2 == 0:
            count += y[j%n]
        else:
            count -= y[j%n]
    ans[i] = count
print(*ans, sep=' ')

### FIXED CODE ###

# D
n = int(input())
y = list(map(int, input().split()))
for i,num in enumerate(y):
    if i % 2 == 1:
        y[i] = -y[i]

a2=[0]
for i in y:a2.append(a2[-1]+i)
def SumArea(r, l):
    return a2[l]-a2[r]
    
ans = [0 for i in range(n)]
for i in range(n):
    count=0
    if i % 2 == 1:
        count -= SumArea(i, n)
        count += SumArea(0, i)
    else:
        count += SumArea(i, n)
        count -= SumArea(0, i)
    ans[i] = count
print(*ans, sep=' ')
### BUGGY CODE ###

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

for i in range(1,n+1):
	print(a.count(i))

### FIXED CODE ###

import collections

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

c = collections.Counter(a)

for i in range(n):
  print(c.get(i+1, "0"))
### BUGGY CODE ###

import heapq

n,m  = map(int,input().split())
a = list(map(int, input().split()))
bcs = []
for _ in range(m):
    bcs.append(list(map(int, input().split())))

heapq.heapify(a)

for bc in bcs:
    b = bc[0]
    c = bc[1]
    while b > 0:
        ta = heapq.heappop(a)
        if ta < c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,ta)
            break
        b -= 1

print(sum(a))

### FIXED CODE ###

import heapq

n,m  = map(int,input().split())
a = list(map(int, input().split()))
bcs = []
for _ in range(m):
    bcs.append(list(map(int, input().split())))

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

for bc in bcs:
    b = bc[0]
    c = bc[1]
    while b > 0:
        ta = heapq.heappop(a)
        if ta < c:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,ta)
            break
        b -= 1

print(sum(a))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())

    for i in range(M//N, 0, -1):
        if (M - N * i) % i == 0:
            print(i)
            break
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import math
import sys
input = sys.stdin.readline

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

def main():
    N, M = map(int, input().split())

    divisors = make_divisors(M)

    for d in divisors:
        tmp = M - d * N
        if tmp >= 0 and tmp % d == 0:
            print(d)
            break
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

H, W = map(int, input().split())
S = [int(input()) for _ in range(W)]
    
floor = list(range(0,H+1))

if S.count(1) >0:
	floor[1]=0
	floor[2]=1
if S.count(2) >0:
    floor[2]=0

teiou = [0]*H
for i in range (0, H+1):
	if S.count(i) >  0:
		teiou[i] = 1
    
for i in range (3, H+1):
		floor[i]=floor[i-2]*(1-teiou[i-2])+floor[i-1]*(1-teiou[i-1])
print(floor[H]%(10**9+7))

### FIXED CODE ###

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

A = []

for i in range (0, M):
	A.append(int(input()))


if N == 1:
	print(1)
	exit()
elif N ==2:
	if len(A) ==1:
		print(1)
	else:
		print(2)
	exit()

DP = [0]*N

if A.count(1)==0:
	DP[0] = 1

if A.count(2)==0:
	if A.count(1)==0:
		DP[1] = 2
	else:
		DP[1] = 1

for i in range (0, M):
	DP[A[i]-1] = -1

for i in range (0, 2):
	if DP[i] == -1:
		DP[i] = 0

for i in range (2, N):
	if DP[i] ==-1:
		DP[i] = 0
	else:
		DP[i] = DP[i-1] + DP[i-2]

print(DP[-1]%(1000000007))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())

Slist = {}
maxNum = 1
for i in range(N):
    S = input()
    if S in Slist.keys():
        Slist[S] += 1
        if Slist[S] > maxNum:
            maxNum = Slist[S]
    else:
        Slist[S] = 1

ans = []
for str in Slist.keys():
    if Slist[str] == maxNum:
        ans.append(str)

ans.sort()
for str in ans:
    print(str)

### FIXED CODE ###

# import sys
# input = sys.stdin.readline

N = int(input())

Slist = []
for i in range(N):
    Slist.append(input())
    # if S in Slist.keys():
    #     Slist[S] += 1
    #     if Slist[S] > maxNum:
    #         maxNum = Slist[S]
    # else:
    #     Slist[S] = 1
Slist.sort()

max_cnt = 1
cnt = 1
s_old = Slist[0]
max_Slist = []

for i in range(1,N):
    if Slist[i] == s_old:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            max_Slist = [s_old]
        elif cnt == max_cnt:
            max_Slist.append(s_old)
        s_old = Slist[i]
        cnt = 1

if Slist[N-1] == s_old:
    if cnt > max_cnt:
        max_Slist = [s_old]
    elif cnt == max_cnt:
        max_Slist.append(s_old)

for str in max_Slist:
    print(str)
### BUGGY CODE ###

n,k,q=(map(int,input().split()))
l=[int(input()) for i in range(q)]
for i in range(1,n+1):
    print("Yes" if k-(len(l)-l.count(i))>0 else "No")

### FIXED CODE ###

n,k,q=map(int, input().split())
p=[-q+k]*n
for i in range(0,q):
    p[int(input())-1]+=1
for i in range(0,n):
    print("Yes" if p[i]>0 else "No")
### BUGGY CODE ###

n,p = map(int,input().split())
ans = 1

for i in range(2,p+1):
    if i>p:
        break
    count = 0
    flag = 0
    while flag == 0:
        if p//i == p/i:
            p = p//i
            count += 1
        else:
            if count >= n:
                ans *= i**(count//n)
            flag = 1
            

print(ans)
        

### FIXED CODE ###

import collections
n,p = map(int,input().split())
ans = 1
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

c = collections.Counter(prime_factors(p))
for i in range(len(c.most_common())):
    if c.most_common()[i][1]>=n:
        ans *= int(c.most_common()[i][0]) ** (c.most_common()[i][1]//n)
print(ans)
### BUGGY CODE ###

def gcd(a, b):
	while a > 0 and b > 0:
		a, b = b, a % b
	return a + b

def st(a, b):
	if b == 0:
		return 1
	if b % 2 == 0:
		q = st(a, b // 2)
		return q * q
	return a * st(a, b - 1)

n = int(input())
a = []
for i in range(n + 1):
	x = int(input())
	a.append(x)
ans = 0
for x in range(1, 26):
	tmp = 0
	r = st(x, n)
	for i in range(0, n + 1):
		tmp += a[i] * r
		r //= x
	ans = gcd(ans, abs(tmp))
v = []
j = 2
while j * j <= ans:
	if ans % j == 0:
		ans //= j
		v.append(j)
	else:
		j += 1
if ans != 1:
	v.append(ans)
v.sort()
for i in range(len(v)):
	if i == 0 or v[i] != v[i - 1]:
		print(v[i])


### FIXED CODE ###

def gcd(a, b):
	while a > 0 and b > 0:
		a, b = b, a % b
	return a + b

def st(a, b):
	if b == 0:
		return 1
	if b % 2 == 0:
		q = st(a, b // 2)
		return q * q
	return a * st(a, b - 1)

n = int(input())
a = []
for i in range(n + 1):
	x = int(input())
	a.append(x)
ans = 0
for x in range(1, 18):
	tmp = 0
	r = st(x, n)
	for i in range(0, n + 1):
		tmp += a[i] * r
		r //= x
	ans = gcd(ans, abs(tmp))
v = []
j = 2
while j * j <= ans:
	if ans % j == 0:
		ans //= j
		v.append(j)
	else:
		j += 1
if ans != 1:
	v.append(ans)
v.sort()
for i in range(len(v)):
	if i == 0 or v[i] != v[i - 1]:
		print(v[i])
### BUGGY CODE ###

from fractions import gcd 
from functools import reduce
import itertools
k = int(input())
a = [i for i in range(1,k+1)]
s =0
#同じ数字３つの時
s = int(k*(k+1)/2)
#同じ数字２つと違う数字一つ
for q in itertools.combinations(a,2):
  s += reduce(gcd,q)*3*2
for t in itertools.combinations(a,3):
  s += reduce(gcd,t)*6
print(s)

### FIXED CODE ###

import math
from functools import reduce
import itertools
k = int(input())
a = [i for i in range(1,k+1)]
s =0
#同じ数字３つの時
s = int(k*(k+1)/2)
#同じ数字２つと違う数字一つ
for q in itertools.combinations(a,2):
  s += reduce(math.gcd,q)*3*2
for t in itertools.combinations(a,3):
  s += reduce(math.gcd,t)*6
print(s)
### BUGGY CODE ###

from collections import Counter
N = int(input())
S = str(input())
S += "x"*4001
c = Counter(S)
after_happen = {}
after_happen[0] = c.copy()
after_happen[0][S[0]] -= 1

for i in range(1, N):
    after_happen[i] = after_happen[i-1].copy()
    after_happen[i][S[i]] -= 1
# print(after_happen)
ans = 0
rgb = set(["R", "G", "B"])
for i in range(N-2):
    for j in range(i+1, N-1):
        # 同じ文字ならcontinue
        if S[i] == S[j]:
            continue
        # jより後ろにtargetがいくつ存在するか確認する, after_happen[j] := jより後ろの情報
        target = rgb - set([S[i], S[j]])
        target = list(target)[0]
        ans += after_happen[j][target]
        if S[j+(j-i)] == target:
            ans -= 1
print(ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
S = str(input())
S += "x"*4000
all_string = Counter(S)

after_happen = {0: all_string}
for i in range(1, N+1):
    tmp = after_happen[i-1].copy()
    after_happen[i] = tmp
    after_happen[i][S[i-1]] -= 1
ans = 0
rgb = set(["R", "G", "B"])
for i in range(N-2):
    for j in range(i+1, N-1):
        # 最後に引くのを忘れない
        # j+1以降で探す
        if S[i] == S[j]:
            continue
        target = rgb-set([S[i], S[j]])
        target = list(target)[0]
        # print(target)
        ans += after_happen[j][target]
        # 余分に数えている分を引きたい
        if S[j+(j-i)] == target:
            ans -= 1
print(ans)
### BUGGY CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 仕方ないので，numpy で同時代入
import numpy as np
H, W = list(map(int, input().split()))
L = np.asarray([True if j == "#" else False for i in range(H) for j in input()])
all_count = H * W
blacks = [i for i in range(all_count) if L[i]]
#print(blacks)
black_count = len(blacks)

cands_H = [-W, W]
cands_W = [-1, 1]
result = 0
while black_count < all_count:
  next_steps = set([black+cand for black in blacks for cand in cands_H]) | set([black+cand for black in blacks for cand in cands_W if black%W not in [0, W-1]])
  blacks = [i for i in next_steps if i >= 0 and i < all_count and not L[i]]
  L[blacks] = True
  black_count += len(blacks)
  #print(blacks)
  result += 1

print(result)


### FIXED CODE ###

# python には結構厳しいTLE・・・python以外のお勉強時間ないよ～( ;∀;)
# . から見た # の最大距離の方が楽ではあるが・・・
# 嫌いだけど def main も使ってみた．
from collections import deque
import copy

def main():
  H, W = list(map(int, input().split()))
  L = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if L[i][j]])
  cands = [(0, -1), (0, 1), (-1, 0), (1, 0)]
  result = 0
  while True:
    nq = deque()
    while q:
      i, j = q.popleft()
      if i > 0 and not L[i-1][j]:
        L[i-1][j] = True
        nq.append((i-1, j))
      if j > 0 and not L[i][j-1]:
        L[i][j-1] = True
        nq.append((i, j-1))
      if i < H-1 and not L[i+1][j]:
        L[i+1][j] = True
        nq.append((i+1, j))
      if j < W-1 and not L[i][j+1]:
        L[i][j+1] = True
        nq.append((i, j+1))
    if nq:
      q = copy.copy(nq)
    else:
      break    
    result += 1
  print(result)

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

s = input()

idx = [i for i,x in enumerate(s) if x =='W']


count = 0
for i in idx:
  count += s[0:i].count('B')
  
print(count)

### FIXED CODE ###

s = input()

count = 0
black = 0
for i in s:
  if i=='W':
    count += black
  else:
    black+=1

print(count)
### BUGGY CODE ###

n = int(input())
A = [int(i) for i in input().split()]
ans = 1
for i in range(n):
    ans = ans * A[i]

if ans >pow(10,18):
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())
A = [int(i) for i in input().split()]
the = pow(10,18)
ans = 1

if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans >the:
            print(-1)
            break
        else:
            continue
    if ans <= the:
        print(ans)
### BUGGY CODE ###

input()
aa = list(map(int, input().split()))
uu = list(set(aa))
cc = uu.copy()
total = 0
for i in range(len(uu)):
    cc[i] = aa.count(uu[i])
    total += cc[i] * (cc[i]-1) / 2

dic = dict(zip(uu,cc))

for a in aa:
    print(int(total - dic[a] + 1))

### FIXED CODE ###

input()
from collections import Counter
aa = list(map(int, input().split()))
dic = Counter(aa)

total = 0
for v in dic.values():
    total += v * (v-1) / 2

for a in aa:
    print(int(total - dic[a] + 1))
### BUGGY CODE ###

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

def factorization(n):
    arr = dict()
    temp = n
    for i in range(2, int(n**0.5//1)+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if arr==[]:
        arr[n] = 1

    return arr

a_fac = []
lcm_fac = dict()
for i in range(n):
    tem = factorization(a[i])
    a_fac.append(tem)
    for fac in tem.keys():
        if fac in lcm_fac.keys():
            lcm_fac[fac] = max(tem[fac], lcm_fac[fac])
        else:
            lcm_fac[fac] = tem[fac]


ans = 0
for i in range(n):
    tem = 1
    for j in lcm_fac.keys():
        if j in a_fac[i].keys():
            tem *= j ** (lcm_fac[j] - a_fac[i][j])
        else:
            tem *= j ** lcm_fac[j]
    ans += tem

print(ans % (10**9+7))






### FIXED CODE ###

n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()

for i in range(Q):
    l,r = map(int,input().split())
    S_rep = S[l-1:r].replace('AC','')
    print(int((len(S[l-1:r])-len(S_rep))/2))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)

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

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

def is_able(n, m):
    res = [0]
    for i in range(1, n+1):
        for j in range(1, m+1):
            count = 0
            count += i*j
            count += (n-i)*(m-j)
            if count not in res:
                res.append(count)
    return res


if k in is_able(n, m):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from collections import defaultdict
n, m, k = map(int, input().split())

def is_able(n, m, k):
    res = defaultdict(bool)
    res[0] = True
    for i in range(1, n+1):
        for j in range(1, m+1):
            count = 0
            count += i*j
            count += (n-i)*(m-j)
            res[count] = True
    return res[k]


if is_able(n, m, k):
    print("Yes")
else:
    print("No")