Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
lst = [input() for _ in range(n)]

counter_lst = []
counter_num = []
res = 0
for i in range(n):
    a = Counter(lst[i])
    if a in counter_lst:
        m = counter_lst.index(a)
        counter_num[m] += 1
        res += counter_num[m]
    else:
        counter_lst.append(a)
        counter_num.append(0)
    
print(res)

Fixed submission:
n = int(input())
lst = [input() for _ in range(n)]

dic = dict()
res = 0
for i in range(n):
    sorted_string = "".join(sorted(lst[i]))
    if sorted_string in dic:
        dic[sorted_string] += 1
        res += dic[sorted_string]
    else:
        dic[sorted_string] = 0
    
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
lst = [input() for _ in range(n)]

counter_lst = []
counter_num = []
for i in range(n):
    a = Counter(lst[i])
    if a in counter_lst:
        m = counter_lst.index(a)
        counter_num[m] += 1
    else:
        counter_lst.append(a)
        counter_num.append(1)
    
res = 0
for i in counter_num:
    if i > 1:
        res += i * (i-1) // 2
print(res)

Fixed submission:
n = int(input())
lst = [input() for _ in range(n)]

dic = dict()
res = 0
for i in range(n):
    sorted_string = "".join(sorted(lst[i]))
    if sorted_string in dic:
        dic[sorted_string] += 1
        res += dic[sorted_string]
    else:
        dic[sorted_string] = 0
    
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
lst = [input() for _ in range(n)]

counter_lst = []
counter_num = []
for i in range(n):
    a = Counter(lst[i])
    if a in counter_lst:
        m = counter_lst.index(a)
        counter_num[m] += 1
    else:
        counter_lst.append(a)
        counter_num.append(1)
    
res = 0
for i in counter_num:
    if i > 0:
        res += i * (i-1) // 2
print(res)

Fixed submission:
n = int(input())
lst = [input() for _ in range(n)]

dic = dict()
res = 0
for i in range(n):
    sorted_string = "".join(sorted(lst[i]))
    if sorted_string in dic:
        dic[sorted_string] += 1
        res += dic[sorted_string]
    else:
        dic[sorted_string] = 0
    
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
lst = [input() for _ in range(n)]

counter_lst = []
counter_num = []
for i in range(n):
    a = Counter(lst[i])
    if a in counter_lst:
        m = counter_lst.index(a)
        counter_num[m] += 1
    else:
        counter_lst.append(a)
        counter_num.append(1)
    
res = 0
for i in counter_num:
    if i > 0:
        res += i * (i-1) // 2
print(res)

Fixed submission:
n = int(input())
lst = [input() for _ in range(n)]

dic = dict()
res = 0
for i in range(n):
    sorted_string = "".join(sorted(lst[i]))
    if sorted_string in dic:
        dic[sorted_string] += 1
        res += dic[sorted_string]
    else:
        dic[sorted_string] = 0
    
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
lst = [input() for _ in range(n)]

counter_lst = []
counter_num = [0] * n
for i in range(n):
    a = Counter(lst[i])
    if a in counter_lst:
        m = counter_lst.index(a)
        counter_num[m] += 1
        counter_lst.append(0)
    else:
        counter_lst.append(a)
        counter_num[i] = 1
    
res = 0
for i in counter_num:
    if i > 0:
        res += i * (i-1) // 2
print(res)

Fixed submission:
n = int(input())
lst = [input() for _ in range(n)]

dic = dict()
res = 0
for i in range(n):
    sorted_string = "".join(sorted(lst[i]))
    if sorted_string in dic:
        dic[sorted_string] += 1
        res += dic[sorted_string]
    else:
        dic[sorted_string] = 0
    
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = [input() for _ in range(n)]

counter_lst = []
counter_num = [0] * n
for i in range(n):
    a = Counter(lst[i])
    if a in counter_lst:
        m = counter_lst.index(a)
        counter_num[m] += 1
        counter_lst.append(0)
    else:
        counter_lst.append(a)
        counter_num[i] = 1
    
res = 0
for i in counter_num:
    if i > 0:
        res += i * (i-1) // 2
print(res)

Fixed submission:
n = int(input())
lst = [input() for _ in range(n)]

dic = dict()
res = 0
for i in range(n):
    sorted_string = "".join(sorted(lst[i]))
    if sorted_string in dic:
        dic[sorted_string] += 1
        res += dic[sorted_string]
    else:
        dic[sorted_string] = 0
    
print(res)