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

from collections import defaultdict


def divisor(n):  # nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    div_set = set(table)
    return div_set


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

divcount = defaultdict(int)
for n in A_list:
    for i in divisor(n):
        divcount[i] += 1

# print(divcount)

max_divisor = 0
for key, value in divcount.items():
    if value >= N - 1 and key > max_divisor:
        max_divisor = key

print(max_divisor)


### FIXED CODE ###

from collections import defaultdict
import bisect


def divisor(n):  # nの約数を全て求める
    i = 1
    div_set = set()
    while i * i <= n:
        if n % i == 0:
            div_set.add(i)
            div_set.add(n//i)
        i += 1
    return div_set


def divisor2(n):  # 既存のリストからnの約数だけを返す
    div_set = set()

    for i in kouho:
        if i > n:
            return div_set
        if n % i == 0:
            div_set.add(i)
    return div_set


N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
max_index = bisect.bisect_left(A_list, A_list[-1])
# print(max_index)
times = max_index

divcount = defaultdict(int)
for n in A_list[:2]:
    # print(n)
    for i in divisor(n):
        divcount[i] += 1

kouho = list(divcount.keys())
kouho.sort()
# print(kouho)

for n in A_list[2:max_index+1]:
    # print(n)
    for i in divisor2(n):
        divcount[i] += 1

# print(divcount)
max_divisor = 0
for key, value in divcount.items():
    if value >= max_index and key > max_divisor:
        max_divisor = key

print(max_divisor)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
c = 0
for i in set(A):
  if A.count(i) >= i:
    c += A.count(i)-i
  else:
    c += A.count(i)
print(c)

### FIXED CODE ###

import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
c = 0
temp = 0
for i in sorted(list(set(A))):
  d = bisect.bisect_right(A, i)
  if d-temp >= i:
    c += d-temp - i
  else:
    c += d-temp
  temp = d
print(c)
### BUGGY CODE ###


s = input()
q = int(input())
ans = []
ans_s = ''
one_count = 0
key = 0
for i in range(q):
    ans.append(list(input().split()))
for i in ans:
    if int(i[0])==1:
        one_count += 1
    else:
        if one_count%2==0:
            if int(i[1]) == 1:
                #ans_q.insert(0,i[2])
                s = i[2]+s
                #ans_s = ans_s+i[2]
            else:
                s = s+i[2]
                #ans_q.insert(len(ans_q),i[2])
                #ans_s = i[2]+ans_s
                #key += 1
        else:
            if int(i[1]) == 1:
                #ans_q.insert(len(ans_q),i[2])
                s = s+i[2]
                #ans_s = i[2]+ans_s

            else:
                #ans_q.2insert(0,i[2])
                s = i[2]+s
                #ans_s = ans_s+i[2]

if one_count%2==0:
    print(s)
else:
    print(s[::-1])


### FIXED CODE ###


from collections import deque
s = input()
q = int(input())
s = deque(s)
ans = []
ans_s = ''
one_count = 0
key = 0
for i in range(q):
    ans.append(list(input().split()))
for i in ans:
    if int(i[0])==1:
        one_count += 1
    else:
        if one_count%2==0:
            if int(i[1]) == 1:
                s.appendleft(i[2])
            else:
                s.append(i[2])
        else:
            if int(i[1]) == 1:
                s.append(i[2])
            else:
                s.appendleft(i[2])

if one_count%2==0:
    print(''.join(s))
else:
    print(''.join(s)[::-1])
### BUGGY CODE ###

from collections import Counter 
import itertools

N = int(input())
D = list(map(int, input().split()))
M = Counter(D)
if max(M.values()) > 2:
    print(0)
else:
    D = [[x, 24-x] for x in D]
    generator = list(itertools.product([0, 1], repeat=N))
    D_gen = [[D[i][g[i]] for i in range(N)] for g in generator]
    ans = 0
    for d in D_gen:
        tmp = [0] + sorted(d) + [24]
        s = 13
        for i in range(N+1):
            s = min(s, tmp[i+1]-tmp[i])
        ans = max(ans, s)
    print(ans)


### FIXED CODE ###

from collections import Counter 
import itertools

N = int(input())
D = list(map(int, input().split()))
D.append(12)
M = Counter(D)
if max(M.values()) > 2:
    print(0)
elif 0 in D:
    print(0)
elif N > 11:
    print(1)
else:
    D.remove(12)
    D = [[x, 24-x] for x in D]
    generator = list(itertools.product([0, 1], repeat=N))
    D_gen = [[D[i][g[i]] for i in range(N)] for g in generator]
    ans = 0
    for d in D_gen:
        if len(set(d)) < N:
            pass
        else:
            tmp = [0] + sorted(d) + [24]
            s = 13
            for i in range(N+1):
                s = min(s, tmp[i+1]-tmp[i])
            ans = max(ans, s)
    print(ans)
### BUGGY CODE ###

N,M=map(int,input().split())
path=[[0 if i==j or i==max(j-1,0) else float("inf") for i in range(N)] for j in range(N)]
for _ in range(M):
  l,r,c=map(int,input().split())
  path[l-1][r-1]=c

seen=[]
dist=[float("inf")]*N
dist[0]=0
v=-1
while v!=N-1:
  v=-1
  for i in range(N):
    if i not in seen and v==-1:
      v=i
    if i not in seen and dist[i]<dist[v]:
      v=i
  seen.append(v)
  for i in range(N):
    dist[i]=min(dist[v]+path[v][i],dist[i])
    
if dist[N-1]==float("inf"):
  print(-1)
else:
  print(dist[N-1])


### FIXED CODE ###

import heapq
N,M=map(int,input().split())
path=[[] for _ in range(N)]
for _ in range(M):
  l,r,c=map(int,input().split())
  path[l-1].append([r,c])
for i in range(1,N):
  path[i].append([i,0])

dist=[float("inf")]*N
dist[0]=0
q=[[dist[i],i] for i in range(N)]
heapq.heapify(q)

while q:
  d,ind=heapq.heappop(q)
  if d<=dist[ind]:
    for i in range(len(path[ind])):
      r,c=path[ind][i]
      if dist[r-1]>d+c:
        dist[r-1]=d+c
        heapq.heappush(q,[dist[r-1],r-1])

if dist[N-1]==float("inf"):
  print(-1)
else:
  print(dist[N-1])
### BUGGY CODE ###

mod = 10**9+7

N,M = [int(x) for x in input().split()]
a = [int(input()) for _ in range(M)]
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(N+1):
    if(i in a):
        continue
    if(i<N-1):
        if(i+2 not in a):
            dp[i+2]+=dp[i]
    if(i<N):
        if(i+1 not in a):
            dp[i+1]+=dp[i]
print(dp[-1]%mod)


### FIXED CODE ###

mod = 10**9+7
import sys
sys.setrecursionlimit(10000000)

N,M = [int(x) for x in input().split()]
a = [int(input()) for _ in range(M)]
di = {}
for i in a:
    di[i]=1
dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(N+1):
    if(i in di):
        continue
    if(i<N-1):
        if(i+2 not in di):
            dp[i+2]+=dp[i]
            dp[i+2]%=mod
    if(i<N):
        if(i+1 not in di):
            dp[i+1]+=dp[i]
            dp[i+1]%=mod
print(dp[N])
### BUGGY CODE ###

rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

from collections import deque
def solve(N, A):
    ans = 0
    todo = N * (N-1)
    to_inspect = range(N)
    while True:
        ans += 1
        found = False
        pairings = [None] * N
        to_inspect2 = set()
        for i in to_inspect:
            row = A[i]
            if row:
                j = row[0]
                if pairings[i] == pairings[j] == None and A[j] and A[j][0] == i:
                    pairings[i] = j
                    pairings[j] = i
                    row.popleft()
                    A[j].popleft()
                    found = True
                    todo -= 2
                    to_inspect2.add(i)
                    to_inspect2.add(j)
        if not todo: return ans
        if not found: return -1
        to_inspect = to_inspect2
    
        
                
        

N = rri()
A = []
for _ in xrange(N):
    row = rrm()
    A.append(deque(x-1 for x in row))
print solve(N, A)


### FIXED CODE ###

rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

from collections import deque
def solve(N, A):
    ans = 0
    todo = N * (N-1)
    to_inspect = range(N)
    while True:
        ans += 1
        found = False
        to_inspect2 = set()
        for i in to_inspect:
            row = A[i]
            if row:
                j = row[0]
                if (i not in to_inspect2 and j not in to_inspect2 and
                        A[j] and A[j][0] == i):
                    row.popleft()
                    A[j].popleft()
                    found = True
                    todo -= 2
                    to_inspect2.add(i)
                    to_inspect2.add(j)
        if not todo: return ans
        if not found: return -1
        to_inspect = to_inspect2


N = rri()
A = []
for _ in xrange(N):
    row = rrm()
    A.append(deque(x-1 for x in row))
print solve(N, A)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,K = map(int,input().split())
h = [0] + list(map(int,input().split()))

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

for i in range(2,N+1):
    scope = min(i-1,K)
    jump = [dp[i-x] + abs(h[i]-h[i-x]) for x in range(1,scope+1)]
    dp[i] = min(jump)
    
print(dp[N])

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
N,K = map(int,input().split())
h = [0] + list(map(int,input().split()))
 
dp = [None for _ in range(N+1)]
dp[1] = 0
 
for i in range(2,N+1):
    scope = min(i-1,K)
    jump = [dp[i-x] + abs(h[i]-h[i-x]) for x in range(1,scope+1)]
    dp[i] = min(jump)
    
print(dp[N])
### BUGGY CODE ###

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

def main():
    def _create_trio(_list):
        ret = []
        ret.append(_list.pop())
        ret.append(_list.pop())
        ret.append(_list.pop(0))
        return ret

    n = int(raw_input())
    a = map(int,raw_input().split())

    if n <= 0 or n > 10 ** 5:
        return
    for i in a:
        if i <= 0 or i > 10 ** 9:
            return

    a.sort()
    trio_sum = 0

    for i in range(n):
        trio_sum += _create_trio(a)[1]

    return trio_sum

print main()


### FIXED CODE ###

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

def main():

    n = int(raw_input())
    a = map(int,raw_input().split())

    if n <= 0 or n > 10 ** 5:
        return
    for i in a:
        if i <= 0 or i > 10 ** 9:
            return

    a.sort(reverse=True)
    trio_sum = 0

    for i in range(n):
        index = (i * 2) + 1
        trio_sum += a[index]

    return trio_sum

print main()
### BUGGY CODE ###

N=int(input())
P=list(map(float,input().split()))
C=[[0.00]*(N+1) for i in range(N+1)]
C[0][0]=1.00
for i in range(1,N+1):
    for j in range(0,i+1):
        """
        #print(i-1)
        print(P[i-1])
        print(C[i-1][j-1])
        print(C[i-1][j-1]*P[i-1])
        """
        C[i][j]=float(C[i-1][j-1]*P[i-1])+float(C[i-1][j]*(1-P[i-1]))
        #print(C[i][j])
ans=float(0.00)
for i in range((N-1)//2+1):
    ans+=C[N][i]
ans=float(1.00-ans)
print(ans)


### FIXED CODE ###

N=int(input())
P=list(map(float,input().split()))
C=[[0.00]*(N+1) for i in range(N+1)]
C[0][0]=1.00
for i in range(1,N+1):
    for j in range(0,i+1):
        """
        #print(i-1)
        print(P[i-1])
        print(C[i-1][j-1])
        print(C[i-1][j-1]*P[i-1])
        """
        C[i][j]=float(C[i-1][j-1]*P[i-1])+float(C[i-1][j]*(1-P[i-1]))
        #print(C[i][j])
ans=float(0.00)
for i in range((N-1)//2+1):
    ans+=C[N][i]
ans=float(1.00-ans)
print(ans)
### BUGGY CODE ###

n,m = map(int,input().split( ))
ans = ""
ls_a = []
ls_b = [[] for i in range(n)]
for i in range(m):
    p,y = map(int,input().split( ))
    ls_a.append([p,y])
    ls_b[p-1].append(y)
for i in range(n):
    if len(ls_b[i]) !=0:
        ls_b[i].sort()
for i in range(m):
    ans += str(ls_a[i][0]).zfill(6) + str(ls_b[ls_a[i][0]-1].index(ls_a[i][1])+1).zfill(6)+"\n"
print(ans)

### FIXED CODE ###

N,M=map(int,input().split())
PY=[list(map(int,input().split()))+[i] for i in range(M)] #定義終了
 
PY.sort(key= lambda x:x[1])
num=[0]*N
w=[""]*M
 
for p,y,i in PY:
	num[p-1]+=1
	w[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for i in range(M):
  	print(w[i])
### BUGGY CODE ###

s = str(input())
t= str(input())

sdict = {}
for i in range(len(s)):
    if s[i] not in sdict:
        sdict[s[i]]=[]
    sdict[s[i]].append(i+1)
    
#print(sdict)

ans = 0
mark = 0
for _ in range(len(t)):
    target = t[_]
    if target not in sdict:
        ans = -1
        break
    else:
        for j in range(len(sdict[target])):
            if sdict[target][j]>mark:
                mark = sdict[target][j]
                break
            if j == len(sdict[target])-1:
                mark = sdict[target][0]
                ans += len(s)
                break
        
if ans != -1:
    ans += mark
print(ans)

### FIXED CODE ###

s = str(input())
t= str(input())

sdict = {}
for i in range(len(s)):
    if s[i] not in sdict:
        sdict[s[i]]=[]
    sdict[s[i]].append(i+1)
    
#print(sdict)

#二分木探索
def search(list_,mark_,sta,gol):
    if  sta == gol:
            return list_[sta]
    else:
            mid = (gol+sta)//2
            if list_[mid]>mark_:
                return search(list_,mark_,sta,mid)
            else:
                return search(list_,mark_,mid+1,gol)

ans = 0
mark = 0
for _ in range(len(t)):
    target = t[_]
    if target not in sdict:
        ans = -1
        break
    else:
        if sdict[target][-1]<=mark:
            mark = sdict[target][0]
            ans += len(s)
        elif sdict[target][0]>mark:
            mark = sdict[target][0]
        else:
            posi = search(sdict[target],mark,0,len(sdict[target])-1)
            mark = posi
        
if ans != -1:
    ans += mark
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

H,W,K=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
MAP=[list(input().strip()) for i in range(H)]

for i in range(H):
    for j in range(W):
        if MAP[i][j]==".":
            MAP[i][j]=1<<30
        else:
            MAP[i][j]=-1

Q=[]
Q.append((x1-1,y1-1))
MAP[x1-1][y1-1]=0

while Q:
    x,y=Q.pop()

    for i in range(1,K+1):
        if 0<=x+i<H and 0<=y<W and (MAP[x+i][y]==1<<30 or MAP[x+i][y]>MAP[x][y]):
            MAP[x+i][y]=MAP[x][y]+1
            Q.append((x+i,y))
        else:
            break

    for i in range(1,K+1):
        if 0<=x-i<H and 0<=y<W and (MAP[x-i][y]==1<<30 or MAP[x-i][y]>MAP[x][y]):
            MAP[x-i][y]=MAP[x][y]+1
            Q.append((x-i,y))
        else:
            break

    for i in range(1,K+1):
        if 0<=x<H and 0<=y+i<W and (MAP[x][y+i]==1<<30 or MAP[x][y+i]>MAP[x][y]):
            MAP[x][y+i]=MAP[x][y]+1
            Q.append((x,y+i))
        else:
            break

    for i in range(1,K+1):
        if 0<=x<H and 0<=y-i<W and (MAP[x][y-i]==1<<30 or MAP[x][y-i]>MAP[x][y]):
            MAP[x][y-i]=MAP[x][y]+1
            Q.append((x,y-i))
        else:
            break
if MAP[x2-1][y2-1]==1<<30:
    print(-1)
else:
    print(MAP[x2-1][y2-1])


### FIXED CODE ###

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

H,W,K=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
MAP=[list(input().strip()) for i in range(H)]

for i in range(H):
    for j in range(W):
        if MAP[i][j]==".":
            MAP[i][j]=1<<30
        else:
            MAP[i][j]=-1

Q=deque()
Q.append((x1-1,y1-1))
MAP[x1-1][y1-1]=0

while Q:
    x,y=Q.pop()

    for i in range(1,K+1):
        if 0<=x+i<H and 0<=y<W and (MAP[x+i][y]==1<<30 or MAP[x+i][y]>MAP[x][y]):
            if MAP[x+i][y]==1<<30:
                MAP[x+i][y]=MAP[x][y]+1
                Q.appendleft((x+i,y))
        else:
            break

    for i in range(1,K+1):
        if 0<=x-i<H and 0<=y<W and (MAP[x-i][y]==1<<30 or MAP[x-i][y]>MAP[x][y]):
            if MAP[x-i][y]==1<<30:
                MAP[x-i][y]=MAP[x][y]+1
                Q.appendleft((x-i,y))
        else:
            break

    for i in range(1,K+1):
        if 0<=x<H and 0<=y+i<W and (MAP[x][y+i]==1<<30 or MAP[x][y+i]>MAP[x][y]):
            if MAP[x][y+i]==1<<30:
                MAP[x][y+i]=MAP[x][y]+1
                Q.appendleft((x,y+i))
        else:
            break

    for i in range(1,K+1):
        if 0<=x<H and 0<=y-i<W and (MAP[x][y-i]==1<<30 or MAP[x][y-i]>MAP[x][y]):
            if MAP[x][y-i]==1<<30:
                MAP[x][y-i]=MAP[x][y]+1
                Q.appendleft((x,y-i))
        else:
            break
if MAP[x2-1][y2-1]==1<<30:
    print(-1)
else:
    print(MAP[x2-1][y2-1])
### BUGGY CODE ###

# D - Knapsack 1
from collections import defaultdict


def main():
    N, W, *WV = map(int, open(0).read().split())
    dp = defaultdict(int)
    dp[0] = 0
    for w, v in zip(*[iter(WV)] * 2):
        for cur_w, cur_v in tuple(dp.items()):
            if w + cur_w <= W:
                dp[w + cur_w] = max(dp[w + cur_w], v + cur_v)
    print(max(dp.values()))


if __name__ == "__main__":
    main()


### FIXED CODE ###

# EduDPD - Knapsack 1
import sys
input = sys.stdin.readline

n, w = list(map(int, input().rstrip().split()))
arr = [tuple(map(int, input().rstrip().split())) for _ in range(n)]
dp = [0] * (w + 1)
for i in range(n):
    for j in range(w, arr[i][0] - 1, -1):
        dp[j] = max(dp[j], dp[j - arr[i][0]] + arr[i][1])
print(max(dp))
### BUGGY CODE ###

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

print( (max(sum(P[i:i+K]) for i in range(0, N-K+1)) + K)/2 )


### FIXED CODE ###

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

# print( (max(sum(P[i:i+K]) for i in range(0, N-K+1)) + K)/2 )

tmp = sum(P[0:K])
result = tmp

for i in range(1, N-K+1):
    tmp += (P[i+K-1] - P[i-1])
    if (tmp > result):
        result = tmp

print((result+K)/2)
### BUGGY CODE ###

n = int(input())
A = list(map(int,input().split()))
ans = 0
for  i,a in enumerate(A):
    for j,b in enumerate(A[i+1:]):
        ans += (abs(j+1)==a+b)
print(ans)


### FIXED CODE ###

import numpy as np
import collections
n = int(input())
A = np.array(list(map(int,input().split())))
B = np.array([i+1 for i in range(n)])
C,D = A+B,B-A
ans = 0

c = collections.Counter(C)
d = collections.Counter(D)
ans = 0
for i in c.keys():
    ans += c[i]*d[i]
print(ans)
### BUGGY CODE ###

H, W = map(int, input().split())
INF = 10**9
sheet = []
score = [[INF]*W for i in range(H)]
step = [(-1,0),(1,0),(0,-1),(0,1)]
stuck = []
ans = -1

for i in range(H):
  line = input()
  for j in range(W):
    if line[j]=='#':
      stuck += [(i,j,0)]
      score[i][j] = 0
      
while stuck:
  y, x, m = stuck.pop()
  for s in step:
    dx, dy = s
    if x+dx<0 or x+dx>W-1 or y+dy<0 or y+dy>H-1:
      continue
    if score[y+dy][x+dx]>m+1:
      score[y+dy][x+dx]=m+1
      stuck += [(y+dy, x+dx, m+1)]
      
for i in range(H):
  ans = max(ans, *score[i])
  
print(ans)

### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
INF = 10**9
sheet = []
log = [[True]*W for i in range(H)]
step = [(-1,0),(1,0),(0,-1),(0,1)]
stuck = deque()
ans = 0

for i in range(H):
  line = input()
  for j in range(W):
    if line[j]=='#':
      stuck += [(i,j,0)]
      log[i][j] = False
      
while stuck:
  y, x, m = stuck.popleft()
  for s in step:
    dx, dy = s
    if x+dx<0 or x+dx>W-1 or y+dy<0 or y+dy>H-1:
      continue
    if log[y+dy][x+dx]:
      log[y+dy][x+dx]=False
      stuck += [(y+dy, x+dx, m+1)]
      if ans<m+1:
        ans = m+1
      
print(ans)
### BUGGY CODE ###

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

A = []
B = []

for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        A.append(b)
    elif b == N:
        B.append(a)

ans = 'IMPOSSIBLE'
for a in A:
    if a in B:
        ans = 'POSSIBLE'
        break
print(ans)

### FIXED CODE ###

N, M = list(map(int, input().split()))
A = [0 for i in range(200000+1)]
B = [0 for i in range(200000+1)]
ans = 'IMPOSSIBLE'

for i in range(M):
    a, b = list(map(int, input().split()))
    if a == 1:
        A[b] = 1
        if A[b] and B[b]:
            ans = 'POSSIBLE'
            break
    elif b == N:
        B[a] = 1
        if A[a] and B[a]:
            ans = 'POSSIBLE'
            break
print(ans)
### BUGGY CODE ###

n = int(input())
aa = [0]*n
bb = [0]*n
for i in range(n):
    aa[i],bb[i] = map(int, input().split())
ans = 0
for i in range(1,n+1):
    cnt = 0
    if aa[-i] % bb[-i] > 0:
        cnt = ((aa[-i] - 1) // bb[-i] +1) * bb[-i] - aa[-i]
        # print(aa[-i], bb[-i], cnt, aa)
        ans += cnt
        aa = list(map(lambda x: x + cnt, aa))
    
print(ans)

### FIXED CODE ###

n = int(input())
aa = [0]*n
bb = [0]*n
for i in range(n):
    aa[i],bb[i] = map(int, input().split())
ans = 0
for i in range(1,n+1):
    cnt = 0
    cur = aa[-i] + ans
    if cur % bb[-i] > 0:
        cnt = ((cur - 1) // bb[-i] +1) * bb[-i] - cur
        # print(cur, bb[-i], cnt, aa)
        ans += cnt
    
print(ans)
### BUGGY CODE ###

import fractions
k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for l in range(1,k+1):
      a=fractions.gcd(i,j)
      a=fractions.gcd(a,l)
      ans+=a
print(ans)

### FIXED CODE ###

import math
k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    b=math.gcd(i,j)
    for l in range(1,k+1):
      a=math.gcd(b,l)
      ans+=a
print(ans)
### BUGGY CODE ###

import collections
n = int(input())

s = []
C = []
for i in range(n):                                                                                                                                                                                          
    a = input()                                                                                                                                                                                             
    b = str(a)                                                                                                                                                                                              
    d = sorted(b)                                                                                                                                                                                           
    s.append(d)                                                                                                                                                                                             
    # c = collections.Counter(s[i])                                                                                                                                                                         
    # C.append(c)                                                                                                                                                                                           

count = 0
for j in range(n-1):                                                                                                                                                                                        
    for k in range(j+1, n):                                                                                                                                                                                 
        # if C[j].items() == C[k].items():                                                                                                                                                                  
        if s[j] == s[k]:                                                                                                                                                                                    
            count += 1                                                                                                                                                                                      

print(count)


### FIXED CODE ###

N = int(input())
ana = {}
answer = 0

for i in range(N):
    s = sorted(input())
    new_str = ''.join(s)
    flag = 0

    if new_str in ana.keys():
        ana[new_str] += 1
        answer += ana[new_str]
        flag = 1

    if flag == 0:
        ana[new_str] = 0

print(answer)