Buggy python submission (verdict: Runtime Error):
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
dic_s = {}
for i in range(N):
    s = "".join(sorted(input()))
    if s in dic_s:
        dic_s[s] += 1
    else:
        dic_s[s] = 1
counter = 0
for key,value in dic_s.items():
    counter += combinations_count(value,2)
print(counter)

Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
dic_s = {}
for i in range(N):
    s = "".join(sorted(input()))
    if s in dic_s:
        dic_s[s] += 1
    else:
        dic_s[s] = 1
counter = 0
for key,value in dic_s.items():
    if value >1:
        counter += combinations_count(value,2)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for i in range(N) ]
counter = 0
for i in range(N):
    for j in range(i+1,N):
        if sorted(S[i]) == sorted(S[j]):
            counter += 1
print(counter)

Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
dic_s = {}
for i in range(N):
    s = "".join(sorted(input()))
    if s in dic_s:
        dic_s[s] += 1
    else:
        dic_s[s] = 1
counter = 0
for key,value in dic_s.items():
    if value >1:
        counter += combinations_count(value,2)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for i in range(N) ]
counter = 0
for i in range(N):
    for j in range(i+1,N):
        if set(S[i]) == set(S[j]):
            if sorted(S[i]) == sorted(S[j]):
                counter += 1
print(counter)

Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
dic_s = {}
for i in range(N):
    s = "".join(sorted(input()))
    if s in dic_s:
        dic_s[s] += 1
    else:
        dic_s[s] = 1
counter = 0
for key,value in dic_s.items():
    if value >1:
        counter += combinations_count(value,2)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for i in range(N) ]
counter = 0
for i in range(N):
    for j in range(i+1,N):
        if set(S[i]) == set(S[j]):
            if sorted(S[i]) == sorted(S[j]):
                counter += 1
print(counter)


Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
dic_s = {}
for i in range(N):
    s = "".join(sorted(input()))
    if s in dic_s:
        dic_s[s] += 1
    else:
        dic_s[s] = 1
counter = 0
for key,value in dic_s.items():
    if value >1:
        counter += combinations_count(value,2)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [sorted(input()) for i in range(N) ]
counter = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(10):
            if S[i][k]!=S[j][k]:
                break
            if k == 9:
                counter +=1
print(counter)


Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
dic_s = {}
for i in range(N):
    s = "".join(sorted(input()))
    if s in dic_s:
        dic_s[s] += 1
    else:
        dic_s[s] = 1
counter = 0
for key,value in dic_s.items():
    if value >1:
        counter += combinations_count(value,2)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [sorted(input()) for i in range(N) ]
counter = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(10):
            if S[i][k]!=S[j][k]:
                break
            if k == 9:
                counter +=1
print(counter)


Fixed submission:
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
dic_s = {}
for i in range(N):
    s = "".join(sorted(input()))
    if s in dic_s:
        dic_s[s] += 1
    else:
        dic_s[s] = 1
counter = 0
for key,value in dic_s.items():
    if value >1:
        counter += combinations_count(value,2)
print(counter)