Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def is_anagram(s1,s2):
  cnt_s1 = Counter(s1)
  for key in cnt_s1:
    if s2.count(key) != cnt_s1[key]:
      return False
  return True

N = int(input())
S = [input() for _ in range(N)]
used = [False for _ in range(N)]
ans = 0
for i in range(N-1):
  if used[i]==True:
    continue
  tmp_ans = 0
  for j in range(i+1,N):
    if used[j]==True:
      continue
    if is_anagram(S[i],S[j]):
      tmp_ans += 1
      used[i], used[j] = True, True
  
  ans += (tmp_ans+1)*tmp_ans//2 
print(ans)

Fixed submission:
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
anagrams = {}
for i in range(N):
  string = ''.join(sorted(input()))
  if string in anagrams:
    anagrams[string] += 1
  else:
    anagrams[string] = 0

ans = 0
for anagram_num in anagrams.values():
  if anagram_num> 0:
    ans += int(cmb(anagram_num+1,2)) 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
strings = []
anagrams_num = []
for i in range(N):
  string = ''.join(sorted(input()))
  try:
    anagram_index = strings.index(string)
    anagrams_num[anagram_index] += 1
  except:
    strings.append(string)
    anagrams_num.append(0)

ans = 0
for anagram_num in anagrams_num:
  if anagram_num > 0:
    ans += int(cmb(anagram_num+1,2)) 
print(ans)

Fixed submission:
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
anagrams = {}
for i in range(N):
  string = ''.join(sorted(input()))
  if string in anagrams:
    anagrams[string] += 1
  else:
    anagrams[string] = 0

ans = 0
for anagram_num in anagrams.values():
  if anagram_num> 0:
    ans += int(cmb(anagram_num+1,2)) 
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

N = int(input())
strings = [input() for i in range(N)]
ans = 0

for i in range(len(strings)):
  anagrams_index = []
  anagrams_num = 0
  for j in range(i+1, len(strings)):
    if i > len(strings) or j > len(strings):
      break
    if is_anagram(strings[i], strings[j]):
      anagrams_num += 1
      strings.pop(j)
  
  if anagrams_num == 1:
    ans +=1
  elif anagrams_num > 1:
    ans += int(math.factorial(anagrams_num+1)/math.factorial(anagrams_num)) 
print(ans) 

Fixed submission:
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
anagrams = {}
for i in range(N):
  string = ''.join(sorted(input()))
  if string in anagrams:
    anagrams[string] += 1
  else:
    anagrams[string] = 0

ans = 0
for anagram_num in anagrams.values():
  if anagram_num> 0:
    ans += int(cmb(anagram_num+1,2)) 
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

N = int(input())
strings = [input() for i in range(N)]
ans = 0

for i in range(len(strings)-1):
  anagrams_index = []
  anagrams_num = 0
  for j in range(i+1, len(strings)):
    if i > len(strings) or j > len(strings):
      break
    if is_anagram(strings[i], strings[j]):
      anagrams_num += 1
      strings.pop(j)
  
  if anagrams_num == 1:
    ans +=1
  elif anagrams_num > 1:
    ans += int(math.factorial(anagrams_num+1)/math.factorial(anagrams_num)) 
print(ans) 

Fixed submission:
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
anagrams = {}
for i in range(N):
  string = ''.join(sorted(input()))
  if string in anagrams:
    anagrams[string] += 1
  else:
    anagrams[string] = 0

ans = 0
for anagram_num in anagrams.values():
  if anagram_num> 0:
    ans += int(cmb(anagram_num+1,2)) 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

N = int(input())
strings = [input() for i in range(N)]
ans = 0
for i in range(0, N-1):
  for j in range(i+1, N):
    if is_anagram(strings[i], strings[j]):
      ans += 1
print(ans) 

Fixed submission:
import math
def is_anagram(string1, string2):
  for a in string1:
    if a not in string2:
      return False
    string2 = string2.replace(a, "", 1)
  if len(string2) == 0:
    return True
  else:
    return False

from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
anagrams = {}
for i in range(N):
  string = ''.join(sorted(input()))
  if string in anagrams:
    anagrams[string] += 1
  else:
    anagrams[string] = 0

ans = 0
for anagram_num in anagrams.values():
  if anagram_num> 0:
    ans += int(cmb(anagram_num+1,2)) 
print(ans)