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 = map(int, input())
a = []
new_a = []

for k in n:
    a[k] = map(str, input())

for k in n:
    new_a[k] = ''.join(list(reversed(a[k])))

sorted(new_a)

b = 0

for k in n:
    if(new_a[k] == new_a[k+1]):
        b = b +1
        
print(b)


import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)


set_mo = set(list_mo)
list_mo_s = list(set_mo)
ans = []
for s in list_mo_s:
    ans.append(list_mo.count(s))

ans_val = []
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(len(ans)):
    if ans[i] == 1:
        break
    else:
        ans_val.append(combinations_count(ans[i], 2))

print(sum(ans_val))

n = int(input())
a = []
new_a = []

for k in range(n):
    a.append(input())

for k in range(n):
    new_a.append( ''.join(list(reversed(a[k]))))

sorted(new_a)

b = 0

for k in range(n-1):
    if(new_a[k] == new_a[k+1]):
        b = b +1

print(b)


new_a = []

for k in range(n):
    a.append(str(input()))

for k in range(n):
    new_a.append( ''.join(list(sorted(a[k]))))

new_a.sort()

b = 0

for k in range(n-1):
    for m in range(k+1, n):
        if(new_a[k] == new_a[m]):
            b = b +1

print(b)


n = int(input())
a = []
new_a = []

for k in range(n):
    a.append(str(input()))

for k in range(n):
    new_a.append( ''.join(list(sorted(a[k]))))

print(new_a)
new_a.sort()
print(new_a)

b = 0

for k in range(n-1):
    if(new_a[k] == new_a[k+1]):
        b = b +1

print(b)


n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)


set_mo = set(list_mo)
list_mo_s = list(set_mo)
ans = []
for s in list_mo_s:
    ans.append(list_mo.count(s))

if max(ans) == 1:
    print(0)
else:
    print(sum(ans) - 1)

n = int(input())
a = []
new_a = []

for k in range(n):
    a.append(str(input()))

for k in range(n):
    new_a.append( ''.join(list(sorted(a[k]))))

print(new_a)
new_a.sort()
print(new_a)

b = 0

for k in range(n-1):
    if(new_a[k] == new_a[k+1]):
        b = b +1

print(b)


from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

from collections import Counter
n = int(input())
list_N = []
ans = 0

for _ in range(n):
    s = sorted(input())
    list_N.append("".join(s))

list_M = list(Counter(list_N).values())

for i in list_M:
    if i != 1:
        ans += cmb(i, 2)
print(ans)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted