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

N = int(input())

check = []
ans = {}
answer = 0
for _ in range(N):
    s = Counter(input())
    if s not in check:
        check.append(s)
        ans[str(sorted(s.items(), key=lambda x:x[0]))] = 0

    else:
        ans[str(sorted(s.items(), key=lambda x:x[0]))] += 1
        answer += ans[str(sorted(s.items(), key=lambda x:x[0]))]

print(answer)

Fixed submission:
from collections import Counter

N = int(input())

# check = []
# ans = {}
# answer = 0
# for _ in range(N):
#     s = Counter(input())
#     if s not in check:
#         check.append(s)
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] = 0
#
#     else:
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] += 1
#         answer += ans[str(sorted(s.items(), key=lambda x:x[0]))]
#
# print(answer)

ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(input()))

    if s not in ans:
        ans[s] = 0

    else:
        ans[s] += 1
        answer += ans[s]

print(answer)

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

N = int(input())

s = []
check = []
ans = 0
# for x in range(N):
#     for c in input():
#         s[x].append(c)

for _ in range(N):
    check.append(Counter(input()))

while check:
    cc = check.pop(0)
    ans += check.count(cc)


print(ans)

Fixed submission:
from collections import Counter

N = int(input())

# check = []
# ans = {}
# answer = 0
# for _ in range(N):
#     s = Counter(input())
#     if s not in check:
#         check.append(s)
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] = 0
#
#     else:
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] += 1
#         answer += ans[str(sorted(s.items(), key=lambda x:x[0]))]
#
# print(answer)

ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(input()))

    if s not in ans:
        ans[s] = 0

    else:
        ans[s] += 1
        answer += ans[s]

print(answer)

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

N = int(input())

s = []
check = []
ans = 0
# for x in range(N):
#     for c in input():
#         s[x].append(c)

for _ in range(N):
    s.append(input())
for x in s:
    check.append(Counter(x))

while check:
    cc = check.pop(0)
    ans += check.count(cc)


print(ans)

Fixed submission:
from collections import Counter

N = int(input())

# check = []
# ans = {}
# answer = 0
# for _ in range(N):
#     s = Counter(input())
#     if s not in check:
#         check.append(s)
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] = 0
#
#     else:
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] += 1
#         answer += ans[str(sorted(s.items(), key=lambda x:x[0]))]
#
# print(answer)

ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(input()))

    if s not in ans:
        ans[s] = 0

    else:
        ans[s] += 1
        answer += ans[s]

print(answer)

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

N = int(input())

s = [[] for _ in range(N)]
check = []
ans = []
for x in range(N):
    for c in input():
        s[x].append(c)

for x in s:
    check.append(Counter(x))

for x in range(N):
    if check:
        cc = check.pop(0)
        ans.append(check.count(cc))


print(sum(ans))

Fixed submission:
from collections import Counter

N = int(input())

# check = []
# ans = {}
# answer = 0
# for _ in range(N):
#     s = Counter(input())
#     if s not in check:
#         check.append(s)
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] = 0
#
#     else:
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] += 1
#         answer += ans[str(sorted(s.items(), key=lambda x:x[0]))]
#
# print(answer)

ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(input()))

    if s not in ans:
        ans[s] = 0

    else:
        ans[s] += 1
        answer += ans[s]

print(answer)

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

N = int(input())

s = [[] for _ in range(N)]
check = []
ans = []
for x in range(N):
    for c in input():
        s[x].append(c)

for x in s:
    check.append(Counter(x))

for x in range(N):
    for y in range(x+1,N):
        ans.append(dict(check[x])==dict(check[y]))


print(sum(ans))

Fixed submission:
from collections import Counter

N = int(input())

# check = []
# ans = {}
# answer = 0
# for _ in range(N):
#     s = Counter(input())
#     if s not in check:
#         check.append(s)
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] = 0
#
#     else:
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] += 1
#         answer += ans[str(sorted(s.items(), key=lambda x:x[0]))]
#
# print(answer)

ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(input()))

    if s not in ans:
        ans[s] = 0

    else:
        ans[s] += 1
        answer += ans[s]

print(answer)