stablegradients/pie-gem5-pairs huggingface dataset:
// 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.5066540256474574x):


#include <bits/stdc++.h>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<cstdlib>

#include<string.h>

using namespace std;

#define pb push_back

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

#define  rep(i,n,v) for(i=n;i<v;i++)

#define per(i,n,v) for(i=n;i>v;i--)

#define ff first 

#define ss second 

#define pp pair<ll,ll>

#define ll  long long

#define endl '\n'

void solve()

{

  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;

  string s, r, y;

  cin>>n;

  vector<string>v;

  map<string,int>mp;

  rep(i,0,n) {cin>>s;

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

  //v.pb(s);

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

  mp[s]=1;

  else mp[s]++;

  }

  sort(all(v));

 /* rep(i,0,v.size())

  {

   /* rep(j,i+1,v.size())

    {

      string r=v[i],y=v[j];

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

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

      if(r==y) k++;

    }*/

    /*  rep(j,i+1,v.size())

      {

        if(v[i]==v[j]) k++;

      }

  }*/

    for(auto& it : mp) {m=it.ss;k+=(m*(m-1))/2;}

  cout<<k;

}

int main()

{

 ios_base::sync_with_stdio(false);

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

    ll t=1;

  // cin>>t;

    while(t--)

    {

      solve();

    }

    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.269299485117835x):


#include <bits/stdc++.h>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<cstdlib>

#include<string.h>

using namespace std;

#define pb push_back

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

#define  rep(i,n,v) for(i=n;i<v;i++)

#define per(i,n,v) for(i=n;i>v;i--)

#define ff first 

#define ss second 

#define pp pair<ll,ll>

#define ll  long long

#define endl '\n'

void solve()

{

  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;

  string s, r, y;

  cin>>n;

  vector<string>v;

  map<string,int>mp;

  rep(i,0,n) {cin>>s;

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

  //v.pb(s);

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

  mp[s]=1;

  else mp[s]++;

  }

  sort(all(v));

 /* rep(i,0,v.size())

  {

   /* rep(j,i+1,v.size())

    {

      string r=v[i],y=v[j];

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

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

      if(r==y) k++;

    }*/

    /*  rep(j,i+1,v.size())

      {

        if(v[i]==v[j]) k++;

      }

  }*/

    for(auto& it : mp) {m=it.ss;k+=(m*(m-1))/2;}

  cout<<k;

}

int main()

{

 ios_base::sync_with_stdio(false);

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

    ll t=1;

  // cin>>t;

    while(t--)

    {

      solve();

    }

    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.860000600573882x):


#include <bits/stdc++.h>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<cstdlib>

#include<string.h>

using namespace std;

#define pb push_back

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

#define  rep(i,n,v) for(i=n;i<v;i++)

#define per(i,n,v) for(i=n;i>v;i--)

#define ff first 

#define ss second 

#define pp pair<ll,ll>

#define ll  long long

#define endl '\n'

void solve()

{

  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;

  string s, r, y;

  cin>>n;

  vector<string>v;

  map<string,int>mp;

  rep(i,0,n) {cin>>s;

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

  //v.pb(s);

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

  mp[s]=1;

  else mp[s]++;

  }

  sort(all(v));

 /* rep(i,0,v.size())

  {

   /* rep(j,i+1,v.size())

    {

      string r=v[i],y=v[j];

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

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

      if(r==y) k++;

    }*/

    /*  rep(j,i+1,v.size())

      {

        if(v[i]==v[j]) k++;

      }

  }*/

    for(auto& it : mp) {m=it.ss;k+=(m*(m-1))/2;}

  cout<<k;

}

int main()

{

 ios_base::sync_with_stdio(false);

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

    ll t=1;

  // cin>>t;

    while(t--)

    {

      solve();

    }

    return 0;

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

using namespace std;



int main() {

  int n;

  cin >> n;

  

  string s;

  map<string, int> a;

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

    cin >> s;

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

    a[s]++;

  }

  

  int64_t ans = 0;

  vector<int64_t> memo(100001, -1);

  for(pair<string, int64_t> p : a) {

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

  }

  

  cout << ans << endl;

  return 0;

}

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

using namespace std;



int main() {

  int n;

  cin >> n;

  

  string s;

  map<string, int> a;

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

    cin >> s;

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

    a[s]++;

  }

  

  int64_t ans = 0;

  for(pair<string, int64_t> p : a) {

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

  }

  

  cout << ans << endl;

  return 0;

}
// 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.243469793863839x):
#include<bits/stdc++.h>

#include<iostream>

#include<set>

#define ll long long

using namespace std;

int main(){

   ll t;

   cin >>t;

   ll num=0;

   map<string , int> a;

   while(t--){

    string s;

    cin >>s;

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

    num +=a[s]++;

   }

   cout<<num<<endl;

     return 0;

}
// 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.243469793863839x):
#include<bits/stdc++.h>

#include<iostream>

#include<set>

#define ll long long

using namespace std;

int main() {

	ll t;

	cin >>t;

	ll num=0;

	map<string , int> a;

	while(t--) {

		string s;

		cin >>s;

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

		num +=a[s]++;

	}

	cout<<num<<endl;

	return 0;

}
// 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.2773341083329x):
/*

         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗

         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝

         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗

    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║

    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║

     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝

*/

