criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}


int solve(int b , int n){
    int res = 0;
    while(n > 0){
        res += n % b;
        n /= b;
    }
    return res;
}

signed main(){
    int n,s;
    cin >> n >> s;

    int b = 2;
    int ans = INF;
    if(n < 100){
        while(1){
            if(solve(b,n) == s){
                cout << b << endl;
                return 0;
            }
        }
        b ++;
        if(b > n + 1){
            cout << - 1 << endl;
            return 0;
        }
    }

    while(1){
        if( (b -1 ) * (b - 1) > n ) break;
        if(solve(b,n) == s){
            cout << b << endl;
            return 0;
        }
        b ++;
    }

    int ans = INF;
    int shou = 1;
    while( (shou + 1) * (shou + 1) < n) shou++;
    while(shou > 0){
        int amari = s - shou;
        if( amari >= 0 and (n - amari) % shou  == 0){
            b = (n - amari) / shou;
            if(amari < b and shou < b){
                chmin(ans,b);
            }
        }
        shou --;
    }
    
    if(ans == INF) cout << - 1 << endl;
    else cout << ans << endl;

}

Compiler output:
a.cc: In function 'bool Add(llong&, llong)':
a.cc:26:42: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | bool Add(int &a,int b){a = (a + b) % MOD;}
      |                                          ^
a.cc: In function 'int main()':
a.cc:71:9: error: redeclaration of 'llong ans'
   71 |     int ans = INF;
      |         ^~~
a.cc:47:9: note: 'llong ans' previously declared here
   47 |     int ans = INF;
      |         ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}


int solve(int b , int n){
    int res = 0;
    while(n > 0){
        res += n % b;
        n /= b;
    }
    return res;
}

signed main(){
    int n,s;
    cin >> n >> s;

    int b = 2;
    int ans = INF;
    if(n < 100000){
        while(1){
            if(solve(b,n)) == s){
                cout << b << endl;
                return 0;
            }
        }
        b ++;
        if(b > n + 1) cout << - 1 << endl;
    }

    while(1){
        if( (b -1 ) * (b - 1) > n ) break;
        if(solve(b,n) == s){
            chmin(ans,b);
        }
        b ++;
    }

    int shou = 2;
    while( shou * shou <= n) shou++;
    while(shou > 0){
        int amari = s - shou;
        if( amari >= 0 and (n - amari) % shou  == 0){
            b = (n - amari) / shou;
            if(amari < b and shou < b){
                chmin(ans,b);
            }
        }
        shou --;
    }
    if(ans == INF) cout << - 1 << endl;
    else cout << ans << endl;


}

Compiler output:
a.cc: In function 'bool Add(llong&, llong)':
a.cc:26:42: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | bool Add(int &a,int b){a = (a + b) % MOD;}
      |                                          ^
