Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ss = []
ht = []
ans = 0

for i in range(N):
    s = sorted(input())
    if not s in ss:
        ss.append(s)
        ht.append(1)
    else:
        ans += ht[ss.index(s)]
        ht[ss.index(s)] += 1

print(ans)


Fixed submission:
N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
abc = [chr(i) for i in range(97, 97+26)]
ss = []
ct = []
ans = 0

for i in range(N):
    s = input()
    cnt = []
    for j in abc:
        num = s.count(j)
        cnt.append(num)
    if not cnt in ss:
        ss.append(cnt)
        ct.append(1)
    else:
        ans += ct[ss.index(cnt)]
        ct[ss.index(cnt)] += 1

print(ans)


Fixed submission:
N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
abc = [chr(i) for i in range(97, 97+26)]
ss = []
ct = []
ans = 0

for i in range(N):
    s = input()
    cnt = [0]*26
    for j in s:
        cnt[abc.index(j)] += 1
    if not cnt in ss:
        ss.append(cnt)
        ct.append(1)
    else:
        ct[ss.index(cnt)] += 1

for i in range(len(ct)):
    if ct[i] > 1:
        ans += int((ct[i] * (ct[i] - 1))/2)


print(ans)


Fixed submission:
N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
abc = [chr(i) for i in range(97, 97+26)]
ss = []
ct = []
ans = 0

for i in range(N):
    s = input()
    cnt = []
    for j in abc:
        num = s.count(j)
        cnt.append(num)
    if not cnt in ss:
        ss.append(cnt)
        ct.append(1)
    else:
        ct[ss.index(cnt)] += 1

for i in range(len(ct)):
    if ct[i] > 1:
        ans += int((ct[i] * (ct[i] - 1))/2)


print(ans)


Fixed submission:
N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
abc = [chr(i) for i in range(97, 97+26)]
ss = []

for i in range(N):
    s = input()
    cnt = []
    for j in abc:
        num = s.count(j)
        cnt.append(num)
    ss.append(cnt)

ans = 0

for i in ss:
    k = ss.count(i)
    ans += k-1

print(int(ans/2))


Fixed submission:
N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

print(ans)

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

for i in range(N):
    ss.append(sorted(input()))
    
ans = 0

for i in ss:
    k = ss.count(i)
    ans += k-1

print(int(ans/2))


Fixed submission:
N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

print(ans)

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

for i in range(N):
    ss.append(sorted(input()))
    
ans = []

for i in ss:
    k = ss.count(i)
    ans.append(k-1)

print(int(sum(ans)/2))


Fixed submission:
N = int(input())
ss = {}
ht = []
ans = 0

for i in range(N):
    s = ''.join(sorted(input()))
    if not s in ss.keys():
        ss[s] = 1
    else:
        ans += ss[s]
        ss[s] += 1

print(ans)