Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0

l = [sorted(input()) for _ in range(n)]
dellist = lambda items, indices: [item for idx, item in enumerate(items) if idx not in indices]

while True:
    a = l.pop(0)
    li = []
    for i in range(len(l)):
        if l[i] == a:
            li.append(i)

    dellist(l, li)

    ans += sum(range(li + 1))

print(ans)

Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0

l = []

for _ in range(n):
    s = sorted(input())
    for le in l:
        if le == s:
            ans += 1

    l.append(s)

print(ans)

Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()

Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
ans = 0

l = []

for _ in range(n):
    s = collections.Counter(input())
    for le in l:
        if le == s:
            ans += 1

    l.append(s)

print(ans)

Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()

Buggy python submission (verdict: Time Limit Exceeded):
import collections


def p_c():
    n = int(input())
    ans = 0

    l = []

    for _ in range(n):
        s = collections.Counter(input())
        for le in l:
            if le == s:
                ans += 1

        l.append(s)

    print(ans)


if __name__ == '__main__':
    p_c()

Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()

Buggy python submission (verdict: Time Limit Exceeded):
import collections


def p_c():
    n = int(input())
    ans = 0

    l = [collections.Counter(input()) for _ in range(n)]

    for i in range(n):
        for j in range(i + 1, n):
            if l[i] == l[j]:
                ans += 1

    print(ans)


if __name__ == '__main__':
    p_c()


Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import itertools


def p_c():
    n = int(input())
    ans = 0

    l = [collections.Counter(input()) for _ in range(n)]

    b = list(itertools.combinations(l, 2))
    for i in b:
        if i[0] == i[1]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_c()

Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import itertools


def p_c():
    n = int(input())
    l = []
    ans = 0

    for _ in range(n):
        l.append(collections.Counter(input()))

    for i in list(itertools.combinations(l, 2)):
        if i[0] == i[1]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_c()

Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()

Buggy python submission (verdict: Time Limit Exceeded):
import collections


def p_c():
    n = int(input())
    s = [input() for _ in range(n)]

    s_d = [collections.Counter(i) for i in s]
    ans = 0

    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if s_d[i] == s_d[j]:
                ans += 1

    print(ans//2)


if __name__ == '__main__':
    p_c()

Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()