Language: C++

//
// Created by kuroneko on 2019-08-10.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000000000000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

//10^7まで
const int MAX = 100005;
long long fac[MAX], finv[MAX], inv[MAX];
void com_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long com(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    com_init();
    int N; cin >> N;
    vector<vector<char>> v(N);
    vector<string> s(N);

    for (int i = 0; i < N; i++) {
        string st; cin >> st;
        for (int j = 0; j < 10; j++) v[i].push_back(st[j]);
        sort(v[i].begin(), v[i].end());
        for (int j = 0; j < 10; j++) st[j] = v[i][j];
        s[i] = st;
    }

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

    bool prev = false;
    vector<int> res;
    for (int i = 0; i < N-1; i++) {
        bool flag = true;
        for (int j = 0; j < 10; j++) {
            if (s[i][j] != s[i+1][j]) flag = false;
        }
        if (flag) {
            if (prev) {
                res[int(res.size())-1] += 1;
            } else {
                res.push_back(2);
            }

            prev = true;
        } else {
            prev = false;
        }
    }
    ll ans = 0;
    for (int i = 0; i < res.size(); i++) {
        ans += com(res[i], 2);
    }

    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc:40:33: warning: integer constant is too large for its type
   40 |         fac[i] = fac[i-1] * i % MOD;
      |                                 ^~~
a.cc:41:18: warning: integer constant is too large for its type
   41 |         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      |                  ^~~
a.cc:41:28: warning: integer constant is too large for its type
   41 |         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      |                            ^~~
a.cc:41:38: warning: integer constant is too large for its type
   41 |         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      |                                      ^~~
a.cc:41:49: warning: integer constant is too large for its type
   41 |         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      |                                                 ^~~
a.cc:42:40: warning: integer constant is too large for its type
   42 |         finv[i] = finv[i-1] * inv[i] % MOD;
      |                                        ^~~
a.cc:49:46: warning: integer constant is too large for its type
   49 |     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
      |                                              ^~~
a.cc:49:53: warning: integer constant is too large for its type
   49 |     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
      |                                                     ^~~
a.cc: In function 'int main()':
a.cc:61:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   61 |         sort(v[i].begin(), v[i].end());
      |         ^~~~
      |         sqrt
a.cc:66:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   66 |     sort(s.begin(), s.end());
      |     ^~~~
      |     sqrt