Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)

#出現文字列
sdict = {}

ans = 0

for i in range(N):

    s_i = str(s[i])

    if s_i in sdict:
        #組み合わせが増えるので
        sdict[s_i]+= 1
        continue

    for j in range(i+1,N):
        sdict[s_i] = 1

for i in sdict.values():
    ans += i*(i-1)//2

print(ans)


Fixed submission:
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)

#出現文字列
sdict = {}

for i in range(N):

    s_i = str(s[i])

    if s_i in sdict:
        #組み合わせが増えるので
        sdict[s_i]+= 1
        continue

    else:
        sdict[s_i] = 1

ans = 0
for i in sdict.values():
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = ["".join(sorted(list(input()))) for i in range(N)]

#出現文字列
sdict = {}

ans = 0

for i in range(N):

    s_i = str(s[i])

    if s_i in sdict:
        #組み合わせが増えるので
        sdict[s_i]+= 1
        continue

    for j in range(i+1,N):
        sdict[s_i] = 1

for i in sdict.values():
    ans += i*(i-1)//2

print(ans)


Fixed submission:
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)

#出現文字列
sdict = {}

for i in range(N):

    s_i = str(s[i])

    if s_i in sdict:
        #組み合わせが増えるので
        sdict[s_i]+= 1
        continue

    else:
        sdict[s_i] = 1

ans = 0
for i in sdict.values():
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = ["".join(sorted(list(input()))) for i in range(N)]

#出現文字列
dict = {}

ans = 0

for i in range(N):

    s_i = str(s[i])

    if s_i in dict:
        #組み合わせが増えるので
        dict[s_i]+= 1

        ans += dict[s_i]
        continue

    for j in range(i+1,N):
        dict[s_i] = 0

print(ans)


Fixed submission:
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)

#出現文字列
sdict = {}

for i in range(N):

    s_i = str(s[i])

    if s_i in sdict:
        #組み合わせが増えるので
        sdict[s_i]+= 1
        continue

    else:
        sdict[s_i] = 1

ans = 0
for i in sdict.values():
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [sorted(list(input())) for i in range(N)]

#出現文字列
dict = {}

ans = 0

for i in range(N):

    s_i = str(s[i])

    if s_i in dict:
        #組み合わせが増えるので
        dict[s_i] = dict[s_i] + 1

        ans += dict[s_i]
        continue

    for j in range(i+1,N):
        dict[s_i] = 0

print(ans)


Fixed submission:
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)

#出現文字列
sdict = {}

for i in range(N):

    s_i = str(s[i])

    if s_i in sdict:
        #組み合わせが増えるので
        sdict[s_i]+= 1
        continue

    else:
        sdict[s_i] = 1

ans = 0
for i in sdict.values():
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [sorted(list(input())) for i in range(N)]
s.sort()

#[print(i) for i in s]

ans = 0

for i in range(N):
    for j in range(i+1,N):
        if s[i] == s[j]:
            #print("s[" + str(i)+"]" + " = s[" + str(j)+"]" )
            ans+=1

if not ans == 0:
    print(ans)
else:
    print(0)


Fixed submission:
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)

#出現文字列
sdict = {}

for i in range(N):

    s_i = str(s[i])

    if s_i in sdict:
        #組み合わせが増えるので
        sdict[s_i]+= 1
        continue

    else:
        sdict[s_i] = 1

ans = 0
for i in sdict.values():
    ans += i*(i-1)//2
print(ans)