//password:+BdCHpO8dQvpo5fnV3/u

#include<bits/stdc++.h>



using namespace std;

typedef long long ll;

const int maxn = 5e5 + 5;

const int inf = 0x3f3f3f3f;







int main() {

    int n;

    cin>>n;

    map<string,ll>mp;

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

    {

        string s;

        cin>>s;

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

        mp[s]++;

    }

    ll ans=0;

    for(auto it:mp)

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

    cout<<ans<<endl;

    return 0;

}
// 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.283867754959714x):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <map>

#include <string>

using namespace std;

	

map<string,int> mp;

long long sum=0;

int n; 

int main(){

	scanf("%d",&n);

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

		string ss;

		cin>>ss;

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

		sum+=mp[ss]++; 

	}

	printf("%lld",sum);

	return 0;

}
// 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.28670376645686x):
#include<iostream>

#include<algorithm>

#include<map>



using namespace std;



typedef long long ll;



int main(){

	ll n, ans = 0;

	cin >> n;

	string s;

	map<string, ll> 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++){

		ans += (it->second  * (it->second - 1)) >> 1;

	}

	cout << ans << '\n';

	return 0;

}
// 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.216847027454279x):
/*g++ main.cpp -o main.out*/

/*./main.out*/



#include<bits/stdc++.h>

using namespace std;



#define LL long long

#define LD long double

#define Mod 1000000007

#define L_Mod 17100000013



const double eps = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = 3.1415926535;



#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);



#define ree(a,n) memset(a,n,sizeof(a));



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

#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))

#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))



map<string,LL> m;



int main()

{

    NO_TLE

    string s;

    int n;

    LL sum=0;

    cin>>n;

    while(n--)

    {

        cin>>s;

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

        m[s]++;

    }

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

    {

        LL t=(it->second);

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

    }

    cout<<sum<<endl;

    return 0;

}
// 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.243350404382416x):
#include <bits/stdc++.h>

#define ll long long

using namespace std;



int main()

{

	map<string,ll>m;

	string s;

	ll n,ans=0;

	cin>>n;

	while(n--)

	{

		cin>>s;

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

		m[s]++;

	}

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

		ans+=it->second*(it->second-1)/2;

	cout<<ans<<endl;

}
// 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.241773535978334x):
#include <iostream>

#include <map>

#include <string>

#include <algorithm>



using namespace std;



map<string,int> m;



int main()

{

	long long sum=0,n;

	cin>>n;

	while(n--)

	{

		string s;

		cin>>s;

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

		m[s]++;

	}

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

	{

		long long t=(it->second);

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

	}

	cout<<sum<<endl;

	return 0;

 }
// 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.285635053140098x):
#include <bits/stdc++.h>

using namespace std;

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

#define pb push_back 

#define mp make_pair

typedef long long ll;







int main(){

	int n; cin>>n;

	map<string,int> anagram;

	ll ans=0;

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

		string s; cin>>s;

		sort(all(s));

		ans+=anagram[s];

		anagram[s]++;

	}

	cout<<ans;

	return 0;

}
// 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.281840868882055x):
#include <bits/stdc++.h>

#define ll long long

using namespace std;



int main() {

	ll n,count=0;

	string s;

	cin>>n;

	map<string,ll> m;

	while(n--){

		cin>>s;

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

		m[s]++;

	}

	for(auto x:m){

		if(x.second>=2){

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

		}

	}

	cout<<count<<endl;

	// your code goes here

	return 0;

}
// 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.286091788341119x):
#include <iostream>

#include <string>

#include <algorithm>

#include <vector>

using namespace std;



int main(){

	int n, slen;

	long long int res = 0, count=1;

	string s;

	cin >> n;

	vector<string> arr;

	bool ana;

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

		cin >> s;

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

		arr.push_back(s);

	}

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

	//

	for(int i=0; i<arr.size()-1; ++i){

		if(arr[i] == arr[i+1]){

			count += 1;

			ana = true;

		}

		else {

			if(count > 1){

				//cout << "Apply inner sumatoria de: " << count << '\n';

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

				ana = false;

				count = 1;

			}

		}

	}

	if(ana){

		//cout << "Apply sumatoria de: " << count << '\n';

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

	}

	cout << res << '\n';

	return 0;

}
// 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.205852159038508x):
#include <bits/stdc++.h>

#define F first

//#define S second

//#define T second.first

//#define C second.second

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<int,pair<int,int>> piii;



const int N= 1e5+5, L = 14, OO = 0x3f3f3f3f;

const ll M=10 ;

const double ESP = 1e-8;





int main(){

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

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

    ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    int n;

    cin>>n;

    string s;

    map<string ,ll>mp;

    set<string>st;

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

        cin>>s;

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

        mp[s]++;

        st.insert(s);

    }

    ll ans = 0;

    for(string z: st){

        ll x = mp[z];

        if(x){



            ans+= x*(x-1LL)/2LL;

        }

    }

    cout<<ans<<endl;

}

/*

*/