Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline
n = int(input())
strs = [input() for i in range(n)]

ret = []
for str in strs:
  l = list(str.strip())
  l.sort()
  ret.append("".join(l))

count = 0
length = len(ret)
for index, content in enumerate(ret):
  if index < length - 1:
    for i in range(index+1, length):
      if ret[index] == ret[i]:
        count += 1
print(count)

Fixed submission:
import sys

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

ret = {}
count = 0
for original in originals:
  str = "".join(sorted(list(original)))
  if str in ret:
    count += ret[str]
    ret[str] += 1
  else:
    ret[str] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline
n = int(input())
strs = [input() for i in range(n)]


ret = []
for str in strs:
  l = list(str)
  l.sort()
  ret.append("".join(l))

set = set(ret)

count = 0
for index, content in enumerate(ret):
  if index < len(ret) - 1:
    list = ret[index+1:]
    count += list.count(content)
print(count)

Fixed submission:
import sys

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

ret = {}
count = 0
for original in originals:
  str = "".join(sorted(list(original)))
  if str in ret:
    count += ret[str]
    ret[str] += 1
  else:
    ret[str] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline
n = int(input())
strs = [input() for i in range(n)]


ret = []
for str in strs:
  l = list(str)
  s = sorted(l)
  ret.append("".join(s))

set = set(ret)

count = 0
for index, content in enumerate(ret):
  if index < len(ret) - 1:
    list = ret[index+1:]
    count += list.count(content)
print(count)

Fixed submission:
import sys

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

ret = {}
count = 0
for original in originals:
  str = "".join(sorted(list(original)))
  if str in ret:
    count += ret[str]
    ret[str] += 1
  else:
    ret[str] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

ret = []
for str in strs:
  l = list(str)
  s = sorted(l)
  ret.append("".join(s))

set = set(ret)

count = 0
for index, content in enumerate(ret):
  if index < len(ret) - 1:
    list = ret[index+1:]
    count += list.count(content)
print(count)

Fixed submission:
import sys

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

ret = {}
count = 0
for original in originals:
  str = "".join(sorted(list(original)))
  if str in ret:
    count += ret[str]
    ret[str] += 1
  else:
    ret[str] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

ret = []
for str in strs:
  l = list(str)
  s = sorted(l)
  ret.append("".join(s))

set = set(ret)

count = 0
for index, content in enumerate(ret):
  if index < len(ret) - 1:
    list = ret[index+1:]
    count += list.count(content)
print(count)

Fixed submission:
import sys

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

ret = {}
count = 0
for original in originals:
  str = "".join(sorted(list(original)))
  if str in ret:
    count += ret[str]
    ret[str] += 1
  else:
    ret[str] = 1
print(count)