Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
lst = []
num = [1]*n
ans = 0
lst_append = lst.append
s_all = [sorted(input()) for _ in range(n)]
for s in s_all:
    if s not in lst:
        lst_append(s)
    else:
        pos = lst.index(s)
        ans += num[pos]
        num[pos] += 1

print(int(ans))

Fixed submission:
from collections import defaultdict
N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
lst = []
num = [1]*n
ans = 0
lst_append = lst.append
s_all = [sorted(input()) for _ in range(n)]
for s in s_all:
    if s not in lst:
        lst_append(s)
    else:
        pos = lst.index(s)
        num[pos] += 1
for j in num:
    ans += (j * (j-1)) / 2
print(int(ans))

Fixed submission:
from collections import defaultdict
N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
lst = []
num = [1]*n
ans = 0
lst_append = lst.append
for i in range(n):
    s = sorted(input())
    s = "".join(s)
    if s not in lst:
        lst_append(s)
    else:
        pos = lst.index(s)
        num[pos] += 1
for j in num:
    ans += (j * (j-1)) / 2
print(int(ans))

Fixed submission:
from collections import defaultdict
N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = []
num = [1]*n
ans = 0
for i in range(n):
    s = sorted(input())
    s = "".join(s)
    if s not in lst:
        lst.append(s)
    else:
        pos = lst.index(s)
        num[pos] += 1
for j in num:
    ans += (j * (j-1)) / 2
print(int(ans))

Fixed submission:
from collections import defaultdict
N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = []
num = [1]*n
ans = 0
for i in range(n):
    s = sorted(input())
    s = "".join(s)
    if s not in lst:
        lst.append(s)
    else:
        pos = lst.index(s)
        num[pos] += 1
for j in num:
    ans += (j * (j-1)) / 2
print(int(ans))

Fixed submission:
from collections import defaultdict
N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = []
num = [1]*n
ans = 0
for i in range(n):
    s = sorted(input())
    if s not in lst:
        lst.append(s)
    else:
        pos = lst.index(s)
        num[pos] += 1
for j in num:
    ans += (j * (j-1)) / 2
print(int(ans))

Fixed submission:
from collections import defaultdict
N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)