Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 0
i = 0
while i < N-1:
    num = s.count(s[i])
    count += num * (num - 1) // 2
    i += num
print(count)

Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
count = 0
s_set = list(set(s))
for i in range(len(s_set)):
    s_count = s.count(s_set[i])
    if s_count > 1:
        count += (s_count * (s_count - 1)) // 2
print(count)


Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input().split() for i in range(N)]

count = 0
s = [''.join(sorted(str(i))) for i in s]
s_set = list(set([x for x in s if s.count(x) > 1]))
for i in range(len(s_set)):
    s_count = s.count(s_set[i])
    count += (s_count * (s_count - 1)) // 2
print(count)


Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input().split() for i in range(N)]

count = 0
s = [''.join(sorted(str(i))) for i in s]
s_set = list(set(s))
for i in range(len(s_set)):
    s_count = s.count(s_set[i])
    if s_count > 1:
        count += (s_count * (s_count - 1)) // 2
print(count)

Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input().split() for i in range(N)]

count = 0
s = [''.join(sorted(str(i))) for i in s]
s_set = list(set(s))
for i in range(len(s_set)):
    s_count = s.count(s_set[i])
    count += (s_count * (s_count - 1)) // 2
print(count)


Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input().split() for i in range(N)]
count = 0

s = [''.join(sorted(str(i))) for i in s]
s_set = list(set(s))
for i in range(len(s_set)):
    count += sum(range(1, s.count(s_set[i])))
print(count)

Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input().split() for i in range(N)]
count = 0

s = [sorted(str(i)) for i in s]
for i in range(N):
    for j in range(i+1, N):
        if s[i] == s[j]:
            count += 1
print(count)


Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [input().split() for i in range(N)]
count = 0

for i in range(N):
    for j in range(i+1, N):
        if sorted(str(s[i])) == sorted(str(s[j])):
            count += 1
print(count)

Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
s.sort()
count = 0
num = 1
for i in range(N-1):
    if s[i] == s[i+1]:
        num += 1
    else:
        count += num * (num - 1) // 2
        num = 1
print(count + num * (num - 1) // 2)