Buggy python submission (verdict: Runtime Error):
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(count)

Fixed submission:
N, *s = open(0).read().split()
sl = [''.join(sorted(c)) for c in s]
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

Buggy python submission (verdict: Runtime Error):
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(int(count))

Fixed submission:
N, *s = open(0).read().split()
sl = [''.join(sorted(c)) for c in s]
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

Buggy python submission (verdict: Runtime Error):
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(int(count))

Fixed submission:
N, *s = open(0).read().split()
sl = [''.join(sorted(c)) for c in s]
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

Buggy python submission (verdict: Runtime Error):
from math import factorial
import collections
import itertools
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    #count += len(list(itertools.combinations(range(c[s]), 2)))
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(int(count))

Fixed submission:
N, *s = open(0).read().split()
sl = [''.join(sorted(c)) for c in s]
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import itertools
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += len(list(itertools.combinations(range(c[s]), 2)))
  elif c[s] == 2:
    count += 1
print(count)

Fixed submission:
N, *s = open(0).read().split()
sl = [''.join(sorted(c)) for c in s]
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)

Buggy python submission (verdict: Runtime Error):
N, *s = open(0).read().split()
s_sorted = []
s_sorted = ''.join(sorted(c)) for c in s:
count = 0
for s in s_sorted:
  count += s_sorted.count(s)-1
  s_sorted.pop(0)
print(count)

Fixed submission:
N, *s = open(0).read().split()
sl = [''.join(sorted(c)) for c in s]
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)