stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)

#define REP(i,a,b) REPP(i,a,b,1)

#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)

#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) REP(i,0,(int)a-1)

#define FORD(i,a) REV(i,(int)a-1,0)

#define PB push_back

#define POB pop_back

#define MP make_pair

#define FI first

#define SE second

typedef long long ll;

typedef unsigned long long ull;

typedef pair < int , int > pii;

typedef vector < int > vi;

typedef vector < pii > vii;

typedef vector < ll > vl;



const double EPS = 1e-9;

const double PI = acos(-1);

const int INF = 1e9;

const ll MOD = 1e9 + 7;



ll addMod(ll a, ll b){

	return (a+b) % MOD;

}



ll mulMod(ll a, ll b){

	return (a*b) % MOD;

}



ll fast(ll a, ll b){

	if(b == 0) return 1;

	ll tmp = fast(a,b/2);

	tmp = mulMod(tmp, tmp);

	if(b & 1) tmp = mulMod(tmp, a);

	return tmp;

}



/////////////////////////////////////////////////////////



const int N = 1e5;



int n;

string str[N+5];





ll solve(){

	ll ret = 0, sz = 0;

	int bef = 0;

	FOR(i,n){

		if(str[i] != str[bef]){

			ret += sz * (sz - 1) / 2;

			bef = i;

			sz = 0;

		}

		sz++;

	}

	ret += sz * (sz - 1) / 2;

	return ret;

}



int main(){

	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> n;

	FOR(i,n){

		cin >> str[i];

		sort(str[i].begin(), str[i].end());

	}

	sort(str,str+n);

	cout << solve() << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.25354771828044x):
#include <bits/stdc++.h>

using namespace std;

#define ll	    long long

#define vi      vector <int>

#define vii     vector <pair<int,int>>

#define ii      pair<int,int>

#define loop(n)	for(int i=0;i<n;i++)

ll mod=1e9+7;

bool is_prime(int n)

{

    if(n==2)

        return true;

    if(n%2==0||n<2)

        return false;

    for(int i=3; i<=sqrt(n); i+=2)

    {

        if(n%i==0)

            return false;

    }

    return true;

}

long long power(ll n, ll k){

    if(k==0) return 1;

    ll sq=(power(n,k/2))%mod;

    sq=(sq*sq)%mod;

    if(k%2==1)

        sq=(sq*n)%mod;

    return sq%mod;

}

void low(char &c){

c=tolower(c);

}

void primeFactors(int n)

{

    while (n % 2 == 0)

    {

        cout << 2 << " ";

        n = n/2;

    }



    for (int i = 3; i <= sqrt(n); i = i + 2)

    {

        while (n % i == 0)

        {

            cout << i << " ";

            n = n/i;

        }

    }



    if (n > 2)

        cout << n << " ";

}



#include <iostream>

using namespace std;

void fast();

map<string,ll> M;



int main() {

fast();

int n;

string s;

cin >>n;

loop(n){

    cin >> s;

    sort(s.begin(),s.end());

    M[s]++;

}

ll sum=0;

for(auto it : M){

    sum += (((it.second-1)*it.second)/2);

}

cout << sum;

}











void fast(){

std::ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);



}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define ll unsigned long long int

ll ar[500009],br[500009],fr[500009];

string s1,s2,s3[200005];

map<string,int>mp;

int main()

{

    ll i,j,k,e,r,n,s,d,f,g,h,u,ck=0,ck1=0,t;

    cin >> n;

    g=0;

    for(i=1; i<=n; i++)

    {

        cin >> s3[i];

    sort(s3[i].begin(),s3[i].end());

    mp[s3[i]]++;

    if(mp[s3[i]]>1)

    {



        g+=mp[s3[i]]-1;

    }

    }

//    for(i=1;i<n;i++)

//    {

//        for(j=i+1;j<=n;j++)

//        {

//            if(s3[i]==s3[j])

//            {

//                g++;

//            }

//        }

//    }

    cout << g << endl;

    return 0;

}

/*

2

greenbin

beginner

*/


