Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def main():
  n = int(input())
  base = []
  base_ans = []

  for i in range(n):
    temp = 0
    s = input()
    sign = 0
  
    for j in range(10):
      temp  = temp + 10**(ord(s[j]) - 97)
    
    for j in range(len(base)):
      if temp == base[j][0]:
        base[j][1] = base[j][1] + 1
        sign = 1
      
    if sign == 0:
      base.append([temp,1])

  ans = 0
  for i in range(len(base)):
    if base[i][1] >= 2:
      ans = ans + base[i][1]*(base[i][1] - 1)//2
      
  print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
  n = int(input())
  mydict = {}

  for i in range(n):
    temp = list(input())
    temp.sort()
    temp = ''.join(temp)
    
    if temp not in mydict:
      mydict[temp] = 1
    else:
      mydict[temp] =  mydict[temp] + 1
      
  ans = 0
  for i in mydict.values():
    if i >= 2:
      ans = ans + i*(i-1)//2
    
  print(ans)
  
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
base = []
base_ans = []

for i in range(n):
  temp = [0]*26
  s = input()
  sign = 0
  
  for j in range(10):
    temp[ord(s[j]) - 97]  = temp[ord(s[j]) - 97] + 1
    
  for j in range(len(base)):
    if temp == base[j][0]:
      base[j][1] = base[j][1] + 1
      sign = 1
      
  if sign == 0:
    base.append([temp,1])

ans = 0
for i in range(len(base)):
  if base[i][1] >= 2:
    ans = ans + base[i][1]*(base[i][1] - 1)//2


print(ans)

Fixed submission:
def main():
  n = int(input())
  mydict = {}

  for i in range(n):
    temp = list(input())
    temp.sort()
    temp = ''.join(temp)
    
    if temp not in mydict:
      mydict[temp] = 1
    else:
      mydict[temp] =  mydict[temp] + 1
      
  ans = 0
  for i in mydict.values():
    if i >= 2:
      ans = ans + i*(i-1)//2
    
  print(ans)
  
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
base = []
base_ans = []

for i in range(n):
  temp = [0]*26
  s = input()
  sign = 0
  
  for j in range(10):
    temp[ord(s[j]) - 97]  = temp[ord(s[j]) - 97] + 1
    
  for j in range(len(base)):
    if temp == base[j][0]:
      base[j][1] = base[j][1] + 1
      sign = 1
      
  if sign == 0:
    base.append([temp,1])

ans = 0
for i in range(len(base)):
  if base[i][1] >= 2:
    ans = ans + base[i][1]*(base[i][1] - 1)//2


print(ans)

Fixed submission:
def main():
  n = int(input())
  mydict = {}

  for i in range(n):
    temp = list(input())
    temp.sort()
    temp = ''.join(temp)
    
    if temp not in mydict:
      mydict[temp] = 1
    else:
      mydict[temp] =  mydict[temp] + 1
      
  ans = 0
  for i in mydict.values():
    if i >= 2:
      ans = ans + i*(i-1)//2
    
  print(ans)
  
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
base = []
count = 0

for i in range(n):
  temp = [0]*26
  s = input()
  sign = 0
  
  for j in range(10):
    temp[ord(s[j]) - 97]  = temp[ord(s[j]) - 97] + 1
    
  for j in range(len(base)):
    if base[j][0] == temp:
      base[j][1] = base[j][1] + 1
      sign = 1
  
  if (temp not in base) and (sign == 0):
    base.append([temp,1])

ans = 0    
for i in range(len(base)):
  if base[i][1] >= 2:
    ans = ans + int(base[i][1]*(base[i][1] - 1)/2)


print(ans)

Fixed submission:
def main():
  n = int(input())
  mydict = {}

  for i in range(n):
    temp = list(input())
    temp.sort()
    temp = ''.join(temp)
    
    if temp not in mydict:
      mydict[temp] = 1
    else:
      mydict[temp] =  mydict[temp] + 1
      
  ans = 0
  for i in mydict.values():
    if i >= 2:
      ans = ans + i*(i-1)//2
    
  print(ans)
  
if __name__ == '__main__':
    main()