Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)


set_mo = set(list_mo)
list_mo_s = list(set_mo)
ans = []
for s in list_mo_s:
    ans.append(list_mo.count(s))

ans_val = []

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for s in ans:
    if s != 1:
        ans_val.append(cmb(s, 2))


print(sum(ans_val))


Fixed submission:
import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)

ans = {}
for s in list_mo:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1


ans_val = []

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for s in ans:
    if ans[s] != 1:
        ans_val.append(cmb(ans[s], 2))


print(sum(ans_val))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
new_a = []

for k in range(n):
    a.append(str(input()))
    new_a.append( ''.join(list(sorted(a[k]))))

new_a.sort()

b = 0

for k in range(n-1):
    for m in range(k+1, n):
        if(new_a[k] == new_a[m]):
            b = b + 1

print(b)

Fixed submission:
import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)

ans = {}
for s in list_mo:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1


ans_val = []

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for s in ans:
    if ans[s] != 1:
        ans_val.append(cmb(ans[s], 2))


print(sum(ans_val))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
new_a = []

for k in range(n):
    a.append(str(input()))

for k in range(n):
    new_a.append( ''.join(list(sorted(a[k]))))

new_a.sort()

b = 0

for k in range(n-1):
    for m in range(k+1, n):
        if(new_a[k] == new_a[m]):
            b = b + 1

print(b)

Fixed submission:
import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)

ans = {}
for s in list_mo:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1


ans_val = []

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for s in ans:
    if ans[s] != 1:
        ans_val.append(cmb(ans[s], 2))


print(sum(ans_val))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
new_a = []

for k in range(n):
    a.append(str(input()))

for k in range(n):
    new_a.append( ''.join(list(sorted(a[k]))))

new_a.sort()

b = 0

for k in range(n-1):
    for m in range(k+1, n):
        if(new_a[k] == new_a[m]):
            b = b + 1

print(b)

Fixed submission:
import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)

ans = {}
for s in list_mo:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1


ans_val = []

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for s in ans:
    if ans[s] != 1:
        ans_val.append(cmb(ans[s], 2))


print(sum(ans_val))

Buggy python submission (verdict: Runtime Error):
new_a = []

for k in range(n):
    a.append(str(input()))

for k in range(n):
    new_a.append( ''.join(list(sorted(a[k]))))

new_a.sort()

b = 0

for k in range(n-1):
    for m in range(k+1, n):
        if(new_a[k] == new_a[m]):
            b = b +1

print(b)


Fixed submission:
import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)

ans = {}
for s in list_mo:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1


ans_val = []

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for s in ans:
    if ans[s] != 1:
        ans_val.append(cmb(ans[s], 2))


print(sum(ans_val))

Buggy python submission (verdict: Runtime Error):
n = map(int, input())
a = []
new_a = []

for k in n:
    a[k] = map(str, input())

for k in n:
    new_a[k] = ''.join(list(reversed(a[k])))

sorted(new_a)

b = 0

for k in n:
    if(new_a[k] == new_a[k+1]):
        b = b +1
        
print(b)


Fixed submission:
import math
n = int(input())
list_voc = [str(input()) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = ''.join(list_n)
    list_mo.append(list_n)

ans = {}
for s in list_mo:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1


ans_val = []

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


for s in ans:
    if ans[s] != 1:
        ans_val.append(cmb(ans[s], 2))


print(sum(ans_val))