Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    table = [''.join(sorted(list(input()))) for _ in range(N)]
    sort_table = list(set(list(table)))
    ans = 0
    for i in sort_table:
        n = table.count(i)
        if n <= 1:
            continue
        x = (n * (n - 1)) // 2
        ans += x

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import collections


def main():
    N = int(input())
    table = [''.join(sorted(list(input()))) for _ in range(N)]
    sort_table = set(table)
    cnt_table = collections.Counter(table)
    ans = 0
    for i in sort_table:
        num_of_i = cnt_table[i]
        if num_of_i <= 1:
            continue
        x = (num_of_i * (num_of_i - 1)) // 2
        ans += x

    print(ans)


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    table = [''.join(sorted(list(input()))) for _ in range(N)]
    sort_table = list(set(list(table)))
    ans = 0
    for i in sort_table:
        n = table.count(i)
        if n <= 1:
            continue
        x = math.factorial(n) / (2 * math.factorial(n - 2))
        ans += x

    print(int(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import collections


def main():
    N = int(input())
    table = [''.join(sorted(list(input()))) for _ in range(N)]
    sort_table = set(table)
    cnt_table = collections.Counter(table)
    ans = 0
    for i in sort_table:
        num_of_i = cnt_table[i]
        if num_of_i <= 1:
            continue
        x = (num_of_i * (num_of_i - 1)) // 2
        ans += x

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    table = [sorted(list(input())) for _ in range(N)]

    cnt = 0

    for i in range(N - 1):
        for j in range(i + 1, N):
            if table[i] == table[j]:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import collections


def main():
    N = int(input())
    table = [''.join(sorted(list(input()))) for _ in range(N)]
    sort_table = set(table)
    cnt_table = collections.Counter(table)
    ans = 0
    for i in sort_table:
        num_of_i = cnt_table[i]
        if num_of_i <= 1:
            continue
        x = (num_of_i * (num_of_i - 1)) // 2
        ans += x

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
table = [list(input()) for _ in range(N)]

cnt = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        if sorted(table[i]) == sorted(table[j]):
            cnt += 1

print(cnt)


Fixed submission:
import collections


def main():
    N = int(input())
    table = [''.join(sorted(list(input()))) for _ in range(N)]
    sort_table = set(table)
    cnt_table = collections.Counter(table)
    ans = 0
    for i in sort_table:
        num_of_i = cnt_table[i]
        if num_of_i <= 1:
            continue
        x = (num_of_i * (num_of_i - 1)) // 2
        ans += x

    print(ans)


if __name__ == '__main__':
    main()