Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)
L = set(S)
L = list(L)
L_cnt = [0 for i in range(len(L))]
for i in S:
    L_cnt[L.index(i)]+=1
for i in range(len(L)):
    ans+=((L_cnt[i])*(L_cnt[i]-1))//2
print(ans)

Fixed submission:
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)

S.sort()

cnt = 0
ans = 0

for i in range(N):
    if i == 0 or S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        cnt = 1
ans += cnt*(cnt-1)//2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)
L = set(S)
L = list(L)
L_cnt = [0 for i in range(len(L))]
for i in S:
    L_cnt[L.index(i)]+=1
for i in range(len(L)):
    ans+=((L_cnt[i])*(L_cnt[i]-1))//2
print(ans)

Fixed submission:
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)

S.sort()

cnt = 0
ans = 0

for i in range(N):
    if i == 0 or S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        cnt = 1
ans += cnt*(cnt-1)//2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)
L = set(S)
L = list(L)
L_cnt = [0 for i in range(len(L))]
for i in S:
    L_cnt[L.index(i)]+=1
L_ans = [((L_cnt[i])*(L_cnt[i]-1))//2 for i in range(len(L))]
print(sum(L_ans))

Fixed submission:
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)

S.sort()

cnt = 0
ans = 0

for i in range(N):
    if i == 0 or S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        cnt = 1
ans += cnt*(cnt-1)//2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)
L = set(S)
L = list(L)
L_cnt = [0 for i in range(len(L))]
for i in S:
    L_cnt[L.index(i)]+=1
L_ans = [((L_cnt[i])*(L_cnt[i]-1))//2 for i in range(len(L))]
print(sum(L_ans))

Fixed submission:
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)

S.sort()

cnt = 0
ans = 0

for i in range(N):
    if i == 0 or S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        cnt = 1
ans += cnt*(cnt-1)//2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
cnt = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    S.append(tmp)
for i in range(N-1):
    for j in range(i+1,N):
        if S[i]==S[j]:
            cnt+=1
print(cnt)

Fixed submission:
N = int(input())
S = []
ans = 0
for i in range(N):
    tmp = list(input())
    tmp.sort()
    tmp = "".join(tmp)
    S.append(tmp)

S.sort()

cnt = 0
ans = 0

for i in range(N):
    if i == 0 or S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        cnt = 1
ans += cnt*(cnt-1)//2
    
print(ans)