stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

#include<string.h>

using namespace std;

#define ll long long

string a[100001];

int main()

{

	int n;

	cin>>n;

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

	{

		char b[11];

		cin>>b;

		sort(b,b+strlen(b));

		a[i]=b;

	}

	sort(a,a+n);

	ll count=0;

	ll sum=0;

	for(int i=0;i<n-1;i++)

	{

		if(a[i]==a[i+1])

		{

			count++;

		}

		else

		{

			if(count)

			{

				sum+=count*(count+1)/2;

			}

			count=0;

		}

	}

	if(count)

	{

		sum+=count*(count+1)/2;

	}

	cout<<sum<<endl;

	return 0;

} 

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

#include<iostream>

#include<bits/stdc++.h> 

using namespace std;

int main(){

    int n;

    string a;

    vector<string> v;

    cin>>n;

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

        cin>>a;

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

        v.push_back(a);

    }

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

   

    long long total=0,can=0;

    int j=0;

    int k=0;

        for(auto x: v)

        {

           if(v[k]==x)

           {

               can=can+1;

           }

           else

           {

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

               k=j;

               can=1;

           }

            j+=1;

        }

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

        cout<<total;

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

#include<string>

#include<algorithm>

#include<string.h>

using namespace std;

#define ll long long

string a[100001];

int main()

{

	int n;

	cin>>n;

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

	{

		char b[11];

		cin>>b;

		sort(b,b+strlen(b));

		a[i]=b;

	}

	sort(a,a+n);

	ll count=0;

	ll sum=0;

	for(int i=0;i<n-1;i++)

	{

		if(a[i]==a[i+1])

		{

			count++;

		}

		else

		{

			if(count)

			{

				sum+=count*(count+1)/2;

			}

			count=0;

		}

	}

	if(count)

	{

		sum+=count*(count+1)/2;

	}

	cout<<sum<<endl;

	return 0;

} 

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

using namespace std;

typedef long long ll;



const int N = 1e5+5, M = 1e6+6, OO = 0x3f3f3f3f;

map<string, ll> m;

int n;

int main()

