Buggy python submission (verdict: Time Limit Exceeded):
import sys

N = int(input())
L = []
for i in range(N):
    L.append(sorted(sys.stdin.readline().strip()))

Sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        if L[i] == L[j]:
            Sum += 1

print(Sum)
        


Fixed submission:
import sys

N = int(input())
L = {}
count = 0
for i in range(N):
    A = ''.join(sorted(sys.stdin.readline().strip()))
    if A not in L:
        L[A] = 1
    else:
        count += L[A]
        L[A] += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

L = []
for i in range(N):
    L.append(sorted(input().strip()))

Sum = 0
for i in range(N):
    if i == N - 1:
        break
    
    for j in range(i+1, N):
        if L[i] == L[j]:
            #print(L[i], L[j])
            Sum += 1

print(Sum)
        


Fixed submission:
import sys

N = int(input())
L = {}
count = 0
for i in range(N):
    A = ''.join(sorted(sys.stdin.readline().strip()))
    if A not in L:
        L[A] = 1
    else:
        count += L[A]
        L[A] += 1

print(count)

Buggy python submission (verdict: Runtime Error):
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = ''.join(sorted(raw_input("")))
    if smap.get(tmp, None) == None:
        smap[tmp] = 1
    else:
        smap[tmp] += 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print(count)


Fixed submission:
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = ''.join(sorted(raw_input("")))
    if smap.get(tmp, None) == None:
        smap[tmp] = 1
    else:
        smap[tmp] += 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print count

Buggy python submission (verdict: Time Limit Exceeded):
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = ''.join(sorted(raw_input("")))
    if smap.get(tmp, None) == None:
        smap[tmp] = 1
    else:
        smap[tmp] += 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print count


Fixed submission:
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = ''.join(sorted(raw_input("")))
    if smap.get(tmp, None) == None:
        smap[tmp] = 1
    else:
        smap[tmp] += 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print count

Buggy python submission (verdict: Time Limit Exceeded):
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = raw_input("")
    tmp_s = ''.join(sorted(tmp))
    if smap.get(tmp_s, None) != None:
        smap[tmp_s] += 1
    else:
        smap[tmp_s] = 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print count


Fixed submission:
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = ''.join(sorted(raw_input("")))
    if smap.get(tmp, None) == None:
        smap[tmp] = 1
    else:
        smap[tmp] += 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print count