// Faster C++ solution for the same problem (measured speedup: 8.043621329024626x):
#include <bits/stdc++.h>

using namespace std;

#define ll	    long long

#define vi      vector <int>

#define vii     vector <pair<int,int>>

#define ii      pair<int,int>

#define loop(n)	for(int i=0;i<n;i++)

ll mod=1e9+7;

bool is_prime(int n)

{

    if(n==2)

        return true;

    if(n%2==0||n<2)

        return false;

    for(int i=3; i<=sqrt(n); i+=2)

    {

        if(n%i==0)

            return false;

    }

    return true;

}

long long power(ll n, ll k){

    if(k==0) return 1;

    ll sq=(power(n,k/2))%mod;

    sq=(sq*sq)%mod;

    if(k%2==1)

        sq=(sq*n)%mod;

    return sq%mod;

}

void low(char &c){

c=tolower(c);

}

void primeFactors(int n)

{

    while (n % 2 == 0)

    {

        cout << 2 << " ";

        n = n/2;

    }



    for (int i = 3; i <= sqrt(n); i = i + 2)

    {

        while (n % i == 0)

        {

            cout << i << " ";

            n = n/i;

        }

    }



    if (n > 2)

        cout << n << " ";

}



#include <iostream>

using namespace std;

void fast();

map<string,ll> M;



int main() {

fast();

int n;

string s;

cin >>n;

loop(n){

    cin >> s;

    sort(s.begin(),s.end());

    M[s]++;

}

ll sum=0;

for(auto it : M){

    sum += (((it.second-1)*it.second)/2);

}

cout << sum;

}











void fast(){

std::ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);



}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cstring>

#include<string>

#include<cstdio>

using namespace std;

string a[100000];

int main(){

    long long n;

    cin>>n;

    long long ans=0;

    for(long long i=0;i<n;i++){

        cin>>a[i];

        std::sort(a[i].begin(),a[i].end());

    }

    sort(a,a+n);

    long long z[100000]={0},cnt=0;

    for(long long  i=0;i<n;i++){

        if(i==0){

            z[cnt]=1;

            continue;

        }

        if(a[i]==a[i-1]){

            z[cnt]++;

        }

        else{

            cnt++;

            z[cnt]++;

        }

    }



    for(long long  i=0;i<=cnt;i++){

        ans+=((z[i]*(z[i]-1))/2);

    }

    cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 5.176359578733251x):
#include <bits/stdc++.h>

using namespace std;

#define ll	    long long

#define vi      vector <int>

#define vii     vector <pair<int,int>>

#define ii      pair<int,int>

#define loop(n)	for(int i=0;i<n;i++)

ll mod=1e9+7;

bool is_prime(int n)

{

    if(n==2)

        return true;

    if(n%2==0||n<2)

        return false;

    for(int i=3; i<=sqrt(n); i+=2)

    {

        if(n%i==0)

            return false;

    }

    return true;

}

long long power(ll n, ll k){

    if(k==0) return 1;

    ll sq=(power(n,k/2))%mod;

    sq=(sq*sq)%mod;

    if(k%2==1)

        sq=(sq*n)%mod;

    return sq%mod;

}

void low(char &c){

c=tolower(c);

}

void primeFactors(int n)

{

    while (n % 2 == 0)

    {

        cout << 2 << " ";

        n = n/2;

    }



    for (int i = 3; i <= sqrt(n); i = i + 2)

    {

        while (n % i == 0)

        {

            cout << i << " ";

            n = n/i;

        }

    }



    if (n > 2)

        cout << n << " ";

}



#include <iostream>

using namespace std;

void fast();

map<string,ll> M;



int main() {

fast();

int n;

string s;

cin >>n;

loop(n){

    cin >> s;

    sort(s.begin(),s.end());

    M[s]++;

}

ll sum=0;

for(auto it : M){

    sum += (((it.second-1)*it.second)/2);

}

cout << sum;

}











void fast(){

std::ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);



}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int N = 1e5;



int readInt ()

