Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
 
N = int(input())
S = []
ans = [1] * N
for _ in range(N):
    s = Counter(input())
    for i in range(len(S)):
        if s == S[i]:
            ans[i] += 1
            break
    else:
        S.append(s)
        
print(sum(a * (a-1) // 2 for a in ans if a > 1))

Fixed submission:
from collections import Counter

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))

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

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))

Fixed submission:
from collections import Counter

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))

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

N = int(input())
S = []
ans = [1] * N
for _ in range(N):
    s = Counter(input())
    for i in range(len(S)):
        if s == S[i]:
            ans[i] += 1
            break
    else:
        S.append(s)

print(sum(a * (a-1) // 2 for a in ans if a > 1))

Fixed submission:
from collections import Counter

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))

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

N = int(input())
S = []
ans = [1] * N
for _ in range(N):
    s = input()
    s = Counter(s)
    for i in range(len(S)):
        if s == S[i]:
            ans[i] += 1
            break
    else:
        S.append(s)

answer = 0

for a in ans:
    if a > 1:
        answer += a * (a-1) / 2

print(int(answer))

Fixed submission:
from collections import Counter

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))

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

N = int(input())
S = []
for _ in range(N):
    s = input()
    S.append(Counter(s))

ans = 0

for j in range(N-1, 0, -1):
    for i in range(j-1, -1, -1):
        if S[j] == S[i]:
            ans += 1
        
print(ans)



Fixed submission:
from collections import Counter

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))

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

N = int(input())
S = []
for _ in range(N):
    s = input()
    S.append(Counter(s))

ans = 0

for j in range(N-1, 0, -1):
    for i in range(j-1, -1, -1):
        if S[j] == S[i]:
            ans += 1
        
print(ans)



Fixed submission:
from collections import Counter

N = int(input())
dic = {}

for _ in range(N):
    s = sorted(input())
    s = str(s)
    if s in dic.keys():
        dic[s] += 1
    else:
        dic[s] = 1

print(sum(d * (d-1) // 2 for d in dic.values() if d > 1))