Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
r = [[0 for _ in range(26)] for i in range(n)]
for i in range(n):
    s = str(input())
    for j in range(10):
        r[i][ord(s[j])-97] += 1
w = []
cnt = []
for i in range(n):
    if r[i] in w:
        cnt[w.index(r[i])] += 1
    else:
        w.append(r[i])
        cnt.append(1)
ans = 0
for i in range(len(cnt)):
    ans += (cnt[i]*(cnt[i]-1))//2
print(ans)

Fixed submission:
n = int(input())
s = [str(input()) for _ in range(n)]
e = []
for i in range(n):
    e.append("".join(sorted(s[i])))
e.sort()
g = [1]
for i in range(n-1):
    if e[i] != e[i+1]:
        g.append(1)
    else:
        g[-1] += 1
ans = 0
for i in g:
    ans += (i*(i-1)//2)
print(ans)

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

Fixed submission:
n = int(input())
s = [str(input()) for _ in range(n)]
e = []
for i in range(n):
    e.append("".join(sorted(s[i])))
e.sort()
g = [1]
for i in range(n-1):
    if e[i] != e[i+1]:
        g.append(1)
    else:
        g[-1] += 1
ans = 0
for i in g:
    ans += (i*(i-1)//2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    s.append(sorted(str(input())))
r = []
g = []
for i in range(n):
    if(s[i] in r):
        g[r.index(s[i])] += 1
    else:
        r.append(s[i])
        g.append(1)
ans = 0
for i in range(len(g)):
    ans += max(((g[i])*(g[i]-1))//2,0)
print(ans)

Fixed submission:
n = int(input())
s = [str(input()) for _ in range(n)]
e = []
for i in range(n):
    e.append("".join(sorted(s[i])))
e.sort()
g = [1]
for i in range(n-1):
    if e[i] != e[i+1]:
        g.append(1)
    else:
        g[-1] += 1
ans = 0
for i in g:
    ans += (i*(i-1)//2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))
    s[i] = sorted(s[i])
r = []
g = []
for i in range(n):
    if(s[i] in r):
        g[r.index(s[i])] += 1
    else:
        r.append(s[i])
        g.append(1)
ans = 0
for i in range(len(g)):
    ans += max(((g[i])*(g[i]-1))//2,0)
print(ans)

Fixed submission:
n = int(input())
s = [str(input()) for _ in range(n)]
e = []
for i in range(n):
    e.append("".join(sorted(s[i])))
e.sort()
g = [1]
for i in range(n-1):
    if e[i] != e[i+1]:
        g.append(1)
    else:
        g[-1] += 1
ans = 0
for i in g:
    ans += (i*(i-1)//2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))
    s[i] = sorted(s[i])
r = []
g = []
for i in range(n):
    if(s[i] in r):
        g[r.index(s[i])] += 1
    else:
        r.append(s[i])
        g.append(1)
ans = 0
for i in range(len(g)):
    ans += max(((g[i])*(g[i]-1))//2,0)
print(ans)

Fixed submission:
n = int(input())
s = [str(input()) for _ in range(n)]
e = []
for i in range(n):
    e.append("".join(sorted(s[i])))
e.sort()
g = [1]
for i in range(n-1):
    if e[i] != e[i+1]:
        g.append(1)
    else:
        g[-1] += 1
ans = 0
for i in g:
    ans += (i*(i-1)//2)
print(ans)