Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
lis = []
for i in range(n):
    s = input()
    s_lis = [s[j] for j in range(10)]
    lis.append(s_lis)
for i in range(n-1):
    for j in range(i+1,n):
        s_i = set(lis[i])
        s_j = set(lis[j])
        if s_i == s_j:
            same = True
            for k in range(10):
                if lis[i].count(lis[i][k]) == lis[j].count(lis[i][k]):
                    continue
                else:
                    same = False
                    break
            if same == True:
                ans += 1
print(ans)


Fixed submission:
n = int(input())
ans = 0
dic = {}
for i in range(n):
    sorted_s = sorted(input())
    s = ""
    for j in range(10):
        s = s + sorted_s[j]
    
    if s not in dic:
        dic[s] = 1
    else:
        ans += dic[s]
        dic[s] = dic[s] + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
lis = []
for i in range(n):
    s = input()
    s_lis = [s[j] for j in range(10)]
    lis.append(s_lis)
for i in range(n-1):
    for j in range(i+1,n):
        same = True
        for k in range(10):
            if lis[i][k] in lis[j]  and lis[i].count(lis[i][k]) == lis[j].count(lis[i][k]):
                continue
            else:
                same = False
                break
        if same == True:
            ans += 1
print(ans)


Fixed submission:
n = int(input())
ans = 0
dic = {}
for i in range(n):
    sorted_s = sorted(input())
    s = ""
    for j in range(10):
        s = s + sorted_s[j]
    
    if s not in dic:
        dic[s] = 1
    else:
        ans += dic[s]
        dic[s] = dic[s] + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = []
ans = 0
for i in range(n):
    s = input()
    key = []
    val = []
    for j in range(10):
        cnt = 1
        if s[j] not in key and j < 9:
            for k in range(j+1,10):
                if s[j] == s[k]:
                    cnt += 1
            key.append(s[j])
            val.append(cnt)
        elif j == 9:
            if s[j] not in key:
                key.append(s[j])
                val.append(cnt)
    d = dict(zip(key, val))
    lis.append(d)
    if n > 0:
        for l in range(len(lis)-1):
            if lis[-1] == lis[l]:
                ans += 1

print(ans)

Fixed submission:
n = int(input())
ans = 0
dic = {}
for i in range(n):
    sorted_s = sorted(input())
    s = ""
    for j in range(10):
        s = s + sorted_s[j]
    
    if s not in dic:
        dic[s] = 1
    else:
        ans += dic[s]
        dic[s] = dic[s] + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = []
for i in range(n):
    s = input()
    key = []
    val = []
    for j in range(10):
        cnt = 1
        if s[j] not in key and j < 9:
            for k in range(j+1,10):
                if s[j] == s[k]:
                    cnt += 1
            key.append(s[j])
            val.append(cnt)
        elif j == 9:
            if s[j] not in key:
                key.append(s[j])
                val.append(cnt)
    d = dict(zip(key, val))
    lis.append(d)
#print(lis)
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        if lis[i] == lis[j]:
            ans += 1
#print(lis[1] == lis[3])
print(ans)

Fixed submission:
n = int(input())
ans = 0
dic = {}
for i in range(n):
    sorted_s = sorted(input())
    s = ""
    for j in range(10):
        s = s + sorted_s[j]
    
    if s not in dic:
        dic[s] = 1
    else:
        ans += dic[s]
        dic[s] = dic[s] + 1
print(ans)