Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;

const int N = (int)1e5+5;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

set<ll,custom_hash> mp;
void prime(ll n) {
    mp.insert(n);
    for(int i=2;(ll)i*i<=n;i++) {
        if(n%i==0) {
            mp.insert(i);
            if(i!=(n/i)) {
                mp.insert(n/i);
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n,t,ans=0;
    cin>>n;
    prime(n);
    prime(n-1);
    for(auto it:mp) {
        ll m = n;
        while(m%it==0) {
            m/=it;
        }
        if(m%it==1){
            ans++;
        }
    }
    cout<<ans;
}


Compiler output:
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = custom_hash; _Alloc = std::allocator<long long int>; key_type = long long int]':
/usr/include/c++/14/bits/stl_tree.h:2169:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const long long int&; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = custom_hash; _Alloc = std::allocator<long long int>]'
 2169 |         = _M_get_insert_unique_pos(_KeyOfValue()(__v));
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:514:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = long long int; _Compare = custom_hash; _Alloc = std::allocator<long long int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<long long int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::rebind<long long int>; typename _Alloc::value_type = long long int; value_type = long long int]'
  514 |           _M_t._M_insert_unique(__x);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:24:14:   required from here
   24 |     mp.insert(n);
      |     ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:2116:42: error: no match for call to '(custom_hash) (const std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::key_type&, const long long int&)'
 2116 |           __comp = _M_impl._M_key_compare(__k, _S_key(__x));
      |                    ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:16:12: note: candidate: 'size_t custom_hash::operator()(uint64_t) const'
   16 |     size_t operator()(uint64_t x) const {
      |            ^~~~~~~~
a.cc:16:12: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_tree.h:2127:33: error: no match for call to '(custom_hash) (const long long int&, const std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::key_type&)'
 2127 |       if (_M_impl._M_key_compare(_S_key(__j._M_node), __k))
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:16:12: note: candidate: 'size_t custom_hash::operator()(uint64_t) const'
   16 |     size_t operator()(uint64_t x) const {
      |            ^~~~~~~~
a.cc:16:12: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_(_Base_ptr, _Base_ptr, _Arg&&, _NodeGen&) [with _Arg = const long long int&; _NodeGen = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::_Alloc_node; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = custom_hash; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::iterator; _Base_ptr = std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:2174:26:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const long long int&; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = custom_hash; _Alloc = std::allocator<long long int>]'
 2174 |           return _Res(_M_insert_(__res.first, __res.second,
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 2175 |                                  _GLIBCXX_FORWARD(_Arg, __v), __an),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:514:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = long long int; _Compare = custom_hash; _Alloc = std::allocator<long long int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<long long int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::rebind<long long int>; typename _Alloc::value_type = long long int; value_type = long long int]'
  514 |           _M_t._M_insert_unique(__x);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:24:14:   required from here
   24 |     mp.insert(n);
      |     ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:1824:56: error: no match for call to '(custom_hash) (const long long int&, const long long int&)'
 1824 |                               || _M_impl._M_key_compare(_KeyOfValue()(__v),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
 1825 |                                                         _S_key(__p)));
      |                                                         ~~~~~~~~~~~~
a.cc:16:12: note: candidate: 'size_t custom_hash::operator()(uint64_t) const'
   16 |     size_t operator()(uint64_t x) const {
      |            ^~~~~~~~
a.cc:16:12: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_(_Base_ptr, _Base_ptr, _Arg&&, _NodeGen&) [with _Arg = long long int; _NodeGen = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::_Alloc_node; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = custom_hash; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::iterator; _Base_ptr = std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:2174:26:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = long long int; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = custom_hash; _Alloc = std::allocator<long long int>]'
 2174 |           return _Res(_M_insert_(__res.first, __res.second,
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 2175 |                                  _GLIBCXX_FORWARD(_Arg, __v), __an),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:523:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = long long int; _Compare = custom_hash; _Alloc = std::allocator<long long int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, custom_hash, std::allocator<long long int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<long long int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::rebind<long long int>; typename _Alloc::value_type = long long int; value_type = long long int]'
  523 |           _M_t._M_insert_unique(std::move(__x));
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:27:22:   required from here
   27 |             mp.insert(i);
      |             ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:1824:56: error: no match for call to '(custom_hash) (long long int&, const long long int&)'
 1824 |                               || _M_impl._M_key_compare(_KeyOfValue()(__v),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
 1825 |                                                         _S_key(__p)));
      |                                                         ~~~~~~~~~~~~
a.cc:16:12: note: candidate: 'size_t custom_hash::operator()(uint64_t) const'
   16 |     size_t operator()(uint64_t x) const {
      |            ^~~~~~~~
a.cc:16:12: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(_Const_Link_type) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = custom_hash; _Alloc = std::a