Language: C++

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;
const ll inf=1e18+10;

///---program start---///

const int M=1e6;

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

int get_big(int n,int s)
{
    int res=inf;
    for (int val=1;val<=min({n,s,M});val++){
        int rest=s-val;
        if ((n-rest)%val==0){
            int b=(n-rest)/val;
            if (n/b==val){
                if (b>=2){
                    res=min(res,b);
                }
            }
        }
    }
    /// if val==0
    if (n==s){
        if (n==1){
            res=min(res,2);
        }
        else{
            res=min(res,n);
        }
    }
    return (res==inf?-1:res);
}

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int n,s;
    cin>>n>>s;
    for (int b=2;b<M;b++){
        if (sum(n,b)==s){
            cout<<b<<"\n";
            return 0;
        }
    }
    cout<<get_big(n,s)<<"\n";
}


Compiler output:
a.cc: In function 'long long int get_big(long long int, long long int)':
a.cc:63:20: error: no matching function for call to 'min(long long int&, int)'
   63 |             res=min(res,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:4:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:63:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   63 |             res=min(res,2);
      |                 ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:63:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   63 |             res=min(res,2);
      |                 ~~~^~~~~~~
a.cc: At global scope:
a.cc:72:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   72 | main()
      | ^~~~