a.cc: In function 'int main()':
a.cc:50:28: error: expected primary-expression before '==' token
   50 |             if(solve(b,n)) == s){
      |                            ^~
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
signed main(){
	ll n,s;
	cin>>n>>s;
	if(n<s){
		cout<<-1<<endl;
		return 0;
	}
	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}
	for(int i=2;i*i<=n;i++){
		ll sum = 0;
		ll cur = n;
		while(cur>0){
			sum += cur%i;
			cur /= i;
		}
		if(sum == s){
			cout<<i<<endl;
			return 0;
		}
	}
	vector<ll> ldiv;
	for(int i=1;i*i<=n;i++){
		if( (n-s)%i == 0){
			ldiv.pb((n-s)/i + 1);
			//cout<<ldiv[ldiv.size()-1]<<endl;
		}
	}
	sort(ldiv.begin(),ldiv.end());
	for(int i=0;i<ldiv.size();i++){
		ll ct = ldiv[i];
		double sq = sqrt(1.0*n)
		if(1.0*ct>sq && n/ct+n%ct==s){
			cout<<ct<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: expected ',' or ';' before 'if'
   42 |                 if(1.0*ct>sq && n/ct+n%ct==s){
      |                 ^~
Language: C++

#include <iostream>
#include <cmath>
using namespace std;
long long digitsum(long long a,long long p){
    long long t = 0;
    while(a>0){
        t+=(a%p);
        a/=p;
    }
    return t;
}
int main(){
    long long n,s;
    cin >> n >> s;
    //sqrt(n)までは全探索
    long long n1 = long(sqrt(n))+1;
    for(int i = 2;i<=n1;i++){
        if(digitsum(n,i)==s){
            cout << i << endl;
            return 0;
        }
    }
    long long n2 = (n/n1)+1;
    for(int i = n2;i>=1;i--){
        long long amari = s-i;
        if(amari>=0 && (n-amari)%i==0 && amari<(n-amari)/i && (n-amari)/i>=2}){
            cout << (n-amari)/i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:77: error: expected ')' before '}' token
   26 |         if(amari>=0 && (n-amari)%i==0 && amari<(n-amari)/i && (n-amari)/i>=2}){
      |           ~                                                                 ^
      |                                                                             )
a.cc:26:77: error: expected primary-expression before '}' token
a.cc:26:78: error: expected primary-expression before ')' token
   26 |         if(amari>=0 && (n-amari)%i==0 && amari<(n-amari)/i && (n-amari)/i>=2}){
      |                                                                              ^
a.cc: At global scope:
a.cc:31:5: error: 'cout' does not name a type
   31 |     cout << -1 << endl;
      |     ^~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

vector<ll> yakusu;

void calc_yakusu(ll A) {
	
	if (A == 1) {
		yakusu.push_back(1);
		return;
	}
	ll waru = 1;
	while (waru * waru <= A) {
		if (A % waru == 0) {
			yakusu.push_back(waru);
			if(waru * waru != A)
				yakusu.push_back(A / waru);
		}
		waru++;
	}

}

int main() {
	ll n, s;
	cin >> n >> s;
	if (s == 1) {
		cout << n << endl;
		return 0;
	}
	if (s > n) {
		cout << -1 << endl;
		return 0;
	}
	for (int shinsu = 2; shinsu * shinsu <= n; shinsu++) {
		ll cpyn = n;
		ll tmp = 0;
		while (cpyn > 0)tmp += (cpyn % shinsu), cpyn /= shinsu;
		if (tmp == s) {
			cout << shinsu << endl;
			return 0;
		}
	}
	
	//n == p * shinsu + q, p + q == s
	//->q == s - p
	//n == p * shinsu + s - p
	//n - s == p * (shinsu - 1) (p > sqrt(n), p < shinsu)
	calc_yakusu(n - s);

	sort(yakusu.begin(), yakusu.end());
	
	for (int i = 0; i < yakusu.size(); i++) {
		ll cur = yakusu[i];
		ll counter = (n - s) / yakusu[i];
		if (cur > 1 && counter > (ll)sqrt(n) && cur + 1 > counter && cur + 1 > s - counter) {
			cout << cur + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:61:46: error: 'sqrt' was not declared in this scope
   61 |                 if (cur > 1 && counter > (ll)sqrt(n) && cur + 1 > counter && cur + 1 > s - counter) {
      |                                              ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
map<long long,map<long long, long long> > f;
long long count(long long b,long long n){
	if(f[b][n]!=0){
		return f[b][n];
	}
	if(n<b){
		//cout << b << " " << n<<endl;
		return n;
	}
	else{
		f[b][n] = count(b,n/b) + n%b;
		return f[b][n];
	}
}
signed main(){
	long long n,s;
	cin >> n >> s;
	long long l=1;
	long long r=1e11;
	for(int i=1;i<=10000){
		if(count(1,n)==s||count(n-i,n)){
			cout << i;
			return 0;
		}
	}
	cout << "-1";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:29: error: expected ';' before ')' token
   22 |         for(int i=1;i<=10000){
      |                             ^
      |                             ;
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 998244353;
vel kai(4001, 1);
vel ink(4001, 1);
vel uni(vel &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	vel ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 4000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 4001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int dig(int b,int n){
    int ans=0;
    while(n>0){
        ans+=n%b;n=n/b;
    }   
    return ans;
}
signed main() {
    int n,s;cin>>n>>s;
    int dif=n-s;
    if(dif==0){
        cout << n+1<<endl;return 0;
    }
    else if(dif<0){cout << -1<<endl;return 0;}
    else{
        vel ans(0);
        for(int i=1;i*i<=diff;i++){
            if(dif%i==0){
                int mi=i;
                if(dig(n,mi+1)==s){ans.push_back(mi+1);}
                mi=diff/mi;
                if(dig(n,mi+1)==s){ans.push_back(mi+1);}
            }
        }
        sor(ans);
        if(ans.size()>0){cout << ans[0]<<endl;}
        else{cout << -1<<endl;}
    }
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:26: error: 'diff' was not declared in this scope; did you mean 'dif'?
   65 |         for(int i=1;i*i<=diff;i++){
      |                          ^~~~
      |                          dif
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n, s; cin >> n >> s;
  if(n == s) {
    cout << n + 1 << endl; return 0;
  }
  if(s > n) {
    cout << -1 << endl; return 0;
  }
  ll b = 2;
  for(; b * b <= n; b++) {
    ll N = n;
    ll f = 0;
    while(N != 0) {
      f += N % b;
      N /= b;
    }
    if(f == s) {
      cout << b << "\n";
      return 0;
    }
  }
  b ++;
  ll N = n - s;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      if(i >= b - 1 && s >= i + 1 && s <= 2 * i + 1) {
      cout << i + 1 << endl; return 0;
      }
    }
  }
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      j = n / i;
      if(j >= b - 1 && s >= j + 1 && s <= 2 * j + 1) {
      cout << j + 1 << endl; return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:86:7: error: 'j' was not declared in this scope
   86 |       j = n / i;
      |       ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n, s; cin >> n >> s;
  if(n == s) {
    cout << n + 1 << endl; return 0;
  }
  if(s > n) {
    cout << -1 << endl; return 0;
  }
  for(ll b = 2; b * b <= n; b++) {
    ll N = n;
    ll f = 0;
    while(N == 0) {
      f += N % b;
      N /= b;
    }
    if(f == s) {
      cout << b << "\n";
      return 0;
    }
  }
  b ++;
  ll N = n - s;
  vector<ll> divisor;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      divisor.push_back(i);
      if(i * i != n) divisor.push_back(n / i);
    }
  }
  sort(divisor.begin(), divisor.end());
  for(int i = 0; i < divisor.size(); i++) {
    if(divisor[i] >= b - 1) {
      cout << divisor[i] << endl; return 0;
    }
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:74:3: error: 'b' was not declared in this scope
   74 |   b ++;
      |   ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 50+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

int main() {
    LL n,s;
    scanf("%lld%lld",&n,&s);
    if(n==s)
        printf("%lld\n",s+1);
    else if(n<s)
        printf("-1\n");
    else {
        LL mid=sqrt(n)+1;
        bool flag=false;

        //b>sqrt(n)
        LL res;
        for(LL i=2; i<=mid; i++) { //枚举b
            res=0;
            LL temp=n;
            while(temp) {
                res+=temp%i;
                temp/=i;
            }
            if(res==s) {
                printf("%lld\n",i);
                flag=true;
                break;
            }
        }

        //b<=sqrt(n)
        if(!flag) {
            LL factor=n-s;
            LL res;
            for(LL i=sqrt(n-s)+1;; i>=1; i--) {//枚举x1
                if(factor%i==0) {
                    res=factor/i+1;
                    LL j=s-i;//x2
                    if(i<res&&res>=2&&j<res&&i>=0) { //判断b的合法性
                        printf("%lld\n",res);
                        flag=true;
                        break;
                    }
                }
            }
        }

        //其他情况
        if(!flag)
            printf("-1\n");
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:40: error: expected ')' before ';' token
   56 |             for(LL i=sqrt(n-s)+1;; i>=1; i--) {//枚举x1
      |                ~                       ^
      |                                        )
a.cc:56:42: error: 'i' was not declared in this scope
   56 |             for(LL i=sqrt(n-s)+1;; i>=1; i--) {//枚举x1
      |                                          ^
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 50+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;

int main() {
    LL n,s;
    scanf("%lld%lld",&n,&s);
    if(n==s)
        prLLf("%lld\n",s+1);
    else if(n<s)
        prLLf("-1\n");
    else {
        LL mid=sqrt(n);
        bool flag=false;

        //b>sqrt(n)
        LL res;
        for(LL i=2; i<=mid; i++) { //枚举b
            res=0;
            LL temp=n;
            while(temp) {
                res+=temp%i;
                temp/=i;
            }
            if(res==s) {
                prLLf("%lld\n",i);
                flag=true;
                break;
            }
        }

        //b<=sqrt(n)
        if(!flag) {
            LL factor=n-s;
            LL res;
            for(LL i=mid; i>=1; i--) {//枚举x1
                if(factor%i==0) {
                    res=factor/i+1;
                    LL j=s-i;//x2
                    if(i<res&&res>=2&&j<res&&i>=0) { //判断b的合法性
                        prLLf("%lld\n",res);
                        flag=true;
                        break;
                    }
                }
            }
        }

        //其他情况
        if(!flag)
            prLLf("-1\n");
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'prLLf' was not declared in this scope
   29 |         prLLf("%lld\n",s+1);
      |         ^~~~~
a.cc:31:9: error: 'prLLf' was not declared in this scope
   31 |         prLLf("-1\n");
      |         ^~~~~
a.cc:46:17: error: 'prLLf' was not declared in this scope
   46 |                 prLLf("%lld\n",i);
      |                 ^~~~~
a.cc:61:25: error: 'prLLf' was not declared in this scope
   61 |                         prLLf("%lld\n",res);
      |                         ^~~~~
a.cc:71:13: error: 'prLLf' was not declared in this scope
   71 |             prLLf("-1\n");
      |             ^~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 50+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
 
int main() {
    LL n,s;
    scanf("%lld%lld",&n,&s);
    if(n==s)
        prLLf("%lld\n",s+1);
    else if(n<s)
        prLLf("-1\n");
    else {
        LL mid=sqrt(n);
        bool flag=false;
 
        //b>sqrt(n)
        LL res;
        for(LL i=2; i<=mid; i++) { //枚举b
            res=0;
            LL temp=n;
            while(temp) {
                res+=temp%i;
                temp/=i;
            }
            if(res==s) {
                prLLf("%lld\n",i);
                flag=true;
                break;
            }
        }
 
        //b<=sqrt(n)
        if(!flag) {
            LL factor=n-s;
            LL res;
            for(LL i=mid; i>=1; i--) {//枚举x1
                if(factor%i==0) {
                    res=factor/i+1;
                    LL j=s-i;//x2
                    if(i<res&&res>=2&&j<res&&i>=0) { //判断b的合法性
                        prLLf("%lld\n",res);
                        flag=true;
                        break;
                    }
                }
            }
        }
 
        //其他情况
        if(!flag)
            prLLf("-1\n");
    }
 
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'prLLf' was not declared in this scope
   29 |         prLLf("%lld\n",s+1);
      |         ^~~~~
a.cc:31:9: error: 'prLLf' was not declared in this scope
   31 |         prLLf("-1\n");
      |         ^~~~~
a.cc:46:17: error: 'prLLf' was not declared in this scope
   46 |                 prLLf("%lld\n",i);
      |                 ^~~~~
a.cc:61:25: error: 'prLLf' was not declared in this scope
   61 |                         prLLf("%lld\n",res);
      |                         ^~~~~
a.cc:71:13: error: 'prLLf' was not declared in this scope
   71 |             prLLf("-1\n");
      |             ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,s;
bool check(ll base)
{
    ll tmp=n;
    ll ans=0;
    while(tmp)
    {
        ans+=tmp%base;
        tmp/=base;
    }
    return ans==s;
}
bool check(ll i,ll sum)
{
    ll a1=s-i;//x0
    ll a2=sum/i+1;//b
    if(a1>=0&&a1<b&&i<a2)return 1;
    return 0;
}
int main()
{
    scanf("%lld%lld",&n,&s);
    /*第一种情况
    x0+x1*b^1+x2*b^2+...=n
    x0+x1+x2+...=s
    这个时候b^2<=n
    所以b<=根号n
    这个时候暴力枚举即可
    */
    ll Sn=(ll)(sqrt(n))+1;
    ll base;
    for(base=2;base<=Sn;base++)
    {
        if(check(base))
        {
            printf("%lld\n",base);
            return 0;
        }
    }
    /*
    第二种情况
    */
    if(n<=s)
    {
        if(n==s)
        {
            printf("%lld\n",n+1);
        }else
        {
            printf("-1\n");
        }
    }
    /*
    第三种情况暴力枚举
    x0+x1*b^1=n;
    x0+x1=s;
    这个时候联立二式子
    得到x1*(b-1)=n-s
    我们枚举x1，然后判断是否成立，包括题目条件以及进制常识
    */
    ll sum=n-s;
    ll up=sum/Sn+1;
    for(ll i=up;i>=1;i--)
    {
        if(!(sum%i)&&(check(i,sum)))
        {
            printf("%lld\n",sum/i+1);
            return 0;
        }
    }
}


Compiler output:
a.cc: In function 'bool check(long long int, long long int)':
a.cc:20:18: error: 'b' was not declared in this scope
   20 |     if(a1>=0&&a1<b&&i<a2)return 1;
      |                  ^
Language: C++

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

int main(){
  long int n, s;
  cin >> n;
  cin >> s;
  bool judge = true;
  long int i ;
  long int f = 0;
  long int x;
  if(s > 1000000){
    cout << -1 << endl;
    continue;
  }
  else{
    i = 2;
  }
  
  while(judge){
    x = n;
    f = 0;
    if(n<i){
      if(n == s){
        cout << i << endl;
      }
      else{
        cout << -1 << endl;
      }
      judge = false;
    }
    else if(n >= i){
      for(int j = 0; ;j++){
        f += x%i;
        x = x/i;
        if(x < i){
          f += x;
          break;
        }
      }
      if(f == s){
        cout << i << endl;
        judge = false;
      }
      i++;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: continue statement not within a loop
   14 |     continue;
      |     ^~~~~~~~
Language: C++

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

int main(){
  int n, s;
  cin >> n;
  cin >> s;
  bool judge = true;
  int i = 2;
  int f = 0;
  
  while(judge){
    if(n<i){
      if(n == s){
        cout << i << endl;
      }
      else{
        cout << -1 << endl;
      }
      judge = false;
    }
    else if(n >= i){
      for(int j = 0; ;j++){
        f += n%i;
        n = n/i;
        if(n < i){
          f += n;
          break;
      }
      if(f == s){
        cout << i << endl;
        judge = false;
      }
      i++;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:2: error: expected '}' at end of input
   37 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
  int n, s;
  cin >> n;
  cin >> s;
  bool judge = true;
  int i = 2;
  int f = 0;
  
  while(judge){
    if(n<i){
      if(n == s){
        cout << i << endl;
      }
      else{
        cout << -1 << endl;
      }
      judge = false;
    }
    else if(n >= i){
      for(int j = 0; ;j++){
        f += n%i;
        if(n%i = 0){
          break;
        }
        n = n/i;
      }
      if(f == s){
        cout << i << endl;
        judge = false;
      }
      i++;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: lvalue required as left operand of assignment
   25 |         if(n%i = 0){
      |            ~^~
Language: C++

#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef long long int;
#define ECHO(v) cout << v << endl;

ll f(ll b, ll n){
    if(n < b)return n;
    return f(b, n/b) + n % b;
}
int main(void){
    ll n, s;
    cin >> n;
    cin >> s;
    if(n == s){
        cout << n+1 << endl;
        return 0;
    }
    ll sqrtn = sqrt(n);
    FOR(i, 2, sqrtn){
        if(f(i, n)==s){
            cout << i << endl;
            return 0;
        }
    }
    FOR(p, 1, sqrtn){
        if((n-s)%p != 0)continue;
        ll b = 1 + (n-s)/p;
        if(b == 0)continue;
        if(f(b, n) == s){
            cout << b << endl;
            printf("%ld", b);
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Compiler output:
a.cc:8:19: error: declaration does not declare anything [-fpermissive]
    8 | typedef long long int;
      |                   ^~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0

lli calc(lli b,lli n){
	if(n<b) return n;
	else return calc(b,n/b)+n%b;
}

int main(){

	lli n,s;
	cin>>n>>s;

	if(s>n){
		cout<<-1<<endl;
		return 0;
	}
	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}

	set<lli> s;
	for(lli b=2;b*b<=n;b++){
		if(calc(b,n)==s){
			s.insert();
		}
	}

	for(lli p=1;p*p<n && p<=s;p++){
		lli m = s-p;
		if(n-m>=0 && (n-m)%p==0){
			lli b = (n-m)/p;
			if(b>p && b>m){
				s.insert((n-m)/p);
			}
		}
	}

	if(s.size())cout<<*s.begin()<<endl;
	else cout<<-1<<endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:18: error: conflicting declaration 'std::set<long long int> s'
   35 |         set<lli> s;
      |                  ^
a.cc:23:15: note: previous declaration as 'long long int s'
   23 |         lli n,s;
      |               ^
a.cc:38:27: error: request for member 'insert' in 's', which is of non-class type 'long long int'
   38 |                         s.insert();
      |                           ^~~~~~
a.cc:47:35: error: request for member 'insert' in 's', which is of non-class type 'long long int'
   47 |                                 s.insert((n-m)/p);
      |                                   ^~~~~~
a.cc:52:14: error: request for member 'size' in 's', which is of non-class type 'long long int'
   52 |         if(s.size())cout<<*s.begin()<<endl;
      |              ^~~~
a.cc:52:30: error: request for member 'begin' in 's', which is of non-class type 'long long int'
   52 |         if(s.size())cout<<*s.begin()<<endl;
      |                              ^~~~~
Language: C++

#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

LL dig(LL x, LL n) {
  if(n<x) return n;
  else return dig(x/n)+x%n;
}
int main(void)
{
  LL n,s;
  cin >> n >> s;
  vector<LL> f;
  for(LL i=2; i*i <= n;++i) {
    if((n-s)%i) continue;
    f.push_back(i);
    f.push_back((n-s)/i);
  }
  vector<LL> as;
  for(LL x: f) {
    if(dig(x,n)==s) as.push_back(x);
  }
  sort(as.begin(),as.end());
  as.push_back(-1ll);
  cout << as[0] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'LL dig(LL, LL)':
a.cc:10:18: error: too few arguments to function 'LL dig(LL, LL)'
   10 |   else return dig(x/n)+x%n;
      |               ~~~^~~~~
a.cc:8:4: note: declared here
    8 | LL dig(LL x, LL n) {
      |    ^~~
Language: C++

#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

LL dig(LL x, LL n) {
  if(n<x) return n;
  else return dig(x/n)+x%n;
}
int main(void)
{
  LL n,s;
  cin >> n >> s;
  vector<LL> f;
  FOR(i, 1, 1048576) {
    if((n-s)%i) continue;
    f.push_back(i);
    f.push_back((n-s)/i);
  }
  vector<LL> as;
  for(LL x: f) {
    if(dig(x,n)==s) as.push_back(x);
  }
  sort(as.begin(),as.end());
  as.push_back(-1ll);
  cout << as[0] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'LL dig(LL, LL)':
a.cc:10:18: error: too few arguments to function 'LL dig(LL, LL)'
   10 |   else return dig(x/n)+x%n;
      |               ~~~^~~~~
a.cc:8:4: note: declared here
    8 | LL dig(LL x, LL n) {
      |    ^~~
Language: C++

import math
n = int(input())
s = int(input())

if s == 1:
    print(n)
    quit()

if n == s:
    print(n+1)
    quit()

def f(b, n):
    ret = 0
    while n > 0:
        ret += n % b
        n = n // b
    return ret

for i in range(2, int(math.sqrt(n)+2)):
    t = f(i, n)
    if s == t:
        print(i)
        quit()

for x in range(1, int(math.sqrt(n)+10)):
    y = s - x
    if (n-s)%x == 0:
        b = (n-s)//x
        if x < b and y < b and x*b+y == n and x+y == s:
            print(b)
            quit()
print(-1)


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import math
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include<iostream>
#include<map>
using namespace std;
map<__int64,int> m1;
int check(int b,int n){
	if(n<b)return n;
	int s=n%b;
	n/=b;
	s+=check(b,n);
	return s;
}
int main(){
	int i,j,k;
	int a,n,s;
	int b,c;
	int s1=-1;
	m1[1]=1;
	map<__int64,int>::iterator itr;
	cin>>n>>s;
	a=n-s;
	for(i=2;i<100000;i++){
		if(a==i)break;
		while(a%i==0){
			a/=i;
			itr=m1.begin();
			while(itr!=m1.end()){
				b=(*itr).first;
				b*=i;
				m1[b]=1;
			}
		}
	}
	cout<<"OK!"<<endl;
	itr=m1.begin();
	while(itr!=m1.end()){
		b=(*itr).first;
		b++;
		if(check(b,n)==s){
			s1=b;
			break;
		}
	}
	cout<<s1<<endl;
	return 0;
}

Compiler output:
a.cc:4:5: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
    4 | map<__int64,int> m1;
      |     ^~~~~~~
      |     __int64_t
a.cc:4:16: error: template argument 1 is invalid
    4 | map<__int64,int> m1;
      |                ^
a.cc:4:16: error: template argument 3 is invalid
a.cc:4:16: error: template argument 4 is invalid
a.cc: In function 'int main()':
a.cc:17:11: error: invalid types 'int[int]' for array subscript
   17 |         m1[1]=1;
      |           ^
a.cc:18:13: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   18 |         map<__int64,int>::iterator itr;
      |             ^~~~~~~
      |             __int64_t
a.cc:18:24: error: template argument 1 is invalid
   18 |         map<__int64,int>::iterator itr;
      |                        ^
a.cc:18:24: error: template argument 3 is invalid
a.cc:18:24: error: template argument 4 is invalid
a.cc:18:36: error: expected initializer before 'itr'
   18 |         map<__int64,int>::iterator itr;
      |                                    ^~~
a.cc:25:25: error: 'itr' was not declared in this scope
   25 |                         itr=m1.begin();
      |                         ^~~
a.cc:25:32: error: request for member 'begin' in 'm1', which is of non-class type 'int'
   25 |                         itr=m1.begin();
      |                                ^~~~~
a.cc:26:39: error: request for member 'end' in 'm1', which is of non-class type 'int'
   26 |                         while(itr!=m1.end()){
      |                                       ^~~
a.cc:29:35: error: invalid types 'int[int]' for array subscript
   29 |                                 m1[b]=1;
      |                                   ^
a.cc:34:9: error: 'itr' was not declared in this scope
   34 |         itr=m1.begin();
      |         ^~~
a.cc:34:16: error: request for member 'begin' in 'm1', which is of non-class type 'int'
   34 |         itr=m1.begin();
      |                ^~~~~
a.cc:35:23: error: request for member 'end' in 'm1', which is of non-class type 'int'
   35 |         while(itr!=m1.end()){
      |                       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,nsub,s,sub;
	cin>>n>>s;
	for(ll i=2;i<=sqrt(n);i++){
		nsub=n;
		sub=0;
		while(i<=nsub){
			sub+=(nsub%i);
			nsub/=i;
		}
		sub+=nsub;
		if(sub==s){
			cout<<i<<endl;
			return 0;
		}
	}
	for(ll i=1;i<sqrt(n);i++){
		if((n-s)%i==0){
			ll b=(n-s)/i+1;
			if(sqrt(n)<b<=n){
				cout<<b<<endl;
				return 0;
			}
		}
	}
	else if(n==s){
		cout<<n+1<<endl;
		return 0;
	}
	cout<<-1<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:9: error: 'else' without a previous 'if'
   66 |         else if(n==s){
      |         ^~~~
Language: C++

#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back
#define se second
#define fi first

typedef long long ll;
using namespace std;
const int NUM = 1e5 + 5;
const int mod = 998244353;
int INF = 2e9;
pair <int ,int> pinf = {INF, INF};
ll f (ll b, ll n){
    if (n < b)
        return n;
    return n % b + f(b, n / b);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n, s;
    cin >> n >> s;
    for (ll i = 2; i * i <= n; i++)
        if (f(i, n) == s){
            cout << i;
            return 0;
        }
    ll t = n - s;
    if (s == 1){
        cout << max(n, 2);
        return 0;
    }
    if (t <= 0){
        cout << -1;
        return 0;
    }
    for (ll i = 1; i * i <= t; i++){
        if (t % i != 0)
            continue;
        ll b = i + 1;
        ll x = t / i;
        ll y = s - x;
        if (max(x, y) < b){
            cout << b;
            return 0;
        }
    }
    cout << -1;
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:33:20: error: no matching function for call to 'max(ll&, int)'
   33 |         cout << max(n, 2);
      |                 ~~~^~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:33:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   33 |         cout << max(n, 2);
      |                 ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:33:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |         cout << max(n, 2);
      |                 ~~~^~~~~~
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
int shit(int b,int n){
	if(n<b) return n;
	else return shit(b,floor(n/b))+(n%b);
}
int main(){
	long long a,b;
    cin>>a>>b;
    if(a==1){
	    cout<<"-1";
    }
	else if(b==1){
		cout<<a;
	} 
	else if(a==b){
		cout<<1;
	}
	else if(a<=10000000&&b<=1000000){
		for(int i=2;i<=100000;i++){
			if(shit(i,a)==b){
				cout<<a;
				break;
			}
			else if(i==100000000&&f(i,a)!=b){
				cout<<"-1";
			}
	    }	
	}  
	else cout<<"-1";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:47: error: 'f' was not declared in this scope
   26 |                         else if(i==100000000&&f(i,a)!=b){
      |                                               ^
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
int shit(int b,int n){
	if(n<b) return n
	else return shit(b,floor(n/b))+(n%b);
}
int main(){
	long long a,b;
    cin>>a>>b;
    if(a==1){
	    cout<<"-1";
    }
	else if(b==1){
		cout<<a;
	} 
	else if(a==b){
		cout<<1;
	}
	else if(a<=10000000&&b<=1000000){
		for(int i=2;i<=100000;i++){
			if(shit(i,a)==b){
				cout<<a;
				break;
			}
			else if(i==100000000&&f(i,a)!=b){
				cout<<"-1";
			}
	    }	
	}  
	else cout<<"-1";
	return 0;
}

Compiler output:
a.cc: In function 'int shit(int, int)':
a.cc:5:25: error: expected ';' before 'else'
    5 |         if(n<b) return n
      |                         ^
      |                         ;
    6 |         else return shit(b,floor(n/b))+(n%b);
      |         ~~~~             
a.cc: In function 'int main()':
a.cc:26:47: error: 'f' was not declared in this scope
   26 |                         else if(i==100000000&&f(i,a)!=b){
      |                                               ^
Language: C++

#include <iostream>
#include <cmath>
using namespace std;

int f(int n, int b){
	int result = 0;
	while(n >= b){
		result += n % b;
		n /= b;
	}
	result += n;
	return result;
}

int main(){
	int n, s;
	int a[16] = {2, 5, 7, 8, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000};

	cin >> n >> s;
	
	for(int i = 0; i < 16; i++){
		if(f(n, a[i]) == s){
			cout << i << endl;
			break;
		}
		if(i == 14){
			cout << "-1" << endl;
		}
		
	}
	
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:106: error: narrowing conversion of '10000000000' from 'long int' to 'int' [-Wnarrowing]
   17 |         int a[16] = {2, 5, 7, 8, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000};
      |                                                                                                          ^~~~~~~~~~~
a.cc:17:119: error: narrowing conversion of '100000000000' from 'long int' to 'int' [-Wnarrowing]
   17 |         int a[16] = {2, 5, 7, 8, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000};
      |                                                                                                                       ^~~~~~~~~~~~
Language: C++

#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

ll n,s;

ll f(ll x, ll y){
	if(x==0)return 0;
	return x%y+f(x/y,y);
}

int main(){
	cin>>n>>s;
    if(s>n){
        cout<<-1<<endl;
        return 0
    }
	if(s==n){
		cout<<n+1<<endl;
		return 0;
	}
	for(ll i=2;i*i<=n;i++){
		if(f(n,i)==s){
			cout<<i<<endl;
			return 0;
		}
	}
	for(ll i=sqrt(n)+1;i>=1;i--){
		if((n-s)/i+1!=1&&f(n,(n-s)/i+1)==s){
			cout<<(n-s)/i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:17: error: expected ';' before '}' token
   35 |         return 0
      |                 ^
      |                 ;
   36 |     }
      |     ~
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
long long tmp;
long long trans(long long b,long long n){
	if(n<b){
		return n;
	}
	return trans(b,n/b)+n%b;
}
vector<long long> divi;
signed main(){
	long long n,s;
	cin>>n>>s;
	tmp=n;
	if(s==1){
		cout<<n;
		return 0;
	}
	long long k=sqrt(n);
	for(int i=2;i*i<=n;i++){
		if(trans(i,tmp)==s){
			cout<<i;
			return 0;
		}
		else{
			tmp=n;q
		}
	}
	if(s>n){
		cout<<"-1";
		return 0;
	}
	for(int i=1;i*i<=n-s;i++){
		if((n-s)%i==0){
			divi.push_back(i);
			divi.push_back((n-s)/i);
			if(i*i==(n-s)){
				divi.pop_back();
			}
		}
	}
	sort(divi.begin(),divi.end());
	for(int i=0;i<divi.size();i++){
		if((divi[i]+1)*(divi[i]+1)>n&&trans(divi[i]+1,n)==s&&(n-s)/(divi[i])<divi[i]+1){
			cout<<divi[i]+1;
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:31: error: 'q' was not declared in this scope
   27 |                         tmp=n;q
      |                               ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll n,s,sq;

bool check(ll b)
{
	ll ret=0,t=n;
	for(;t;t/=b) ret+=t%b;
	return (ret==s);
}

ll solve()
{
	if(s==n) return n+1;
	if(s>n) return -1;
	
	for(ll i=2;i*i<=n;i++)
		if(check(i)) return i;
	for(ll i=1;i*i<=n;i++)
		if((n-s)%i==0&&check((n-s)/i+1)) return ((n-s)/i+1);
	return -1;
}

int main()
{
	scanf("%lld%lld",&n,&s);s
	printf("%lld",solve());
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:34: error: expected ';' before 'printf'
   28 |         scanf("%lld%lld",&n,&s);s
      |                                  ^
      |                                  ;
   29 |         printf("%lld",solve());
      |         ~~~~~~
Language: C++

// D.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>

using namespace std;
typedef long long LL;

LL check(LL b, LL n) {
	LL c = 0;
	while (n) {
		c += n % b;
		n /= b;
	}
	return c;
}

int main(int argc, char *argv[]) {
	LL n, s;
	cin >> n >> s;
	LL ans = 1LL << 60;
	if (s == 1LL) {
		ans = n;
	}
	for (LL b = 2; b <= 10000; ++b) {
		if (check(b, n) == s) {
			ans = min(ans, b);
		}
	}
	for (LL d = 2; d <= 5; ++d) {
		LL q = (LL)pow(n, 1.0 / d);
		for (LL b = max(2LL, q - 100); b <= q + 100; ++b) {
			if (check(b, n) == s) {
				ans = min(ans, b);
			}
		}
	}
	cout << (ans == (1LL << 60) ? -1 : ans) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:34:28: error: 'pow' was not declared in this scope
   34 |                 LL q = (LL)pow(n, 1.0 / d);
      |                            ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
using namespace std;

long long f(long long b, long long n) {
	if (n < b)return n;
	else return f(b, n / b) + n % b;
}

int main() {
	long long n, s; cin >> n >> s;
	//n = 1e11;
	/*for (int b = 2; b <= n; b++) {
		cerr << b << " " << f(b, n) << endl;
	}*/

	if ((n+1)/2 < s)cout << -1 << endl;
	else {
		long long ans = n;
		long long x = 2;
		for(int i=1;i<=sqrt(n);i++){
			long long y = n / i;
			long long z = f(y, n);
			if (z > s)continue;
			if ((s - z) % i)continue;

			long long tmp = y - (s - z) / i;
			if (tmp < n / (i + 1))continue;

			ans = min(ans, tmp);
		}
		for (int i = 2; i<=sqrt(n); i++) {
			long long y = i;
			if (f(y, n) == s)ans = min<long long>(ans, i);
		}

		cout << ans << endl;
	}



	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:32: error: 'sqrt' was not declared in this scope
   25 |                 for(int i=1;i<=sqrt(n);i++){
      |                                ^~~~
a.cc:36:36: error: 'sqrt' was not declared in this scope
   36 |                 for (int i = 2; i<=sqrt(n); i++) {
      |                                    ^~~~
Language: C++

#include <cstdio>
#include <cmath>

using namespace std;
long long N, S;
double n;

long long function(long long b, long long n) {
  if (n < b) {
    return n;
  } else {
    return function(b, n/b) + n % b;
  }
}

long long solve() {
  if (N < S) {
    return -1;
  }
  if (N == S) {
    return N+1;
  }
  for (long long i = 2; i < n+1; i++) {
    if (function(i, N) == S) {
      return i;
    }
  }
  for (long long p = (long long)(n+1); p >= 1; p--) {
    if ((N-S)/p == 0) {
      continue;
    }
    if (N % p == S % p && function((N-S)/p + 1, N) == S) {
      return (N-S)/p+1;
    }
  }
  return -1;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status