Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
my_list = [None] * N
for i in range(N):
    s_i = input()
    my_dict = {}
    for j in range(10):
        if s_i[j] in my_dict:
            my_dict[s_i[j]] += 1
        else:
            my_dict[s_i[j]] = 1
    my_list[i] = my_dict
sum = 0
trash = []
for i in range(N - 1):
    if i in trash:
        continue
    num = 0
    a = 0
    for j in range(i + 1, N):
        if my_list[i] == my_list[j]:
            num += 1
            trash.append(j)
    for j in range(1, num + 1):
        a += j
    sum += a
print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
my_list = [None] * N
for i in range(N):
    s_i = input()
    my_dict = {}
    for j in range(10):
        if s_i[j] in my_dict:
            my_dict[s_i[j]] += 1
        else:
            my_dict[s_i[j]] = 1
    my_list[i] = my_dict
sum = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if my_list[i] == my_list[j]:
            sum += 1
print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
my_list = [None] * N
for i in range(N):
    s_i = sorted(list(input()))
    my_list[i] = s_i
sum = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if my_list[i] == my_list[j]:
            sum += 1
print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
my_list = [None] * N
for i in range(N):
    s_i = sorted(list(input()))
    my_list[i] = s_i
sum = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(10):
            if not(my_list[i][k] == my_list[j][k]):
                break
            elif k == 9:
                sum += 1
print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
my_list = [None] * N
for i in range(N):
    s_i = sorted(input())
    my_list[i] = s_i
sum = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(10):
            if not(my_list[i][k] == my_list[j][k]):
                break
            elif k == 9:
                sum += 1
print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)

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

my_list = [None] * N

for i in range(N):
    s_i = sorted(input())
    my_list[i] = s_i

sum = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(10):
            if not(my_list[i][k] == my_list[j][k]):
                break
            elif k == 9:
                sum += 1


print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)

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

my_list = [None] * N

for i in range(N):
    s_i = sorted(input())
    my_list[i] = s_i

sum = 0

for i in range(N):
    for j in range(i + 1, N):
        if my_list[i] == my_list[j]:
            sum += 1

print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)

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

my_list = [None] * N

for i in range(N):
    s_i = input()
    my_dict = {}
    for j in range(10):
        if s_i[j] in my_dict:
            my_dict[s_i[j]] += 1
        else:
            my_dict[s_i[j]] = 1
    my_dict = sorted(my_dict.items())
    my_list[i] = my_dict

sum = 0

for i in range(N):
    num = 0
    for j in range(i + 1, N):
        if my_list[i] == my_list[j]:
            num += 1
    sum += num

print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)

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

my_list = []

for i in range(N):
    s_i = input()
    my_dict = {}
    for j in range(10):
        if s_i[j] in my_dict:
            my_dict[s_i[j]] += 1
        else:
            my_dict[s_i[j]] = 1
    my_dict = sorted(my_dict.items())
    my_list.append(my_dict)

sum = 0

for i in range(N):
    num = 0
    for j in range(i + 1, N):
        if my_list[i] == my_list[j]:
            num += 1
    sum += num

print(sum)


Fixed submission:
n = int(input())
dict = {}
ans = 0

for i in range(n):
    s = str(sorted(input()))
    if s in dict.keys():
        ans += dict[s]
        dict[s] += 1
    else:
        dict[s] = 1
print(ans)