Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
B=[]
ans=0
for i in range(N):
    x="".join(sorted(input()))
    if x in A:
      ii=A.index(x)
      B[ii]+=1
    else:
      A.append(x)
      B.append(1)
ans=0
for b in B:
  ans+=(b-1)*(b)/2
print(int(ans))





Fixed submission:
N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = []
B=[]
ans=0
for i in range(N):
    x=collections.Counter(list(input()))
    if x in A:
      ii=A.index(x)
      B[ii]+=1
    else:
      A.append(x)
      B.append(1)
ans=0
for b in B:
  ans+=(b-1)*(b)/2
print(int(ans))




Fixed submission:
N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
ans=0
N = int(input())
A=[]
for i In range(N):
    x=collections.Counter(list(input()))
    for s in A:
        if x==s:
            ans+=1
        else:
            A.append(x)
print(ans)

Fixed submission:
N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = [collections.Counter(list(input())) for i in range(N)]
ans=0
for i in range(N):
    for j in range(i+1,N):
        if A[i]==A[j]:
            ans+=1
print(ans)

Fixed submission:
N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
A = [input() for i in range(N)]
def verify_anagrams(w1, w2):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(w1) == f(w2)
 
ans=0
for i in range(N):
    for j in range(i+1,N):
        if verify_anagrams(A[i],A[j]):
            ans+=1
print(ans)

Fixed submission:
N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


N = int(input())
A = [input() for i in range(N)]
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)

ans=0
for i in range(N):
    for j in range(i+1,N):
#         print(i,j)
#         print(verify_anagrams(A[i],A[j]))
        if verify_anagrams(A[i],A[j]):
            ans+=1
print(ans)

Fixed submission:
N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):


N = int(input())
A=[]
for i in range(N):
    A.append(input())
    
 
def verify_anagrams(w1, w2):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(w1) == f(w2)
  
ans=0
for i in range(N):
    for j in range(i+1,N):
#         print(i,j)
#         print(verify_anagrams(A[i],A[j]))
        if verify_anagrams(A[i],A[j]):
            ans+=1
print(ans)

Fixed submission:
N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


N = int(input())
A=[]
for i in range(N):
    A.append(input())
    
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)

ans=0
for i in range(N):
    for j in range(i+1,N):
#         print(i,j)
#         print(verify_anagrams(A[i],A[j]))
        if verify_anagrams(A[i],A[j]):
            ans+=1
print(ans)

Fixed submission:
N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = "".join(sorted(input()))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)