Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
count=0
for i in range(n):
    d=input()
    d="".join(sorted(d))
    count+=a.count(d)
    a.append(d)
print(count)

Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
count=0
for i in range(n):
    d=input()
    d="".join(sorted(d))
    count+=a.count(d)
    a.append(d)
print(count)

Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    d=input()
    a.append("".join(sorted(d)))
#print(a)

count=0
for i in range(n):
    temp=a.pop()
    count+=a.count(temp)
print(count)


Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    d=input()
    a.append(sorted(d))
#print(a)

count=0
for i in range(n):
    temp=a.pop()
    count+=a.count(temp)
print(count)


Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    d=input()
    a.append(sorted(d))
#print(a)

count=0
for i in range(n):
    temp=a.pop()
    if temp in a:
        count+=a.count(temp)
print(count)


Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
for i in range(n):
    d=input()
    a.append(sorted(d))
#print(a)

count=0
for i in range(n):
    temp=a.pop()
    if temp in a:
        count+=a.count(temp)
print(count)


Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict as ddict

n=int(input())
a=[]
dict={}
for i in range(n):
    d=ddict(int)
    s=input()
    for x in s:
        d[x]+=1
    a.append(sorted(d.items()))
#print(a)

count=0
for i in range(n):
    temp=a.pop()
    if temp in a:
        count+=a.count(temp)
print(count)

Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict as ddict

n=int(input())
a=[]
dict={}
for i in range(n):
    d=ddict(int)
    s=input()
    for x in s:
        d[x]+=1
    a.append(sorted(d.items()))
#print(a)

count=0
for i in range(n):
    temp=a.pop()
    if temp in a:
        count+=a.count(temp)
print(count)

Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict as ddict

n=int(input())
a=[]
dict={}
for i in range(n):
    d=ddict(int)
    s=input()
    for x in s:
        d[x]+=1
    a.append(sorted(d.items()))
#print(a)

count=0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]==a[j]:
            count+=1

print(count)


Fixed submission:
from collections import Counter
n=int(input())
d=Counter()
ans=0
for i in range(n):
    t=str("".join(sorted(input())))
    if t in d:
        ans+=d[t]
    d[t]+=1
print(ans)