Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=[]
for i in range(N):
  S=input()
  tmp=[0]*26
  for s in S:
    tmp[ord(s)-ord('a')]+=1
  L.append(tmp)
ans=0
for i in range(N):
  for j in range(i+1,N):
    if L[i]==L[j]:
      ans+=1
print(ans)

Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=[[0]*26 for _ in range(N)]
a=ord('a')
for i in range(N):
  s=input()
  for c in s:
    L[i][ord(c)-a]+=1
count = 0
for i in range(N-1):
  for j in range(i+1,N):
    if L[i] == L[j]:
      count+=1
print(count)

Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy python submission (verdict: Runtime Error):
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d
        d+=1
    else:
        d[s]=1
print(rslt)


Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = []
for _ in range(n):
    sl.append(input())
rl=[]
ll=[]
rslt=0
for i in range(n):
    r=sorted(sl[i])
    if r in rl: tmp=rl.index(r); ll[tmp]+=1; rslt+=ll[tmp]
    else: rl.append(r); ll.append(0)
print(rslt)


Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = []
for _ in range(n):
    sl.append(input())
rl=[]
ll=[]
rslt=0
for i in range(n):
    r=sorted(sl[i])
    if r in rl: ll[rl.index(r)]+=1; rslt+=ll[rl.index(r)]
    else: rl.append(r); ll.append(0)
print(rslt)


Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = []
for _ in range(n):
    sl.append(input())
rl=[]
ll=[]
for i in range(n):
    r=sorted(sl[i])
    if r in rl: ll[rl.index(r)]+=1
    else: rl.append(r); ll.append(0)
rslt=0
for i in ll:
    if not i==0: rslt+=((1+i)*i >> 1)
print(rslt)


Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = []
for _ in range(n):
    sl.append(input())
rl=[]
ll=[]
for i in range(n):
    r=sorted(sl[i])
    if r in rl: ll[rl.index(r)]+=1
    else: rl.append(r); ll.append(0)
rslt=0
for i in ll:
    if not i==0: rslt+=((1+i)*i >> 1)
print(rslt)


Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = []
for _ in range(n):
    sl.append(input())
rl=[[0 for _ in range(26)] for _ in range(n)]
for i in range(n):
    for c in sl[i]:
        a=ord(c)-ord('a')
        rl[i][a]+=1
rslt=0
for i in range(n-1):
    for j in range(i+1,n):
        if rl[i] == rl[j]: rslt+=1
print(rslt)


Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = []
for _ in range(n):
    sl.append(input())
rl=[[0 for _ in range(26)] for _ in range(n)]
for i in range(n):
    for c in sl[i]:
        a=ord(c)-ord('a')
        rl[i][a]+=1
rslt=0
for i in range(n-1):
    for j in range(i+1,n):
        if rl[i] == rl[j]: rslt+=1
print(rslt)


Fixed submission:
n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)