Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())

#ss = [sorted(list(input())) for _ in range(n)]
ss = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    ss.append(str(tmp))

checked = set()
count = 0

for i, t_ss in enumerate(ss[:-1]):
    if t_ss in checked:
        continue
    checked.add(t_ss)
    add_count = 1
    for t_j_ss in ss[i+1:]:
        if t_ss == t_j_ss:
            count += add_count
            add_count += 1

print(count)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())

#ss = [sorted(list(input())) for _ in range(n)]
ss = []
checked = {}
count = 0
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = str(tmp)
    if not(tmp in checked):
        checked[tmp] = 1
    else:
        count += checked[tmp]
        checked[tmp] += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())

ss = [sorted(list(input())) for _ in range(n)]
'''
ss = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    ss.append(tmp)
'''

checked = set()
count = 0

for i in range(n-1):
    if i in checked:
        continue
    same_str = set()
    for j in range(i+1, n):
        if ss[i] == ss[j]:
            count += 1

            for s in same_str:
                count += 1

            same_str.add(j)
            checked.add(j)

print(count)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())

#ss = [sorted(list(input())) for _ in range(n)]
ss = []
checked = {}
count = 0
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = str(tmp)
    if not(tmp in checked):
        checked[tmp] = 1
    else:
        count += checked[tmp]
        checked[tmp] += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())

ss = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    ss.append(tmp)

checked = set()
count = 0

for i in range(n-1):
    if i in checked:
        continue
    same_str = set()
    for j in range(i+1, n):
        if ss[i] == ss[j]:
            count += 1

            for s in same_str:
                count += 1

            same_str.add(j)
            checked.add(j)

print(count)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())

#ss = [sorted(list(input())) for _ in range(n)]
ss = []
checked = {}
count = 0
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = str(tmp)
    if not(tmp in checked):
        checked[tmp] = 1
    else:
        count += checked[tmp]
        checked[tmp] += 1

print(count)

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

ss = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    ss.append(tmp)

checked = set()
count = 0

for i in range(n-1):
    if i in checked:
        continue
    same_str = set()
    for j in range(i+1, n):
        if ss[i] == ss[j]:
            count += 1

            for s in same_str:
                count += 1

            same_str.add(j)
            checked.add(j)

print(count)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())

#ss = [sorted(list(input())) for _ in range(n)]
ss = []
checked = {}
count = 0
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = str(tmp)
    if not(tmp in checked):
        checked[tmp] = 1
    else:
        count += checked[tmp]
        checked[tmp] += 1

print(count)

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

ss = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    ss.append(tmp)

matrix = [[0 for _ in range(n)] for _ in range(n)]
checked = set()

for i in range(n-1):
    if i in checked:
        continue
    same_str = set()
    for j in range(i+1, n):
        if ss[i] == ss[j]:
            matrix[i][j] = 1

            for s in same_str:
                matrix[s][j] = 1

            same_str.add(j)
            checked.add(j)

count = 0
for row in matrix:
    count += sum(row)

print(count)

Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())

#ss = [sorted(list(input())) for _ in range(n)]
ss = []
checked = {}
count = 0
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = str(tmp)
    if not(tmp in checked):
        checked[tmp] = 1
    else:
        count += checked[tmp]
        checked[tmp] += 1

print(count)

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

ss = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    ss.append(tmp)
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        if ss[i] == ss[j]:
            count += 1

print(count)


Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())

#ss = [sorted(list(input())) for _ in range(n)]
ss = []
checked = {}
count = 0
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = str(tmp)
    if not(tmp in checked):
        checked[tmp] = 1
    else:
        count += checked[tmp]
        checked[tmp] += 1

print(count)