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

using namespace std;

long long int ar[1000000];

int main()

{

  long long  int x, y,rem,temp,i,j,total,f=0;

   cin >> x >> y;

    temp=x;

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

    ar[i]=-1;

     i=0;

    while(temp>=1)

    {

        rem=temp%y;

        temp=temp/y;

        ar[i]=rem;

        i++;



    }

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

    {

         total=ar[j]%10;

            f++;

    }

    cout<<f<<endl;

}


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

#define ll long long

#define vl vector<ll int>

#define vs vector<string>

#define v vector<int>

#define mi map<int,int>

#define mc map<char,int>



//ios_base::sync_with_stdio(false);cin.tie(NULL);



using namespace std;



int main(){

     ios_base::sync_with_stdio(false);cin.tie(NULL);

     int n,k;

     cin>>n>>k;

     v A,B;

     while(n!=0){

		 A.push_back(n%k);

		 n=n/k;

		 }

		 int m=A.size();

		 cout<<m <<"\n";

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

using namespace std;

long long int ar[1000000];

int main()

{

  long long  int x, y,rem,temp,i,j,total,f=0;

   cin >> x >> y;

    temp=x;

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

    ar[i]=-1;

     i=0;

    while(temp>=1)

    {

        rem=temp%y;

        temp=temp/y;

        ar[i]=rem;

        i++;



    }

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

    {

         total=ar[j]%10;

            f++;

    }

    cout<<f<<endl;

}


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

using namespace std;



#define ll long long



int main() {

    ll n,count=0,k;

    cin>>n>>k;

    while(n!=0)

    {

        count++;

        n=n/k;

    }

    cout<<count;

    return 0;

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

using namespace std;

int main()

{

	long int n,k;

	cin>>n>>k;

	long int t=0;

	if(k==10)

	{

		while(n!=0)

		{

			n=n/10;

			t++;

		}

	}

	else{

		t=1;

		while(n>=k)

		{

			n=n/k;

			t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

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

#include<string.h>

#include<ctype.h>





int main()

{

   int n,k,c=0;

   scanf("%d %d", &n,&k);

   while(n/k>0)

   {

       n=n/k;

       c++;

   }

   printf("%d", c+1);

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

using namespace std;

int main()

{

	long int n,k;

	cin>>n>>k;

	long int t=0;

	if(k==10)

	{

		while(n!=0)

		{

			n=n/10;

			t++;

		}

	}

	else{

		t=1;

		while(n>=k)

		{

			n=n/k;

			t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

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

int main()

{

	long long int N,K,count=0,a;

	scanf("%lld %lld",&N,&K);

	if(N==0){

		printf("1");

		return 0;

	}

	else{

	while(1){

			a=N/K;

			N=a;

			count++;

			if(N==0) break;

	}

	}

	printf("%lld",count);

	return 0;

		

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

using namespace std;

int main()

{

	long int n,k;

	cin>>n>>k;

	long int t=0;

	if(k==10)

	{

		while(n!=0)

		{

			n=n/10;

			t++;

		}

	}

	else{

		t=1;

		while(n>=k)

		{

			n=n/k;

			t++;

		}

	}

	cout<<t<<endl;

	return 0;

}

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

int main()

{

    int n, k, c=0;

    scanf("%d %d", &n, &k);

    while(n>0)

    {

        n=n/k;

        c++;

    }

    printf("%d", c);

    return 0;

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

using namespace std;



int base_conversion(int number, int base)

{

    int t = 1, out = 0, r, a, count = 0;

    a = number;

    while (a != 0)

    {

        r = a % base;

        a = a / base;

        out = out + r * t;

        t = t * 10;

        count++;

    }

    return count;

}



int main()

{

    int n, k;

    cin >> n >> k;

    cout << base_conversion(n, k);

    return 0;

}

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

#include <math.h>

#include <stdlib.h>

long long int myfun(long long int a,long long int x);

int main()

{

    long long int n,k,ans;

    scanf("%lld %lld", &n,&k);

    ans=ceil(myfun(n,k));

    printf("%lld", ans+1);

    return 0;

}

long long int myfun(long long int n,long long int k)

{

    return log(n)/log(k);

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



using namespace std;



#define pb push_back

#define eb emplace_back

#define ll long long

#define pii pair < int, int >

#define fr first

#define sc second

#define mk make_pair

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

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

#define ok puts("ok");

#define whatis(x) cerr << #x << " = " << x << endl;

#define pause system("pause");



const int N = (int)1e5 + 7;

const int inf = (int)1e9 + 7;



ll a, b, sq, mx, aa;

ll ans;



ll sqr(ll x) {

  ll l = 1;

  ll r = 1e9;

  while (r - l > 1) {

    ll mid = (l + r) >> 1;

    if (mid * mid <= x) {

      l = mid;

    } else {

      r = mid;

    }

  }

  return l;

}



void solve() {

  scanf("%lld %lld", &a, &b);

  if (a > b) swap(a, b);

  sq = sqr(a * b - 1);

  ans = sq;

  if (a <= sq) {

    ans--;

  }

  mx = (a * b - 1) / (sq + 1);

  if (b <= mx) {

    ans--;

  }

  ans += mx;

  cout << ans << endl;

}



main() {

  int test;

  scanf("%d", &test);

  while (test--) {

    solve();

  }

}


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

#include<cstdio>

using namespace std;

int main() {

	int Q;

	scanf("%d",&Q);

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

		long long a,b;

		scanf("%lld %lld",&a,&b);

		long long pr=a*b;

		long long t=sqrt(pr),ans;

		if(t*(t+1)<pr)

			ans=t*2-1;

		else if(t*t==pr) {

			ans=(t-1)*2;

			if(a!=b) ans--;

		} else

			ans=(t-1)*2;

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

	}

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

using namespace std;

typedef long long ll;



int main()

{

    int n;

    scanf("%d",&n);

    ll a, b, pr ,sqq;

    ll ans;

    while(n--)

    {

        scanf("%lld%lld",&a,&b);

        pr=a*b;

        sqq=sqrt(pr);

        //printf("%lld\n",sqq);

        ans=sqq*2;

        if(sqq*sqq==pr){

            if(a==sqq&&b==a){

                ans-=2;

            }

            else{

                ans-=3;

            }

        }

        else{

            if((pr-1)/sqq==sqq){

                ans--;

            }

            ans--;

        }

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

    }

    return 0;

}


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

#include<cstdio>

using namespace std;

int main() {

	int Q;

	scanf("%d",&Q);

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

		long long a,b;

		scanf("%lld %lld",&a,&b);

		long long pr=a*b;

		long long t=sqrt(pr),ans;

		if(t*(t+1)<pr)

			ans=t*2-1;

		else if(t*t==pr) {

			ans=(t-1)*2;

			if(a!=b) ans--;

		} else

			ans=(t-1)*2;

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

	}

	return 0;

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

#include<cmath>

#include<cstdio>

using namespace std;

int q;

typedef long long LL;

LL LLsqrt(LL x){

    LL L=0,R=1e9,mid,ans=-1;

    while (L<=R){

        mid=(L+R)>>1;

        if (mid*mid<=x)

            L=mid+1,ans=mid;

        else

            R=mid-1;

    }

    return ans;

}

int main()

{

    long long a,b;

    scanf("%d",&q);

    while(q--)

    {

        long long ans=0;

        scanf("%lld%lld",&a,&b);

        long long c=a*b-1;

        long long p=LLsqrt(c);

        ans+=2*p;

        if(a!=b)

            ans--;

            if(p)

        if(p==c/p)

            ans--;

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

    }

}


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

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

int main() {

    #ifdef LOACL

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

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

    #endif

    int t;

    scanf("%d",&t);

    while(t--) {

    	ll a,b,ans;

    	scanf("%lld %lld",&a,&b);

    	if(a>b)swap(a,b);

    	if(a==b) {

    		ans=2*(a-1);

		} else if(a+1==b) {

			ans=2*(a-1);

		} else {

			ll c=sqrt(a*b);

			if(c*c==a*b)c--;

			if(c*(c+1)>=a*b) {

				ans=2*c-2;

			} else {

				ans=2*c-1;

			}

		}

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

	}

    return 0;

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



#define fr first

#define sc second

#define mk make_pair

#define pb push_back

#define ok puts("OK");

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

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

#define int long long



using namespace std;



int tests, a, b;



int check (int x)

{

    int l = 1, r = x;

    while (r - l > 2)

    {

        int md1 = l + (r - l + 1) / 3, md2 = r - (r - l + 1) / 3;

        if ( md1 * (b + x - md1 + 1) > md2 * (b + x - md2 + 1) )

            r = md2;

        else

            l = md1;

    }

    int ans = l * (b + x - l + 1);



    for (int i = l; i <= r; i++)

        ans = max(ans, i * (b + x - i + 1) );



    return ans;

}



main()

{

    cin >> tests;

    while (tests--)

    {

        cin >> a >> b;

        if (a < b)

            swap(a, b);

        int l = 1, r = b;



        while (r - l > 1)

        {

            int md = (l + r) >> 1;

            if ( (a + 1) * md < a * b )

                l = md;

            else

                r = md;

        }

        int left = b - l - 1;



        l = 0, r = a - left;



        while (r - l > 1)

        {

            int md = (l + r) >> 1;

            if ( check(md) < a * b )

                l = md;

            else

                r = md;

        }

        cout << l + b - 1<< endl;

    }

}


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

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

int main() {

    #ifdef LOACL

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

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

    #endif

    int t;

    scanf("%d",&t);

    while(t--) {

    	ll a,b,ans;

    	scanf("%lld %lld",&a,&b);

    	if(a>b)swap(a,b);

    	if(a==b) {

    		ans=2*(a-1);

		} else if(a+1==b) {

			ans=2*(a-1);

		} else {

			ll c=sqrt(a*b);

			if(c*c==a*b)c--;

			if(c*(c+1)>=a*b) {

				ans=2*c-2;

			} else {

				ans=2*c-1;

			}

		}

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

	}

    return 0;

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

#include <cstring>

#include <cstdlib>

#include <iostream>

#include <algorithm>

using namespace std;

int n,m,a[2000];

int main()

{

while (1)

{

    scanf("%d%d",&n,&m);

    if (n==0&&m==0) break;

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

    scanf("%d",&a[i]);

    int max1=-1;

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

    for (int j=1;j<=n;j++)

        if (i!=j)

    {

        if (a[i]+a[j]<=m&&a[i]+a[j]>max1)

            max1=a[i]+a[j];

    }

    if (max1==-1) printf("NONE\n"); else printf("%d\n",max1);



}



    return(0);

}




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

#include<algorithm>

using namespace std;



int main()

{

    int m, n, a[1005];

    while(1)

    {

        scanf("%d%d",&n,&m);

        if(n==0) return 0;



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

        {

            scanf("%d",a+i);

        }



        int maxsum=0;

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

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

        {

            int sum=a[i]+a[j];

            if(sum>maxsum&&sum<=m)

            {

                maxsum=sum;

            }

        }

        if(maxsum==0) printf("NONE\n");

        else printf("%d\n",maxsum);

    }

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

#include <cstring>

#include <cstdlib>

#include <iostream>

#include <algorithm>

using namespace std;

int n,m,a[2000];

int main()

{

while (1)

{

    scanf("%d%d",&n,&m);

    if (n==0&&m==0) break;

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

    scanf("%d",&a[i]);

    int max1=-1;

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

    for (int j=1;j<=n;j++)

        if (i!=j)

    {

        if (a[i]+a[j]<=m&&a[i]+a[j]>max1)

            max1=a[i]+a[j];

    }

    if (max1==-1) printf("NONE\n"); else printf("%d\n",max1);



}



    return(0);

}




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



int a[1005];



int main()

{

    int n, m;

    while(scanf("%d %d", &n, &m)){

        if(n == 0){

            return 0;

        }

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

            scanf("%d", &a[i]);

        }

        int ans = -1;

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

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

                if((a[i] + a[j]) <= m && (a[i] + a[j]) > ans){

                    ans = (a[i] + a[j]);

                }

            }

        }

        if(ans < 0){

            printf("NONE\n");

        }

        else{

            printf("%d\n", ans);

        }

    }

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

#include<set>

#include<algorithm>

using namespace std;

const int maxn = 1e3 + 5;

int a[maxn];

int n, m;

set<int>s;



int main() {

	while (scanf("%d %d", &n, &m)) {

		s.clear();

		if (n == 0 && m == 0)break;

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

			scanf("%d", &a[i]);

		}

		int max = 0;

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

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

				if(i!=j) s.insert(a[i] + a[j]);

			}

		}

		//set<int>::iterator it = s.upper_bound(m);

		bool flag = false;

		for (set<int>::iterator it = --s.end(); it != s.begin(); it--) {

			if (*it <= m) {

				printf("%d\n", *it);

				flag = true;

				break;

			}

		}

		if (!flag) {

			if (*s.begin() <= m) printf("%d\n", *s.begin());

			else printf("NONE\n");

		}

	}

	return 0;

}


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



int a[1005];



int main()

{

    int n, m;

    while(scanf("%d %d", &n, &m)){

        if(n == 0){

            return 0;

        }

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

            scanf("%d", &a[i]);

        }

        int ans = -1;

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

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

                if((a[i] + a[j]) <= m && (a[i] + a[j]) > ans){

                    ans = (a[i] + a[j]);

                }

            }

        }

        if(ans < 0){

            printf("NONE\n");

        }

        else{

            printf("%d\n", ans);

        }

    }

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

using namespace std;

int n, m;

int nums[1000+10];



int find(int L, int R, int vl)

{

	int l = L, r = R;

	int mid = 0;

	while(l < r)

	{

		mid = (l+r) / 2;

		if(nums[mid] < vl)

			l = mid+1;

		else

			r = mid;

	}

	return l;

}



int main()

{

	while(true)

	{

		scanf("%d%d", &n, &m);

		if(!n && !m)

			break;

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

		{

			scanf("%d", &nums[i]);

		}

		sort(nums, nums+n);

		int ans = 0;

		for(int i = n-1; i >= 0; i--)

		{

			if(nums[i] >= m)

				continue;

//			int pos = lower_bound(nums, nums+n, m-nums[i]) - nums;

			int pos = find(0, n-1, m-nums[i]);

			for(int j = pos; j >= 0; j--)

			{

				if(m-nums[i] >= nums[j] && i != j)

				{

					pos = j;

					break;

				}

			}

			if(i == pos)

				break;

			int tmp = nums[pos];

			if(tmp+nums[i] <= m)

				ans = max(ans, nums[i]+tmp);

		}

		if(ans)

			printf("%d\n", ans);

		else

			printf("NONE\n");

	}

	return 0;

}


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



int a[1005];



int main()

{

    int n, m;

    while(scanf("%d %d", &n, &m)){

        if(n == 0){

            return 0;

        }

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

            scanf("%d", &a[i]);

        }

        int ans = -1;

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

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

                if((a[i] + a[j]) <= m && (a[i] + a[j]) > ans){

                    ans = (a[i] + a[j]);

                }

            }

        }

        if(ans < 0){

            printf("NONE\n");

        }

        else{

            printf("%d\n", ans);

        }

    }

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

#include<iostream>

#include<algorithm>

#include<string>

#include<vector>

using namespace std;

typedef long long ll;

ll b[1000005];

int main()

{

	while(1)

    {

        ll a[1005];

        ll n,m;

        cin >> n>>m;

        if(n==0)break;

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

        {

            cin>>a[i];

        }

        ll k=0;

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

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

            {

                if(i==j)b[k]=0;

                else if(a[i]+a[j]<=m)

                b[k]=a[i]+a[j];

                else b[k]=0;

                k++;

            }

        ll sum=0;

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

        {

            sum=max(b[i],sum);

        }

        if(sum==0)cout<<"NONE"<<endl;

        else cout<<sum<<endl;

    }

	return 0;

}








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



int a[1005];



int main()

{

    int n, m;

    while(scanf("%d %d", &n, &m)){

        if(n == 0){

            return 0;

        }

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

            scanf("%d", &a[i]);

        }

        int ans = -1;

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

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

                if((a[i] + a[j]) <= m && (a[i] + a[j]) > ans){

                    ans = (a[i] + a[j]);

                }

            }

        }

        if(ans < 0){

            printf("NONE\n");

        }

        else{

            printf("%d\n", ans);

        }

    }

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

#include <cstdio>

#include <cmath>

#include <algorithm>

#include <queue>



#define MAX_N 5000



using namespace std;



int N;

int E;

vector<int > in[MAX_N + 1];

vector<int > out[MAX_N + 1];

queue<int > S;

queue<int > L;



bool multi_flag;



bool in_exist(int v){

	bool flag = false;

	if(in[v].empty()) return false;

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

		if(in[v][i] != -1) return true;

	}

	return false;

}



void solve(){

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

		if(in_exist(i) == false) S.push(i);

	}



	while(!S.empty()){

		int u = S.front();S.pop();

		L.push(u);

		int entered = 0;

		for(int i = 0;i < out[u].size();i++){

			int to = out[u][i];

			for(int i = 0;i < in[to].size();i++){

				if(in[to][i] == u) in[to][i] = -1;

			}

			

			if(in_exist(to) == false){

				S.push(to);

				entered++;

			}

		}

		if(entered >= 2) multi_flag = true;

	}



	return ;

}



int main(){



	scanf("%d",&N);

	scanf("%d",&E);

	//for(int i = 0;i <= MAX_N;i++){

	//	for(int j = 0;j <= MAX_N;j++){

	//		edge[i][j] = false;

	//	}

	//}

	int _u,_v;

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

		scanf("%d%d",&_u,&_v);

		in[_v].push_back(_u);

		out[_u].push_back(_v);

	}



	solve();



	while(!L.empty()){

		int team = L.front();L.pop();

		printf("%d\n",team);

	}

	if(multi_flag) puts("1");

	else puts("0");



	return 0;

}

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

#include <cstdio>

#include <algorithm>

#include <stack>

#include <vector>



#define MAX_V 5000



using namespace std;



vector<int > G[MAX_V + 1];

bool visited[MAX_V + 1];



stack<int > L;

int ans[MAX_V];

int num;



int V,E;

bool single;



void init(){

	for(int i = 0;i <= MAX_V;i++) visited[i] = false;

	return ;

}



void count(int to,int cnt){

	//printf("###to = %d:cnt = %d\n",to,cnt);

	if(cnt == V - 1) single = true;

	for(int i = 0;i < G[to].size();i++){

		if(G[to][i] == ans[cnt + 1]) count(G[to][i],cnt + 1);

	}

	return ;

}



void visit(int to){

	//printf("###visited %d\n",to);

	if(!visited[to]){

		visited[to] = true;

		for(int i = 0;i < G[to].size();i++){

			int _to = G[to][i];

			visit(_to);

		}

		L.push(to);

		num++;

	}

	return ;

}



void solve(){

	init();

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

		visit(i);

	}

	single = false;

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

		ans[i] = L.top();L.pop();

	}

	count(ans[0],0);

	return ;

}



