Language: C++

#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
const ll INF=10000000000000;
ll n,s;

ll f(ll b,ll n){
	ll ret=0;

	while(n){
		ret+=n%b;
		n/=b;
	}
	return ret;
}
int main(){
	cin>>n>>s;
	if(n==s){cout<<n+1<<endl; return 0;}
	for(ll i=2;i<=sqrt(n);i++){
		//cout<<f(i,n)<<endl;
		if(f(i,n)==s){
			cout<<i<<endl;
			return 0;
		}
	}

	ll ans=INF;
	for(ll i=1;i<sqrt(n);i++){
		if((n-s)%i==0)if(f((n-s)/i+1,n)==s)ans=min(ans,(n-s)/i+1);

	}
	if(ans==INF)ans=-1;
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:7: note: in expansion of macro 'll'
   18 | const ll INF=10000000000000;
      |       ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:19:1: note: in expansion of macro 'll'
   19 | ll n,s;
      | ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:21:1: note: in expansion of macro 'll'
   21 | ll f(ll b,ll n){
      | ^~
a.cc: In function 'int main()':
a.cc:31:14: error: 'n' was not declared in this scope
   31 |         cin>>n>>s;
      |              ^
a.cc:31:17: error: 's' was not declared in this scope
   31 |         cin>>n>>s;
      |                 ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:33:13: note: in expansion of macro 'll'
   33 |         for(ll i=2;i<=sqrt(n);i++){
      |             ^~
a.cc:33:20: error: 'i' was not declared in this scope
   33 |         for(ll i=2;i<=sqrt(n);i++){
      |                    ^
a.cc:33:23: error: 'sqrt' was not declared in this scope
   33 |         for(ll i=2;i<=sqrt(n);i++){
      |                       ^~~~
a.cc:35:20: error: 'f' was not declared in this scope
   35 |                 if(f(i,n)==s){
      |                    ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:41:9: note: in expansion of macro 'll'
   41 |         ll ans=INF;
      |         ^~
a.cc:42:16: error: expected ';' before 'i'
   42 |         for(ll i=1;i<sqrt(n);i++){
      |                ^
a.cc:42:20: error: 'i' was not declared in this scope
   42 |         for(ll i=1;i<sqrt(n);i++){
      |                    ^
a.cc:42:22: error: 'sqrt' was not declared in this scope
   42 |         for(ll i=1;i<sqrt(n);i++){
      |                      ^~~~
a.cc:43:34: error: 'f' was not declared in this scope
   43 |                 if((n-s)%i==0)if(f((n-s)/i+1,n)==s)ans=min(ans,(n-s)/i+1);
      |                                  ^
a.cc:43:52: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |                 if((n-s)%i==0)if(f((n-s)/i+1,n)==s)ans=min(ans,(n-s)/i+1);
      |                                                    ^~~
      |                                                    abs
a.cc:46:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |         if(ans==INF)ans=-1;
      |            ^~~
      |            abs
a.cc:46:17: error: 'INF' was not declared in this scope
   46 |         if(ans==INF)ans=-1;
      |                 ^~~
a.cc:47:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |         cout<<ans<<endl;
      |               ^~~
      |               abs