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

# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

#define int LL

int n, a, x[101];
int dp[55][55][2550];

int main() {
	cin >> n >> a;
	REP(i, n)cin >> x[i];
	dp[0][0][0] = 1;
	int ans = 0;
	REP(i, n)REP(j, n)REP(k, 2500) {
		dp[i + 1][j][k] += dp[i][j][k];
		dp[i + 1][j + 1][k + x[i]] = dp[i][j][k];
	}
	for (int j = 1; j <= n; j++) {
		ans += dp[n][j][a*j];
	}
	cout << ans << endl;
}

Compiler output:
a.cc:41:13: error: '::main' must return 'int'
   41 | #define int LL
      |             ^~
a.cc:46:1: note: in expansion of macro 'int'
   46 | int main() {
      | ^~~
Language: C++

#include <stdio.h>
#include <vector>

int main(){
    int N, A, tmp;
    int x[51];

    scanf("%d %d", &N, &A);
    for(int i = 0; i < N; ++i){
        scanf("%d", &tmp);
        x[i + 1] = tmp;
    }

    int X = std::max(*std::max_element(&x[1], &x[N]), A);
    long long int dp[N + 1][2 * N * X + 1];

    for(int i = 0; i < N; ++i){
        x[i + 1] -= A;
    }

    for(int j = 0; j <= N; ++j){
        for(int t = 0; t <= 2 * N * X; ++t){
            if (j == 0 && t == N * X) {
                dp[j][t] = 1;
            } else if (1 <= j && 0 <= t - x[j] && t - x[j] <= 2 * N * X){
                dp[j][t] = dp[j - 1][t - x[j]] + dp[j - 1][t];
            } else if (1 <= j && (t - x[j] < 0 || 2 * N * X < t - x[j])){
                dp[j][t] = dp[j - 1][t];
            } else {
                dp[j][t] = 0;
            }
        }
    }

    printf("%lld\n", dp[N][N * X] - 1);

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:28: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   14 |     int X = std::max(*std::max_element(&x[1], &x[N]), A);
      |                            ^~~~~~~~~~~
      |                            tuple_element
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

ll n,a;
ll x[51]={};
ll dp[51][51][2503];

ll dfs(int i, int cnt, int sum){
    if(dp[i][cnt][sum]!=-1)return dp[i][cnt][sum];
    if (i == n){
        return cnt != 0 && sum == cnt * a;
    }
    ll res = 0;
    res += dfs(i+1, cnt, sum) + dfs(i + 1, cnt + 1, sum + x[i]);

    return dp[i][cnt][sum] = res;
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin>>n>>a;
    for(int i=0; i<n; i++)cin>>x[i];
    cout<<dfs(0,0,0)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:5: error: 'memset' was not declared in this scope
   43 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <cctype>
  +++ |+#include <cstring>
    8 | #define rep(i, m, n) for (int i = m; i < n; i++)
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

ll x[55]={};
ll dp[10005][10005][10005]={};

ll dfs(int i,int cnt, int sum){
    if(dp[i][cnt][sum]!=0)return dp[i][cnt][sum];
    ll res;
     if (i==n){
         if (cnt != 0){
             return (double)sum / cnt == (double)a;
         }else{
             return 0;
         }  
    }else{
        res = dfs(i+1, cnt, sum) + dfs(i+1, cnt+1, sum + x[i]);
    }
    return dp[i][cnt][sum] = res;
}

int main(){
    int ans=0;
    cin>>n>>a;
    for(int i=0; i<n; i++)cin>>x[i];
    cout<<dfs(0,0,0)<<endl;
}

Compiler output:
a.cc: In function 'long long int dfs(int, int, int)':
a.cc:33:13: error: 'n' was not declared in this scope
   33 |      if (i==n){
      |             ^
a.cc:35:50: error: 'a' was not declared in this scope
   35 |              return (double)sum / cnt == (double)a;
      |                                                  ^
a.cc: In function 'int main()':
a.cc:47:10: error: 'n' was not declared in this scope
   47 |     cin>>n>>a;
      |          ^
a.cc:47:13: error: 'a' was not declared in this scope
   47 |     cin>>n>>a;
      |             ^
Language: C++

#include<fstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;

int m1=0,m2=0;
int N,A,x[50],y[50],dp[1<<26];
vector<int> r[2][50];
long long res=0;

int nb(int bits)
{
	bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
	bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
	bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
	bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
	return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int bdp(int n,int a[25],int p)
{
	if(dp[p]>=0)return dp[p];
	if(p==0)return dp[p]=0;
	for(int i=0;i<n;i++)
	{
		if(((p>>i)&1))
		{
			int x=p^(1<<i);
			int r=bdp(n,a,x)+a[i];
			dp[p]=r;
		}
	}
	return dp[p];
}

int main()
{
	scanf("%d%d",&N,&A);
	for(int i=0;i<N;i++)
	{
		if(i<N/2)scanf("%d",&x[i]);
		else scanf("%d",&y[i-N/2]);
	}
	memset(dp,-1,sizeof(dp));
	bdp(N/2,x,(1<<(N/2))-1);
	for(int i=0;i<1<<N/2;i++)
	{
		r[0][nb(i)].push_back(dp[i]);
		m1=max(m1,nb(i));
	}
	memset(dp,-1,sizeof(dp));
	bdp(N-N/2,y,(1<<(N-N/2))-1);
	for(int i=0;i<1<<N/2;i++)
	{
		r[1][nb(i)].push_back(dp[i]);
		m2=max(m2,nb(i));
	}

	for(int i=0;i<=m1;i++)
	{
		sort(r[0][i].begin(),r[0][i].end(),less<int>());
		for(int j=0;j<=m2;j++)
		{
			if(i==0&&j==0)continue;
			sort(r[1][j].begin(),r[1][j].end(),less<int>());
			for(int k=0;k<r[0][i].size();k++)
			{
				int a=A*(i+j)-r[0][i][k];
				long long x=upper_bound(r[1][j].begin(),r[1][j].end(),a)-lower_bound(r[1][j].begin(),r[1][j].end(),a);
				res+=x;
			}
		}
	}
	printf("%lld\n",res);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:9: error: 'memset' was not declared in this scope
   50 |         memset(dp,-1,sizeof(dp));
      |         ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    9 | #include<set>
  +++ |+#include <cstring>
   10 | using namespace std;
Language: C++

#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
set<ll> st;
map<ll, ll> mp;

int main()
{
	ll n, k;
	cin >> n >> k;
	v.resize(n);
	REP(i, n) cin >> v[i];
	REP(i, n) v[i] -= k;
	sort(ALL(v));
	REP(i, v.size() - 1) {
		if(!v[i])
		{
			mp[v[i]]++;
			v.erase(v.begin() + i);
			i--;
		}
	}
	REP(i, v.size()) mp[v[i]]++;
	ll cnt = pow(2, v.size());
	ll ans = 0;
	while (cnt--,cnt>0)
	{
		ll a = 0;
		ll b = cnt;
		ll c = 0;
		vector<ll> vm;
		map<ll, ll> pm;
		while(b)
		{
			if (b & 1) {
				c += v[a];
				vm.push_back(v[a]);
				pm[v[a]]++;
			}
			b >>= 1;
			a++;
		}
		if(!c)
		{
			ll prod = 1;
			vector<ll> div;
			REP(i, vm.size()) {
				prod *= mp[vm[i]] - pm[vm[i]] + 1;
				if(mp[vm[i]]-pm[vm[i]])
				{
					div.push_back()
				}
			}
			prod *= pow(2, mp[0]);
			REP(i, vm.size())
			{
				cout << vm[i] << " " << prod << endl;
			}
			cout << endl;
			ans += prod;
		}
	}
	ans += pow(2, mp[0]) - 1;
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:54: error: no matching function for call to 'std::vector<long long int>::push_back()'
   61 |                                         div.push_back()
      |                                         ~~~~~~~~~~~~~^~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; value_type = long long int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; value_type = long long int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 0 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100][100][3100];
int main()
{
    ll sum=0(ll);
    ll x,y,z;
    ll a[1000];
    cin>>x>>z;
    for(int i=0;i<x;i++)
    {
        cin>>a[i];
    }
    dp[0][0][0]=1(ll);
    for(int i=0;i<x;i++)
    {
        for(int j=0;j<=i;j++)
        {
            for(int k=0;k<2051;k++)
            {
                dp[i+1][j+1][k+a[i]]+=dp[i][j][k];
                dp[i + 1][j][k] += dp[i][j][k];
            }
        }
    }
    for(int i=1;i<=x;i++)
    {
        sum+=dp[x][i][i*z];
    }
    cout<<sum<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:12: error: expected primary-expression before 'long'
    3 | #define ll long long
      |            ^~~~
a.cc:7:14: note: in expansion of macro 'll'
    7 |     ll sum=0(ll);
      |              ^~
a.cc:7:16: error: expression cannot be used as a function
    7 |     ll sum=0(ll);
      |                ^
a.cc:3:12: error: expected primary-expression before 'long'
    3 | #define ll long long
      |            ^~~~
a.cc:15:19: note: in expansion of macro 'll'
   15 |     dp[0][0][0]=1(ll);
      |                   ^~
a.cc:15:21: error: expression cannot be used as a function
   15 |     dp[0][0][0]=1(ll);
      |                     ^
Language: C++

long A,x[50],i,j,d[51][5001];main(n){for(scanf("%d%d",&n,&A);~scanf("%d",x+i);x[i++]-=A);d[0][A*=n]=1;for(i=-1;++i<n;)for(j=-1+x[i];j++<2*A+x[i];d[i+1][j]+=d[i][j])d[i+1][j]=d[i][j-x[i]];printf("%ld\n",d[n][A]-1);}

Compiler output:
a.cc:1:34: error: expected constructor, destructor, or type conversion before '(' token
    1 | long A,x[50],i,j,d[51][5001];main(n){for(scanf("%d%d",&n,&A);~scanf("%d",x+i);x[i++]-=A);d[0][A*=n]=1;for(i=-1;++i<n;)for(j=-1+x[i];j++<2*A+x[i];d[i+1][j]+=d[i][j])d[i+1][j]=d[i][j-x[i]];printf("%ld\n",d[n][A]-1);}
      |                                  ^
Language: C++

#include<stdio.h>
long long int n, c, d[50],f[51][51];
long long int as(long long int a, long long int b){
	if(f[a][b]>0) return f[a][b];
if(a==n){
		if(b==0){
			return 1;
		} 
		else return 0;
	}
	return f[a][b][e]=as(a+1,(b+d[a])%c)+as(a+1,b);
}
int main(){
	scanf("%lld %lld",&n,&c);
	for(int i=0;i<n;i++) scanf("%lld",d+i);
	printf("%lld",as(0,0,0)-1);
}


Compiler output:
a.cc: In function 'long long int as(long long int, long long int)':
a.cc:11:24: error: 'e' was not declared in this scope
   11 |         return f[a][b][e]=as(a+1,(b+d[a])%c)+as(a+1,b);
      |                        ^
a.cc: In function 'int main()':
a.cc:16:25: error: too many arguments to function 'long long int as(long long int, long long int)'
   16 |         printf("%lld",as(0,0,0)-1);
      |                       ~~^~~~~~~
a.cc:3:15: note: declared here
    3 | long long int as(long long int a, long long int b){
      |               ^~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int memo[60][1000];

vector<int> X;

long long solve(int i, long long j) {
	if (memo[i][j] != -1) return memo[i][j]; 
	if (i == X.size()) return (j == 0);
	return memo[i][j] = (solve(i+1, j)+solve(i + 1, j + X[i]));
}

int main() {
	int n, a;
	cin >> n >> a;
	X.resize(n);
	for (int i = 0; i < n; i++)cin >> X[i];
	for (auto &v : X)v -= a;
	memset(*memo, -1, sizeof(memo));
	cout << solve(0,0)-1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: 'memset' was not declared in this scope
   22 |         memset(*memo, -1, sizeof(memo));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<vector>
  +++ |+#include <cstring>
    3 |
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

long long result;

void comput(long long target, vector<int>& all, int level) {
	if (target == 0) {
		result++;
                return;
	}
	for (int a = level; a < all.size(); a++) {
               if(all[a] > target) {
                 return;
               }
		comput(target - all[a], all, a + 1);
	}
}

int main() {
        int N, A;
	cin >> N >> A;
	vector<int> all;
	for (int a = 0; a < N; a++) {
		int temp;
		cin >> temp;
		all.push_back(temp);
	}
        sort(all.begin(), all.end());
	for (int a = 1; a <= N; a++) {
		comput((long long)A*a, all, 0);
	}
	cout << result << endl;
        return 0;
}

Compiler output:
a.cc:34:1: error: extended character   is not valid in an identifier
   34 |         sort(all.begin(), all.end());
      | ^
a.cc: In function 'int main()':
a.cc:34:1: error: '\U000000a0' was not declared in this scope
   34 |         sort(all.begin(), all.end());
      | ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

long long result;

void comput(long long target, vector<int>& all, int level) {
	if (target == 0) {
		result++;
                return 0;
	}
	if (target < 0) {
		return;
	}
	for (int a = level; a < all.size(); a++) {
		comput(target - all[a], all, a + 1);
	}
}

int main() {
        int N, A;
	cin >> N >> A;
	vector<int> all;
	for (int a = 0; a < N; a++) {
		int temp;
		cin >> temp;
		all.push_back(temp);
	}

	for (int a = 1; a <= N; a++) {
		comput((long long)A*a, all, 0);
	}
	cout << result << endl;
        return 0;
}

Compiler output:
a.cc: In function 'void comput(long long int, std::vector<int>&, int)':
a.cc:15:24: error: return-statement with a value, in function returning 'void' [-fpermissive]
   15 |                 return 0;
      |                        ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
long long result;
 
void comput(long long target, vector<int>& all, int level) {
	if (target == 0) {
		result++;
	}
	if (target < 0) {
		return;
	}
	for (int a = level; a < all.size(); a++) {
		comput(target - all[a], all, a + 1);
	}
}
 
int main() {
        int N, A;
	cin >> N >> A;
	vector<int> all;
	for (int a = 0; a < N; a++) {
		int temp;
		cin >> temp;
		all.push_back(temp);
	}
 
	for (int a = 1; a <= N; a++) {
		comput((long long)A*a, all, 0);
	}
	cout << result << endl;
        return 0;
}

Compiler output:
a.cc:7:1: error: extended character   is not valid in an identifier
    7 |  
      | ^
a.cc:9:1: error: extended character   is not valid in an identifier
    9 |  
      | ^
a.cc:11:1: error: extended character   is not valid in an identifier
   11 |  
      | ^
a.cc:23:1: error: extended character   is not valid in an identifier
   23 |  
      | ^
a.cc:33:1: error: extended character   is not valid in an identifier
   33 |  
      | ^
a.cc:7:1: error: '\U000000a0' does not name a type
    7 |  
      | ^
a.cc:9:1: error: '\U000000a0' does not name a type
    9 |  
      | ^
a.cc:11:1: error: '\U000000a0' does not name a type
   11 |  
      | ^
a.cc:23:1: error: '\U000000a0' does not name a type
   23 |  
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
long long result;
 
int main() {
  int N, A;
  cin >> N >> A;
  vector<int> all;
  for(int a = 0; a < N; a++) {
    int temp;
    cin >> temp;
    all.push_back(temp);
  }
 
  sort(all);
 
  for(int a = 1; a <= N; a++) {
    comput((long long)A*a, all, 0);
  }
  cout << result << endl;
  return 0;
}
 
void comput(long long target, vector<long long>& all, int level) {
  if(target == 0) {
    result++;
  }
  if(target < 0) {
    return;
  }
  for(int a = level; a < all.size(); a++) {
    compu(target - all[a], all, a + 1);
  }
}

Compiler output:
a.cc:4:1: error: extended character   is not valid in an identifier
    4 |  
      | ^
a.cc:6:1: error: extended character   is not valid in an identifier
    6 |  
      | ^
a.cc:8:1: error: extended character   is not valid in an identifier
    8 |  
      | ^
a.cc:18:1: error: extended character   is not valid in an identifier
   18 |  
      | ^
a.cc:20:1: error: extended character   is not valid in an identifier
   20 |  
      | ^
a.cc:27:1: error: extended character   is not valid in an identifier
   27 |  
      | ^
a.cc:4:1: error: '\U000000a0' does not name a type
    4 |  
      | ^
a.cc:6:1: error: '\U000000a0' does not name a type
    6 |  
      | ^
a.cc:8:1: error: '\U000000a0' does not name a type
    8 |  
      | ^
a.cc:27:1: error: '\U000000a0' does not name a type
   27 |  
      | ^
Language: C++

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

using namespace std;

long long result;

int main() {
  int N, A;
  cin >> N >> A;
  vector<long> all;
  for(int a = 0; a < N; a++) {
    long long temp;
    cin >> temp;
    all.push_back(temp);
  }

  sort(all);

  for(int a = 1; a <= N; a++) {
    comput(A*a, all, 0);
  }
  cout << result << endl;
  return 0;
}

void comput(long long target, vector<long long>& all, int level) {
  if(target == 0) {
    result++;
  }
  if(target < 0) {
    return;
  }
  for(int a = level; a < all.size(); a++) {
    compu(target - all[a], all, a + 1);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: no matching function for call to 'sort(std::vector<long int>&)'
   19 |   sort(all);
      |   ~~~~^~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 1 provided
a.cc:22:5: error: 'comput' was not declared in this scope
   22 |     comput(A*a, all, 0);
      |     ^~~~~~
a.cc: In function 'void comput(long long int, std::vector<long long int>&, int)':
a.cc:36:5: error: 'compu' was not declared in this scope; did you mean 'comput'?
   36 |     compu(target - all[a], all, a + 1);
      |     ^~~~~
      |     comput
Language: Java


import scala.collection.immutable.Range;

import java.math.BigInteger;
import java.util.Scanner;

/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {

    static public void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int A = scanner.nextInt();

        int[] xs = new int[N];
        BigInteger[] counts = new BigInteger[A];
        for(int i = 0; i < A; i++) {
            counts[i] = BigInteger.ZERO;
        }

        for(int i = 0; i < N;i++) {
            xs[i] = scanner.nextInt();
        }


        for(int x: xs) {

            BigInteger[] newCounts = new BigInteger[A];
            for(int i = 0; i < A; i++) {
                newCounts[i] = BigInteger.ZERO.add(counts[i]);
            }


            int y = x % A;

            for (int i = 0; i < A; i++) {
                counts[(i + y) % A] = counts[(i + y) % A].add(newCounts[i]);
            }

            counts[y] = counts[y].add(BigInteger.ONE);

        }

        System.out.println(counts[0].toString());
    }
}

Compiler output:
Main.java:2: error: package scala.collection.immutable does not exist
import scala.collection.immutable.Range;
                                 ^
1 error
Language: C++

class Solution{

public:
    long long minbase(long long n, long long s){

        if(s == 1ll) return n;

        long long b;
        for(b = 2ll; b * b <= n; b ++)
            if(sum(n, b) == s) return b;
        assert(b * b > n);

        if(s == n) return n + 1ll;
//        if(s > (b - 1) + (b - 1)) return -1;

        long long res = LONG_LONG_MAX;
        for(long long k1 = 1; k1 < b; k1 ++){
            if(n + k1 - s > 0 && (n + k1 - s) % k1 == 0){
                long long k2 = s - k1, tb = (n + k1 - s) / k1;
                if(k1 < tb && k2 < tb){
                    assert(sum(n, tb) == s);
                    res = min(res, tb);
                }
            }
        }
        return res == LONG_LONG_MAX ? -1 : res;
    }

private:
    long long sum(long long n, long long b){

        long long res = 0ll;
        while(n){
            res += n % b;
            n /= b;
        }
        return res;
    }
};

Compiler output:
a.cc: In member function 'long long int Solution::minbase(long long int, long long int)':
a.cc:11:9: error: 'assert' was not declared in this scope
   11 |         assert(b * b > n);
      |         ^~~~~~
a.cc:1:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
  +++ |+#include <cassert>
    1 | class Solution{
a.cc:16:25: error: 'LONG_LONG_MAX' was not declared in this scope
   16 |         long long res = LONG_LONG_MAX;
      |                         ^~~~~~~~~~~~~
a.cc:22:27: error: 'min' was not declared in this scope
   22 |                     res = min(res, tb);
      |                           ^~~
Language: C++

#include <iostream>
#include <cstdio>

using namespace std;


class Solution{

public:
    long long minbase(long long n, long long s){

        if(s == 1ll) return n;

        long long b;
        for(b = 2ll; b * b <= n; b ++)
            if(sum(n, b) == s) return b;
        assert(b * b > n);

        if(s > (b - 1) + (b - 1)) return -1;

        long long res = n;
        for(long long k2 = 0; k2 < b; k2 ++){
            if(s - k2 > 0 && (n - k2) % (s - k2) == 0){
                long long k1 = s - k2, tb = (n - k2) / (s - k2);
                if(k1 < tb && k2 < tb) res = min(res, tb);
            }
        }
        return res;
    }

private:
    long long sum(long long n, long long b){

        long long res = 0ll;
        while(n){
            res += n % b;
            n /= b;
        }
        return res;
    }
};


int main() {

//    cout << Solution().minbase(87654ll, 30ll) << endl;
//    // 10
//
//    cout << Solution().minbase(87654ll, 138ll) << endl;
//    // 100
//
//    cout << Solution().minbase(87654ll, 45678ll) << endl;
//    // -1
//
//    cout << Solution().minbase(31415926535ll, 1ll) << endl;
//    // 31415926535
//
//    cout << Solution().minbase(1ll, 31415926535ll) << endl;
//    // -1

    long long n, s;
    scanf("%lld%lld", &n, &s);
    printf("%lld\n", Solution().minbase(n, s));

    return 0;
}


Compiler output:
a.cc: In member function 'long long int Solution::minbase(long long int, long long int)':
a.cc:17:9: error: 'assert' was not declared in this scope
   17 |         assert(b * b > n);
      |         ^~~~~~
a.cc:3:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    2 | #include <cstdio>
  +++ |+#include <cassert>
    3 |
Language: C++

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

#include <conio.h>

int f(int b, int n) {
  if (b > n) return n;
  return f(b, n / b) + n % b;
}

void solve() {
  int n, s;
  cin >> n >> s;
  for (int i = 2; i * i <= n; i++) {
    if (f(i, n) == s) {
      cout << i << '\n';
      return;
    }
  }
  for (int i = 1; i * i <= n - s; i++) {
    if ((n - s) % i == 0 && f((n - s) / i + 1, n) == s) {
      cout << (n - s) / i + 1 << '\n';
      return;
    }
  }
  cout << -1 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  // ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Compiler output:
a.cc:12:10: fatal error: conio.h: No such file or directory
   12 | #include <conio.h>
      |          ^~~~~~~~~
compilation terminated.
Language: C++

//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

ll f(ll b, ll n){
    ll res;
    if(n==0) return 0;
    if(n<b) return n;
    res=f(b,n/b)+n%b;
    return res;
}
int main(){
    ll n,s;
    cin>>n>>s;

    if(s>(n+1)/2) cout<<-1<<endl;
    else{
        REP2(i,2,sqrt(n)+1){
            if(f(i,n)==s){
                cout<<i<<endl;
                return 0;
            }
        }

        REP2(i,1,sqrt(n)+1){
            if((n-s)%p==0){
                cout<<(n-2)/p+1<<endl;
                return 0;
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:22: error: 'p' was not declared in this scope
   55 |             if((n-s)%p==0){
      |                      ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

ll f(ll b, ll n){
  if(n == 0) return 0;
  return f(b, n/b) + (n%b);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,s,d;
  cin >> n >> s;
  d = n-s;
  if(d < 0){
    cout << -1 << endl;
    return 0;
  }
  if(d==0){
    cout << n+1 << endl;
    return 0;
  }
  for(ll b=2;b*b<=n;b++){
    if(f(b,n) == s){
      cout << b << endl;
      return 0;
    }
  }
  ll ans = INF;
  for(ll p=1;p*p<n;p++){
    if(d%p==0 && d/i>0){
      ll b=d/p+1;
      if(f(b,n) == s) ans = min(ans,b);
    }
  }
  if(ans == INF) ans=-1;
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:20: error: 'i' was not declared in this scope
   46 |     if(d%p==0 && d/i>0){
      |                    ^
Language: C++

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

ll f(ll b, ll n){
  if (b == 1) return -1;
  else if (n < b) return n;
  else return f(b,n/b) + n % b;
}


ll ma(vector<ll> ANS){
  if(ANS.size()==0) return -1;
  ll ans=1000000000000;
  for (ll i: ANS) ans=min(ans,i);
  return ans;
}


ll gcd(ll a, ll b)
  {return b==0 ? a : gcd(b,a%b);}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  ll n,s;
  ll ans=1000000000000;
  cin >> n >> s;
  if (n==s) cout<<n+1<<endl;
  else{
    for (int i=1; i*i<=n-s; i++){
      if ((n-s)%i==0){
        if (f(i+1,n)==s) ans=min(ans,i+1);
        if (f(n/i+1,n)==s) ans=min(ans,n/i+1);
      } 
    }

    if (ans==1000000000000) ans=-1;
    cout<<ans<<endl;
  }
  
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:34:33: error: no matching function for call to 'min(ll&, int)'
   34 |         if (f(i+1,n)==s) ans=min(ans,i+1);
      |                              ~~~^~~~~~~~~
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: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:34:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   34 |         if (f(i+1,n)==s) ans=min(ans,i+1);
      |                              ~~~^~~~~~~~~
/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:34:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |         if (f(i+1,n)==s) ans=min(ans,i+1);
      |                              ~~~^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007

ll f(ll b, ll n){
  ll ans = 0;
  while(n > 0){
    ans += n % b;
    n /= b;
  }

  return ans;
}

int main(){
  ll n,s;

  scanf("%lld", &n);
  scanf("%lld", &s);

  ll i = 2;
  int f = 0;
  ll ans;

  if(s > n){
    printf("-1\n");
    return 0;
  }

  if(s == n){
    printf("%lld", n + 1);
    return 0;
  }

  for(i = 2;i*i <= n;i++){
    if(f(i,n) == s){
      printf("%lld\n", i);
      return 0;
    }
  }

  ll t = n - s;
  ll ans = -1;

  for(i = 1;i*i < n;i++){
    ll b = t/i + 1;

    if(b >= 2 && f(b,n) == s) ans = b;
  }

  printf("%lld\n", ans);


  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: 'f' cannot be used as a function
   38 |     if(f(i,n) == s){
      |        ~^~~~~
a.cc:45:6: error: redeclaration of 'll ans'
   45 |   ll ans = -1;
      |      ^~~
a.cc:25:6: note: 'll ans' previously declared here
   25 |   ll ans;
      |      ^~~
a.cc:50:19: error: 'f' cannot be used as a function
   50 |     if(b >= 2 && f(b,n) == s) ans = b;
      |                  ~^~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007

int main(){
  ll n,s;
  ll t;

  scanf("%lld", &n);
  scanf("%lld", &s);

  int i = 2;
  int f = 0;
  ll ans;

  if(s == n){
    printf("%lld", n + 1);
    return 0;
  }

  int limit;
  limit = sqrt(n);
  while(1){
    t = n;
    ans = 0;
    while(t > 0){
      ans += t % i;
      t /= i;
    }

    if(ans == s){
      f = 1;
      break;
    }

    i++;

    if(i > limit) break;
  }

  if(f == 1){
    printf("%lld\n", i);
    return 0;
  }

  ll b;
  int i = 1;
  while(1){
    ans = 0;
    t = n;
    b = (n - s)/i + 1;

    while(b > 0){
      ans += t % b;
      t /= b;
    }

    if(ans == s){
      f = 1;
      break;
    }

    i++;

    if(i > limit) break;
  }

  if(f == 1) printf("%lld\n", b);
  else printf("-1\n");
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:7: error: redeclaration of 'int i'
   49 |   int i = 1;
      |       ^
a.cc:14:7: note: 'int i' previously declared here
   14 |   int i = 2;
      |       ^
Language: C++

#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

ll digitsum(ll n, ll b)
{
	int y = log(n)/log(b) +1;
	ll ans = 0;
	for(int i = 0; i<y; i++)
	{
		ans += n%b;
		n /= b;
	}
	return ans;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, s;
	cin>>n>>s;
	if(s>n)
	{
		cout<<-1<<endl;
		return 0;
	}
	ll ans = -1;
	for(int i = 2; i<=sqrt(n); i++)
	{
		ll y = digitsum(n,i);
		if(y==s)
		{
			cout<<i<<endl;
			return  0;
		}
	}
	n-=s;
	for(ll i = 1; i<=sqrt(n); i++)
	{
		if(n%i==0)
		{
			y = digitsum(n+s,n/i+1);
			if(y==s)
				ans = n/i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:25: error: 'y' was not declared in this scope
   47 |                         y = digitsum(n+s,n/i+1);
      |                         ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <math.h>
#include <stack>

using namespace std;

int cou(long long int a,long long int b) {
	if (a > b) {
		return b;
	}
	else {
		return cou(a, b / a) + b % a;
	}
}
int main() {
	long long int n, s;
	
	cin >> n;
	cin >> s;
	if (s == n) {
		cout << n + 1;
		return 0;
	}
	if (s > n) {
		cout << "-1";
		return 0;
	}
	int y = sqrt(n);
	for (int i = 2; i < y + 1; i++) {
		if (cou(i, n) == s&) {
			cout << i;
			return 0;
		}
	}

	for (int i = y; i >0; i--) {
		if ((n - s) % i != 0)continue;
		long long int a = (n - s) / i + 1;
		if (cou(a, n) == s&&a>1) {
			cout << a;
			return 0;
		}
	}
	cout << "-1";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:36: error: expected primary-expression before ')' token
   38 |                 if (cou(i, n) == s&) {
      |                                    ^
Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

ll func(ll b, ll m){
  if(m < b){
    return m;
  } else{
    return func(b, m / b) + (m % b);
  }
}

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

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

  ll sqn = 1;
  while(sqn * sqn < n) sqn++;

  rep2(b, 2, sqn + 1){
    if(func(b, n) == s){
      cout << b << endl;
      return 0;
    }
  }

  rep_inv(a1, sqn, 0){
    if((n - s) % b != 0) continue;
    
    ll b = (n - s) / a1 + 1;
    if(func(b, n) == s){
      cout << b << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:18: error: 'b' was not declared in this scope
   45 |     if((n - s) % b != 0) continue;
      |                  ^
Language: C++

#include <bits/stdc++.h>
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() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	long long n, s;
	cin >> n >> s;

	if (n == s) {
		cout << n+1 << '\n';
		return 0;
	}

	for (long long b = 2; b*b <= n; b++) {
		if (f(b, n) == s) {
			cout << b << '\n';
			return 0;
		}
	}

	for (long long p = 1; p*p <= n; p++) {
		if ((n-q) % p != 0) {
			continue;
		}

		long long q = s - p;
		long long b = (n-s) / p + 1;
		if (b >= 2 && q >= 0 && f((n - q) / p, n) == s) {
			cout << (n - q) / p << '\n';
			return 0;
		}
	}

	cout << "-1\n";

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:24: error: 'q' was not declared in this scope
   34 |                 if ((n-q) % p != 0) {
      |                        ^
Language: C++

#include <bits/stdc++.h>
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() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	long long n, s;
	cin >> n >> s;

	if (n == s) {
		cout << n+1 << '\n';
		return 0;
	}

	for (long long b = 2; b*b <= n; b++) {
		if (f(b, n) == s) {
			cout << b << '\n';
			return 0;
		}
	}

	for (long long p = 1; p*p <= n; p++) {
		long long q = s - p;
		if (q >= 0 && (n-q) % p == 0 && (n-q) / p >= 2 && p*b + q == n && f((n - q) / p, n) == s) {
			cout << (n - q) / p << '\n';
			return 0;
		}
	}

	cout << "-1\n";

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:69: error: 'b' was not declared in this scope
   35 |                 if (q >= 0 && (n-q) % p == 0 && (n-q) / p >= 2 && p*b + q == n && f((n - q) / p, n) == s) {
      |                                                                     ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

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

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

	// 2≦b<sqrt(n)
	// sqrt(n)≦b≦n
	// b=n+1

	long long ans = -1;
	long long sqrt_n = (long long)sqrt((double)n);
	if (n == s) {
		// b=n+1 先にわかる
		ans = n + 1;
	} else {
		// 2≦b<sqrt(n)ここまで全探索
		for (long long i = 2; i < sqrt_n; i++) {
			if (s == calc_sum(n, i)) {
				ans = i;
				break;
			}
		}
		// sqrt(n)≦b≦n 二つの和になる
		// s1+s2=s  s1+s2*b=n
		// => s2*(b-1)=n-s  ただし、max(1,s-b)≦s2≦min(sqrt(n),s)かつsqrt(n)≦b≦n
		if (-1 == ans) {
			long long range = min(sqrt_n, s);
			long long n_s = n - s;
			for (long long i = range; i >= 1; i--) {
				if (n_s % i) continue;//bが整数にならない
				long long ans_tmp = n_s / i + 1;
				if (s - ans_tmp > i)continue;//max(1,s-b)≦s2不成立
				if (sqrt_n <= ans_tmp && ans_tmp <= n) {
					ans = ans_tmp;
					break;
				}
			}
		}
	}

	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:39: error: 'sqrt' was not declared in this scope; did you mean 'sqrt_n'?
   21 |         long long sqrt_n = (long long)sqrt((double)n);
      |                                       ^~~~
      |                                       sqrt_n
Language: C++

#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)					(x).begin(),(x).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 約数の列挙 */
vector<ll> divisorExec(ll n)
{
	vector<ll> res;
    for(ll i = 1; i <= sqrt(n); i++){
		if ((n % i) == 0) {
			res.push_back(i);
			if ((i * i) != n) {
				res.push_back(n / i);
			}
		}
	}
	sort(res.begin(), res.end());
	return res;
}

/* 素因数分解 */
map<ll, ll> factMap;
void primeFactor(ll n)
{
	if ((n % 2) == 0){
		while((n % 2) == 0) {
			factMap[2]++;
			n = n / 2;
		}
	}

	for(ll i = 3; i <= sqrt(n); i += 2){
		while ((n % i) == 0){
			factMap[i]++;
			n = n / i;
		}
	}

	if (n != 1) {
		factMap[n]++;
	}
}

ll compExec(ll n, ll s, ll mid)
{
	ll ans = 0;

	if (mid == 1) {
		return n;
	}
	while (0 != n) {
		ans += n % mid;
		n /= mid;
	}
	return ans;
}

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

	vector<ll> yakusu = divisorExec(n);
	auto idx = lower_bound(ALL(yakusu), s) - yakusu.begin();
	if (yakusu[idx] == s) {
		cout <<  << endl;
	} else {
		cout << compExec(n, s, i + 1) << endl;
	}
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:99:26: error: expected primary-expression before '<<' token
   99 |                 cout <<  << endl;
      |                          ^~
a.cc:101:40: error: 'i' was not declared in this scope
  101 |                 cout << compExec(n, s, i + 1) << endl;
      |                                        ^
Language: C

long n,s;
f(long b)
{
	long sum=0;
	long _n=n;
	while(_n)
	{
		sum+=_n%b;
		_n/=b;
	}
	return sum==s;
}
main()
{
	scanf("%ld%ld",&n,&s);
	if(n==s)
	{
		printf("%ld\n",n+1);
		return 0;
	}
	for(long i=2;i*i<=n;i++)
		if(f(i))
		{
			printf("%ld\n",i);
			return 0;
		}
	long minb=n+1;
	for(long i=1;i*i<=n;i++)
	{
		long b=(n-s)/i+1;
		if(b>1&&f(b))
		{
			minb=min(minb,b);
		}
	}
	printf("%ld\n",minb==n+1?-1:minb);
}

Compiler output:
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int]
    2 | f(long b)
      | ^
main.c:13:1: error: return type defaults to 'int' [-Wimplicit-int]
   13 | main()
      | ^~~~
main.c: In function 'main':
main.c:15:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   15 |         scanf("%ld%ld",&n,&s);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | long n,s;
main.c:15:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   15 |         scanf("%ld%ld",&n,&s);
      |         ^~~~~
main.c:15:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:18:17: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   18 |                 printf("%ld\n",n+1);
      |                 ^~~~~~
main.c:18:17: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:18:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:18:17: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:24:25: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   24 |                         printf("%ld\n",i);
      |                         ^~~~~~
main.c:24:25: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:33:30: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
   33 |                         minb=min(minb,b);
      |                              ^~~
      |                              main
main.c:36:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   36 |         printf("%ld\n",minb==n+1?-1:minb);
      |         ^~~~~~
main.c:36:9: note: include '<stdio.h>' or provide a declaration of 'printf'