Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = []
n_list = []
ana = 0
for i in range(n):
    s = "".join(sorted(input()))
    #print(s)
    if len(s_list) > 0:
        for num, s_i in enumerate(s_list):
            is_exist = False
            if s_i == s:
                n_list[num] += 1
                ana += n_list[num]
                is_exist = True
                break
        if not is_exist:
            s_list.append(s)
            n_list.append(0)
    else:
        s_list.append(s)
        n_list.append(0)

print(int(ana))

Fixed submission:
n = int(input())
s_dict = {}
ana = 0
for i in range(n):
    s = "".join(sorted(input()))
    #print(s)
    if s in s_dict:
        ana += s_dict[s]
        s_dict[s] += 1
    else:
        s_dict[s] = 1
        
print(ana)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = []
n_list = []
ana = 0
for i in range(n):
    s = sorted(input())
    #print(s)
    if len(s_list) > 0:
        for num, s_i in enumerate(s_list):
            is_exist = False
            if s_i == s:
                n_list[num] += 1
                ana += n_list[num]
                is_exist = True
                break
        if not is_exist:
            s_list.append(s)
            n_list.append(0)
    else:
        s_list.append(s)
        n_list.append(0)

print(int(ana))

Fixed submission:
n = int(input())
s_dict = {}
ana = 0
for i in range(n):
    s = "".join(sorted(input()))
    #print(s)
    if s in s_dict:
        ana += s_dict[s]
        s_dict[s] += 1
    else:
        s_dict[s] = 1
        
print(ana)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = []
n_list = []
ana = 0
for i in range(n):
    s = sorted(input())
    #print(s)
    if len(s_list) > 0:
        for num, s_i in enumerate(s_list):
            is_exist = False
            if s_i == s:
                n_list[num] += 1
                ana += n_list[num]
                is_exist = True
                break
        if not is_exist:
            s_list.append(s)
            n_list.append(0)
    else:
        s_list.append(s)
        n_list.append(0)



print(int(ana))

Fixed submission:
n = int(input())
s_dict = {}
ana = 0
for i in range(n):
    s = "".join(sorted(input()))
    #print(s)
    if s in s_dict:
        ana += s_dict[s]
        s_dict[s] += 1
    else:
        s_dict[s] = 1
        
print(ana)

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

n = int(input())
s_list = []
n_list = []
ana = 0
for i in range(n):
    s = sorted(input())
    #print(s)
    if len(s_list) > 0:
        for num, s_i in enumerate(s_list):
            is_exist = False
            if s_i == s:
                n_list[num] += 1
                is_exist = True
                break
        if not is_exist:
            s_list.append(s)
            n_list.append(0)
    else:
        s_list.append(s)
        n_list.append(0)


for n_i in n_list:
    if n_i > 0:
        if n_i == 1:
            ana += 1
        else:
            ana += math.factorial(n_i+1) / math.factorial(n_i-1) / 2
print(int(ana))

Fixed submission:
n = int(input())
s_dict = {}
ana = 0
for i in range(n):
    s = "".join(sorted(input()))
    #print(s)
    if s in s_dict:
        ana += s_dict[s]
        s_dict[s] += 1
    else:
        s_dict[s] = 1
        
print(ana)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = []
ana = 0
for i in range(n):
    s = sorted(input())
    if len(s_list) > 0:
        for s_i in s_list:
            if s_i == s:
                ana += 1
    s_list.append(s)
print(ana)

Fixed submission:
n = int(input())
s_dict = {}
ana = 0
for i in range(n):
    s = "".join(sorted(input()))
    #print(s)
    if s in s_dict:
        ana += s_dict[s]
        s_dict[s] += 1
    else:
        s_dict[s] = 1
        
print(ana)