{

    cin>>n;

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

    {

        string s;

        cin>>s;

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

        m[s]++;

    }

    ll ans = 0;

    for(auto p : m)

        ans += (p.second  * (p.second - ll(1) )/ ll(2));

    cout<<ans<<endl;

    

    return 0;

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

#include<string>

#include<algorithm>

#include<string.h>

using namespace std;

#define ll long long

string a[100001];

int main()

{

	int n;

	cin>>n;

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

	{

		char b[11];

		cin>>b;

		sort(b,b+strlen(b));

		a[i]=b;

	}

	sort(a,a+n);

	ll count=0;

	ll sum=0;

	for(int i=0;i<n-1;i++)

	{

		if(a[i]==a[i+1])

		{

			count++;

		}

		else

		{

			if(count)

			{

				sum+=count*(count+1)/2;

			}

			count=0;

		}

	}

	if(count)

	{

		sum+=count*(count+1)/2;

	}

	cout<<sum<<endl;

	return 0;

} 

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

using namespace std;



const int N = 2e5+5 , M = 1e9+5, OO = 0x3f3f3f3f;

typedef long long ll;

ll n;

map<string, int> ma;

ll ans;

string s;



ll calc(ll x)

{

    return (x * (x-1)/2) ;

}



int main()

{

    cin >> n;

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

    {

        cin >> s;

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

        ma[s]++;

    }

    for(auto sf : ma)

    {

        //cout << sf.first << " " << sf.second << endl;

        if(sf.second > 1)

        {

            //cout << calc(sf.second) << endl;

            ans += calc(sf.second);

        }

    }

    cout << ans << endl;

    return 0;

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

#include<string>

#include<algorithm>

#include<string.h>

using namespace std;

#define ll long long

string a[100001];

int main()

{

	int n;

	cin>>n;

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

	{

		char b[11];

		cin>>b;

		sort(b,b+strlen(b));

		a[i]=b;

	}

	sort(a,a+n);

	ll count=0;

	ll sum=0;

	for(int i=0;i<n-1;i++)

	{

		if(a[i]==a[i+1])

		{

			count++;

		}

		else

		{

			if(count)

			{

				sum+=count*(count+1)/2;

			}

			count=0;

		}

	}

	if(count)

	{

		sum+=count*(count+1)/2;

	}

	cout<<sum<<endl;

	return 0;

} 

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

using namespace std; 

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

 

 

int main()

{

     ios_base::sync_with_stdio(0); 

     cin.tie(0); cout.tie(0);  

     long long n, num=0; 

     cin >> n;

     string arr[n];

     map<string, int> mp;

    

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

    {        

        cin >> arr[i];

        sort(all(arr[i]));

        mp[arr[i]]++;

    }

 

 

    for(auto it : mp)

    {

        pair<string, long long > p = it;

        num += p.second*(p.second-1)/2;

    }

    cout << num;

 

    return 0;

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

#include<string>

#include<algorithm>

#include<string.h>

using namespace std;

#define ll long long

string a[100001];

int main()

{

	int n;

	cin>>n;

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

	{

		char b[11];

		cin>>b;

		sort(b,b+strlen(b));

		a[i]=b;

	}

	sort(a,a+n);

	ll count=0;

	ll sum=0;

	for(int i=0;i<n-1;i++)

	{

		if(a[i]==a[i+1])

		{

			count++;

		}

		else

		{

			if(count)

			{

				sum+=count*(count+1)/2;

			}

			count=0;

		}

	}

	if(count)

	{

		sum+=count*(count+1)/2;

	}

	cout<<sum<<endl;

	return 0;

} 

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

using namespace std;

int main()

{

    long long int n, sum = 0;

    cin >> n;

    string s;

    map<string, long long int> mp;



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

    {

        cin >> s;

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

        mp[s]++;

    }



    for (auto it = mp.begin(); it != mp.end(); ++it)

    {

        long long int s = it->second;

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

    }

    cout << sum;

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

#include<string>

#include<algorithm>

#include<string.h>

using namespace std;

#define ll long long

string a[100001];

int main()

{

	int n;

	cin>>n;

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

	{

		char b[11];

		cin>>b;

		sort(b,b+strlen(b));

		a[i]=b;

	}

	sort(a,a+n);

	ll count=0;

	ll sum=0;

	for(int i=0;i<n-1;i++)

	{

		if(a[i]==a[i+1])

		{

			count++;

		}

		else

		{

			if(count)

			{

				sum+=count*(count+1)/2;

			}

			count=0;

		}

	}

	if(count)

	{

		sum+=count*(count+1)/2;

	}

	cout<<sum<<endl;

	return 0;

} 

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



using namespace std;



#define ll long long

#define mx 0

#define mn 1e9

#define v(dt) vector<dt>

#define pr(x, y) pair<x,y>

#define loop(x, s, n) for(int x = s; x < n; ++x)

#define in_arr(n) loop(i,0,n){cin>>a[i];}

#define out_arr(n) loop(i,0,n){cout<<a[i];}



const int N = 1e5 + 7;



inline void boost() {

    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);

}



int main() {

    boost();

    ll n;

    cin>>n;

    map <string,ll> mp;

    vector<string> a(n);

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

    {

        cin>>a[i];

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

        ++mp[a[i]];

    }

    ll cnt = 0;

    for (auto i:mp)

    {

        if (i.second>1) cnt+=(i.second*(i.second-1)/2);

    }

    cout<<cnt;



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

using namespace std;

#define ll long long int

ll ar[500009],br[500009];

map<string,ll>mp;

int main()

{

    ll a,b,c,i,j,k=0,x=0;

    string s;

    cin>>a;

    getchar();

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

    {

        cin>>s;

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

        if(mp.find(s)==mp.end())

        {

            k++;

            mp[s]=k;

        }

        ar[mp[s]]++;

    }

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

    {

        x=x+((ar[i]*(ar[i]-1))/2);

    }

    cout<<x;

}


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



using namespace std;

char str[13];



int main() {

    //  freopen("in.txt", "rt", stdin);

    int n;

    scanf("%d", &n);

    map<string, int> mp;

    long long ans = 0;

    while (n--) {

        scanf("%s", str);

        sort(str, str + 10);

        ans += mp[string(str)]++;

    }

    printf("%lld", ans);

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

using namespace std;

#define ll long long int

ll ar[500009],br[500009];

map<string,ll>mp;

int main()

{

    ll a,b,c,i,j,k=0,x=0;

    string s;

    cin>>a;

    getchar();

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

    {

        cin>>s;

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

        if(mp.find(s)==mp.end())

        {

            k++;

            mp[s]=k;

        }

        ar[mp[s]]++;

    }

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

    {

        x=x+((ar[i]*(ar[i]-1))/2);

    }

    cout<<x;

}


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



using namespace std;

typedef long long ll;

map<string, ll> mp;



int main() {

    int n;

    cin >> n;

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

        string s;

        cin >> s;

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

        mp[s]++;

    }

    ll ans = 0;

    for (auto i : mp) {

        ans += i.second * (i.second-1) / 2;

    }

    cout << ans << endl;

    return 0;

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

using namespace std;

#define ll long long int

ll ar[500009],br[500009];

map<string,ll>mp;

int main()

{

    ll a,b,c,i,j,k=0,x=0;

    string s;

    cin>>a;

    getchar();

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

    {

        cin>>s;

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

        if(mp.find(s)==mp.end())

        {

            k++;

            mp[s]=k;

        }

        ar[mp[s]]++;

    }

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

    {

        x=x+((ar[i]*(ar[i]-1))/2);

    }

    cout<<x;

}


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

#include<map>

#include<algorithm>

typedef long long ll;

using namespace std;

ll ans=0;

int main(){

	map<string,int> m;

	string s;

	int n;

	cin>>n;

	while(n--){

		cin>>s;

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

		ans=ans+m[s]++;

	}

	cout<<ans<<endl;

	return 0;

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

using namespace std;

#define ll long long int

ll ar[500009],br[500009];

map<string,ll>mp;

int main()

{

    ll a,b,c,i,j,k=0,x=0;

    string s;

    cin>>a;

    getchar();

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

    {

        cin>>s;

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

        if(mp.find(s)==mp.end())

        {

            k++;

            mp[s]=k;

        }

        ar[mp[s]]++;

    }

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

    {

        x=x+((ar[i]*(ar[i]-1))/2);

    }

    cout<<x;

}


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

using namespace std;

int n;

string str;

map<string, long long> cnt;



long long c2(long long x){

	return (x * (x - 1)) / 2;

}



int main(){

	ios_base::sync_with_stdio(0);

	cin.tie(0);



	cin >> n;



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

		cin >> str;

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

		cnt[str]++;

	}



	long long ans = 0;

	for(auto it : cnt){

		ans += c2(it.second);

	}



	cout << ans << endl;



	return 0;

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

using namespace std;

#define ll long long int

ll ar[500009],br[500009];

map<string,ll>mp;

int main()

{

    ll a,b,c,i,j,k=0,x=0;

    string s;

    cin>>a;

    getchar();

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

    {

        cin>>s;

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

        if(mp.find(s)==mp.end())

        {

            k++;

            mp[s]=k;

        }

        ar[mp[s]]++;

    }

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

    {

        x=x+((ar[i]*(ar[i]-1))/2);

    }

    cout<<x;

}


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

using namespace std;

typedef long long ll;

int main(){

    int n;

    cin>>n;

    string s;

    map <string, ll> anagram;

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

        cin>>s;

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

        anagram[s]++;

    }

    ll cnt=0;

    for(auto x: anagram){

        cnt+=(x.second)*(x.second-1)/2;

    }

    cout<<cnt;

    return 0;

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

using namespace std;

#define ll long long int

ll ar[500009],br[500009];

map<string,ll>mp;

int main()

{

    ll a,b,c,i,j,k=0,x=0;

    string s;

    cin>>a;

    getchar();

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

    {

        cin>>s;

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

        if(mp.find(s)==mp.end())

        {

            k++;

            mp[s]=k;

        }

        ar[mp[s]]++;

    }

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

    {

        x=x+((ar[i]*(ar[i]-1))/2);

    }

    cout<<x;

}


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

using namespace std;

int main()

{



    long long int num,val=0;

    map<string,long long int>mp;

    vector<long long int>vec;

    string word;

    cin>>num;

    for(int i=0;i<num;i++)

    {

           cin>>word;

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

           mp[word]++;

    }

    for(auto it:mp)

        vec.push_back(it.second);

    for(int y=0;y<vec.size();y++)

        val+=vec[y]*(vec[y]-1)*0.5;

    cout<<val<<endl;

    return 0;

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

using namespace std;



const int N = 1e5+5;

long long n, cntr = 0, ans = 0;

string s[N], temp;

vector<long long> v;



int main() {

	

	cin >> n;

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

		cin >> s[i];

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

	}

	

	sort(s, s+n);

	temp = s[0];

	cntr = 0;

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

		if(s[i] != temp){

			v.push_back(cntr);

			cntr = 0;

			temp = s[i];

		}

		cntr++;

	}

	v.push_back(cntr);

	

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

		

		if(v[i] == 2)	ans += 1;

		else if(v[i] == 3)	ans += 3;

		else if(v[i] > 3){ ans += v[i]*(v[i]-1)/2;}

		

		// cout << v[i] << " " << ans << endl;

	}

	cout << ans << endl;

	// for(int i = 0 ; i < n ; ++i)	cout << s[i] << " ";

	// puts("");

	// for(int i = 0 ; i < v.size() ; ++i)	cout << v[i] <<  " ";

	

	return 0;

}

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

using namespace std;

int main()

{



    long long int num,val=0;

    map<string,long long int>mp;

    vector<long long int>vec;

    string word;

    cin>>num;

    for(int i=0;i<num;i++)

    {

           cin>>word;

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

           mp[word]++;

    }

    for(auto it:mp)

        vec.push_back(it.second);

    for(int y=0;y<vec.size();y++)

        val+=vec[y]*(vec[y]-1)*0.5;

    cout<<val<<endl;

    return 0;

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

using namespace std;

#define ll long long int

ll ar[500009],br[500009];

map<string,ll>mp;

int main()

{

    ll a,b,c,i,j,k=0,x=0;

    string s;

    cin>>a;

    getchar();

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

    {

        cin>>s;

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

        if(mp.find(s)==mp.end())

        {

            k++;

            mp[s]=k;

        }

        ar[mp[s]]++;

    }

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

    {

        x=x+((ar[i]*(ar[i]-1))/2);

    }

    cout<<x;

}


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



using namespace std;



int main()

{

   long long int n ;

    cin>>n;

    map<string ,long long  int> mp;

    while(n--)

    {

        string x;

        cin>>x;

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

        mp[x]++;

    }

    long long int C=0;

    for( auto i : mp)

    {

        C+=( ( i.second*( i.second - 1 ) ) / 2 );

    }

    cout<<C<<endl;

    return 0;

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

using namespace std;



const int N = 1e5+5;

long long n, cntr = 0, ans = 0;

string s[N], temp;

vector<long long> v;



int main() {

	

	cin >> n;

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

		cin >> s[i];

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

	}

	

	sort(s, s+n);

	temp = s[0];

	cntr = 0;

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

		if(s[i] != temp){

			v.push_back(cntr);

			cntr = 0;

			temp = s[i];

		}

		cntr++;

	}

	v.push_back(cntr);

	

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

		

		if(v[i] == 2)	ans += 1;

		else if(v[i] == 3)	ans += 3;

		else if(v[i] > 3){ ans += v[i]*(v[i]-1)/2;}

		

		// cout << v[i] << " " << ans << endl;

	}

	cout << ans << endl;

	// for(int i = 0 ; i < n ; ++i)	cout << s[i] << " ";

	// puts("");

	// for(int i = 0 ; i < v.size() ; ++i)	cout << v[i] <<  " ";

	

	return 0;

}

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



using namespace std;



int main()

{

   long long int n ;

    cin>>n;

    map<string ,long long  int> mp;

    while(n--)

    {

        string x;

        cin>>x;

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

        mp[x]++;

    }

    long long int C=0;

    for( auto i : mp)

    {

        C+=( ( i.second*( i.second - 1 ) ) / 2 );

    }

    cout<<C<<endl;

    return 0;

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

using namespace std;

const int N=2e5+5;

string A[N];

int n;

long long sum,mem[N];

long long fact(int i){

    if(!i) return 1;

    if(mem[i]!=-1) return mem[i];

    return mem[i]=fact(i-1)*i*1ll;

}

long long ans(int i){

if(i<=1) return 0;

if(i==2) return 1;

return fact(i)/(fact(i-2)*2);

}

long long spdAns(int i){

    if(i<=1) return 0;

    if(i==2) return 1;

    long long ret=1;

    ret=1ll*i*(i-1) / 2;

    return ret;

}

map<string,int> mp;

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    memset(mem,-1,sizeof mem);

    cin>>n;

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

        cin>>A[i];

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

        mp[A[i]]++;

    }

    long long ze=0;

    map<string,int>::iterator it = mp.begin();

    while(it!=mp.end()){

        

        ze+=spdAns(it->second);

        it++;

    }

    /*sort(A,A+n);

    int re=1;

    string cur=A[0];

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

       if(cur!=A[i]){

        sum+=ans(re);

      //  cout<<re<<endl;

        re=0;

        cur=A[i];

       }

       re++;

    }*/



    cout<<ze<<endl;

    return 0;

}


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



using namespace std;



int main()

{

   long long int n ;

    cin>>n;

    map<string ,long long  int> mp;

    while(n--)

    {

        string x;

        cin>>x;

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

        mp[x]++;

    }

    long long int C=0;

    for( auto i : mp)

    {

        C+=( ( i.second*( i.second - 1 ) ) / 2 );

    }

    cout<<C<<endl;

    return 0;

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

using namespace std;

#define ll long long int

ll ar[500009],br[500009];

map<string,ll>mp;

int main()

{

    ll a,b,c,i,j,k=0,x=0;

    string s;

    cin>>a;

    getchar();

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

    {

        cin>>s;

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

        if(mp.find(s)==mp.end())

        {

            k++;

            mp[s]=k;

        }

        ar[mp[s]]++;

    }

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

    {

        x=x+((ar[i]*(ar[i]-1))/2);

    }

    cout<<x;

}


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

#define MAX 11000

#define ll long int

using namespace std;

 

 

int main() {

 

	map<string,int> mp;

	string s ;

	ll i,j,n,count=0,sum=0;

	

	cin >> n;

	

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

	{

		cin >> s;

		sort(s.rbegin(), s.rend(), greater<char>());

		count += mp[s]++;

	

	}

	

	cout << count;





	

 

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

using namespace std;



const int N = 1e5+5;

long long n, cntr = 0, ans = 0;

string s[N], temp;

vector<long long> v;



int main() {

	

	cin >> n;

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

		cin >> s[i];

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

	}

	

	sort(s, s+n);

	temp = s[0];

	cntr = 0;

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

		if(s[i] != temp){

			v.push_back(cntr);

			cntr = 0;

			temp = s[i];

		}

		cntr++;

	}

	v.push_back(cntr);

	

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

		

		if(v[i] == 2)	ans += 1;

		else if(v[i] == 3)	ans += 3;

		else if(v[i] > 3){ ans += v[i]*(v[i]-1)/2;}

		

		// cout << v[i] << " " << ans << endl;

	}

	cout << ans << endl;

	// for(int i = 0 ; i < n ; ++i)	cout << s[i] << " ";

	// puts("");

	// for(int i = 0 ; i < v.size() ; ++i)	cout << v[i] <<  " ";

	

	return 0;

}

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

#define MAX 11000

#define ll long int

using namespace std;

 

 

int main() {

 

	map<string,int> mp;

	string s ;

	ll i,j,n,count=0,sum=0;

	

	cin >> n;

	

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

	{

		cin >> s;

		sort(s.rbegin(), s.rend(), greater<char>());

		count += mp[s]++;

	

	}

	

	cout << count;





	

 

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

using namespace std;

const int N=2e5+5;

string A[N];

int n;

long long sum,mem[N];

long long fact(int i){

    if(!i) return 1;

    if(mem[i]!=-1) return mem[i];

    return mem[i]=fact(i-1)*i*1ll;

}

long long ans(int i){

if(i<=1) return 0;

if(i==2) return 1;

return fact(i)/(fact(i-2)*2);

}

long long spdAns(int i){

    if(i<=1) return 0;

    if(i==2) return 1;

    long long ret=1;

    ret=1ll*i*(i-1) / 2;

    return ret;

}

map<string,int> mp;

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    memset(mem,-1,sizeof mem);

    cin>>n;

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

        cin>>A[i];

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

        mp[A[i]]++;

    }

    long long ze=0;

    map<string,int>::iterator it = mp.begin();

    while(it!=mp.end()){

        

        ze+=spdAns(it->second);

        it++;

    }

    /*sort(A,A+n);

    int re=1;

    string cur=A[0];

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

       if(cur!=A[i]){

        sum+=ans(re);

      //  cout<<re<<endl;

        re=0;

        cur=A[i];

       }

       re++;

    }*/



    cout<<ze<<endl;

    return 0;

}


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

#define MAX 11000

#define ll long int

using namespace std;

 

 

int main() {

 

	map<string,int> mp;

	string s ;

	ll i,j,n,count=0,sum=0;

	

	cin >> n;

	

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

	{

		cin >> s;

		sort(s.rbegin(), s.rend(), greater<char>());

		count += mp[s]++;

	

	}

	

	cout << count;





	

 

}