Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        shurui = 1
        if anagramed[i]:
            continue
        else:
            for j in range(i+1, n):
                if anagramed[j]:
                    continue
                elif is_anagram(m[i], m[j]):
                    shurui += 1
                    anagramed[i] = True
                    anagramed[j] = True
        if shurui > 1:
            count += int(math.factorial(shurui) / 2)
    print(count)


def is_anagram(s1, s2):
    s1_length = len(s1)
    s2_length = len(s2)
    if s1_length != s2_length:
        return False
    else:
        for index in range(s1_length):
            search_char = s1[index: index+1]
            search_result = s2.find(search_char)
            if search_result == -1:
                return False
            else:
                s2 = s2.replace(search_char, "", 1)
    return True

main()

Fixed submission:
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    r = {}
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        s = "".join(sorted(m[i]))
        if r.get(s) is None :
            r[s] = 1
        else:
            count += r[s]
            r[s] += 1
    print(count)


main()

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        shurui = 1
        if anagramed[i]:
            pass
        else:
            for j in range(i+1, n):
                if anagramed[j]:
                    pass
                elif is_anagram(m[i], m[j]):
                    shurui += 1
                    anagramed[i] = True
                    anagramed[j] = True
        if shurui > 1:
            count += int(math.factorial(shurui) / 2)
    print(count)


def check_dp(i, j):
    length_dp2 = len(dp2[i])
    if length_dp2 == 0:
        return False
    else:
        if j in dp2[i]:
            return True


def is_anagram(s1, s2):
    s1_length = len(s1)
    s2_length = len(s2)
    if s1_length != s2_length:
        return False
    else:
        for index in range(s1_length):
            search_char = s1[index: index+1]
            search_result = s2.find(search_char)
            if search_result == -1:
                return False
            else:
                s2 = s2.replace(search_char, "", 1)
    return True

main()

Fixed submission:
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    r = {}
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        s = "".join(sorted(m[i]))
        if r.get(s) is None :
            r[s] = 1
        else:
            count += r[s]
            r[s] += 1
    print(count)


main()

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8


def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    count = 0
    for _ in range(n):
        m.append(input())
    for i in range(n):
        for j in range(i+1, n):
            if is_anagram(m[i], m[j]):
                count += 1
    print(count)


def is_anagram(s1, s2):
    s1_length = len(s1)
    s2_length = len(s2)
    if s1_length != s2_length:
        return False
    else:
        for index in range(s1_length):
            search_char = s1[index: index+1]
            search_result = s2.find(search_char)
            if search_result == -1:
                return False
            else:
                s2 = s2.replace(search_char, "", 1)
    return True

main()

Fixed submission:
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    r = {}
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        s = "".join(sorted(m[i]))
        if r.get(s) is None :
            r[s] = 1
        else:
            count += r[s]
            r[s] += 1
    print(count)


main()