Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = [''.join(sorted(list(input()))) for i in range(N)]
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1

print(ans)


Fixed submission:
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
word = [input() for i in range(N)]
sorted_word = tuple(tuple(sorted(list(word[i]))) for i in range(N))
dict_word = {sorted_word[i]:0 for i in range(N)}
ans = 0


for i in range(N):
  if sorted_word[i] in sorted_word[i+1:]:
    dict_word[sorted_word[i]] += 1
    
for value in dict_word.values():
  ans += int((1+value) * value / 2)
  
print(ans)


Fixed submission:
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
word = [input() for i in range(N)]
sorted_word = [tuple(sorted(list(word[i]))) for i in range(N)]
dict_word = {sorted_word[i]:0 for i in range(N)}
ans = 0



for i in range(N):
  if sorted_word[i] in sorted_word[i+1:]:
    dict_word[sorted_word[i]] += 1
    
for value in dict_word.values():
  ans += (1+value) * value / 2
  
print(int(ans))

Fixed submission:
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
word = [input() for i in range(N)]
sorted_word = [sorted(list(word[i])) for i in range(N)]
dict_word = {sorted_word[i]:0 for i in range(N)}
count = 0
ans = 0

def sum_all(x):
  for i in range(x+1):
    y += i
  return y

for i in range(N):
  if sorted_word[i] in sorted_word[i+1:]:
	dict_word[sorted_word[i]] += 1
    
for value in dict_word.value():
  ans += sum_all(value)
  
print(ans)


Fixed submission:
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)

Buggy python submission (verdict: Runtime Error):
import copy
N = int(input())
word = [input() for i in range(N)]
sorted_word = [sorted(list(word[i])) for i in range(N)]
copy_word = copy.copy(sorted_word)
count = 0
for i in range(N-1):
  copy_word.remove(sorted_word[i])
  if sorted_word[i] in copy_word
    count += 1
print(count)



Fixed submission:
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
word = [input() for i in range(N)]
sorted_word = [sorted(list(word[i])) for i in range(N)]
count = 0
for i in range(N-1):
  for j in range(1,N-i):
    if sorted_word[i] == sorted_word[i+j]:
      count += 1
print(count)



Fixed submission:
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
word = [input() for i in range(N)]
sorted_word = [word[i].sort() for i in range(N)]
count = 0
for i in range(N):
  for j in range(i, N):
    if sorted_word[i] == sorted_word[i+j]:
      count += 1
print(count)




Fixed submission:
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)