Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]!=inlist[j][k]:
        flag1=1
        break
    if flag1==0:#一致
      count+=1
      skip+=1
    else:#不一致
      if skip>=1:
        i=i+skip-1
        count+=int(((skip-1)+1)*(skip-1)/2)
      break
  i+=1
print(count)      


Fixed submission:
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]!=inlist[j][k]:
        flag1=1
        break
    if flag1==0:#一致
      count+=1
      skip+=1
    else:#不一致
      break
  if skip>=1:
    i=i+skip
    count+=int(((skip-1)+1)*(skip-1)/2)
  else:
    i+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]==inlist[j][k]:
        pass
      else:
        flag1=1
        break
    if flag1==0:
      count+=1
      skip+=1
    else:
      if skip>=1:
        i=i+skip
        count+=int(((skip-1)+1)*(skip-1)/2)
      break
  i+=1
print(count)      


Fixed submission:
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]!=inlist[j][k]:
        flag1=1
        break
    if flag1==0:#一致
      count+=1
      skip+=1
    else:#不一致
      break
  if skip>=1:
    i=i+skip
    count+=int(((skip-1)+1)*(skip-1)/2)
  else:
    i+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
for i in range(N):
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]==inlist[j][k]:
        pass
      else:
        flag1=1
        break
    if flag1==0:
      count+=1
    else:
      break
print(count)  

Fixed submission:
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]!=inlist[j][k]:
        flag1=1
        break
    if flag1==0:#一致
      count+=1
      skip+=1
    else:#不一致
      break
  if skip>=1:
    i=i+skip
    count+=int(((skip-1)+1)*(skip-1)/2)
  else:
    i+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
count=0
for i in range(N):
  for j in range(i+1,N):
    if inlist[i]==inlist[j]:
      count+=1
print(count)      


Fixed submission:
N = int(input())
inlist = []
for i in range(N):
  inputst = input()
  inputstlist = list(inputst)
  inputstlist.sort()
  inlist.append(inputstlist)
inlist.sort()
count=0
i=0
while i<N:
  skip=0
  for j in range(i+1,N):
    flag1=0
    for k in range(10):
      if inlist[i][k]!=inlist[j][k]:
        flag1=1
        break
    if flag1==0:#一致
      count+=1
      skip+=1
    else:#不一致
      break
  if skip>=1:
    i=i+skip
    count+=int(((skip-1)+1)*(skip-1)/2)
  else:
    i+=1
print(count)