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

N = int(input())
S = [input() for _ in range(0, N)]
t = {}
for i in range(0, N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
max_k_list = [kv[0] for kv in t.items() if kv[1] == max(t.values())]
max_k_list.sort()
ans = "\n".join(max_k_list)
print(ans)

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(0, N)]
t = {}
for i in range(0, N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
vmax = max(t.values())
ans = []
for key in t.keys():
    if t[key] == vmax:
        ans.append(key)
ans.sort()
for i in ans:
    print (i)
### BUGGY CODE ###

import numpy as np
N_baito,M_days = map(int,input().split())
hosyuList = [[] for _ in range(M_days)]

for _ in range(N_baito):
    days,hosyu = map(int,input().split())
    if days <= M_days:
        hosyuList[days-1].append(hosyu)
        
workList = []
hosyu = 0
for day in range(M_days):
    workList.extend(hosyuList[day])
    workList.sort(reverse=True)
    if workList:
        hosyu += workList[0]
        del workList[0]
print(hosyu)


### FIXED CODE ###

import heapq
N_baito,M_days = map(int,input().split())
hosyuList = [[] for _ in range(M_days)]

for _ in range(N_baito):
    days,hosyu = map(int,input().split())
    if days <= M_days:
        hosyuList[days-1].append(hosyu)

workList = []
hosyu = 0
for day in range(M_days):
    for baito in hosyuList[day]:
        heapq.heappush(workList,-1*baito)
    if workList:
        hosyu += heapq.heappop(workList)
print(-1*hosyu)
### BUGGY CODE ###

def solve(memo, left, right):
    count = 0
    for num in memo:
        if left <= num <= right:
            count += 1
    return count


def main():
    length, questions = map(int, input().split())
    string = input()

    memo = []
    for key in range(length - 1):
        if string[key:key+2] == "AC":
            memo.append(key + 1)

    for question in range(questions):
        left, right = map(int, input().split())
        right -= 1
        ans = solve(memo, left, right)
        print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import bisect


def solve(memo, left, right):
    left_key = bisect.bisect_left(memo, left)
    right_key = bisect.bisect_right(memo, right)
    return right_key - left_key


def main():
    length, questions = map(int, input().split())
    string = input()

    memo = []
    for key in range(length - 1):
        if string[key:key+2] == "AC":
            memo.append(key + 1)

    for question in range(questions):
        left, right = map(int, input().split())
        right -= 1
        ans = solve(memo, left, right)
        print(ans)


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

def main():
    H,W = map(int, input().split())
    S = [input() for _ in range(H)]


    U = [[0 for _ in range(W)] for _ in range(H)]
    D = [[0 for _ in range(W)] for _ in range(H)]
    L = [[0 for _ in range(W)] for _ in range(H)]
    R = [[0 for _ in range(W)] for _ in range(H)]

    #L,U
    for i in range(H):
        for j in range(W):
            if S[i][j] != "#":
                if j == 0:
                    L[i][j] = 1
                else:
                    L[i][j] = L[i][j-1] + 1
            
                if i == 0:
                    U[i][j] = 1
                else:
                    U[i][j] = U[i-1][j] + 1

    #R,D
    for i in reversed(range(H)):
        for j in reversed(range(W)):
            if S[i][j] != "#":
                if j == W-1:
                    R[i][j] = 1
                else:
                    R[i][j] = R[i][j+1] + 1
            
                if i == H-1:
                    D[i][j] = 1
                else:
                    D[i][j] = D[i+1][j] + 1

        
    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == "#":
                continue

            tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
            ans = max(ans, tmp)

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

h,w = map(int, input().split())

grid = [input() for i in range(h)]

L = [[0 for i in range(w)] for j in range(h)]
R = [[0 for i in range(w)] for j in range(h)]
D = [[0 for i in range(w)] for j in range(h)]
U = [[0 for i in range(w)] for j in range(h)]

#左上から
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            L[i][j] = 0
            U[i][j] = 0
        else:
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
            
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

#右下から
for i in reversed(range(h)):
    for j in reversed(range(w)):
        if grid[i][j] == "#":
            R[i][j] = 0
            D[i][j] = 0
        else:
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1
                
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1


ans = 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == "#":
            continue
        tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, tmp)

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

s = input()
K = int(input())
l = []
if len(s) == 1:
    print(s)
    exit()
for i in range(len(s)):
    for j in range(i, len(s)):
        d = s[i:j+1]
        l.append(d)
l = list(set(l))
l.sort()
print(l[K-1])

### FIXED CODE ###

s = input()
K = int(input())
l = []
if len(s) == 1:
    print(s)
    exit()
for i in range(len(s)):
    for j in range(i, len(s)):
        d = s[i:j+1]
        l.append(d)
        if len(d) >= K:
            break
l = list(set(l))
l.sort()
print(l[K-1])
### BUGGY CODE ###

N, M = map(int, input().split())
from  bisect import bisect_right
inf = float("inf")
A = sorted(list(map(int, input().split())))
BC = sorted([tuple(map(int, input().split())) for _ in range(M)], key=lambda x: -x[1])
ans = 0
cnt = 0
for b, c in BC:
    idx = bisect_right(A, c)
    if idx == 0:
        ans += sum(A)
        break
    if idx >= b:
        ans += sum(A[idx:]) + b*c
        A = A[b:idx]
    elif idx < b:
        ans += sum(A[idx:]) + c*idx
        break
    cnt += 1
    if cnt == M:
        ans += sum(A)

print(ans)



### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
P = [(A[i], 1) for i in range(N)]
for j in range(M):
    B, C = map(int, input().split())
    P.append((C, B))
P.sort(reverse=True)
ans, cnt = 0, N
for v, c in P:
    use = min(c, cnt)
    ans += use*v
    cnt -= use
print(ans)
### BUGGY CODE ###

n = int(input())
g = {}
for i in range(1,n+1):
    g[i] = []
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a].append([b,c])
    g[b].append([a,c])
Q,k = map(int,input().split())
q = [list(map(int,input().split())) for _ in range(Q)]
from collections import deque
queue = deque(g[k])
shortest = [0]*(n+1)
while queue:
    a,c = queue.pop()
    shortest[a] = c
    for v in g[a]:
        if shortest[v[0]]==0:
            queue.appendleft([v[0],v[1]+c])
for x,y in q:
    print(shortest[x]+shortest[y])

### FIXED CODE ###

n = int(input())
g = {}
from collections import deque
for i in range(1,n+1):
    g[i] = deque([])
for _ in range(n-1):
    a,b,c = map(int,input().split())
    g[a].appendleft([b,c])
    g[b].appendleft([a,c])
Q,k = map(int,input().split())
q = [list(map(int,input().split())) for _ in range(Q)]
queue = deque(g[k])
shortest = [0]*(n+1)
while queue:
    a,c = queue.pop()
    shortest[a] = c
    while g[a]:
        v = g[a].pop()
        if shortest[v[0]]==0:
            queue.appendleft([v[0],v[1]+c])
for x,y in q:
    print(shortest[x]+shortest[y])
### BUGGY CODE ###

def Warshall_Floyd(edges,N):
  """頂点N個のグラフ上の隣接行列edges(空欄はinfとせよ)が与えられたとき, 
  2点間の最短距離距離を隣接行列で返す"""
  for k, i, j in itertools.product(range(N), range(N),range(N)):
    if edges[i][j]>edges[i][k]+edges[k][j]: return 1
  return 0
 
import sys
import itertools
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if Warshall_Floyd(A,N):
  print(-1)
  sys.exit()
 
ans=0
for i, j in itertools.product(range(N),range(N)):
  need=1
  for k in range(N):
    if k!=i and k!=j and A[i][j]==A[i][k]+A[k][j]:
      need=0
      break
  if need:ans+=A[i][j]
print(ans//2)

### FIXED CODE ###

def Warshall_Floyd(edges,N):
  """頂点N個のグラフ上の隣接行列edges(空欄はinfとせよ)が与えられたとき, 
  2点間の最短距離距離を隣接行列で返す"""
  for k, i, j in itertools.product(range(N), range(N),range(N)):
    if edges[i][j]>edges[i][k]+edges[k][j]: return 1
  return 0
 
import sys
import itertools
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
if Warshall_Floyd(A,N):
  print(-1)
  sys.exit()
 
ans=0
for i, j in itertools.product(range(N),range(N)):
  need=1
  for k in range(N):
    if k!=i and k!=j and A[i][j]==A[i][k]+A[k][j]:
      need=0
      break
  if need:ans+=A[i][j]
print(ans//2)
### BUGGY CODE ###

import copy

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

def median_cal(data):
    num = len(data)
    # データを昇順ソート
    data.sort()
    # データ数が偶数の場合
    median = int((num + 1) / 2 - 1)
    median = data[median]
    return median
  
for i in range(n):
  list1 = copy.copy(x)
  list1.pop(i)
  print(median_cal(list1))

### FIXED CODE ###

import copy

n = int(input())
x = list(map(int, input().split()))
num = 0

y = copy.copy(x)
x.sort()
num1 = x[n//2-1]
num2 = x[n//2]

for i in y:
  if i <= num1:
    print(num2)
  else:
    print(num1)
### BUGGY CODE ###

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

ans = 0
for i in range(n-2):
    s_i = s[i]
    for j in range(i+1, n-1):
        if s[j] == s_i: continue
        s_j = s[j]
        j_i = j-i
        for k in range(j+1, n):
            if k-j == j_i: continue
            if s[k] != s_i and s[k] != s_j:
                ans += 1

print(ans)

### FIXED CODE ###

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

num_r, num_g, num_b = 0, 0, 0
for i in range(n):
    if s[i] == 'R': num_r += 1
    elif s[i] == 'G': num_g += 1
    else: num_b += 1

hiku = 0
for i in range(n-2):
    s_i = s[i]
    for j in range(i+1, n-1):
        if s[j] == s_i: continue
        s_j = s[j]
        j_i = j-i
        if j+j_i < n:
            miru = s[j+j_i]
            if miru != s_i and miru != s_j:
                hiku += 1
        else:
            break

print(num_r*num_g*num_b-hiku)
### BUGGY CODE ###

def make_divisors(n):
  divisors = [n]
  for i in range(1, n//2+1):
    if n % i == 0:
      divisors.append(i)
  divisors.sort()
  return divisors


A, B = map(int, input().split())
divided_1 = min(A, B)
divided_2 = max(A, B)

divisors = make_divisors(divided_1)
cd = []
for d in divisors:
  if divided_2 % d == 0:
    cd.append(d)

res = []
for e in cd:
  flg = True
  for i in range(1, len(res)):
    r = res[i]
    if e % r == 0:
      flg = False
      break
  if flg:
    res.append(e)

print(len(res))

### FIXED CODE ###

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)

    divisors.sort()
    return divisors


A, B = map(int, input().split())
divided_1 = min(A, B)
divided_2 = max(A, B)

divisors = make_divisors(divided_1)
cd = []
for d in divisors:
  if divided_2 % d == 0:
    cd.append(d)

res = []
for e in cd:
  flg = True
  for i in range(1, len(res)):
    r = res[i]
    if e % r == 0:
      flg = False
      break
  if flg:
    res.append(e)

print(len(res))
### BUGGY CODE ###

N,K,Q = input().split()
N = int(N)
K = int(K)
Q = int(Q)

N_point = []

A = []
for i in range(Q):
  A.append(int(input()))

for i in range(N):
  N_point.append(K)

def calc_hiku(n):
    return n - 1

for i in A:
  N_point = list(map(calc_hiku, N_point))
  N_point[i-1] = int(N_point[i-1]) + 1

for num in N_point:
  if num > 0:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

N,K,Q = input().split()
N = int(N)
K = int(K)
Q = int(Q)

N_point = []

A = []
for i in range(Q):
  A.append(int(input()))

for i in range(N):
  N_point.append(K)

def calc_hiku(n):
    return n - Q

for i in A:
  #N_point = list(map(calc_hiku, N_point))
  N_point[i-1] = int(N_point[i-1]) + 1

N_point = list(map(calc_hiku, N_point))
#N_point_w = list(map(lambda x: x - K, N_point))

for num in N_point:
  if num > 0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

N, K = map(int, input().split())
l = []
Ap = 1
An = 1
i = 0
for x in input().split():
    A = int(x)
    l.append(A)
    if i < K:
        Ap = Ap * A
    else:
        An = Ap / l.pop(0) * A
        if An > Ap:
            print("Yes")
        else:
            print("No")
        Ap = An
    i = i + 1


### FIXED CODE ###

N, K = map(int, input().split())
l = []
i = 0
for x in input().split():
    A = int(x)
    if K < N - i:
        l.insert(0, A)
    if i >= K:
        if l.pop() < A:
            print("Yes")
        else:
            print("No")
    i = i + 1
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

n, m = map(int, readline().split())
g = [[] * n for i in range(n)]
for i in range(m):
    u, v = map(int,readline().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)
    
q = int(readline())
chk = []
for i in range(q):
  V,D,C = map(int,readline().split())
  chk.append((V,D,C))
  
from collections import deque
ans = [0]*n

def bfs(s,col,d):
  global cnt
  que = deque()
  que.append((s,1,col))
  if ans[s] == 0:
    ans[s] = col
    cnt += 1
  while que:
      now,p,col = que.popleft()
      if cnt == n:
        break
      for i in g[now]:
          if p <= d and ans[i] == 0:
            ans[i] = col
            cnt += 1
          if p < d:
            que.append((i,p+1,col))

cnt = 0
for i in chk[::-1]:
  vv,d,cc = i
  bfs(vv-1,cc,d)
  if cnt == n:
    break
    
print(*ans, sep='\n')

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(4100000)
  
n,m = map(int, readline().split())
g = [[]*n for i in range(n)]
for i in range(m):
    u,v = map(int,readline().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)
    
q = int(readline())
chk = []
for i in range(q):
  V,D,C = map(int,readline().split())
  chk.append((V,D,C))
  

memo = [[0]*11 for _ in range(n)]

def f(v,d,c):
  if memo[v][d] != 0:
    return
  else:
    memo[v][d] = c
    if d > 0:
      f(v,d-1,c)
      for nxt in g[v]:
        f(nxt,d-1,c)
    else:
      return

for V,D,C in chk[::-1]:
    f(V-1,D,C)

for v in range(n):
    print(memo[v][0])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
count = 1
 
for A in a:
  count = count * A
  
if count > 10**18:
  print('-1')
else:
  print(count)

### FIXED CODE ###

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

n = int(input())
place = [tuple(map(int, input().split())) for _ in range(n)]
m = 0
for x, y in place:
    m = max(m, abs(x)+abs(y))
for x, y in place:
    if (m - abs(x) - abs(y)) % 2 == 1:
        print(-1)
        exit()
print(m)
for _ in range(m):
    print(1, end = ' ')
print()
for x, y in place:
    l = max(0,-x)
    r = max(0,x)
    u = max(0,y)
    d = max(0,-y)
    diff = m - max(l,r) - max(u,d)
    print('L'*l + 'R'*r + 'U'*u + 'D'*d + 'LR' * (diff//2))


### FIXED CODE ###

n = int(input())
place = [tuple(map(int, input().split())) for _ in range(n)]
m = 0
def bitlist(x):
    ret = [0] * 31
    for i in reversed(range(31)):
        if x > 0:
            x -= 1 << i
            ret[i] = 1
        else:
            x += 1 << i
            ret[i] = -1
    return ret
pre = (place[0][0] + place[0][1] + 1) % 2
for x, y in place:
    if (x + y + 1) % 2 != pre:
        print(-1)
        exit()
print(31 + pre)
if pre:
    print(1, end = ' ')
for i in reversed(range(31)):
    print(1 << i, end = ' ')
print()
for x, y in place:
    u = x + y
    v = x - y
    if pre:
        u -= 1
        v -= 1
    ubit = bitlist(u)
    vbit = bitlist(v)
    if pre:
        print('R', end = '')
    for i in reversed(range(31)):
        if ubit[i] == 1 and vbit[i] == 1:
            print('R', end = '')
        elif ubit[i] == 1 and vbit[i] == -1:
            print('U', end = '')
        elif ubit[i] == -1 and vbit[i] == -1:
            print('L', end = '')
        else:
            print('D', end = '')
    print()
### BUGGY CODE ###

def make_divisors(N):
    ans=dict()
    div_sum=1
    n=N
    i=2
    while i*i <=N:
    	while n%i==0:
    		n=n//i
    		if i in ans:
    			ans[i]+=1
    		else:
    			ans[i]=1
    	i+=1
    if n!=1:
    	ans[n]=1

    ans_list=list(ans.items())
    for j in ans_list:
    	div_sum*=j[1]+1
    return div_sum

N = int(input())
ans = 0
for i in range(1, N):
    wa = N - i
    ans += make_divisors(wa)
print(ans)

### FIXED CODE ###

import math
N = int(input())
count = 0
for i in range(1, N):
    if i == 1:
        count += N - 1
        continue
    if N % i == 0:
        count += N / i -1
    elif N % i >= 1:
        count += math.floor(N / i)
print(int(count))
### BUGGY CODE ###


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()

ans = 0

for c in C:

    for b in B:

        if b >= c:
            break

        for a in A:

            if a >= b:
                break

            else:

                ans += 1

print (ans)


### FIXED CODE ###


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()

A.append(10 ** 9 + 2)

ap = 0

Bnum = []

ans = 0

for i in range(N):

    b = B[i]

    while True:

        if A[ap] < b:

            ap += 1

        else:

            break

    if i == 0:
        Bnum.append(ap)

    else:
        Bnum.append(ap + Bnum[-1])

bp = 0
B.append(10 ** 9 + 2)

for i in range(N):

    c = C[i]

    while True:

        if B[bp] < c:

            bp += 1

        else:

            break

    if bp != 0:
        ans += Bnum[bp-1]

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

N, K = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
cnt = [A.count(a) for a in set(A)]
cnt.sort()
vrt = len(cnt)
print(sum(cnt[:vrt-K]) if vrt > K else 0)

### FIXED CODE ###

import bisect as bs
N, K = (int(x) for x in input().split())
A = sorted([int(x) for x in input().split()])
f = lambda X, x: bs.bisect_right(X,x)-bs.bisect_left(X,x)
cnt = sorted([f(A,a) for a in set(A)],reverse=True)
vrt = len(cnt)
print(sum(cnt[K:]) if vrt > K else 0)
### BUGGY CODE ###

x, y = map(int,input().split())
p = list(map(int,input().split()))
ans = 0

for i in range(x-y+1):
    z = (sum(p[i:i+y])+y)/2
    if z > ans:
        ans = z

print(ans)

### FIXED CODE ###

x, y = map(int,input().split())
p = list(map(int,input().split()))
ans = 0

for i in range(x-y+1):
    if i == 0:
        z = sum(p[:y])
    else:
        z = z - n + p[i+y-1]
    n = p[i]
    if z > ans:
        ans = z

print((ans+y)/2)
### BUGGY CODE ###

import itertools
N,K = map(int,input().split())
H = []
for i in range(N):
	h = int(input())
	H.append(h)

kumiawase = list(itertools.combinations(H,K))
Kouhos = []
for ks in kumiawase:
	max_h = max(ks)
	min_h = min(ks)

	kouho = max_h - min_h
	Kouhos.append(kouho)

print(min(Kouhos))

### FIXED CODE ###

import itertools
N,K = map(int,input().split())
H = []
for i in range(N):
	h = int(input())
	H.append(h)
H.sort()

ans = 100000000000000000000000000000
for i in range(N-K+1):
	if(ans>H[i+K-1]-H[i]):
		ans = int(H[i+K-1]-H[i])

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

N = int(input())
S = list(input())
ans = 0
for i in range(1000):
  if i<10:
    cnt0= 0
    cnt1 = 0
    for j in range(N):
      if 2<=cnt0 and S[j]=="%d"%i:
        ans+=1
        break
      if S[j]=="0":
        cnt0+=1
        continue
  elif 10<=i<=99:
    cnt0=0
    cnt1=0
    cnt2=0
    i = list(str(i))
    for j in range(N):
      if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
        ans+=1
        break
      if S[j]=="0" and cnt0!=1:
        cnt0+=1
        continue
      if 1<=cnt0 and S[j]=="%s"%i[0]:
        cnt1 +=1
        continue
  elif 100<=i:
    cnt0=0
    cnt1=0
    cnt2=0
    i = list(str(i))
    for j in range(N):
      if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
        ans+=1
        #print(i)
        break
      if S[j]=="%s"%i[0] and cnt0!=1:
        cnt0+=1
        continue
      if 1<=cnt0 and S[j]=="%s"%i[1]:
        cnt1 +=1
        continue
print(ans)
      
      
      


### FIXED CODE ###

def main():
  N = int(input())
  S = tuple(input())
  ans = 0
  for i in range(1000):
    if i<10:
      cnt0= 0
      cnt1 = 0
      for j in range(N):
        if 2<=cnt0 and S[j]=="%d"%i:
          ans+=1
          break
        if S[j]=="0":
          cnt0+=1
          continue
    elif 10<=i<=99:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
          ans+=1
          break
        if S[j]=="0" and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[0]:
          cnt1 +=1
          continue
    elif 100<=i:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
          ans+=1
          #print(i)
          break
        if S[j]=="%s"%i[0] and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[1]:
          cnt1 +=1
          continue
  print(ans)
main()
### BUGGY CODE ###

N = int(input())
wordl = []

for i in range(N):
    w = input()
    wl = []
    for j in range(10):
        wl.append(w[j])
    wl.sort()
    w2 = ' '
    for p in range(10):
        w2 += wl[p]
    wordl.append(w2)
wordl.sort()
#print(wordl)

ans = 0
for k in range(N):
    for q in range(k+1,N):
        if wordl[k] == wordl[q]:
            ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
wordl = {}
ans = 0

for i in range(N):
    w = input()
    wl = []
    for j in range(10):
        wl.append(w[j])
    wl.sort()
    w2 = ' '
    for p in range(10):
        w2 += wl[p]
    if w2 in wordl:
        ans += wordl[w2]
        wordl[w2] += 1
    else:
        wordl[w2] = 1

print(ans)

'''
#アルゴリズムはあってるがLTE
N = int(input())
wordl = []

for i in range(N):
    w = input()
    wl = []
    for j in range(10):
        wl.append(w[j])
    wl.sort()
    w2 = ' '
    for p in range(10):
        w2 += wl[p]
    wordl.append(w2)
wordl.sort()
#print(wordl)

ans = 0
for k in range(N):
    for q in range(k+1,N):
        if wordl[k] == wordl[q]:
            ans += 1
        else:
            break

print(ans)
'''