Buggy python submission (verdict: Runtime Error):
from math import factorial


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

l = []
count = 0
for i in range(n):
    if a[i] not in l:
        m = a.count(a[i])
        if m > 1:
            count += factorial(m) / 2 / factorial(m - 2)
        l.append(a[i])
    else:
        continue
print(int(count))
    


Fixed submission:
n = int(input())
s = [input() for i in range(n)]

count = 0
dic1 = {}
#print(s)
for i in range(n):
    #print(s[i])
    so = sorted(s[i])
    so = ''.join(so)
    if so in dic1:
        count += dic1[so]
        dic1[so] += 1
    else:
        dic1[so] = 1
    #print(count, dic1)
print(count)

Buggy python submission (verdict: Runtime Error):
from math import factorial


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

l = []
count = 0
for i in range(n):
    if a[i] not in l:
        m = a.count(a[i])
        if m > 1:
            count += factorial(m) / 2 / factorial(m - 2)
        l.append(a[i])
    else:
        pass
print(int(count))
    


Fixed submission:
n = int(input())
s = [input() for i in range(n)]

count = 0
dic1 = {}
#print(s)
for i in range(n):
    #print(s[i])
    so = sorted(s[i])
    so = ''.join(so)
    if so in dic1:
        count += dic1[so]
        dic1[so] += 1
    else:
        dic1[so] = 1
    #print(count, dic1)
print(count)

Buggy python submission (verdict: Runtime Error):
from math import factorial
n = int(input())
s = [input() for i in range(n)]

count = 0
list1 = []
for i in range(n):
    dic1 = {}
    for k in range(10):
        
        if s[i][k] not in dic1:
            dic1[s[i][k]] = s[i].count(s[i][k])
    list1.append(dic1)
list2 = []
for i in range(n):
    if list1[i] not in list2:
        j = list1.count(list1[i])
        if j >= 2:

            a = factorial(j) / factorial(2) / factorial(j - 2)
            count += a
        list2.append(list1[i])
print(int(count))

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

count = 0
dic1 = {}
#print(s)
for i in range(n):
    #print(s[i])
    so = sorted(s[i])
    so = ''.join(so)
    if so in dic1:
        count += dic1[so]
        dic1[so] += 1
    else:
        dic1[so] = 1
    #print(count, dic1)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

count = 0
list1 = []
for i in range(n):
    dic1 = {}
    for k in range(10):
        
        if s[i][k] not in dic1:
            dic1[s[i][k]] = s[i].count(s[i][k])
    list1.append(dic1)
        
for i in range(n):
    for j in range(i + 1, n):
        if list1[i] == list1[j]:    
            count += 1
print(count)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

count = 0
dic1 = {}
#print(s)
for i in range(n):
    #print(s[i])
    so = sorted(s[i])
    so = ''.join(so)
    if so in dic1:
        count += dic1[so]
        dic1[so] += 1
    else:
        dic1[so] = 1
    #print(count, dic1)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

count = 0
list1 = []
for i in range(n):
    dic1 = {}
    for k in range(10):
        
        if s[i][k] in dic1:
            dic1[s[i][k]] += 1
        else:
            dic1[s[i][k]] = 1
    list1.append(dic1)
        
for i in range(n):
    for j in range(i + 1, n):
        if list1[i] == list1[j]:    
            count += 1
print(count)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

count = 0
dic1 = {}
#print(s)
for i in range(n):
    #print(s[i])
    so = sorted(s[i])
    so = ''.join(so)
    if so in dic1:
        count += dic1[so]
        dic1[so] += 1
    else:
        dic1[so] = 1
    #print(count, dic1)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]

count = 0
for i in range(n):
    for j in range(i + 1, n):
        dic1 = {}
        dic2 = {}
        for k in range(10):
            
            if s[i][k] in dic1:
                dic1[s[i][k]] += 1
            else:
                dic1[s[i][k]] = 1
            if s[j][k] in dic2:
                dic2[s[j][k]] += 1
            else:
                dic2[s[j][k]] = 1
        
        if dic1 == dic2:
            #print(dic1, dic2)
            count += 1
print(count)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

count = 0
dic1 = {}
#print(s)
for i in range(n):
    #print(s[i])
    so = sorted(s[i])
    so = ''.join(so)
    if so in dic1:
        count += dic1[so]
        dic1[so] += 1
    else:
        dic1[so] = 1
    #print(count, dic1)
print(count)