Language: C++

#include<iostream>
using namespace std;

long long n,prime_son[209],cnt[209],a[209],tot,end,ANS;
long long prime_son2[209],cnt2[209],tot2,end2,ANS2 = 1;

bool isPrime(long long x)
{
	for(long long i = 2;i*i<=x;i++)if(x%i==0)return false;
	return true;
}

void FenJie(long long x)
{
	for(long long i = 2;i*i<=x;i++)
	{
		if(isPrime(i)==false)continue;
		if(x%i==0)
		{
			prime_son[++tot] = i;
			while(x%i==0)x /= i,cnt[tot]++;
		}
	}
	prime_son[++tot] = x,cnt[tot]++;
	end = tot;
}
void FenJie2(long long x)
{
	for(long long i = 2;i*i<=x;i++)
	{
		if(isPrime(i)==false)continue;
		if(x%i==0)
		{
			prime_son2[++tot2] = i;
			while(x%i==0)x /= i,cnt2[tot2]++;
		}
	}
	prime_son2[++tot2] = x,cnt2[tot2]++;
	end2 = tot2;
}

void Judge(long long x,long long m)
{
	long long remain = m/x;
	if(x==1)return;
	if(remain%x==1)ANS++;//cout << "FUCK\n";
	else if(remain%x==0)Judge(x,remain);
}

void dfs(long long id,long long t,long long now)
{
	a[id] = t;
	for(long long i = 1;i<=t;i++)now *= prime_son[id];
	if(id==end)
	{
		Judge(now,n);
		//cout << now << "!\n";//
		return;
	}
	for(long long i = 0;i<=cnt[id+1];i++)dfs(id+1,i,now);
}

int main()
{
	cin >> n;
	FenJie(n);
	FenJie2(n-1);
	for(int i = 1;i<=end2;i++)ANS2 *= cnt2[i]+1;
	
	//for(long long i = 1;i<5;i++)cout << prime_son[i] << " " << cnt[i] << endl;//
	//cout << "XHZNB!\n" << ANS2 << endl;
	//for(long long i = 1;i<10;i++)cout << prime_son2[i] << " " << cnt2[i] << endl;//
	
	for(long long t = 0;t<=cnt[1];t++)dfs(1,t,1);
	cout << ANS+ANS2-1;
	return 0;
}

Compiler output:
a.cc: In function 'void FenJie(long long int)':
a.cc:25:9: error: reference to 'end' is ambiguous
   25 |         end = tot;
      |         ^~~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/14/bits/range_access.h:36:
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:4:48: note:                 'long long int end'
    4 | long long n,prime_son[209],cnt[209],a[209],tot,end,ANS;
      |                                                ^~~
a.cc: In function 'void dfs(long long int, long long int, long long int)':
a.cc:54:16: error: reference to 'end' is ambiguous
   54 |         if(id==end)
      |                ^~~
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:4:48: note:                 'long long int end'
    4 | long long n,prime_son[209],cnt[209],a[209],tot,end,ANS;
      |                                                ^~~