Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as counter
from sys import stdin 

N = int(stdin.readline().rstrip())
strings = ''
lists = []
for _ in range(N):
  s = ''.join(sorted(stdin.readline().rstrip()))
  strings += s
  lists.append(s)
counts = [strings[(i+1)*len(s):].count(c) for i, c in enumerate(lists)]
match_count = sum(counts)
print(match_count)

Fixed submission:
N = int(input())
dic = {}
count = 0
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in dic.keys():
    count += dic[s]
    dic[s] += 1
  else:
    dic[s] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as counter
from sys import stdin 

N = int(stdin.readline().rstrip())
char_counts = [sorted(stdin.readline().rstrip()) for _ in range(N)]
counts = [list(map(lambda x: x == c, char_counts[i+1:]))  for i, c in enumerate(char_counts)]
match_count = sum(list(map(sum, counts)))
print(match_count)

Fixed submission:
N = int(input())
dic = {}
count = 0
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in dic.keys():
    count += dic[s]
    dic[s] += 1
  else:
    dic[s] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as counter
from sys import stdin 

N = int(stdin.readline())
char_counts = list(map(counter, [stdin.readline().rstrip() for _ in range(N)]))
counts = [list(map(lambda x: x == c, char_counts[i+1:])) for i, c in enumerate(char_counts)]
match_count = sum(list(map(sum, counts)))
print(match_count)

Fixed submission:
N = int(input())
dic = {}
count = 0
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in dic.keys():
    count += dic[s]
    dic[s] += 1
  else:
    dic[s] = 1
print(count)

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

N = int(input())
char_counts = list(map(counter, [input() for i in range(N)]))
counts = [list(map(lambda x: x == c, char_counts[i+1:])) for i, c in enumerate(char_counts)]
match_count = sum(list(map(sum, counts)))
print(match_count)

Fixed submission:
N = int(input())
dic = {}
count = 0
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in dic.keys():
    count += dic[s]
    dic[s] += 1
  else:
    dic[s] = 1
print(count)

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

N = int(input())
char_counts = [counter(input()) for i in range(N)]
match_count = 0
for i, c in enumerate(char_counts):
  for j in range(i+1, N, 1):
    if char_counts[j] == c:
      match_count += 1
print(match_count)

Fixed submission:
N = int(input())
dic = {}
count = 0
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in dic.keys():
    count += dic[s]
    dic[s] += 1
  else:
    dic[s] = 1
print(count)

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

N = int(input())
char_counts = [counter(input()) for i in range(N)]
match_count = 0
for i, c in enumerate(char_counts):
  for j in range(i+1, N, 1):
    if char_counts[j] == c:
      match_count += 1
print(match_count)

Fixed submission:
N = int(input())
dic = {}
count = 0
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in dic.keys():
    count += dic[s]
    dic[s] += 1
  else:
    dic[s] = 1
print(count)

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

N = int(input())
char_counts = [counter(input()) for i in range(N)]
match_count = 0
for i, c in enumerate(char_counts):
  for j in range(i, N, 1):
    if i == j:
      continue
    if char_counts[j] == c:
      match_count += 1
print(match_count)

Fixed submission:
N = int(input())
dic = {}
count = 0
for _ in range(N):
  s = ''.join(sorted(input()))
  if s in dic.keys():
    count += dic[s]
    dic[s] += 1
  else:
    dic[s] = 1
print(count)