Buggy python submission (verdict: Time Limit Exceeded):

def create_count_dic(text):
    count_dic = {}
    for t in text:
        if t in count_dic:
            count_dic[t] += 1
        else:
            count_dic[t] = 1
    return count_dic

N = int(input())
S = [create_count_dic(input()) for x 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:
from collections import defaultdict
counter = defaultdict(int)
N = int(input())
for i in range(N):
    counter[tuple(sorted(list(input())))] += 1
ans = 0
for n in counter.values():
    ans += n * (n - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

def create_count_dic(text):
    count_dic = {}
    for t in text:
        if t in count_dic:
            count_dic[t] += 1
        else:
            count_dic[t] = 1
    return count_dic

def is_anagram(text1, text2):
    text1_dic = create_count_dic(text1)
    text2_dic = create_count_dic(text2)
    if text1_dic == text2_dic:
        return True
    else:
        return False

N = int(input())
S = [input() for x in range(N)]
ans = 0

for i in range(N):
    for j in range(i+1, N):
        if is_anagram(S[i], S[j]):
            ans += 1

print(ans)


Fixed submission:
from collections import defaultdict
counter = defaultdict(int)
N = int(input())
for i in range(N):
    counter[tuple(sorted(list(input())))] += 1
ans = 0
for n in counter.values():
    ans += n * (n - 1) // 2
print(ans)

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

# def create_count_dic(text):
#     count_dic = {}
#     for t in text:
#         if t in count_dic:
#             count_dic[t] += 1
#         else:
#             count_dic[t] = 1
#     return count_dic

def is_anagram(text1, text2):
    # text1_dic = create_count_dic(text1)
    # text2_dic = create_count_dic(text2)
    if Counter(text1) == Counter(text2):
        return True
    else:
        return False

N = int(input())
S = [input() for x in range(N)]
ans = 0

for i in range(N):
    for j in range(i+1, N):
        if is_anagram(S[i], S[j]):
            ans += 1

print(ans)


Fixed submission:
from collections import defaultdict
counter = defaultdict(int)
N = int(input())
for i in range(N):
    counter[tuple(sorted(list(input())))] += 1
ans = 0
for n in counter.values():
    ans += n * (n - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

def create_count_dic(text):
    count_dic = {}
    for t in text:
        if t in count_dic:
            count_dic[t] += 1
        else:
            count_dic[t] = 1
    return count_dic

def is_anagram(text1, text2):
    text1_dic = create_count_dic(text1)
    text2_dic = create_count_dic(text2)
    if text1_dic == text2_dic:
        return True
    else:
        return False

N = int(input())
S = [input() for x in range(N)]
ans = 0

for i in range(N):
    for j in range(i+1, N):
        if is_anagram(S[i], S[j]):
            ans += 1

print(ans)


Fixed submission:
from collections import defaultdict
counter = defaultdict(int)
N = int(input())
for i in range(N):
    counter[tuple(sorted(list(input())))] += 1
ans = 0
for n in counter.values():
    ans += n * (n - 1) // 2
print(ans)

Buggy python submission (verdict: Runtime Error):

def create_count_dic(text):
    count_dic = {}
    [count_dic[t] +=1 if t in count_dic else count_dic[t] = 1 for t in text]
    for t in text:
        if t in count_dic:
            count_dic[t] += 1
        else:
            count_dic[t] = 1
    return count_dic

def is_anagram(text1, text2):
    text1_dic = create_count_dic(text1)
    text2_dic = create_count_dic(text2)
    if text1_dic == text2_dic:
        return True
    else:
        return False

N = int(input())
S = [input() for x in range(N)]
ans = 0

for i in range(N):
    for j in range(i+1, N):
        if is_anagram(S[i], S[j]):
            ans += 1

print(ans)


Fixed submission:
from collections import defaultdict
counter = defaultdict(int)
N = int(input())
for i in range(N):
    counter[tuple(sorted(list(input())))] += 1
ans = 0
for n in counter.values():
    ans += n * (n - 1) // 2
print(ans)

Buggy python submission (verdict: Runtime Error):

def create_count_dic(text):
    count_dic = {}
    [count_dic[t] +=1 if t in count_dic else count_dic[t] = 1 for t in text]
    for t in text:
        if t in count_dic:
            count_dic[t] += 1
        else:
            count_dic[t] = 1
    return count_dic

def is_anagram(text1, text2):
    text1_dic = create_count_dic(text1)
    text2_dic = create_count_dic(text2)
    if text1_dic == text2_dic:
        return True
    else:
        return False

N = int(input())
S = [input() for x in range(N)]
ans = 0

for i in range(N):
    for j in range(i+1, N):
        if is_anagram(S[i], S[j]):
            ans += 1

print(ans)


Fixed submission:
from collections import defaultdict
counter = defaultdict(int)
N = int(input())
for i in range(N):
    counter[tuple(sorted(list(input())))] += 1
ans = 0
for n in counter.values():
    ans += n * (n - 1) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

def create_count_dic(text):
    count_dic = {}
    for t in text:
        if t in count_dic:
            count_dic[t] += 1
        else:
            count_dic[t] = 1
    return count_dic

def is_anagram(text1, text2):
    text1_dic = create_count_dic(text1)
    text2_dic = create_count_dic(text2)
    if text1_dic == text2_dic:
        return True
    else:
        return False

N = int(input())
S = [input() for x in range(N)]
ans = 0

for i in range(N):
    for j in range(i+1, N):
        if is_anagram(S[i], S[j]):
            ans += 1

print(ans)


Fixed submission:
from collections import defaultdict
counter = defaultdict(int)
N = int(input())
for i in range(N):
    counter[tuple(sorted(list(input())))] += 1
ans = 0
for n in counter.values():
    ans += n * (n - 1) // 2
print(ans)