{

    bool minus = false;

    int result = 0;

    char ch;

    ch = getchar();

    while (true)

    {

        if (ch == '-') break;

        if (ch >= '0' && ch <= '9') break;

        ch = getchar();

    }

    if (ch == '-') minus = true;

    else result = ch-'0';

    while (true)

    {

        ch = getchar();

        if (ch < '0' || ch > '9') break;

        result = result*10 + (ch - '0');

    }

    if (minus)

        return -result;

    else

        return result;

}

string s[N + 1];

main() {

    int n = readInt();

    for (int i = 1; i <= n; i++) {

        cin >> s[i];

        sort(s[i].begin(), s[i].end());

    }

    sort(s + 1, s + n + 1);

    int ans = 0, cnt = 1;

    for (int i = 2; i <= n; i++) {

        if (s[i] == s[i - 1]) {

            ++cnt;

        } else {

//            cout << s[i] << " " << cnt << " fuck \n";

            ans += cnt * (cnt - 1) / 2;

            cnt = 1;

        }

    }

    if (cnt) {

        ans += cnt * (cnt - 1) / 2;

    }

    cout << ans;

}


// Faster C++ solution for the same problem (measured speedup: 4.327715700052324x):
#include <bits/stdc++.h>



using namespace std;

const int N = 1e5 + 3;

map<string, int> freq;

char s[22];

