Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    s.sort()
    for i in range(n - 1):
        for j in range(i + 1, n):
            if s[i] == s[j]:
                ans += 1
            else:
                break
    print(ans)
  
  
def SortString(text):
    return "".join(sorted(list(text)))
  
  
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    sDictionary = {}
    for i in range(n):
        if sDictionary.get(s[i]):
            ans += sDictionary.get(s[i])
            sDictionary[s[i]] += 1
        else:
            sDictionary[s[i]] = 1
    print(ans)


def SortString(text):
    return "".join(sorted(list(text)))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
    def main():
        n = int(input())
        s = [""] * n
        ans = 0
        for i in range(n):
            s[i] = SortString(input())
        s.sort()
        for i in range(n - 1):
            for j in range(i + 1, n):
                if s[i] == s[j]:
                    ans += 1
                else:
                    break
        print(ans)
     
     
    def SortString(text):
        return "".join(sorted(list(text)))
     
     
    if __name__ == '__main__':
        main()

Fixed submission:
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    sDictionary = {}
    for i in range(n):
        if sDictionary.get(s[i]):
            ans += sDictionary.get(s[i])
            sDictionary[s[i]] += 1
        else:
            sDictionary[s[i]] = 1
    print(ans)


def SortString(text):
    return "".join(sorted(list(text)))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    s.sort()
    for i in range(n - 1):
        for j in range(i + 1, n):
            if s[i] == s[j]:
                ans += 1
            else:
                break
    print(ans)


def SortString(text):
    return "".join(sorted(list(text)))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    sDictionary = {}
    for i in range(n):
        if sDictionary.get(s[i]):
            ans += sDictionary.get(s[i])
            sDictionary[s[i]] += 1
        else:
            sDictionary[s[i]] = 1
    print(ans)


def SortString(text):
    return "".join(sorted(list(text)))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    s.sort()
    for i in range(n - 1):
        for j in range(i + 1, n):
            if s[i] == s[j]:
                ans += 1
            else:
                break
    print(ans)


def SortString(text):
    n = len(text)
    textList = [""] * n
    for i in range(len(text)):
        textList[i] = text[i]
    return "".join(sorted(textList))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    sDictionary = {}
    for i in range(n):
        if sDictionary.get(s[i]):
            ans += sDictionary.get(s[i])
            sDictionary[s[i]] += 1
        else:
            sDictionary[s[i]] = 1
    print(ans)


def SortString(text):
    return "".join(sorted(list(text)))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    for i in range(n - 1):
        for j in range(i + 1, n):
            if s[i] == s[j]:
                ans += 1
            else:
                continue
    print(ans)


def SortString(text):
    n = len(text)
    textList = [""] * n
    for i in range(len(text)):
        textList[i] = text[i]
    return "".join(sorted(textList))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    sDictionary = {}
    for i in range(n):
        if sDictionary.get(s[i]):
            ans += sDictionary.get(s[i])
            sDictionary[s[i]] += 1
        else:
            sDictionary[s[i]] = 1
    print(ans)


def SortString(text):
    return "".join(sorted(list(text)))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    for i in range(n - 1):
        for j in range(i + 1, n):
            if s[i] == s[j]:
                ans += 1
            else:
                continue
    print(ans)


def SortString(text):
    textList = []
    for i in range(len(text)):
        textList.append(text[i])
    return "".join(sorted(textList))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = [""] * n
    ans = 0
    for i in range(n):
        s[i] = SortString(input())
    sDictionary = {}
    for i in range(n):
        if sDictionary.get(s[i]):
            ans += sDictionary.get(s[i])
            sDictionary[s[i]] += 1
        else:
            sDictionary[s[i]] = 1
    print(ans)


def SortString(text):
    return "".join(sorted(list(text)))


if __name__ == '__main__':
    main()