Language: C++

#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define Sort(n) sort(n.begin(), n.end(), greater<lli>())
#define Reve(n) reverse(n.begin(), n.end())
#define YES puts("YES")
#define NO puts("NO")

//素数
bool IsPrime(lli num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)return false;
  }
  return true;
}
//各桁の和
lli sum(lli n)
{
  lli sum=0;
  if (n<0) return 0;
  while (n>0)
  {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  lli n, flag = 0, j = 0, max = 0, x = 0;
  cin >> n;
  vector<string> s(n);
  vector<pair<lli, string>> ans;
  for(int i = 0;i < n;i++) {
    cin >> s.at(i);
    for(int j = 0;j < x;j++) {
      if(s.at(i) == ans.at(j).second) {
        flag++;
      }
      else {
        ans.at(j).first = flag;
      }
    }
    if(flag == 0) {
      ans.at(x).second == s.at(i);
      x++;
    }
  }
  Sort(ans);
  for(int i = 1;i < n;i++) {
    if(ans.at(i-1).second == ans.at(i).second) continue;
    else cout << ans.at(i-1).second;
    if(ans.at(i).first != ans.at(i).first) return 0;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:24: warning: ignoring return value of 'bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result]
   53 |       ans.at(x).second == s.at(i);
      |       ~~~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:3755:5: note: declared here
 3755 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<long long int, std::__cxx11::basic_string<char> >*, std::vector<std::pair<long long int, std::__cxx11::basic_string<char> > > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<long long int, std::__cxx11::basic_string<char> >*, std::vector<std::pair<long long int, std::__cxx11::basic_string<char> > > >; _Compare = std::greater<long long int>]':
/usr/include/c++/14/bits/stl_algo.h:1777:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1777 |           if (__comp(__i, __first))
      |               ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4805:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = greater<long long int>]'
 4805 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:57:3:   required from here
    5 | #define Sort(n) sort(n.begin(), n.end(), greater<lli>())
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(std::greater<long long int>) (std::pair<long long int, std::__cxx11::basic_string<char> >&, std::pair<long long int, std::__cxx11::basic_string<char> >&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:49:
/usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = long long int]'
  394 |       operator()(const _Tp& __x, const _Tp& __y) const
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:29: note:   no known conversion for argument 1 from 'std::pair<long long int, std::__cxx11::basic_string<char> >' to 'const long long int&'
  394 |       operator()(const _Tp& __x, const _Tp& __y) const
      |                  ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<long long int, std::__cxx11::basic_string<char> >; _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, std::__cxx11::basic_string<char> >*, std::vector<std::pair<long long int, std::__cxx11::basic_string<char> > > >; _Compare = std::greater<long long int>]':
/usr/include/c++/14/bits/stl_algo.h:1757:20:   required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<greater<long long int> >]'
 1757 |       while (__comp(__val, __next))
      |              ~~~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1785:36:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1785 |             std::__unguarded_linear_insert(__i,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
 1786 |                                 __gnu_cxx::__ops::__val_comp_iter(__comp));
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4805:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Compare = greater<long long int>]'
 4805 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:57:3:   required from here
    5 | #define Sort(n) sort(n.begin(), n.end(), greater<lli>())
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:240:30: error: no match for call to '(std::greater<long long int>) (std::pair<long long int, std::__cxx11::basic_string<char> >&, std::pair<long long int, std::__cxx11::basic_string<char> >&)'
  240 |         { return bool(_M_comp(__val, *__it)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = long long int]'
  394 |       operator()(const _Tp& __x, const _Tp& __y) const
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:29: note:   no known conversion for argument 1 from 'std::pair<long long int, std::__cxx11::basic_string<char> >' to 'const long long int&'
  394 |       operator()(const _Tp& __x, const _Tp& __y) const
      |                  ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, std::__cxx11::basic_string<char> >*, std::vector<std::pair<long long int, std::__cxx11::basic_string<char> > > >; _Value = std::pair<long long int, std::__cxx11::basic_string<char> >; _Compare = std::greater<long long int>]':
/usr/include/c++/14/bits/stl_heap.h:140:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<char> >*, vector<pair<long long int, __cxx11::basic_string<char> > > >; _Distance = long int; _Tp = pair<long long int, __cxx11::basic_string<char> >; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<long long int> >]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:247:23:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, __cxx11::basic_string<ch