Buggy python submission (verdict: Runtime Error):
import collections
import math
 
N = int(input())
words = [input() for i in range(N)] 
 
ans = 0
L = []
for ix, word in  enumerate(words):
    word_list = list(word)
    word_list.sort()
    L.append(''.join(map(str, word_list)))
 
c = collections.Counter(L)
 
for i in c.values():    
    ans += math.factorial(i) / math.factorial(2) / math.factorial(i - 2)
 
print(int(ans))

Fixed submission:
N = int(input())
dic = {}

for i in range(N):
    spell = ''.join(sorted(input()))
    if spell in dic.keys():
        dic[spell] += 1
    else:
        dic[spell] = 1

count = 0
for num in dic.values():
    count += sum([i for i in range(num)])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import itertools

N = int(input())
words = [input() for i in range(N)] 

ans = 0
L = []
for ix, word in  enumerate(words):
    word_list = list(word)
    word_list.sort()
    L.append(''.join(map(str, word_list)))

c = collections.Counter(L)

for i in c.values():    
    ans += len(list(itertools.combinations(range(i), 2)))

print(int(ans))


Fixed submission:
N = int(input())
dic = {}

for i in range(N):
    spell = ''.join(sorted(input()))
    if spell in dic.keys():
        dic[spell] += 1
    else:
        dic[spell] = 1

count = 0
for num in dic.values():
    count += sum([i for i in range(num)])

print(count)

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

N = int(input())
words = [input() for i in range(N)] 

ans = 0
L = []
for ix, word in  enumerate(words):
    word_list = list(word)
    word_list.sort()
    L.append(''.join(map(str, word_list)))

c = collections.Counter(L)

for i in c.values():    
    ans += factorial(i) / factorial(2) / factorial(i - 2)

print(int(ans))


Fixed submission:
N = int(input())
dic = {}

for i in range(N):
    spell = ''.join(sorted(input()))
    if spell in dic.keys():
        dic[spell] += 1
    else:
        dic[spell] = 1

count = 0
for num in dic.values():
    count += sum([i for i in range(num)])

print(count)

Buggy python submission (verdict: Runtime Error):
import collections
from scipy.special import comb

N = int(input())
words = [input() for i in range(N)] 

ans = 0
L = []
for ix, word in  enumerate(words):
    word_list = list(word)
    word_list.sort()
    L.append(''.join(map(str, word_list)))

c = collections.Counter(L)

for i in c.values():
    ans += comb(i, 2, exact=True)

print(ans)


Fixed submission:
N = int(input())
dic = {}

for i in range(N):
    spell = ''.join(sorted(input()))
    if spell in dic.keys():
        dic[spell] += 1
    else:
        dic[spell] = 1

count = 0
for num in dic.values():
    count += sum([i for i in range(num)])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
words = [input() for i in range(N)] 

ans = 0
for ix, word in  enumerate(words):
    word_list = list(word)
    word_list.sort()
    for j, compe_word in enumerate(words[ix+1:]):
        compe_word_list = list(compe_word)
        compe_word_list.sort()
        if ''.join(map(str, compe_word_list)) == ''.join(map(str, word_list)):
            ans += 1
print(ans)


Fixed submission:
N = int(input())
dic = {}

for i in range(N):
    spell = ''.join(sorted(input()))
    if spell in dic.keys():
        dic[spell] += 1
    else:
        dic[spell] = 1

count = 0
for num in dic.values():
    count += sum([i for i in range(num)])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
words = [input() for i in range(N)] 

ans = 0
for ix, word in  enumerate(words):
    for j, compe_word in enumerate(words[ix+1:]):
        compe_word_list = list(compe_word)
        for alphabet in word:
            if alphabet in compe_word_list:
                compe_word_list.pop(compe_word_list.index(alphabet))
        if len(compe_word_list) == 0:
            ans += 1
print(ans)


Fixed submission:
N = int(input())
dic = {}

for i in range(N):
    spell = ''.join(sorted(input()))
    if spell in dic.keys():
        dic[spell] += 1
    else:
        dic[spell] = 1

count = 0
for num in dic.values():
    count += sum([i for i in range(num)])

print(count)