Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for x in range(n)]
length = 10
count = 0

for i in range(n):
    s1 = list(s[i])
    s1.sort()
    for j in range(i+1,n):
        flag = True
        s2 = list(s[j])
        s2.sort()
        for k in range(length):
            if (s1[k] == s2[k]):
                continue
            else:
                flag = False
                break
        if (flag):
            count += 1

print(count)


Fixed submission:
n = int(input())
s = [input() for x in range(n)]
count = 0
d = {}

for i in range(n):
    s1 = list(s[i])
    s1.sort()
    string = "".join(s1)
    if (string not in d.keys()):
        d[string] = 0
    else:
        d[string] += 1
        count += d[string]

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())

ans = 0

diclist = []

for i in range(0,N+1):
  temp = list(input())
  temp.sort()
  if temp in diclist:
    ans = ans +1
  else:
    diclist.append(temp)

print(ans)


Fixed submission:
import collections
from scipy.misc import comb

N = int(input())

diclist = []

i=0
while i < N:
  temp = list(input())
  temp.sort()
  tmp_el = ''.join(temp)
  diclist.append(tmp_el)
  i += 1
  
c = collections.Counter(diclist)
clist = list(c.values()) 
ccomb = [comb(clist[i], 2, exact = True) for i in range(0,len(clist))]

print(sum(ccomb))

Buggy python submission (verdict: Runtime Error):
N = int(input())

ans = 0

diclist = []

for i in range(0,N+1):
  temp = list(input()).sort()
  if temp in diclist:
    ans = ans +1
  else:
    diclist.append(temp_str)

print("{}".format(ans))


Fixed submission:
import collections
from scipy.misc import comb

N = int(input())

diclist = []

i=0
while i < N:
  temp = list(input())
  temp.sort()
  tmp_el = ''.join(temp)
  diclist.append(tmp_el)
  i += 1
  
c = collections.Counter(diclist)
clist = list(c.values()) 
ccomb = [comb(clist[i], 2, exact = True) for i in range(0,len(clist))]

print(sum(ccomb))

Buggy python submission (verdict: Runtime Error):
N = int(input())

ans = 0

diclist = []

for i in range(0,N+1):
  temp = list(input()).sort()
  if temp in diclist:
    ans = ans +1
  else:
    diclist.append(temp_str)

print(ans)

Fixed submission:
import collections
from scipy.misc import comb

N = int(input())

diclist = []

i=0
while i < N:
  temp = list(input())
  temp.sort()
  tmp_el = ''.join(temp)
  diclist.append(tmp_el)
  i += 1
  
c = collections.Counter(diclist)
clist = list(c.values()) 
ccomb = [comb(clist[i], 2, exact = True) for i in range(0,len(clist))]

print(sum(ccomb))

Buggy python submission (verdict: Runtime Error):
N = int(input())

ans = 0

diclist = []

for i in range(0,N+1):
  temp = list(input()).sort()
  temp_str = ''.join(temp)
  if temp_str in diclist:
    ans = ans +1
  else:
    diclist.append(temp_str)

print(ans)

Fixed submission:
import collections
from scipy.misc import comb

N = int(input())

diclist = []

i=0
while i < N:
  temp = list(input())
  temp.sort()
  tmp_el = ''.join(temp)
  diclist.append(tmp_el)
  i += 1
  
c = collections.Counter(diclist)
clist = list(c.values()) 
ccomb = [comb(clist[i], 2, exact = True) for i in range(0,len(clist))]

print(sum(ccomb))