Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
s = [str(input()) for _ in range(n)]
s_set = set(["".join(sorted(_)) for _ in [i for i in s]])
s = ["".join(sorted(_)) for _ in [i for i in s]]
ans = 0
for word in s_set:
  cnt = 0
  for _ in s:
    if _ == word:
      cnt += 1
  if cnt >= 2:
  	ans += cmb(cnt, 2)
print(ans)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
s = [str(input()) for _ in range(n)]
s = sorted(["".join(sorted(_)) for _ in [i for i in s]])
ans = 0
preb = str()
cnt = 1
for line in s:
  if preb == line:
    cnt += 1
  elif cnt >= 2:
    ans += cmb(cnt, 2)
    cnt = 1
  else:
    cnt = 1
  preb = line
if cnt >= 2:
    ans += cmb(cnt, 2)
print(ans)

Buggy python submission (verdict: Runtime Error):
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


n = int(input())
s = [str(input()) for _ in range(n)]
s_set = set(["".join(sorted(_)) for _ in [i for i in s]])
s = ["".join(sorted(_)) for _ in [i for i in s]]
ans = 0
for word in s_set:
  cnt = 0
  for _ in s:
    if _ == word:
      cnt += 1
  if cnt >= 2:
  	ans += cmb(cnt, 2)
print(ans)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
s = [str(input()) for _ in range(n)]
s = sorted(["".join(sorted(_)) for _ in [i for i in s]])
ans = 0
preb = str()
cnt = 1
for line in s:
  if preb == line:
    cnt += 1
  elif cnt >= 2:
    ans += cmb(cnt, 2)
    cnt = 1
  else:
    cnt = 1
  preb = line
if cnt >= 2:
    ans += cmb(cnt, 2)
print(ans)

Buggy python submission (verdict: Runtime Error):
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


n = int(input())
s = [str(input()) for _ in range(n)]
s_set = set(["".join(sorted(_)) for _ in [i for i in s]])
s = ["".join(sorted(_)) for _ in [i for i in s]]
ans = 0
for word in s_set:
  cnt = 0
  for _ in s:
    if _ == word:
      cnt += 1
  ans += cmb(cnt, 2)
print(ans)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
s = [str(input()) for _ in range(n)]
s = sorted(["".join(sorted(_)) for _ in [i for i in s]])
ans = 0
preb = str()
cnt = 1
for line in s:
  if preb == line:
    cnt += 1
  elif cnt >= 2:
    ans += cmb(cnt, 2)
    cnt = 1
  else:
    cnt = 1
  preb = line
if cnt >= 2:
    ans += cmb(cnt, 2)
print(ans)