Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = []
cnt = 0
t = 0
tmp = '0000000000'

for i in range(n):
    s = str(input())
    sl = ''.join(sorted(s))
    l.append(sl)
    l.sort()

for i in range(n):
  if tmp == l[i]:
    cnt += 1
  else:
    tmp = l[i]
    if cnt > 0:
      t += int(cnt * (cnt + 1) / 2)
    cnt = 0
else:
  if cnt > 0:
    t += int(cnt * (cnt + 1) / 2)
    
print(t)

Fixed submission:
n = int(input())

l = []
cnt = 0
t = 0

for i in range(n):
    s = str(input())
    sl = ''.join(sorted(s))
    l.append(sl)

l.sort()

tmp = l[0]

for i in range(1, n):
  if tmp == l[i]:
    cnt += 1
  else:
    tmp = l[i]
    t += int(cnt * (cnt + 1) / 2)
    cnt = 0
else:
    t += int(cnt * (cnt + 1) / 2)

print(t)

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

n = int(input())

li = []
r = []
rs = []
cnt = 0

for i in range(n):
    s = str(input())
    sl = list(s)
    li.append(sl)
    r.append([])
    rs.append("")
    coll = collections.Counter(li[i])
    r[i].extend(coll.most_common())
    r[i].sort()
    rs[i] = ''.join(str(s) for s in r[i])

collr = collections.Counter(rs)

for i in collr.values():
    cnt += i * (i-1) / 2

print(int(cnt))

Fixed submission:
n = int(input())

l = []
cnt = 0
t = 0

for i in range(n):
    s = str(input())
    sl = ''.join(sorted(s))
    l.append(sl)

l.sort()

tmp = l[0]

for i in range(1, n):
  if tmp == l[i]:
    cnt += 1
  else:
    tmp = l[i]
    t += int(cnt * (cnt + 1) / 2)
    cnt = 0
else:
    t += int(cnt * (cnt + 1) / 2)

print(t)

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

n = int(input())

li = []
ls = []
cnt = 0
res = [[list(i) for i in string.ascii_lowercase] for _ in range(n)]
# print(res)
r = [[] for _ in range(n)]
rs = ["" for _ in range(n)]

for i in range(n):
    s = str(input())
    sl = list(s)
    #  print(s)
    #  print(sl)
    li.append(sl)
    # for j in range(26):
    #     res[i][j].append(0)

# print(res)

for i in range(n):
    coll = collections.Counter(li[i])
    r[i].extend(coll.most_common())
    r[i].sort()
    rs[i] = ''.join(str(s) for s in r[i])

collr = collections.Counter(rs)

# print(collr)
# print(collr.values())
# print(sum(collr.values()))

for i in collr.values():
    cnt += i * (i-1) / 2

print(int(cnt))
        # print(res[i])
#     if not res[i] in dic:
#         dicdic[res[i]] = 0
#     else:
#         pass

# for m in range(n):
#   for l in range(n):
#     if l <= m:
#       continue
#     else:
#       if res[m] == res[l]:
#         cnt += 1

# print(cnt)

Fixed submission:
n = int(input())

l = []
cnt = 0
t = 0

for i in range(n):
    s = str(input())
    sl = ''.join(sorted(s))
    l.append(sl)

l.sort()

tmp = l[0]

for i in range(1, n):
  if tmp == l[i]:
    cnt += 1
  else:
    tmp = l[i]
    t += int(cnt * (cnt + 1) / 2)
    cnt = 0
else:
    t += int(cnt * (cnt + 1) / 2)

print(t)

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

n = int(input())

li = []
ls = []
cnt = 0
res = [[list(i) for i in string.ascii_lowercase] for _ in range(n)]
# print(res)

for i in range(n):
  s = str(input())
  sl = list(s)
#  print(s)
#  print(sl)
  li.append(sl)
  for j in range(26):
    res[i][j].append(0)

#print(res)

for i in range(n):
  for j in li[i]:
    for k in range(26):
      if res[i][k][0] == j:
        res[i][k][1] += 1
        break
        #print(res[i])

for m in range(n):
  for l in range(n):
    if l <= m:
      continue
    else:
      if res[m] == res[l]:
        cnt += 1

print(cnt)

Fixed submission:
n = int(input())

l = []
cnt = 0
t = 0

for i in range(n):
    s = str(input())
    sl = ''.join(sorted(s))
    l.append(sl)

l.sort()

tmp = l[0]

for i in range(1, n):
  if tmp == l[i]:
    cnt += 1
  else:
    tmp = l[i]
    t += int(cnt * (cnt + 1) / 2)
    cnt = 0
else:
    t += int(cnt * (cnt + 1) / 2)

print(t)

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

n = int(input())

li = []
ls = []
cnt = 0
res = [[list(i) for i in string.ascii_lowercase] for _ in range(n)]
# print(res)

for _ in range(n):
  s = str(input())
  sl = list(s)
#  print(s)
#  print(sl)
  li.append(sl)

for i in range(n):
  for j in range(26):
    res[i][j].append(0)

#print(res)

for i in range(n):
  for j in li[i]:
    for k in range(26):
      if res[i][k][0] == j:
        res[i][k][1] += 1
        #print(res[i])

for m in range(n):
  for l in range(n):
    if l <= m:
      continue
    else:
      if res[m] == res[l]:
        cnt += 1

print(cnt)

Fixed submission:
n = int(input())

l = []
cnt = 0
t = 0

for i in range(n):
    s = str(input())
    sl = ''.join(sorted(s))
    l.append(sl)

l.sort()

tmp = l[0]

for i in range(1, n):
  if tmp == l[i]:
    cnt += 1
  else:
    tmp = l[i]
    t += int(cnt * (cnt + 1) / 2)
    cnt = 0
else:
    t += int(cnt * (cnt + 1) / 2)

print(t)