Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
n = int(input())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
temp = A[0]
counter = 1
ans = 0
for i in range(1,len(A)):
    if temp != A[i]:
        if counter >= 2:
            ans += factorial(counter) / factorial(2) / factorial(counter-2)
        temp = A[i]
        counter = 1
    else:
        counter += 1
if counter >= 2:
    ans += factorial(counter) / factorial(2) / factorial(counter-2)

print(int(ans))

Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
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())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
temp = A[0]
counter = 1
ans = 0
for i in range(1,len(A)):
    if temp != A[i]:
        if counter >= 2:
            # ans += factorial(counter) / factorial(2) / factorial(counter-2)
            ans += cmb(counter,2)
        temp = A[i]
        counter = 1
    else:
        counter += 1
if counter >= 2:
    # ans += factorial(counter) / factorial(2) / factorial(counter-2)
    ans += cmb(counter,2)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
n = int(input())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
C = collections.Counter(A)
ans = 0
for c in C.keys():
    if C[c] >= 2:
        ans += factorial(C[c]) / factorial(2) / factorial(C[c]-2)

print(int(ans))

Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
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())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
temp = A[0]
counter = 1
ans = 0
for i in range(1,len(A)):
    if temp != A[i]:
        if counter >= 2:
            # ans += factorial(counter) / factorial(2) / factorial(counter-2)
            ans += cmb(counter,2)
        temp = A[i]
        counter = 1
    else:
        counter += 1
if counter >= 2:
    # ans += factorial(counter) / factorial(2) / factorial(counter-2)
    ans += cmb(counter,2)
print(int(ans))

Buggy python submission (verdict: Runtime Error):

import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
n = int(input())
A = [str(input()) for _ in range(n)]
B = []
for a in A:
    B.append("".join(sorted(a)))
B = sorted(B)
C = collections.Counter(B)
ans = 0
for c in C.keys():
    if C[c] >= 2:
        ans += factorial(C[c]) / factorial(2) / factorial(C[c]-2)

print(int(ans))

Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
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())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
temp = A[0]
counter = 1
ans = 0
for i in range(1,len(A)):
    if temp != A[i]:
        if counter >= 2:
            # ans += factorial(counter) / factorial(2) / factorial(counter-2)
            ans += cmb(counter,2)
        temp = A[i]
        counter = 1
    else:
        counter += 1
if counter >= 2:
    # ans += factorial(counter) / factorial(2) / factorial(counter-2)
    ans += cmb(counter,2)
print(int(ans))

Buggy python submission (verdict: Runtime Error):

import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
n = int(input())
A = [str(input()) for _ in range(n)]
B = []
for a in A:
    B.append("".join(sorted(a)))
B = sorted(B)
C = collections.Counter(B)
ans = 0
for c in C.keys():
    if C[c] >= 2:
        ans += factorial(C[c]) / factorial(2) / factorial(C[c]-2)

print(int(ans))

Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
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())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
temp = A[0]
counter = 1
ans = 0
for i in range(1,len(A)):
    if temp != A[i]:
        if counter >= 2:
            # ans += factorial(counter) / factorial(2) / factorial(counter-2)
            ans += cmb(counter,2)
        temp = A[i]
        counter = 1
    else:
        counter += 1
if counter >= 2:
    # ans += factorial(counter) / factorial(2) / factorial(counter-2)
    ans += cmb(counter,2)
print(int(ans))