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

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        d[a]+=1
    else:
        d[a] = 1
ans = 0
for i in d:
    ans += len(list(itertools.combinations(range(d[i]), 2)))
print(ans)

Fixed submission:
import collections
import itertools
ans = 0

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        ans+=d[a]
        d[a]+=1
    else:
        d[a] = 1

print(ans)

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

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

s_list.sort()
sorted_list = []
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    sorted_list.append(a)
    
C = collections.Counter(sorted_list)
ans = 0
for i in C:
    ans += len(list(itertools.combinations(range(C[i]), 2)))
print(ans)


Fixed submission:
import collections
import itertools
ans = 0

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        ans+=d[a]
        d[a]+=1
    else:
        d[a] = 1

print(ans)

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

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

sorted_list = []
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    sorted_list.append(a)
    
C = collections.Counter(sorted_list)
ans = 0
for i in C:
    ans += len(list(itertools.combinations(range(C[i]), 2)))
print(ans)

Fixed submission:
import collections
import itertools
ans = 0

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        ans+=d[a]
        d[a]+=1
    else:
        d[a] = 1

print(ans)

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

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

#s_list.sort()
l = []
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l.append(l2)
    
for i in l:
    i.sort()

l3 = []
for i in l:
    s = ""
    for j in i:
        s += j
    l3.append(s)
    
C = collections.Counter(l3)
ans = 0
for i in C:
    ans += len(list(itertools.combinations(range(C[i]), 2)))
print(ans)

Fixed submission:
import collections
import itertools
ans = 0

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        ans+=d[a]
        d[a]+=1
    else:
        d[a] = 1

print(ans)

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

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

s_list.sort()
l = []
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l.append(l2)
    
for i in l:
    i.sort()

l3 = []
for i in l:
    s = ""
    for j in i:
        s += j
    l3.append(s)
    
C = collections.Counter(l3)
ans = 0
for i in C:
    ans += len(list(itertools.combinations(range(C[i]), 2)))
print(ans)

Fixed submission:
import collections
import itertools
ans = 0

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())

d = {}
for s in s_list:
    l2 = []
    for i in range(len(s)):
        l2.append(s[i])
    l2.sort()
    a = ""
    for i in l2:
        a += i
    if a in d:
        ans+=d[a]
        d[a]+=1
    else:
        d[a] = 1

print(ans)