Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = tuple(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]
set_s = set(s)
seq_s = "".join(s)
ans = 0
start_i = 0
used_s = {}
for i in range(n):
    cnt = used_s.get(s[i],seq_s.count(s[i],start_i) if s[i] in set_s else 0)
    ans += cnt - 1
    used_s[s[i]] = cnt - 1
    start_i += len(s[i])

print(ans)

Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]
set_s = set(s)
seq_s = "".join(s)
ans = 0
start_i = 0
used_s = {}
for i in range(n):
    cnt = used_s.get(s[i],seq_s.count(s[i],start_i) if s[i] in set(s) else 0)
    ans += cnt - 1
    used_s[s[i]] = cnt - 1
    start_i += len(s[i])

print(ans)

Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]
seq_s = "".join(s)
ans = 0
start_i = 0
used_s = {}
for i in range(n):
    cnt = used_s.get(s[i],seq_s.count(s[i],start_i))
    ans += cnt - 1
    used_s[s[i]] = cnt - 1
    start_i += len(s[i])

print(ans)

Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]
seq_s = "".join(s)
ans = 0
start_i = 0
for i in range(n):
    cnt = seq_s.count(s[i],start_i)
    ans += cnt - 1
    start_i += len(s[i])

print(ans)

Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [sorted(input()) for _ in range(n)]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if s[i] == s[j]:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s_n = [] * n
for i in range(n):
    s = input()
    s_n.append(collections.Counter(s))

cnt = 0
for i in range(n):
    cur_same = 0
    if s_n[i] == -1:
        continue
    for j in range(i+1,n):
        if s_n[i] == s_n[j]:
            cur_same += 1
            cnt += 1*cur_same
            s_n[j] = -1

print(cnt)


Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s_n = [] * n
for i in range(n):
    s = input()
    s_n.append(collections.Counter(s))

cnt = 0
for i in range(n):
    cur_same = 0
    if s_n[i] == -1:
        continue
    for j in range(i+1,n):
        if s_n[i] == s_n[j]:
            cur_same += 1
            cnt += 1*cur_same
            s_n[j] = -1

print(cnt)


Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s_n = [] * n
for i in range(n):
    s = input()
    s_n.append(collections.Counter(s))

cnt = 0
for i in range(n):
    if s_n[i] == -1:
        continue
    for j in range(i+1,n):
        if s_n[i] == s_n[j]:
            cnt += 1

print(cnt)


Fixed submission:
n = int(input())
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(input()))
    if not s in used_s.keys():
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]

print(ans)