Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
num = []
num_list = []
count_list = []
num_list_counter = 0
count = 0

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

for i in range(N):
    S.append(input())
    num = 1
    num *= pow_k(2, S[i].count('a'))
    num *= pow_k(3, S[i].count('b'))
    num *= pow_k(5, S[i].count('c'))
    num *= pow_k(7, S[i].count('d'))
    num *= pow_k(11, S[i].count('e'))
    num *= pow_k(13, S[i].count('f'))
    num *= pow_k(17, S[i].count('g'))
    num *= pow_k(19, S[i].count('h'))
    num *= pow_k(23, S[i].count('i'))
    num *= pow_k(29, S[i].count('j'))
    num *= pow_k(31, S[i].count('k'))
    num *= pow_k(37, S[i].count('l'))
    num *= pow_k(41, S[i].count('m'))
    num *= pow_k(43, S[i].count('n'))
    num *= pow_k(47, S[i].count('o'))
    num *= pow_k(73, S[i].count('p'))
    num *= pow_k(79, S[i].count('q'))
    num *= pow_k(83, S[i].count('r'))
    num *= pow_k(89, S[i].count('s'))
    num *= pow_k(97, S[i].count('t'))
    num *= pow_k(101, S[i].count('u'))
    num *= pow_k(103, S[i].count('v'))
    num *= pow_k(107, S[i].count('w'))
    num *= pow_k(109, S[i].count('x'))
    num *= pow_k(113, S[i].count('y'))
    num *= pow_k(127, S[i].count('z'))

    if num_list_counter == 0:
        num_list.append(num)
        count_list.append(1)
        num_list_counter += 1
    else:
        judge = 0
        for j in range(num_list_counter):
            if num_list[j] == num:
                judge = 1
                count += count_list[j]
                count_list[j] += 1
        if judge == 0:
            num_list_counter += 1
            num_list.append(num)
            count_list.append(1)

print(count)


Fixed submission:
N = int(input())
S = []
count = 0

dic = {}
for i in range(N):
    S.append(input())
    S[i] = sorted(S[i])
    S[i] = ''.join(S[i])
    if dic.setdefault(S[i], 0) > 0:
        count += dic[S[i]]
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
num = []
num_list = []
count_list = []
num_list_counter = 0
count = 0

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

for i in range(N):
    S.append(input())
    num = 1
    num *= pow_k(2, S[i].count('a'))
    num *= pow_k(3, S[i].count('b'))
    num *= pow_k(5, S[i].count('c'))
    num *= pow_k(7, S[i].count('d'))
    num *= pow_k(11, S[i].count('e'))
    num *= pow_k(13, S[i].count('f'))
    num *= pow_k(17, S[i].count('g'))
    num *= pow_k(19, S[i].count('h'))
    num *= pow_k(23, S[i].count('i'))
    num *= pow_k(29, S[i].count('j'))
    num *= pow_k(31, S[i].count('k'))
    num *= pow_k(37, S[i].count('l'))
    num *= pow_k(41, S[i].count('m'))
    num *= pow_k(43, S[i].count('n'))
    num *= pow_k(47, S[i].count('o'))
    num *= pow_k(73, S[i].count('p'))
    num *= pow_k(79, S[i].count('q'))
    num *= pow_k(83, S[i].count('r'))
    num *= pow_k(89, S[i].count('s'))
    num *= pow_k(97, S[i].count('t'))
    num *= pow_k(101, S[i].count('u'))
    num *= pow_k(103, S[i].count('v'))
    num *= pow_k(107, S[i].count('w'))
    num *= pow_k(109, S[i].count('x'))
    num *= pow_k(113, S[i].count('y'))
    num *= pow_k(127, S[i].count('z'))

    if num_list_counter == 0:
        num_list.append(num)
        count_list.append(1)
        num_list_counter += 1
    else:
        judge = 0
        for j in range(num_list_counter):
            if num_list[j] == num:
                judge = 1
                count += count_list[j]
                count_list[j] += 1
        if judge == 0:
            num_list_counter += 1
            num_list.append(num)
            count_list.append(1)

print(count)


Fixed submission:
N = int(input())
S = []
count = 0

dic = {}
for i in range(N):
    S.append(input())
    S[i] = sorted(S[i])
    S[i] = ''.join(S[i])
    if dic.setdefault(S[i], 0) > 0:
        count += dic[S[i]]
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
num = []
num_list = []
count_list = []
num_list_counter = 0
count = 0

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

for i in range(N):
    S.append(input())
    num = 1
    num *= pow_k(2, S[i].count('a'))
    num *= pow_k(3 , S[i].count('b'))
    num *= pow_k(5 , S[i].count('c'))
    num *= pow_k(7 , S[i].count('d'))
    num *= pow_k(11 , S[i].count('e'))
    num *= pow_k(13 , S[i].count('f'))
    num *= pow_k(17 , S[i].count('g'))
    num *= pow_k(19 , S[i].count('h'))
    num *= pow_k(23 , S[i].count('i'))
    num *= pow_k(29 , S[i].count('j'))
    num *= pow_k(31 , S[i].count('k'))
    num *= pow_k(37 , S[i].count('l'))
    num *= pow_k(41 , S[i].count('m'))
    num *= pow_k(43 , S[i].count('n'))
    num *= pow_k(47 , S[i].count('o'))
    num *= pow_k(73 , S[i].count('p'))
    num *= pow_k(79 , S[i].count('q'))
    num *= pow_k(83 , S[i].count('r'))
    num *= pow_k(89 , S[i].count('s'))
    num *= pow_k(97 , S[i].count('t'))
    num *= pow_k(101 , S[i].count('u'))
    num *= pow_k(103 , S[i].count('v'))
    num *= pow_k(107 , S[i].count('w'))
    num *= pow_k(109 , S[i].count('x'))
    num *= pow_k(113 , S[i].count('y'))
    num *= pow_k(127 , S[i].count('z'))

    if num_list_counter == 0:
        num_list.append(num)
        count_list.append(1)
        num_list_counter += 1
    else:
        judge = 0
        for j in range(num_list_counter):
            if num_list[j] == num:
                judge = 1
                count += count_list[j]
                count_list[j] += 1
        if judge == 0:
            num_list_counter += 1
            num_list.append(num)
            count_list.append(1)

print(count)


Fixed submission:
N = int(input())
S = []
count = 0

dic = {}
for i in range(N):
    S.append(input())
    S[i] = sorted(S[i])
    S[i] = ''.join(S[i])
    if dic.setdefault(S[i], 0) > 0:
        count += dic[S[i]]
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
num = []
num_list = []
count_list = []
num_list_counter = 0
count = 0

for i in range(N):
    S.append(input())
    num = 1
    num *= 2 ** S[i].count('a')
    num *= 3 ** S[i].count('b')
    num *= 5 ** S[i].count('c')
    num *= 7 ** S[i].count('d')
    num *= 11 ** S[i].count('e')
    num *= 13 ** S[i].count('f')
    num *= 17 ** S[i].count('g')
    num *= 19 ** S[i].count('h')
    num *= 23 ** S[i].count('i')
    num *= 29 ** S[i].count('j')
    num *= 31 ** S[i].count('k')
    num *= 37 ** S[i].count('l')
    num *= 41 ** S[i].count('m')
    num *= 43 ** S[i].count('n')
    num *= 47 ** S[i].count('o')
    num *= 73 ** S[i].count('p')
    num *= 79 ** S[i].count('q')
    num *= 83 ** S[i].count('r')
    num *= 89 ** S[i].count('s')
    num *= 97 ** S[i].count('t')
    num *= 101 ** S[i].count('u')
    num *= 103 ** S[i].count('v')
    num *= 107 ** S[i].count('w')
    num *= 109 ** S[i].count('x')
    num *= 113 ** S[i].count('y')
    num *= 127 ** S[i].count('z')

    if num_list_counter == 0:
        num_list.append(num)
        count_list.append(1)
        num_list_counter += 1
    else:
        judge = 0
        for j in range(num_list_counter):
            if num_list[j] == num:
                judge = 1
                count += count_list[j]
                count_list[j] += 1
        if judge == 0:
            num_list_counter += 1
            num_list.append(num)
            count_list.append(1)

print(count)


Fixed submission:
N = int(input())
S = []
count = 0

dic = {}
for i in range(N):
    S.append(input())
    S[i] = sorted(S[i])
    S[i] = ''.join(S[i])
    if dic.setdefault(S[i], 0) > 0:
        count += dic[S[i]]
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
num = []
num_list = []
count_list = []
num_list_counter = 0
count = 0

for i in range(N):
    S.append(input())
    num = 1
    num *= 2 ** S[i].count('a')
    num *= 3 ** S[i].count('b')
    num *= 5 ** S[i].count('c')
    num *= 7 ** S[i].count('d')
    num *= 11 ** S[i].count('e')
    num *= 13 ** S[i].count('f')
    num *= 17 ** S[i].count('g')
    num *= 19 ** S[i].count('h')
    num *= 23 ** S[i].count('i')
    num *= 29 ** S[i].count('j')
    num *= 31 ** S[i].count('k')
    num *= 37 ** S[i].count('l')
    num *= 41 ** S[i].count('m')
    num *= 43 ** S[i].count('n')
    num *= 47 ** S[i].count('o')
    num *= 73 ** S[i].count('p')
    num *= 79 ** S[i].count('q')
    num *= 83 ** S[i].count('r')
    num *= 89 ** S[i].count('s')
    num *= 97 ** S[i].count('t')
    num *= 101 ** S[i].count('u')
    num *= 103 ** S[i].count('v')
    num *= 107 ** S[i].count('w')
    num *= 109 ** S[i].count('x')
    num *= 113 ** S[i].count('y')
    num *= 127 ** S[i].count('z')

    if num_list_counter == 0:
        num_list.append(num)
        count_list.append(1)
        num_list_counter += 1
    else:
        judge = 0
        for j in range(num_list_counter):
            if num_list[j] == num:
                judge = 1
                count += count_list[j]
                count_list[j] += 1
        if judge == 0:
            num_list_counter += 1
            num_list.append(num)
            count_list.append(1)

print(count)


Fixed submission:
N = int(input())
S = []
count = 0

dic = {}
for i in range(N):
    S.append(input())
    S[i] = sorted(S[i])
    S[i] = ''.join(S[i])
    if dic.setdefault(S[i], 0) > 0:
        count += dic[S[i]]
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
num = []
num_list = []
count_list = []
num_list_counter = 0
count = 0

for i in range(N):
    S.append(input())
    num = 1
    num *= 2 ** S[i].count('a')
    num *= 3 ** S[i].count('b')
    num *= 5 ** S[i].count('c')
    num *= 7 ** S[i].count('d')
    num *= 11 ** S[i].count('e')
    num *= 13 ** S[i].count('f')
    num *= 17 ** S[i].count('g')
    num *= 19 ** S[i].count('h')
    num *= 23 ** S[i].count('i')
    num *= 29 ** S[i].count('j')
    num *= 31 ** S[i].count('k')
    num *= 37 ** S[i].count('l')
    num *= 41 ** S[i].count('m')
    num *= 43 ** S[i].count('n')
    num *= 47 ** S[i].count('o')
    num *= 73 ** S[i].count('p')
    num *= 79 ** S[i].count('q')
    num *= 83 ** S[i].count('r')
    num *= 89 ** S[i].count('s')
    num *= 97 ** S[i].count('t')
    num *= 101 ** S[i].count('u')
    num *= 103 ** S[i].count('v')
    num *= 107 ** S[i].count('w')
    num *= 109 ** S[i].count('x')
    num *= 113 ** S[i].count('y')
    num *= 127 ** S[i].count('z')

    if num_list_counter == 0:
        num_list.append(num)
        count_list.append(1)
        num_list_counter += 1
    else:
        judge = 0
        for j in range(num_list_counter):
            if num_list[j] == num:
                judge = 1
                count += count_list[j]
                count_list[j] += 1
        if judge == 0:
            num_list_counter += 1
            num_list.append(num)
            count_list.append(1)

print(count)


Fixed submission:
N = int(input())
S = []
count = 0

dic = {}
for i in range(N):
    S.append(input())
    S[i] = sorted(S[i])
    S[i] = ''.join(S[i])
    if dic.setdefault(S[i], 0) > 0:
        count += dic[S[i]]
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
num = []
count = 0
for i in range(N):
    S.append(input())
    num.append(1)
    for j in range(S[i].count('a')):
        num[i] *= 103
    for j in range(S[i].count('b')):
        num[i] *= 107
    for j in range(S[i].count('c')):
        num[i] *= 109
    for j in range(S[i].count('d')):
        num[i] *= 113
    for j in range(S[i].count('e')):
        num[i] *= 127
    for j in range(S[i].count('f')):
        num[i] *= 2
    for j in range(S[i].count('1')):
        num[i] *= 3
    for j in range(S[i].count('h')):
        num[i] *= 5
    for j in range(S[i].count('i')):
        num[i] *= 7
    for j in range(S[i].count('j')):
        num[i] *= 11
    for j in range(S[i].count('k')):
        num[i] *= 13
    for j in range(S[i].count('l')):
        num[i] *= 17
    for j in range(S[i].count('m')):
        num[i] *= 19
    for j in range(S[i].count('n')):
        num[i] *= 23
    for j in range(S[i].count('o')):
        num[i] *= 29
    for j in range(S[i].count('p')):
        num[i] *= 31
    for j in range(S[i].count('q')):
        num[i] *= 37
    for j in range(S[i].count('r')):
        num[i] *= 41
    for j in range(S[i].count('s')):
        num[i] *= 43
    for j in range(S[i].count('t')):
        num[i] *= 47
    for j in range(S[i].count('u')):
        num[i] *= 73
    for j in range(S[i].count('v')):
        num[i] *= 79
    for j in range(S[i].count('w')):
        num[i] *= 83
    for j in range(S[i].count('x')):
        num[i] *= 89
    for j in range(S[i].count('y')):
        num[i] *= 97
    for j in range(S[i].count('z')):
        num[i] *= 101

for i in range(N):
    for j in range(i+1, N):
        if num[i] == num[j]:
            count += 1

print(count)


Fixed submission:
N = int(input())
S = []
count = 0

dic = {}
for i in range(N):
    S.append(input())
    S[i] = sorted(S[i])
    S[i] = ''.join(S[i])
    if dic.setdefault(S[i], 0) > 0:
        count += dic[S[i]]
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
print(count)