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

result = 0
word_list = {}

for i in range(n):
    input_word = "".join(sorted(input()))
    flag = 1
    for this_word in word_list:
        if this_word == input_word:
            word_list[this_word] += 1
            result += word_list[this_word]
            flag = 0
            break
    if flag:
        word_list[input_word] = 0

print(result)

Fixed submission:
n = int(input())

result = 0
word_list = {}

for i in range(n):
    input_word = "".join(sorted(input()))
    flag = 1
    if input_word in word_list:
        word_list[input_word] += 1
        result += word_list[input_word]
        flag = 0
    else:
        word_list[input_word] = 0

print(result)

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

word_list = {}
for i in range(n):
    input_word = "".join(sorted(input()))
    flag = 1
    for this_word in word_list:
        if this_word == input_word:
            word_list[this_word] += 1
            flag = 0
            break
    if flag:
        word_list[input_word] = 0

result = 0
for index in word_list:
    cnt = word_list[index]
    result += int(cnt*(cnt+1)/2)
print(result)

Fixed submission:
n = int(input())

result = 0
word_list = {}

for i in range(n):
    input_word = "".join(sorted(input()))
    flag = 1
    if input_word in word_list:
        word_list[input_word] += 1
        result += word_list[input_word]
        flag = 0
    else:
        word_list[input_word] = 0

print(result)

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

def make_charcount(word):
    charcount = {}
    for c in word:
        if c not in charcount:
            charcount[c] = 1
        else:
            charcount[c] += 1
    return charcount

charcount_list_index = 0
charcount_list = {}
same_log = {}

for i in range(n):
    word = input()
    this_charcount = make_charcount(word)
    index = -1
    for i in charcount_list:
        if charcount_list[i] == this_charcount:
            index = i
            break
    if index != -1:
        if index not in same_log:
            same_log[index] = 1
        else:
            same_log[index] += 1
    else:
        charcount_list[charcount_list_index] = this_charcount
        charcount_list_index += 1

result = 0
for index in same_log:
    cnt = same_log[index]
    result += int(cnt*(cnt+1)/2)
print(result)

Fixed submission:
n = int(input())

result = 0
word_list = {}

for i in range(n):
    input_word = "".join(sorted(input()))
    flag = 1
    if input_word in word_list:
        word_list[input_word] += 1
        result += word_list[input_word]
        flag = 0
    else:
        word_list[input_word] = 0

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
word_list = [input() for i in range(n)]

def make_charcount(word):
    charcount = {}
    for c in word:
        if c not in charcount:
            charcount[c] = 1
        else:
            charcount[c] += 1
    return charcount

charcount_list = {}
charcount_list_index = 0
same_log = {}
for word in word_list:
    this_charcount = make_charcount(word)
    index = -1
    for i in charcount_list:
        if charcount_list[i] == this_charcount:
            index = i
            break
    if index != -1:
        if index not in same_log:
            same_log[index] = 1
        else:
            same_log[index] += 1
    else:
        charcount_list[charcount_list_index] = this_charcount
        charcount_list_index += 1
        
result = 0
for index in same_log:
    cnt = same_log[index]
    result += int(cnt*(cnt+1)/2)
print(result)

Fixed submission:
n = int(input())

result = 0
word_list = {}

for i in range(n):
    input_word = "".join(sorted(input()))
    flag = 1
    if input_word in word_list:
        word_list[input_word] += 1
        result += word_list[input_word]
        flag = 0
    else:
        word_list[input_word] = 0

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
word_list = [input() for i in range(n)]

def make_charcount(word):
    charcount = {}
    for c in word:
        if c not in charcount:
            charcount[c] = 1
        else:
            charcount[c] += 1
    return charcount

charcount_list = [make_charcount(word) for word in word_list]

result = 0
while(len(charcount_list)):
    charcount = charcount_list.pop()
    result += len([1 for c in charcount_list if charcount == c])

print(result)

Fixed submission:
n = int(input())

result = 0
word_list = {}

for i in range(n):
    input_word = "".join(sorted(input()))
    flag = 1
    if input_word in word_list:
        word_list[input_word] += 1
        result += word_list[input_word]
        flag = 0
    else:
        word_list[input_word] = 0

print(result)