Buggy python submission (verdict: Time Limit Exceeded):
count = 0
scounts = []
N = int(input())
for n in range(N):
    s = sorted(input())
    found = False
    index = -1
    for i in range(len(scounts)):
        # print("s="+str(s))
        if scounts[i][0] == s:
            # print("EQUALS : "+str(scounts[i][0])+" == "+str(s))
            found = True
            count += scounts[i][1]
            scounts[i][1] += 1
            break
        elif scounts[i][0] > s:
            # print("MORE THAN : "+str(scounts[i][0])+" > "+str(s))
            index = i
            break
        else: # scounts[i][0] > s:
            pass
            # print("LESS THAN : "+str(scounts[i][0])+" < "+str(s))

    # print("index="+str(index))
    if not found:
        if index<0:
            # print("append(["+str(s)+",1]")
            scounts.append([s,1])
        else:
            # print("insert("+str(index)+",["+str(s)+",1]")
            scounts.insert(index, [s, 1])

        # print(str(s))
        # print("DONE: "+str(scounts))
    # print("===")
print(count)


Fixed submission:
ss = []
N = int(input())
for n in range(N):
    s = sorted(input())
    ss.append(s)

ss = sorted(ss)

total = 0
count = 0
for n in range(N):
    if n==0:
        continue
    # print("ss["+str(n-1)+"]="+str(ss[n-1]))
    # print("ss["+str(n)+"]="+str(ss[n]))
    if ss[n-1]==ss[n]:
        count += 1
    else:
        total += int(count*(count+1)/2)
        count = 0
    # print("===")
total += int(count*(count+1)/2)
count = 0

print(int(total))

Buggy python submission (verdict: Runtime Error):
count = 0
scounts = []
N = int(input())
for n in range(N):
    s = sorted(input())
    found = False
    index = -1
    for i in range(len(scounts)):
        if scounts[i][0] == s:
            found = True
            count += scounts[i][1]
            scounts[i][1] += 1
            break
        elif scounts[i][0] > s:
            index = i
            break
        else: # scounts[i][0] > s:
			pass

    print("index="+str(index))
    if not found:
        if index<0:
            scounts.append([s,1])
        else:
            scounts.insert(index, [s, 1])

        print(str(s))
        print("DONE: "+str(scounts))
    print("===")
print(count)


Fixed submission:
ss = []
N = int(input())
for n in range(N):
    s = sorted(input())
    ss.append(s)

ss = sorted(ss)

total = 0
count = 0
for n in range(N):
    if n==0:
        continue
    # print("ss["+str(n-1)+"]="+str(ss[n-1]))
    # print("ss["+str(n)+"]="+str(ss[n]))
    if ss[n-1]==ss[n]:
        count += 1
    else:
        total += int(count*(count+1)/2)
        count = 0
    # print("===")
total += int(count*(count+1)/2)
count = 0

print(int(total))

Buggy python submission (verdict: Time Limit Exceeded):
count = 0
scounts = []
N = int(input())
for n in range(N):
    s = sorted(input())
    found = False
    for scount in scounts:
        # print("s="+str(s))
        # print("scount[0]="+str(scount[0]))
        if scount[0] == s:
            found = True
            count += scount[1]
            scount[1] += 1
            break
    if not found:
        scounts.append([s, 1])
print(count)


Fixed submission:
ss = []
N = int(input())
for n in range(N):
    s = sorted(input())
    ss.append(s)

ss = sorted(ss)

total = 0
count = 0
for n in range(N):
    if n==0:
        continue
    # print("ss["+str(n-1)+"]="+str(ss[n-1]))
    # print("ss["+str(n)+"]="+str(ss[n]))
    if ss[n-1]==ss[n]:
        count += 1
    else:
        total += int(count*(count+1)/2)
        count = 0
    # print("===")
total += int(count*(count+1)/2)
count = 0

print(int(total))

Buggy python submission (verdict: Time Limit Exceeded):
s = []
N = int(input())
for n in range(N):
    s.append(input())

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


Fixed submission:
ss = []
N = int(input())
for n in range(N):
    s = sorted(input())
    ss.append(s)

ss = sorted(ss)

total = 0
count = 0
for n in range(N):
    if n==0:
        continue
    # print("ss["+str(n-1)+"]="+str(ss[n-1]))
    # print("ss["+str(n)+"]="+str(ss[n]))
    if ss[n-1]==ss[n]:
        count += 1
    else:
        total += int(count*(count+1)/2)
        count = 0
    # print("===")
total += int(count*(count+1)/2)
count = 0

print(int(total))