Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

s = [sorted(input()) for i in range(N)]
    

c = [s[i+1:].count(elm) for i, elm in enumerate(s)]
    

print(sum(c))


Fixed submission:
N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
    int N;
    cin >> N;
    
    vector<string> v;
    string s;
    for(int i=0; i<N; i++) {
        cin >> s;
        v.push_back(s);
    }

    for(int i=0; i<v.size(); i++) {
        sort(v[i].begin(), v[i].end());
    }

    int result = 0;
    for(int i=0; i<v.size(); i++) {
        result += count(v.begin()+i, v.end(), v[i]) - 1;
    }
    
    cout << result << endl;
    
    return 0;
}


Fixed submission:
N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
    int N;
    cin >> N;
    
    vector<string> v;
    string s;
    for(int i=0; i<N; i++) {
        cin >> s;
        v.push_back(s);
    }

    for(int i=0; i<v.size(); i++) {
        sort(v[i].begin(), v[i].end());
    }

    int result = 0;
    for(int i=0; i<v.size(); i++) {
        result += count(v.begin()+i, v.end(), v[i]);
    }
    
    cout << result << endl;
    
    return 0;
}


Fixed submission:
N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

s = [sorted(input()) for i in range(N)]
    

c = [s[i+1:].count(elm) for i, elm in enumerate(s)]
    

print(sum(c))


Fixed submission:
N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

s = []
for i in range(N):
    s.append(sorted(input()))

c = [s[i+1:].count(elm) for i, elm in enumerate(s)]
    

print(sum(c))


Fixed submission:
N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

s = []
for i in range(N):
    s.append(sorted(input()))

result = 0
for i, elm in enumerate(s):
    result += s[i+1:].count(elm)

print(result)


Fixed submission:
N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

s = []
for i in range(N):
    s.append(sorted(input()))

result = 0
for i, elm in enumerate(s):
    for j in range(i+1, N):
        if s[j] == elm:
            result += 1

print(result)


Fixed submission:
N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)

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

N = int(input())

s = []
for i in range(N):
    c = Counter(input())
    s.append(sorted(list(c.items()))) 

result = 0
for elm in s:
    result += s.count(elm) - 1

print(int(result/2))


Fixed submission:
N = int(input())

s = ["".join(sorted(input())) for i in range(N)]

count = 0
d = {}
for elm in s:
    if elm in d:
        count += d[elm]
        d[elm] += 1
    else:
        d[elm] = 1

print(count)