Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8
int C[100007][100007];
int D[100007];

int main(){
    int N;
    cin>>N;
    vector<string> V;
    string s;
    rep(i,N){
        cin>>s;
        sort(All(s));
        V.push_back(s);
    }
    sort(All(V));
    ll ans=0, k;
    rep(i,N){
        k = *upper_bound(All(V),V[i])-V.begin();
        k-=i+1;
        ans+=k;
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:38: error: no match for 'operator-' (operand types are 'std::__cxx11::basic_string<char>' and 'std::vector<std::__cxx11::basic_string<char> >::iterator')
   32 |         k = *upper_bound(All(V),V[i])-V.begin();
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
      |             |                                |
      |             std::__cxx11::basic_string<char> std::vector<std::__cxx11::basic_string<char> >::iterator
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:32:47: note:   'std::__cxx11::basic_string<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
   32 |         k = *upper_bound(All(V),V[i])-V.begin();
      |                                               ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:32:47: note:   'std::__cxx11::basic_string<char>' is not derived from 'const std::move_iterator<_IteratorL>'
   32 |         k = *upper_bound(All(V),V[i])-V.begin();
      |                                               ^
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1312 |     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note:   template argument deduction/substitution failed:
a.cc:32:47: note:   'std::__cxx11::basic_string<char>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
   32 |         k = *upper_bound(All(V),V[i])-V.begin();
      |                                               ^
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1325 |     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note:   template argument deduction/substitution failed:
a.cc:32:47: note:   'std::__cxx11::basic_string<char>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
   32 |         k = *upper_bound(All(V),V[i])-V.begin();
      |                                               ^