stablegradients/pie-gem5-pairs huggingface dataset:
// 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.107692821410192x):
/*	MASTER HAS FAILED MORE TIMES

	THAN BEGINNER HAS EVER TRIED

*/



#include <bits/stdc++.h>



using namespace std;



#define endl             '\n'

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

#define mem(a, n)        memset(a, n, sizeof(a))

#define Unique(n)        (n).erase(unique(all(n)), (n).end())

#define NumofDigits(n)   ((long long)log10(n)+1)

#define repeat(i, a, n)  for(int i=a; i<n; i++)

#define isPowerOfTwo(n)  (n && !(n & (n - 1)))



typedef long long ll;

typedef long double ld;



int sieve(int n);

unsigned long long pow(long long base, long long power);

long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }

long long lcm(long long a, long long b){ return a*b/gcd(a, b); }



void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

void file(){

    #ifdef ONLINE_JUDGE

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

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

    #endif /*ONLINE_JUDGE*/

}



int main(){

    quicken();



    ll n, num=0; cin >> n;

    string arr[n];



    map<string, int> mp;

    repeat(i, 0, n){

        cin >> arr[i];

        sort(all(arr[i]));

        mp[arr[i]]++;

    }





    for(auto it:mp){

        pair<string, ll> p = it;

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

    }

    cout << num;



    return 0;

}



unsigned long long pow(long long base, long long power){ /// mod?

    if(power==0) return 1;

    if(power==1) return base;



    unsigned long long ans = pow(base, power/2); /// mod?

    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;



    if(power&1) return ans*base; /// ((ans%mod)*(base%mod))%mod;

    return ans;

}



int sieve(int n){

    int c = 0;

    vector<bool> isPrime(n+1, true);

    isPrime[0] = isPrime[1] = 0;



    for(long long i=2; i*i<=n; i++)

        if(isPrime[i])

            for(long long j=i*2; j<=n; j+=i)

                isPrime[j] = 0;

    repeat(i, 0, n+1)

        if(isPrime[i]) c++;

    return c; /// primeCount [1:n]

}
// 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.217591888133124x):
/*	MASTER HAS FAILED MORE TIMES

	THAN BEGINNER HAS EVER TRIED

*/



#include <bits/stdc++.h>



using namespace std;



#define endl             '\n'

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

#define mem(a, n)        memset(a, n, sizeof(a))

#define Unique(n)        (n).erase(unique(all(n)), (n).end())

#define NumofDigits(n)   ((long long)log10(n)+1)

#define repeat(i, a, n)  for(int i=a; i<n; i++)

#define isPowerOfTwo(n)  (n && !(n & (n - 1)))



typedef long long ll;

typedef long double ld;



int sieve(int n);

unsigned long long pow(long long base, long long power);

long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }

long long lcm(long long a, long long b){ return a*b/gcd(a, b); }



void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

void file(){

    #ifdef ONLINE_JUDGE

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

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

    #endif /*ONLINE_JUDGE*/

}



int main(){

    quicken();



    ll n, num=0; cin >> n;

    string arr[n];



    map<string, int> mp;

    repeat(i, 0, n){

        cin >> arr[i];

        sort(all(arr[i]));

        mp[arr[i]]++;

    }





    for(auto it:mp){

        pair<string, ll> p = it;

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

    }

    cout << num;



    return 0;

}



unsigned long long pow(long long base, long long power){ /// mod?

    if(power==0) return 1;

    if(power==1) return base;



    unsigned long long ans = pow(base, power/2); /// mod?

    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;



    if(power&1) return ans*base; /// ((ans%mod)*(base%mod))%mod;

    return ans;

}



int sieve(int n){

    int c = 0;

    vector<bool> isPrime(n+1, true);

    isPrime[0] = isPrime[1] = 0;



    for(long long i=2; i*i<=n; i++)

        if(isPrime[i])

            for(long long j=i*2; j<=n; j+=i)

                isPrime[j] = 0;

    repeat(i, 0, n+1)

        if(isPrime[i]) c++;

    return c; /// primeCount [1:n]

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



using namespace std;



void init()

{

    cin.tie(0);

    cin.sync_with_stdio(0);

}









int main()

{

    init();

    int n ;

    cin>>n;

    string arr[n];

    long long x=0;

     map<string,long long>mp;

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

     cin>>arr[i];

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

    mp[arr[i]]++;

    //if(mp[arr[i]]>1){

     //    x++;

   //  }



     }

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

        if(mp[arr[i]]>1){ x+=(mp[arr[i]]*(mp[arr[i]]-1))/2;

        mp[arr[i]]=0;

        }

    }









     cout<<x;

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



using namespace std;



void init()

{

    cin.tie(0);

    cin.sync_with_stdio(0);

}









int main()

{

    init();

    int n ;

    cin>>n;

    string arr[n];

    long long x=0;

     map<string,long long>mp;

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

     cin>>arr[i];

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

    mp[arr[i]]++;

    //if(mp[arr[i]]>1){

     //    x++;

   //  }



     }

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

        if(mp[arr[i]]>1){ x+=(mp[arr[i]]*(mp[arr[i]]-1))/2;

        mp[arr[i]]=0;

        }

    }









     cout<<x;

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



using namespace std;



void init()

{

    cin.tie(0);

    cin.sync_with_stdio(0);

}









int main()

{

    init();

    int n ;

    cin>>n;

    string arr[n];

    long long x=0;

     map<string,long long>mp;

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

     cin>>arr[i];

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

    mp[arr[i]]++;

    //if(mp[arr[i]]>1){

     //    x++;

   //  }



     }

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

        if(mp[arr[i]]>1){ x+=(mp[arr[i]]*(mp[arr[i]]-1))/2;

        mp[arr[i]]=0;

        }

    }









     cout<<x;

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

#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define F first

#define S second

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



using ll = long long;

using ld = long double;

using ul = unsigned long long;

using ii = pair<int, int>;

#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ReadFile            freopen("input.in","r",stdin)

#define WriteFile           freopen("output.txt","w",stdout)

const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;

const ld EPS = 1e-7;

double Pi=acos(-1);

const ld rad=Pi/180.0;

ll power(ll x, ll y, ll p)

{

    ll res = 1;

    while (y > 0)

    {

        if (y & 1)

            res = (res*x) % p;

        y = y>>1;

        x = (x*x) % p;

    }

    return res;

}

ll nCr (ll n,ll m)

{

        return(m == 0)?1:n*nCr(n-1,m-1)/m;

}

/*****************************************************/





int main()

{

    int n;

    cin >> n;

    vector <string> vec;

    while(n--){

        string s;

        cin >> s;

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

        vec.pb(s);

    }



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

    string s = vec[0];

    ll x = 1 , ans = 0;



    for(int i = 1; i < (int) vec.size(); ++i){

        string m = vec[i];

        if(s == m){

            x++;

        }else{

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

            x = 1;

            s = m;

        }

    }



    ans += x * (x - 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.187973895469765x):
#include <iostream>

#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define F first

#define S second

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



using ll = long long;

using ld = long double;

using ul = unsigned long long;

using ii = pair<int, int>;

#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ReadFile            freopen("input.in","r",stdin)

#define WriteFile           freopen("output.txt","w",stdout)

const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;

const ld EPS = 1e-7;

double Pi=acos(-1);

const ld rad=Pi/180.0;

ll power(ll x, ll y, ll p)

{

    ll res = 1;

    while (y > 0)

    {

        if (y & 1)

            res = (res*x) % p;

        y = y>>1;

        x = (x*x) % p;

    }

    return res;

}

ll nCr (ll n,ll m)

{

        return(m == 0)?1:n*nCr(n-1,m-1)/m;

}

/*****************************************************/





int main()

{

    int n;

    cin >> n;

    vector <string> vec;

    while(n--){

        string s;

        cin >> s;

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

        vec.pb(s);

    }



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

    string s = vec[0];

    ll x = 1 , ans = 0;



    for(int i = 1; i < (int) vec.size(); ++i){

        string m = vec[i];

        if(s == m){

            x++;

        }else{

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

            x = 1;

            s = m;

        }

    }



    ans += x * (x - 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.269255646246618x):
#include <iostream>

#include <bits/stdc++.h>

using namespace std;



#define pb push_back

#define F first

#define S second

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



using ll = long long;

using ld = long double;

using ul = unsigned long long;

using ii = pair<int, int>;

#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ReadFile            freopen("input.in","r",stdin)

#define WriteFile           freopen("output.txt","w",stdout)

const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;

const ld EPS = 1e-7;

double Pi=acos(-1);

const ld rad=Pi/180.0;

ll power(ll x, ll y, ll p)

{

    ll res = 1;

    while (y > 0)

    {

        if (y & 1)

            res = (res*x) % p;

        y = y>>1;

        x = (x*x) % p;

    }

    return res;

}

ll nCr (ll n,ll m)

{

        return(m == 0)?1:n*nCr(n-1,m-1)/m;

}

/*****************************************************/





int main()

{

    int n;

    cin >> n;

    vector <string> vec;

    while(n--){

        string s;

        cin >> s;

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

        vec.pb(s);

    }



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

    string s = vec[0];

    ll x = 1 , ans = 0;



    for(int i = 1; i < (int) vec.size(); ++i){

        string m = vec[i];

        if(s == m){

            x++;

        }else{

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

            x = 1;

            s = m;

        }

    }



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



    cout << ans << "\n";



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

using namespace std;

long long cnt = 1, ans;

int main() {

	int n;

	cin >> n;

	string s;

	vector<string> v;

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

		cin >> s;

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

		v.push_back(s);

	}

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

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

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

			cnt++;

		else {

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

			cnt = 1;

		}

	}

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

	cout << ans;

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

using namespace std;

long long cnt = 1, ans;

int main() {

	int n;

	cin >> n;

	string s;

	vector<string> v;

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

		cin >> s;

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

		v.push_back(s);

	}

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

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

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

			cnt++;

		else {

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

			cnt = 1;

		}

	}

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

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

using namespace std;

long long cnt = 1, ans;

int main() {

	int n;

	cin >> n;

	string s;

	vector<string> v;

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

		cin >> s;

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

		v.push_back(s);

	}

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

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

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

			cnt++;

		else {

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

			cnt = 1;

		}

	}

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

	cout << ans;

	return 0;

}