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):
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
counter = Counter(ss)
for k, v in counter.items():
  cnt += v*(v-1)/2
print(cnt)

from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic.items():
  cnt += int(v)
print(cnt)

n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s]=1
  else:
    dic[s]+=1
print(cnt)

from collections import Counter
n=int(input())
string_list=[sorted(Counter(input()), key=lambda x:x[0]) for i in range(n)]
cnt=0
for i in range(n):
  si = string_list[i]
  for j in range(i, n):
    sj = string_list[j]
    if si.items() == sj.items():
      cnt += 1
print(cnt)

from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
counter = Counter(ss)
for k, v in counter.items():
  cnt += 1
print(cnt)

from collections import Counter
n=int(input())
string_list=[Counter(input()) for i in range(n)]
cnt=0
for i in range(n):
  si = string_list[i]
  for j in range(i, n):
    sj = string_list[j]
    if si==sj:
      cnt += 1
print(cnt)

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



n=int(input())
string_list=[sorted(input()) for i in range(n)]
string_set=set(string_list)
cnt=0
for s in string_set:
  n=string_list.count(s)
  cnt+=int(n*(n-1)/2)
print(cnt)

n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
dic = {}
print(cnt)

from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic:
  cnt += v
print(cnt)

from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)

from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic.items():
  cnt += v
print(cnt)

from collections import Counter
n=int(input())
string_list=[sorted(Counter(input()), key=lambda x:x[0]) for i in range(n)]
cnt=0
for i in range(n):
  si = string_list[i]
  for j in range(i, n):
    sj = string_list[j]
    if si==sj:
      cnt += 1
print(cnt)

n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s]=1
  else :
    dic[s]+=1
for v in dic.values():
  cnt += v*(v-1)/2
print(cnt)

n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt=0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s] = 1
  else :
    dic[s] += 1
for v in dic.values():
  cnt += v
print(cnt)

from collections import Counter
n=int(input())
string_list=[Counter(input()) for i in range(n)]
string_set=set(string_list)
cnt=0
for s in string_set:
  n=string_list.count(s)
  cnt+=int(n*(n-1)/2)
print(cnt)

from collections import Counter
n = int(input())
ss = ["".join(sorted(input())) for i in range(n)]
cnt = 0
counter = Counter(ss)
for k, v in counter.items():
  cnt += v*(v-1)/2
print(int(cnt))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted