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())
l=[input() for j in range(n)]
for i in range(n)[:-1]:
	f=l[i]
	for s in range(n)[i+1:]:
		a=[f[k] for k in range(10)]
        g=l[s]
        b=[g[c] for c in range(10)]
        q +=1 if sorted(a)==sorted(b)
print(q)

n=input()
l=list()
q=0
for k in range(n):
	st=input()
    l.append(st)
for i in range(n)[:-1]:
	f=l[i]
	for s in range(n)[i+1:]:
		a=[f[k] for k in range(10)]
        g=l[s]
        b=[g[c] for c in range(10)]
        q +=1 if sorted(a)==sorted(b)
print(q)

n=int(input())
l=[input() for j in range(n)]
for i in range(n)[:-1]:
	f=l[i]
	for s in range(n)[i1:]:
    	if s != i:
			a=[f[k] for k in range(10)]
            g=l[s]
            b=[g[c] for c in range(10)]
            q +=1 if sorted(a)==sorted(b)
print(q)

from collections import Counter as co
from itertools import combinations as com
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

n=int(input())
a=0
l=co([set(co(input())) for i in range(n)])
for d,s in l.items():
  if s>=2:a+=combinations_count(s, 2)
print(a)

from collections import Counter as co
from itertools import combinations as com
from operator import mul
from functools import reduce

def combinations_count(n, r):
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer//denom

n=int(input())
a=0
l=co([set(co(input())) for i in range(n)])
for d,s in l.items():
  if s>=2:a+=combinations_count(s, 2)
print(a)

from collections import Counter as co
from itertools import combinations as com
from operator import mul
from functools import reduce

def combinations_count(n, r):
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer//denom

n=int(input())
a=0
l=co([set(co(input())) for i in range(n)])
for d,s in l.items():
  if d>=2:a+=combinations_count(d, 2)
print(a)

n=int(input())
l=list()
q=0
for k in range(n):
	st=input()
    l.append(st)
for i in range(n)[:-1]:
	f=l[i]
	for s in range(n)[i+1:]:
		a=[f[k] for k in range(10)]
        g=l[s]
        b=[g[c] for c in range(10)]
        q +=1 if sorted(a)==sorted(b)
print(q)

from collections import Counter as co
from operator import mul
from functools import reduce

def combinations_count(n, r):
  r = min(r, n - r)
  numer = reduce(mul, range(n, n - r, -1), 1)
  denom = reduce(mul, range(1, r + 1), 1)
  return numer//denom


n=int(input())
a=0
l=[''.join(list(map(str,sum(sorted(list(map(list,co(input()).items()))),[])))) for i in range(n)]
for d,s in co(l).items():
  if s>=2:a+=combinations_count(s, 2)
print(a)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted