Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A=[]
S=[]
for i in range(N):
    a = list(input())
    a.sort()
    A.append(a)
    if a not in S:
        S.append(a)

count=0
for i in S:
    if A.count(i)==1:
        continue
    count += A.count(i)*(A.count(i)-1)//2
print(count)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
def factorial(i):
    ans = 1
    for j in range(1,i+1):
        ans *= j
    return ans

N = int(input())
A = [input() for i in range(N)]
a = []
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
ans = a[0]
count=0
for i in range(0,N):
    ans = a[i]
    for j in range(i+1,N):
        if ans == a[j]:
            count+=1
print(count)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def factorial(i):
    ans = 1
    for j in range(1,i+1):
        ans *= j
    return ans
N = int(input())
A = [input() for i in range(N)]
a = []
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
c = list(map(list, set(map(tuple, a))))
count = 0
for i in c:
    if a.count(i)==1:
        continue
    if a.count(i) > 2:
        count += factorial(a.count(i)) // (factorial(a.count(i) - 2) * factorial(2))
    else:
        count += 1

print(count)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def factorial(i):
    ans = 1
    for j in range(1,i+1):
        ans *= j
    return ans
N = int(input())
A = [input() for i in range(N)]
a = []
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
c = list(map(list, set(map(tuple, a))))
d=[]
for i in c:
    if a.count(i)==1:
        continue
    d.append(a.count(i))
count=0
for i in d:

    if i>2:
        count += factorial(i) // (factorial(i - 2) * factorial(2))
    elif i ==2:
        count += 1
print(count)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def factorial(i):
    ans = 1
    for j in range(1,i+1):
        ans *= j
    return ans
N = int(input())
A = [input() for i in range(N)]
a = []
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
c = list(map(list, set(map(tuple, a))))
d=[]
for i in c:
    d.append(a.count(i))
count=0
for i in d:
    if i ==1:
        continue
    if i>2:
        count += factorial(i) // (factorial(i - 2) * factorial(2))
    elif i ==2:
        count += 1
print(count)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def factorial(i):
    ans = 1
    for j in range(1,i+1):
        ans *= j
    return ans
N = int(input())
A = [input() for i in range(N)]
a = []*N
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
c = list(map(list, set(map(tuple, a))))
d=[]
for i in c:
    d.append(a.count(i))
count=0
for i in d:
    if i>2:
        count += factorial(i) // (factorial(i - 2) * factorial(2))
    elif i ==2:
        count += 1
print(count)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
N = int(input())
A = [input() for i in range(N)]
a = []*N
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

a.sort()
c = list(map(list, set(map(tuple, a))))
d=[]
for i in c:
    d.append(a.count(i))
count=0
for i in d:
    count += math.factorial(i) // (math.factorial(i - 2) * math.factorial(2))

print(count)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = [input() for i in range(N)]
a = []*N
for i in A:
    b = list(i)
    b.sort()
    a.append(b)

count=0
ans = a[0]
for i in range(0,N):
    ans = a[i]
    for j in range(i+1,N):
        if ans == a[j]:
            count += 1
print(count)

Fixed submission:
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)