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())
s = [input() for i in range(n)]
r=[]
c=0
a=0
for i in range(n):
   r.append((sorted([s[i][j] for j in range(10)])))

for i in range(n-1):
    for j in range(i+1,n):
        for k in range(10):
            if r[i][k]==r[j][k]:
                c+=1
        if c==10:
            c=0
            a+=1
print(a)           
        

n=int(input())
s = [input() for i in range(n)]
c=0
a=["" for i in range(n)]
for i in range(n):
   b[i]=sorted(s[i])
   a[i]=''.join(b[i])

for i in range(n-1):
    for j in range(i+1,n):
        if a[i]==a[j]:
            c+=1
print(c)

n=int(input())
s = [input() for i in range(n)]
c=0
a=["" for i in range(n)]
for i in range(n):
   b[i]=sorted(s[i])
   a[i]=''.join(b[i])
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]==a[j]:
            c+=1
print(c)

n=int(input())
s = [input() for i in range(n)]
c=0
print(s)
for i in range(n):
   r[i]=(sorted([s[i][j] for j in range(10)]))
   r[i]=''.join(r[i])
for i in range(n-1):
    for j in range(i+1,n):
        if r[i]==r[j]:
            c+=1
print(c)

n=int(input())
s = [input() for i in range(n)]
c=0
for i in range(n):
   b[i]=sorted(s[i])
   a[i]=''.join(b[i])
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]==a[j]:
            c+=1
print(c)

n = int(input())
s = []
for _ in range(n):
    tmp = input()
    tmp.sort()
    s.append(tmp)
cnt = 0
for i in range(n-1):
    for j in range(1,n):
        if s[i]==s[j]:
            cnt+=1
print(cnt)


n=int(input())
s = [input() for i in range(n)]
c=0
a=["" for i in range(n)]
for i in range(n):
   b[i]=sorted(s[i])
   a[i]=''.join(b[i])
   print(a)
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]==a[j]:
            c+=1
print(c)

n=int(input())
s = [input() for i in range(n)]
c=0
for i in range(n):
   b[i]=sorted(s[i])
   a[i]=''.join(b[i])
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]==a[j]:
            c+=1
print(c)

n=int(input())
s = [input() for i in range(n)]
c=0
for i in range(n):
   r[i]=(((sorted([s[i][j] for j in range(10)]))))
   r[i]=''.join(r[i])
for i in range(n-1):
    for j in range(i+1,n):
        if r[i]==r[j]:
            c+=1
print(c)

n = int(input())
mydict = {}
for _ in range(n):
    tmp=sorted(input(), key=str.lower)
    tmp = ''.join(sorted(tmp))
    if tmp in mydict:
        mydict[tmp]+=1
    else:
        mydict.setdefault(tmp, 1)
ans = 0
for i in mydict.values():
    ans+=i*(i-1)/2
print(int(ans))



Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted