Problem: We will call a string obtained by arranging the characters contained in a string a in some order, an _anagram_ of a.  For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.  Given are N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Submission attempts (in order):
N = int(input())
liss = {}
for i in range(N):
  s = input()
  a = sorted(s)
  if a in liss:
    liss[a] += 1
  else:
    liss[a] = 1

ans = 0
for cc in liss:
  ans = ans + (liss[cc] * (liss[cc] - 1) / 2)
print(int(ans))


import collections
N = int(input())
liss = {}
for i in range(N):
  s = input()
  a = s.sorted()
  if a in liss:
    liss[a] += 1
  else:
    liss[a] = 1

ans = 0
for cc in liss:
  ans = ans + (liss[cc] * (liss[cc] - 1) / 2)
print(int(ans))


import collections
N = int(input())
liss = []
for i in range(N):
  s = input()
  a = s.sorted()
  if a in liss:
    liss[a] += 1
  else:
    liss[a] = 1

ans = 0
for cc in liss:
  ans = ans + (liss[cc] * (liss[cc] - 1) / 2)
print(int(ans))


import collections
N = int(input())
countr = []
liss = []
for i in range(N):
  s = input()
  a = collections.Counter(s)
  if a in liss:
    ind = liss.index(a)
    countr[ind] += 1
  else:
    liss.append(a)
    countr.append(1)

ans = 0
for cc in countr:
  if cc > 1:
    ans = ans + (cc * (cc - 1) / 2)
print(ans)


N = int(input())
liss = {}
for i in range(N):
  s = input()
  a = sorted(s)
  if a in liss:
    liss[a] += 1
  else:
    liss[a] = 1

ans = 0
for cc in liss:
  ans = ans + (liss[cc] * (liss[cc] - 1) / 2)
print(int(ans))


import collections
N = int(input())
s = [0]*N
countr = []
liss = []
for i in range(N):
  s[i] = input()
  a = collections.Counter(s[i])
  if a in liss:
    ind = liss.index(a)
    countr[ind] += 1
  else:
    liss.append(a)
    countr[len(liss)-1] = 1

ans = 0
for cc in countr:
  if cc > 1:
    ans = ans + cc * (cc - 1) / 2
print(ans)


import collections
N = int(input())
countr = []
liss = []
for i in range(N):
  s = input()
  a = collections.Counter(s)
  if a in liss:
    ind = liss.index(a)
    countr[ind] += 1
  else:
    liss.append(a)
    countr.append(1)

ans = 0
for cc in countr:
  if cc > 1:
    ans = ans + cc * (cc - 1) / 2
print(ans)


import collections
N = int(input())
s = [0]*N
counter = {}
for i in range(N):
  s[i] = input()
  a = collections.Counter(s[i])
  if a in counter:
    counter[a] += 1
  else:
    counter[a] = 1

ans = 0
for key in counter:
  if counter[key] > 1:
    ans = ans + counter[key] * (counter[key] - 1) / 2
print(ans)

import collections
N = int(input())
countr = []
liss = []
ccr = []
for i in range(N):
  s = input()
  a = collections.Counter(s)
  if a in liss:
    ind = liss.index(a)
    countr[ind] += 1
    ccr[ind] + countr[ind]
  else:
    liss.append(a)
    countr.append(1)
    ccr.append(0)


print(int(sum(ccr)))


import collections
N = int(input())
countr = []
liss = []
ccr = []
for i in range(N):
  s = input()
  a = collections.Counter(s)
  if a in liss:
    ind = liss.index(a)
    countr[ind] += 1
    ccr[ind] += countr[ind]
  else:
    liss.append(a)
    countr.append(1)
    ccr.append(0)


print(int(sum(ccr)))


import collections
N = int(input())
countr = []
liss = []
for i in range(N):
  s = input()
  a = collections.Counter(s)
  if a in liss:
    ind = liss.index(a)
    countr[ind] += 1
  else:
    liss.append(a)
    countr[len(liss)-1] = 1

ans = 0
for cc in countr:
  if cc > 1:
    ans = ans + cc * (cc - 1) / 2
print(ans)


N = int(input())
liss = {}
for i in range(N):
  s = input()
  a = "".join(sorted(s))
  if a in liss:
    liss[a] += 1
  else:
    liss[a] = 1

ans = 0
for cc in liss:
  ans = ans + (liss[cc] * (liss[cc] - 1) / 2)
print(int(ans))


Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted