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

#define ll long long

using namespace std;

int main()

{

    ll n;

    cin>>n;

    vector<string>v;

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

    {

        string s;

        cin>>s;

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

        v.push_back(s);

        //cout<<s<<endl;

    }

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

    ll sum=0,cnt=1;

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

    {

        if(v[i]==v[i-1])

            cnt++;

        else

        {

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

            cnt=1;

        }

    }

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

    cout<<sum<<endl;

    return 0;

}
// 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: 1.553914716835233x):
#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;

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

#include<string>

#include<cstring>

#include<algorithm>

#include<vector>

#include<cmath>

#include<map>

#include<set>

#include<cstdio>

#define MAXA 100000

#define MAX 20000000000

#define s(i) scanf("%d", &(i))

#define p(i) printf("%d", (i))

#define ps() printf(" ") 

#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))

#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))

using namespace std;

char str[100000][11] = {0};

int main(){

	long long int i, n, j, Count = 0;

	map<string, int> m;

	cin >> n;

	rer(i,0,n){

		cin >> str[i];

		sort(str[i],str[i]+strlen(str[i]));

		Count += m[str[i]]++;

	}

//	map<string,int>::iterator mi;

//	for(mi=m.begin(); mi!=m.end();mi++){

//		if(mi->second!=1){

//			Count+=mi->second;

//		}

//	}

	cout << Count << endl;

	return 0;

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

#include<string>

#include<cstring>

#include<algorithm>

#include<vector>

#include<cmath>

#include<map>

#include<set>

#include<cstdio>

#define MAXA 100000

#define MAX 20000000000

#define s(i) scanf("%d", &(i))

#define p(i) printf("%d", (i))

#define ps() printf(" ") 

#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))

#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))

using namespace std;

char str[100000][11] = {0};

int main(){

	long long int i, n, j, Count = 0;

	map<string, int> m;

	cin >> n;

	rer(i,0,n){

		cin >> str[i];

		sort(str[i],str[i]+strlen(str[i]));

		Count += m[str[i]]++;

	}

//	map<string,int>::iterator mi;

//	for(mi=m.begin(); mi!=m.end();mi++){

//		if(mi->second!=1){

//			Count+=mi->second;

//		}

//	}

	cout << Count << 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.284854718705282x):
#include<iostream>

#include<string>

#include<cstring>

#include<algorithm>

#include<vector>

#include<cmath>

#include<map>

#include<set>

#include<cstdio>

#define MAXA 100000

#define MAX 20000000000

#define s(i) scanf("%d", &(i))

#define p(i) printf("%d", (i))

#define ps() printf(" ") 

#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))

#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))

using namespace std;

char str[100000][11] = {0};

int main(){

	long long int i, n, j, Count = 0;

	map<string, int> m;

	cin >> n;

	rer(i,0,n){

		cin >> str[i];

		sort(str[i],str[i]+strlen(str[i]));

		Count += m[str[i]]++;

	}

//	map<string,int>::iterator mi;

//	for(mi=m.begin(); mi!=m.end();mi++){

//		if(mi->second!=1){

//			Count+=mi->second;

//		}

//	}

	cout << Count << endl;

	return 0;

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

#include <string>

#include <map>

#include <iterator>



using namespace std;



int N = 0;

long long result = 0;

string word;

map <string,int> test;



int main() {

  cin >> N;

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

  {

    cin >> word;

    map <char,int> letter;

    for(char a: word) {letter[a]++;}

    word = "";

    for(map<char,int>::iterator iter = letter.begin();iter != letter.end(); iter++)

    {word += string((*iter).second,(*iter).first);}

    test[word]++;

  }

  for(map<string,int>::iterator iter = test.begin(); iter != test.end(); iter++)

  {

    if((*iter).second > 1)

    {

      long long sum = (*iter).second;

      sum *= (sum-1);

      result += sum/2;

    }

  }

  cout << result;

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

#include <string>

#include <map>

#include <iterator>



using namespace std;



int N = 0;

long long result = 0;

string word;

map <string,int> test;



int main() {

  cin >> N;

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

  {

    cin >> word;

    map <char,int> letter;

    for(char a: word) {letter[a]++;}

    word = "";

    for(map<char,int>::iterator iter = letter.begin();iter != letter.end(); iter++)

    {word += string((*iter).second,(*iter).first);}

    test[word]++;

  }

  for(map<string,int>::iterator iter = test.begin(); iter != test.end(); iter++)

  {

    if((*iter).second > 1)

    {

      long long sum = (*iter).second;

      sum *= (sum-1);

      result += sum/2;

    }

  }

  cout << result;

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

#include <string>

#include <map>

#include <iterator>



using namespace std;



int N = 0;

long long result = 0;

string word;

map <string,int> test;



int main() {

  cin >> N;

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

  {

    cin >> word;

    map <char,int> letter;

    for(char a: word) {letter[a]++;}

    word = "";

    for(map<char,int>::iterator iter = letter.begin();iter != letter.end(); iter++)

    {word += string((*iter).second,(*iter).first);}

    test[word]++;

  }

  for(map<string,int>::iterator iter = test.begin(); iter != test.end(); iter++)

  {

    if((*iter).second > 1)

    {

      long long sum = (*iter).second;

      sum *= (sum-1);

      result += sum/2;

    }

  }

  cout << result;

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

#include <string>

#include <algorithm>

#include <map>



#define lli long long int



using namespace std;

string ordena(string s){

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

  return s;

}



int main() {



  lli n;

  cin >> n;

  map<string,lli> M;

  string s;

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

    cin >> s;

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

    M[s]++;



  }

  lli cont=0, aux, aux1;

  map<string,lli>::iterator it;

  for(it=M.begin(); it!=M.end(); it++){

    if(it->second>1)  {

      aux=it->second;

      aux1=aux*(aux-1);

      cont+=aux1/2;

    }

  }

  cout << cont;

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

#include <string>

#include <algorithm>

#include <map>



#define lli long long int



using namespace std;

string ordena(string s){

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

  return s;

}



int main() {



  lli n;

  cin >> n;

  map<string,lli> M;

  string s;

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

    cin >> s;

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

    M[s]++;



  }

  lli cont=0, aux, aux1;

  map<string,lli>::iterator it;

  for(it=M.begin(); it!=M.end(); it++){

    if(it->second>1)  {

      aux=it->second;

      aux1=aux*(aux-1);

      cont+=aux1/2;

    }

  }

  cout << cont;

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

#include <string>

#include <algorithm>

#include <map>



#define lli long long int



using namespace std;

string ordena(string s){

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

  return s;

}



int main() {



  lli n;

  cin >> n;

  map<string,lli> M;

  string s;

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

    cin >> s;

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

    M[s]++;



  }

  lli cont=0, aux, aux1;

  map<string,lli>::iterator it;

  for(it=M.begin(); it!=M.end(); it++){

    if(it->second>1)  {

      aux=it->second;

      aux1=aux*(aux-1);

      cont+=aux1/2;

    }

  }

  cout << cont;

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

using namespace std;



int main () {

  int n;

  cin >> n;

  map <string, int> make_pair;

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

    string s;

    cin >> s;

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

    make_pair[s]++;

  }

  long long ans = 0;

  for (auto pp: make_pair) {

    long long cnt = pp.second;

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

  }

  cout << ans << '\n';

  return (0);

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

using namespace std;



int main () {

  int n;

  cin >> n;

  map <string, int> make_pair;

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

    string s;

    cin >> s;

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

    make_pair[s]++;

  }

  long long ans = 0;

  for (auto pp: make_pair) {

    long long cnt = pp.second;

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

  }

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

using namespace std;



int main () {

  int n;

  cin >> n;

  map <string, int> make_pair;

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

    string s;

    cin >> s;

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

    make_pair[s]++;

  }

  long long ans = 0;

  for (auto pp: make_pair) {

    long long cnt = pp.second;

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

  }

  cout << ans << '\n';

  return (0);

}