Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = list()
    pairs = 0
    for i in s:
        count_word = dict()
        for j in i:
            count_word[j] = i.count(j)

        if count_word in ans:
            pairs += ans.count(count_word)

        ans.append(count_word)

    print(pairs)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = dict()
    pairs = 0
    for i in s:
        i = ''.join(sorted(list(i)))

        if i in ans:
            pairs += ans[i]
            ans[i] += 1
            continue

        ans[i] = 1

    print(pairs)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = [None] * n
    index = 0
    for i in s:
        count_word = dict()
        sorted_word = list()
        for j in i:
            if not j in sorted_word:
                count_word[j] = i.count(j)
                sorted_word.append(j)

        ans[index] = count_word
        index += 1

    pairs = 0
    sorted_num = list()
    for i in range(n):
        if i in sorted_num:
            continue
        count = 0
        for j in range(i + 1, n):
            if ans[i] == ans[j]:
                sorted_num.append(j)
                count += 1
        if count >= 2:
            pairs += int(count * (count - 1) / 2) + count
        else:
            pairs += count

    print(pairs)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = dict()
    pairs = 0
    for i in s:
        i = ''.join(sorted(list(i)))

        if i in ans:
            pairs += ans[i]
            ans[i] += 1
            continue

        ans[i] = 1

    print(pairs)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = [None] * n
    index = 0
    for i in s:
        count_word = dict()
        sorted_word = list()
        for j in i:
            if not j in sorted_word:
                count_word[j] = i.count(j)
                sorted_word.append(j)

        ans[index] = count_word
        index += 1

    pairs = list()
    sorted_num = list()
    for i in range(n):
        if i in sorted_num:
            continue
        for j in range(i + 1, n):
            if ans[i] == ans[j]:
                pairs.append(i)
                sorted_num.append(j)

    count = 0
    for v in collections.Counter(pairs).values():
        if v >= 2:
            count += int(v * (v - 1) / 2) + v
        else:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = dict()
    pairs = 0
    for i in s:
        i = ''.join(sorted(list(i)))

        if i in ans:
            pairs += ans[i]
            ans[i] += 1
            continue

        ans[i] = 1

    print(pairs)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = [None] * n
    index = 0
    for i in s:
        count_word = dict()
        sorted_word = list()
        for j in i:
            if not j in sorted_word:
                count_word[j] = i.count(j)
                sorted_word.append(j)

        ans[index] = count_word
        index += 1

    pairs = list()
    sorted_num = list()
    for i in range(n):
        if i in sorted_num:
            continue
        for j in range(i + 1, n):
            if ans[i] == ans[j]:
                pairs.append(i)
                sorted_num.append(j)

    count = 0
    for v in collections.Counter(pairs).values():
        if v >= 2:
            count += int(v * (v - 1) / 2) + v
        else:
            count += 1

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = dict()
    pairs = 0
    for i in s:
        i = ''.join(sorted(list(i)))

        if i in ans:
            pairs += ans[i]
            ans[i] += 1
            continue

        ans[i] = 1

    print(pairs)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = [None] * n
    index = 0
    for i in s:
        count_word = dict()
        sorted_word = list()
        for j in i:
            if not j in sorted_word:
                count_word[j] = i.count(j)
                sorted_word.append(j)

        ans[index] = count_word
        index += 1

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

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = dict()
    pairs = 0
    for i in s:
        i = ''.join(sorted(list(i)))

        if i in ans:
            pairs += ans[i]
            ans[i] += 1
            continue

        ans[i] = 1

    print(pairs)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = list()
    for i in s:
        count_word = dict()
        for j in i:
            count_word[j] = i.count(j)

        ans.append(count_word)

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

    print(count)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = [None] * n
    for i in range(n):
        s[i] = str(input()).replace("\n", "")

    ans = dict()
    pairs = 0
    for i in s:
        i = ''.join(sorted(list(i)))

        if i in ans:
            pairs += ans[i]
            ans[i] += 1
            continue

        ans[i] = 1

    print(pairs)


if __name__ == '__main__':
    main()