Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []
count=0

for i in range(N):
  s.append("".join(sorted(input())))
  
duplicate_list =sorted(set(s), key=s.index)

for i in range (len(duplicate_list)):
  for j in range (s.count(duplicate_list[i])):
    count += j

print(count)

Fixed submission:
from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []
count=0

for i in range(N):
  a = list(input())
  a.sort()
  s.append(''.join(a))
  
duplicate_list =sorted(set(s), key=s.index)

for i in range (len(duplicate_list)):
  for j in range (s.count(duplicate_list[i])):
    count += j

print(count)

Fixed submission:
from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []
count=0

def duplicates(list):
  seen=[]
  return [x for x in s if x not in seen and not seen.append(x)]

for i in range(N):
  a = list(input())
  a.sort()
  s.append(''.join(a))

duplicate_list = duplicates(s)

for i in range (len(duplicate_list)):
  for j in range (s.count(duplicate_list[i])):
    count += j

print(count)

Fixed submission:
from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []
count=0

def duplicates(list):
  seen=[]
  return [x for x in s if x not in seen and not seen.append(x)]

for i in range(N):
  a = list(input())
  a.sort()
  s.append(a)

duplicate_list = duplicates(s)

for i in range (len(duplicate_list)):
  for j in range (s.count(duplicate_list[i])):
    count += j

print(count)

Fixed submission:
from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)

Buggy python submission (verdict: Runtime Error):
for i in range(N):
  a = list(input())
  a.sort()
  s.append(a)

duplicate_list = duplicates(s)

for i in range (len(duplicate_list)):
  for j in range (s.count(duplicate_list[i])):
    count += j

print(count)

Fixed submission:
from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []
count=0
for i in range(N):
  a = list(input())
  a.sort()
  s.append(a)

while True:
  if len(s) == 0:
    break
  count += s.count(s[0]) - 1
  del s[0]
  
print(count)

Fixed submission:
from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)

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

N = int(input())
s = []
for i in range(N):
    s.append(input())
count = 0
for i in range(N):
    for j in range(N - i - 1):
        if Counter(s[i]) == Counter(s[i + j + 1]):
            count += 1
print(count)


Fixed submission:
from collections import defaultdict

N = int(input())
s = defaultdict(lambda:0)
count=0

for i in range(N):
  a = "".join(sorted(input()))
  s[a] +=1
  
  if s[a] >1:
    count += s[a]-1
print(count)