int main(){



	scanf("%d%d",&V,&E);

	int _u,_v;

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

		scanf("%d%d",&_u,&_v);

		G[_u].push_back(_v);

	}



	solve();

	

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

		printf("%d\n",ans[i]);

	}

	if(single)puts("0");

	else puts("1");



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

using namespace std;



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

#define rloop(i,n) for(int i = int(n);i >= 0;i--)

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

#define SZ(c) int(c.size())

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

#define RALL(c) c.rbegin(), c.rend()

#define PI acos(-1)

#define pb push_back

#define mp make_pair

#define fr first

#define sc second

#define sfi1(v) scanf("%d",&v)

#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)

#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)

#define sfll1(v) scanf("%I64d",&v);

#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)

#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

#define endl '\n'



typedef vector<int> vi;

typedef vector<pair<int,int> > vii;

typedef long long ll;

typedef pair<int, int> pii;







int main()

{



#ifndef ONLINE_JUDGE

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

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

#endif

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



    int n;

    string str;

    map<string, int> m;

    ll ans = 0;

    cin >> n;

    loop(i,n){

        cin >> str;

        sort(ALL(str));

        ans += m[str]++;

    }



    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.284909652459364x):
#include <iostream>

#include <map>

#include<string>

#include<algorithm>

using namespace std;

int main()

{

	long long n;

	string str;

	map<string,int> s;

	cin>>n;

	long long sum=0;

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

	{

		cin>>str;	

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

		s[str];

		int x=s[str]++;		

		sum+=x;

	}

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

using namespace std;

typedef long long ll;

int main(){

	ll n;

	cin>>n;



	multiset<string>v;

	set<string> vi;

	

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

		string S;

		cin>>S;

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

		vi.insert(S);

		v.insert(S);

	}

	ll cont =0;

	for(auto it:vi)

		cont += v.count(it)*(v.count(it)-1)/2;

	

	cout<<cont;

}