Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
def count_s(s):
  count = []
  while s != []:
    moji = s.pop(0)
    num = s.count(moji)
    if num > 0:
      for i in range(num):
        s.pop(s.index(moji))
      count.append(num+1)
  return count
count = count_s(s)
ans = 0
if len(count) == 0:
  print(ans)
else:
  for i in count:
    ans += math.factorial(i)/2
  print(int(ans))

Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

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

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
for i in range(n-1):
  ans += str_list[i+1:].count(str_list[i])
print(ans)


Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

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

input = sys.stdin.readline
n = int(input())
counter_list = [Counter(input().rstrip()) for i in range(n)]
ans = 0
for i in range(n-1):
  if counter_list[i] in counter_list[i+1:]:
    ans +=counter_list[i+1:].count(counter_list[i])
print(ans)


Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
import sys
input = sys.stdin.readline
n = int(input())
str_list = [input() for i in range(n)]
counter_list = [Counter[i] for i in str_list]
ans = 0
for i in range(n):
  first = Counter(str_list[i])
  for j in range(n-i-1):
    second = Counter(str_list[j+i+1])
    if first == second:
      ans +=1
print(ans)

Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
str_list = [input() for i in range(n)]
ans = 0
for i in range(n):
  first = Counter(str_list[i])
  for j in range(n-i-1):
    second = Counter(str_list[j+i+1])
    if first == second:
      ans +=1
print(ans)

Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
str_list = [input() for i in range(n)]
ans = 0
for i in range(n):
  first = Counter(str_list[i])
  for j in range(n-i-1):
    second = Counter(str_list[j+i+1])
    if first == second:
      ans +=1
print(ans)

Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
str_list = [input() for i in range(n)]
ans = 0
for i in range(n):
  for j in range(n-i-1):
    if Counter(str_list[i])==Counter(str_list[j+i+1]):
      ans +=1
print(ans)

Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
str_list = [input() for i in range(n)]
ans = 0
for i in range(n):
  for j in range(n-i-1):
    if Counter(str_list[i])==Counter(str_list[j+i+1]):
      ans +=1
print(ans)

Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
str_list = [input() for i in range(n)]
ans = 0
from collections import Counter
def verify_anagrams(first_word, second_word):
  if Counter(first_word) == Counter(second_word):
    return 1
  else:
    return 0
for i in range(n):
  for j in range(n-i-1):
    ans += verify_anagrams(str_list[i], str_list[j+i+1])
    
print(ans)

Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
str_list = [input() for i in range(n)]
ans = 0
from collections import Counter
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
    if get_counter(first_word) == get_counter(second_word):
      return 1
    else:
      return 0
for i in range(n):
  for j in range(n-i-1):
    ans += verify_anagrams(str_list[i], str_list[j+i+1])
    
print(ans)

Fixed submission:
from collections import Counter
import sys

input = sys.stdin.readline
n = int(input())
str_list = [''.join(sorted(input().rstrip())) for i in range(n)]
ans = 0
count_list = list(Counter(str_list).values())
for i in count_list:
  sum = 0
  for j in range(int(i)):
    sum += j
  ans +=sum
print(ans)