Buggy python submission (verdict: Runtime Error):
n = int(input())

l = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = ''.join(tmp)
    l.append(tmp)

from collections import Counter
c = Counter(l)
num = c.values()

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

ans = 0
for i in num:
    ans += combinations_count(i, 2)
    if i == 1:
        break

print(ans)


Fixed submission:
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
#print(s)

x = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            x += 1
 
print(x)

Fixed submission:
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
        s.append(''.join(sorted(input())))
    #''.join(sorted((sorted(input()))
#print(s)

x = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            x += 1
 
print(x)

Fixed submission:
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    s.append(sorted(input())) # !!!
#print(s)
 
x = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            x += 1
 
print(x)

Fixed submission:
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    s.append(sorted(list(input()))) # !!!
#print(s)

x = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            x += 1

print(x)
    



Fixed submission:
n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))