int main() {

#ifndef ONLINE_JUDGE

//	freopen("input.in", "r", stdin);

//	freopen("output.out", "w", stdout);

#endif

	int n;

	scanf("%d", &n);

	long long res = 0;

	for (int i = 0; i < n; ++i) {

		scanf("%s", s);

		sort(s, s + 10);

		res += freq[s]++;

	}

	printf("%lld\n", res);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int N = 1e5;



int readInt ()

{

    bool minus = false;

    int result = 0;

    char ch;

    ch = getchar();

    while (true)

    {

        if (ch == '-') break;

        if (ch >= '0' && ch <= '9') break;

        ch = getchar();

    }

    if (ch == '-') minus = true;

    else result = ch-'0';

    while (true)

    {

        ch = getchar();

        if (ch < '0' || ch > '9') break;

        result = result*10 + (ch - '0');

    }

    if (minus)

        return -result;

    else

        return result;

}

string s[N + 1];

main() {

    int n = readInt();

    for (int i = 1; i <= n; i++) {

        cin >> s[i];

        sort(s[i].begin(), s[i].end());

    }

    sort(s + 1, s + n + 1);

    int ans = 0, cnt = 1;

    for (int i = 2; i <= n; i++) {

        if (s[i] == s[i - 1]) {

            ++cnt;

        } else {

//            cout << s[i] << " " << cnt << " fuck \n";

            ans += cnt * (cnt - 1) / 2;

            cnt = 1;

        }

    }

    if (cnt) {

        ans += cnt * (cnt - 1) / 2;

    }

    cout << ans;

}


// Faster C++ solution for the same problem (measured speedup: 4.271915758083379x):
#include<iostream>

#include<map>

#include<algorithm>

#include<string>

using namespace std ;



int main()

{

	long long n ;

	long long G = 0 ;

	map <string , long long> name ;

	string str ;

	cin >> n ;

	while(n --)

	{

		cin >> str ;

		sort(str.begin() , str.end()) ;

		name[str] ++ ;

		if(name[str] > 1)

		{

			G += name[str] - 1 ;

		}

	}

	cout << G << endl ;

	return 0 ;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int N = 1e5;



int readInt ()

{

    bool minus = false;

    int result = 0;

    char ch;

    ch = getchar();

    while (true)

    {

        if (ch == '-') break;

        if (ch >= '0' && ch <= '9') break;

        ch = getchar();

    }

    if (ch == '-') minus = true;

    else result = ch-'0';

    while (true)

    {

        ch = getchar();

        if (ch < '0' || ch > '9') break;

        result = result*10 + (ch - '0');

    }

    if (minus)

        return -result;

    else

        return result;

}

string s[N + 1];

main() {

    int n = readInt();

    for (int i = 1; i <= n; i++) {

        cin >> s[i];

        sort(s[i].begin(), s[i].end());

    }

    sort(s + 1, s + n + 1);

    int ans = 0, cnt = 1;

    for (int i = 2; i <= n; i++) {

        if (s[i] == s[i - 1]) {

            ++cnt;

        } else {

//            cout << s[i] << " " << cnt << " fuck \n";

            ans += cnt * (cnt - 1) / 2;

            cnt = 1;

        }

    }

    if (cnt) {

        ans += cnt * (cnt - 1) / 2;

    }

    cout << ans;

}


// Faster C++ solution for the same problem (measured speedup: 4.271931692798426x):
#include<iostream>

#include<string>

#include<map>

#include<algorithm>

using namespace std;

string a;

int main()

{

    long long N,ans=0,i;

    map<string,long long> mp;

    cin>>N;

    for( i=0;i<N;i++)

    {

        cin>>a;

        sort(a.begin(),a.end());

        ans+=mp[a];

        mp[a]++;

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int N = 1e5;



int readInt ()

{

    bool minus = false;

    int result = 0;

    char ch;

    ch = getchar();

    while (true)

    {

        if (ch == '-') break;

        if (ch >= '0' && ch <= '9') break;

        ch = getchar();

    }

    if (ch == '-') minus = true;

    else result = ch-'0';

    while (true)

    {

        ch = getchar();

        if (ch < '0' || ch > '9') break;

        result = result*10 + (ch - '0');

    }

    if (minus)

        return -result;

    else

        return result;

}

string s[N + 1];

main() {

    int n = readInt();

    for (int i = 1; i <= n; i++) {

        cin >> s[i];

        sort(s[i].begin(), s[i].end());

    }

    sort(s + 1, s + n + 1);

    int ans = 0, cnt = 1;

    for (int i = 2; i <= n; i++) {

        if (s[i] == s[i - 1]) {

            ++cnt;

        } else {

//            cout << s[i] << " " << cnt << " fuck \n";

            ans += cnt * (cnt - 1) / 2;

            cnt = 1;

        }

    }

    if (cnt) {

        ans += cnt * (cnt - 1) / 2;

    }

    cout << ans;

}


// Faster C++ solution for the same problem (measured speedup: 4.313186049907054x):
#include <bits/stdc++.h>



using namespace std;



int main() {

    int n;

    long long temp, total=0;

    cin >> n;



    map<string,int> words;

    for(int i=0; i<n; i++){

        string str;

        cin >> str;

        sort(str.begin(), str.end());

        words[str]++;

    }



    for(auto word : words){

        temp = word.second;

        total += temp*(temp-1)/2;

    }



    cout << total;



    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int N = 1e5;



int readInt ()

{

    bool minus = false;

    int result = 0;

    char ch;

    ch = getchar();

    while (true)

    {

        if (ch == '-') break;

        if (ch >= '0' && ch <= '9') break;

        ch = getchar();

    }

    if (ch == '-') minus = true;

    else result = ch-'0';

    while (true)

    {

        ch = getchar();

        if (ch < '0' || ch > '9') break;

        result = result*10 + (ch - '0');

    }

    if (minus)

        return -result;

    else

        return result;

}

string s[N + 1];

main() {

    int n = readInt();

    for (int i = 1; i <= n; i++) {

        cin >> s[i];

        sort(s[i].begin(), s[i].end());

    }

    sort(s + 1, s + n + 1);

    int ans = 0, cnt = 1;

    for (int i = 2; i <= n; i++) {

        if (s[i] == s[i - 1]) {

            ++cnt;

        } else {

//            cout << s[i] << " " << cnt << " fuck \n";

            ans += cnt * (cnt - 1) / 2;

            cnt = 1;

        }

    }

    if (cnt) {

        ans += cnt * (cnt - 1) / 2;

    }

    cout << ans;

}


// Faster C++ solution for the same problem (measured speedup: 4.2567525797095405x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

string s,ss,str;

map<string,ll>mp;

vector<string>v;

int main()

{

    ll n,i,f=0,r=0,j,c=0,res=0;

    cin>>n;

    ss="";

    r=n;

    while(n--){

        cin>>s;

        sort(s.begin(),s.end());

        mp[s]++;

        if(mp[s]>1)continue;

        v.push_back(s);

       // cout<<v[0]<<endl;

    }

    //cout<<v.size();

    for(i=0;i<v.size();i++){

      if(mp[v[i]]==1)continue;

       f=f+mp[v[i]];

       f--;

       res=res+(f*(f+1))/2;

       f=0;

    }

    f--;

    cout<<res<<endl;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int N = 1e5;



int readInt ()

{

    bool minus = false;

    int result = 0;

    char ch;

    ch = getchar();

    while (true)

    {

        if (ch == '-') break;

        if (ch >= '0' && ch <= '9') break;

        ch = getchar();

    }

    if (ch == '-') minus = true;

    else result = ch-'0';

    while (true)

    {

        ch = getchar();

        if (ch < '0' || ch > '9') break;

        result = result*10 + (ch - '0');

    }

    if (minus)

        return -result;

    else

        return result;

}

string s[N + 1];

main() {

    int n = readInt();

    for (int i = 1; i <= n; i++) {

        cin >> s[i];

        sort(s[i].begin(), s[i].end());

    }

    sort(s + 1, s + n + 1);

    int ans = 0, cnt = 1;

    for (int i = 2; i <= n; i++) {

        if (s[i] == s[i - 1]) {

            ++cnt;

        } else {

//            cout << s[i] << " " << cnt << " fuck \n";

            ans += cnt * (cnt - 1) / 2;

            cnt = 1;

        }

    }

    if (cnt) {

        ans += cnt * (cnt - 1) / 2;

    }

    cout << ans;

}


// Faster C++ solution for the same problem (measured speedup: 4.246902506069432x):
#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#include<iostream>

#include<algorithm>

#include<iomanip>

#include<string>

#include<cmath>

#include<vector>

#include<set>

#include<queue>

#include<stack>

#include<fstream>

#include<map>

#include<bitset>

#include<unordered_map>

#include<cstring>

#include<cctype>

using namespace std;

#define  ll long long

#define  ull unsigned long long

#define  ul unsigned long

#define all(v) v.begin(),v.end()

#define sz(n) (int)n.size()

#define pb(s) push_back(s);

#define format(n) fixed<<setprecision(n)

#define finl "\n"

#define Mohammed_Atef_Hassan fast();

#define mod 1000000007

#define INF LLONG_MAX

#define PI acos(-1)

#define clr(dp,n) memset(dp,n,sizeof dp)

#define ex(n) return cout<<n<<finl,0;

int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };

ll fix_mod(ll x, ll y)

{

	return (y + x % y) % y;

}

void fast() {

	std::ios_base::sync_with_stdio(false);

	cin.tie(nullptr); cout.tie(nullptr);





}

map<string, ll>cnt;

int main()

{

	Mohammed_Atef_Hassan

		int t; string s;

	cin >> t;

	while (t--)

	{

		cin >> s;

		sort(all(s));

		cnt[s]++;

	}

	ll res = 0;

	for (auto v : cnt)

	{

		res += v.second*(v.second - 1) / 2;

	}

	ex(res);

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int N = 1e5;



int readInt ()

{

    bool minus = false;

    int result = 0;

    char ch;

    ch = getchar();

    while (true)

    {

        if (ch == '-') break;

        if (ch >= '0' && ch <= '9') break;

        ch = getchar();

    }

    if (ch == '-') minus = true;

    else result = ch-'0';

    while (true)

    {

        ch = getchar();

        if (ch < '0' || ch > '9') break;

        result = result*10 + (ch - '0');

    }

    if (minus)

        return -result;

    else

        return result;

}

string s[N + 1];

main() {

    int n = readInt();

    for (int i = 1; i <= n; i++) {

        cin >> s[i];

        sort(s[i].begin(), s[i].end());

    }

    sort(s + 1, s + n + 1);

    int ans = 0, cnt = 1;

    for (int i = 2; i <= n; i++) {

        if (s[i] == s[i - 1]) {

            ++cnt;

        } else {

//            cout << s[i] << " " << cnt << " fuck \n";

            ans += cnt * (cnt - 1) / 2;

            cnt = 1;

        }

    }

    if (cnt) {

        ans += cnt * (cnt - 1) / 2;

    }

    cout << ans;

}


// Faster C++ solution for the same problem (measured speedup: 4.255062009256815x):
#include <bits/stdc++.h>

using namespace std;



#define all(v)   v.begin(), v.end()

#define endl "\n";

#define pb push_back

#define F first

#define S second

#define JULEE_DO_THE_THING fast()

#define to_str to_string

#define isOdd(n)    (n&1)

#define LLMAX LLONG_MAX

#define LLMIN LLONG_MIN

#define IMIN INT_MIN

#define IMAX INT_MAX

#define pow POW



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef double dd;

typedef string str;

typedef vector<int> vecint;

typedef vector<ll> vecll;

typedef pair<int, int> pii;



void fast() {

	cin.tie(0);

	cout.tie(0);

	cin.sync_with_stdio(0);

}



bool compare(int &a, int &b) {

	return a > b;

}



ll numOfDigits(ll n) {

	if (!n)

		return 1;

	return (ll) (log10(n)) + 1;

}



ull POW(ll a, ll b);



/*



 */



ll BN();



int main() {

	JULEE_DO_THE_THING;

	//freopen("test cases\\.txt", "r", stdin) ;

    int n; cin>>n;

    map<str, int> mp;

    ll sum = 0;

    for(int i =0; i<n; i++){

        str s; cin>>s;

        sort(all(s));

        mp[s]++;

    }

    for(auto &it: mp){

        ll x = it.S;

        sum += x*(x-1)/2;

    }

    cout<<sum;

	return 0;

}



ll BN() {

	ll low = 0;

	ll up = 0;

	ll ans = 0;

	while (low <= up) {

		ll mid = ((low + up) / 2);

		if (mid) {

			ans = mid;

			low = mid + 1;

		} else

			up = mid - 1;

	}

	return ans;

}



ull POW(ll a, ll b) {

	ull res = 1;

	while (b > 0) {

		if (b & 1)

			res = res * a;

		a = a * a;

		b >>= 1;

	}

	return res;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long



using namespace std;



const int N = 1e5;



int readInt ()

{

    bool minus = false;

    int result = 0;

    char ch;

    ch = getchar();

    while (true)

    {

        if (ch == '-') break;

        if (ch >= '0' && ch <= '9') break;

        ch = getchar();

    }

    if (ch == '-') minus = true;

    else result = ch-'0';

    while (true)

    {

        ch = getchar();

        if (ch < '0' || ch > '9') break;

        result = result*10 + (ch - '0');

    }

    if (minus)

        return -result;

    else

        return result;

}

string s[N + 1];

main() {

    int n = readInt();

    for (int i = 1; i <= n; i++) {

        cin >> s[i];

        sort(s[i].begin(), s[i].end());

    }

    sort(s + 1, s + n + 1);

    int ans = 0, cnt = 1;

    for (int i = 2; i <= n; i++) {

        if (s[i] == s[i - 1]) {

            ++cnt;

        } else {

//            cout << s[i] << " " << cnt << " fuck \n";

            ans += cnt * (cnt - 1) / 2;

            cnt = 1;

        }

    }

    if (cnt) {

        ans += cnt * (cnt - 1) / 2;

    }

    cout << ans;

}


// Faster C++ solution for the same problem (measured speedup: 4.301364156258935x):
#include <iostream>

#include<bits/stdc++.h>

using namespace std;











vector<string>finall;

int main(){

int n;

cin>>n;

for(int i=0;i<n;i++){

    string str;

    cin>>str;

    sort(str.begin(),str.end());

    finall.push_back(str);



}







long long int counter=1;

long long int res=0;

sort(finall.begin(),finall.end());

//for(auto x: finall)cout<<x<< " ";

string str2="";

for(int i=0;i<n;i++){



    if(str2==finall[i])counter++;

    else {

            res+=((counter*(counter-1))/2);

              counter=1 ;}



    str2=finall[i];



}

res+=((counter*(counter-1))/2);

cout<<res<<endl;













}