criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;
import java.lang.*;

public class MyTest {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n;
        String s;
        n = Integer.valueOf(in.nextLine());
        s = in.nextLine();

        int pop1, pop2;
        pop1 = popCount(s);
        pop2 = pop1-1;
        pop1++;

        long x1=0L, x2=0L, temp=0L;
        for(int i=0; i<n; i++){
            if(s.charAt(i)=='1'){
                temp = Math.round(Math.pow(2, n-i-1));
                if(pop1>0){
                    x1 += temp % pop1;
                }
                if(pop2>0){
                    x2 += temp % pop2;
                }
            }
        }

        for(int i=0;i<n;i++){
            int count = 0;
            long xi = 0;
            int pop;
            
            if(s.charAt(i)=='1'){
                pop = pop2;
                xi = x2;
            }else{
                pop = pop1;
                xi = x1;
            }

            if(pop>0){
                if(s.charAt(i)=='1'){
                    xi -= Math.round(Math.pow(2, n-i-1)) % pop;
                }else{
                    xi += Math.round(Math.pow(2, n-i-1)) % pop;
                }
                xi = xi % pop;
                count++;
            }

            while(xi > 0){
                xi = xi % popCount(xi);
                count++;
            }
            print(count);
        }

        in.close();
    }

    private static int popCount(String s){
        int count = 0;
        for(int i=0; i<s.length(); i++){
            count += s.charAt(i)=='1' ? 1 : 0;
        }
        return count;
    }

    private static int popCount(long n){
        int count = 0;
        while(n>0){
            count += n%2;
            n /= 2;
        }
        return count;
    }

    private static void print(Object obj){
        System.out.println(obj);
    }
} // javac MyTest.java; java MyTest < input.txt > out

Compiler output:
Main.java:4: error: class MyTest is public, should be declared in a file named MyTest.java
public class MyTest {
       ^
1 error
Language: Java

import java.util.*;
import java.lang.*;

public class MyTest {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n, pop1, pop2;
        String s;

        n = Integer.valueOf(in.nextLine());
        s = in.nextLine();
        pop1 = popCount(s);
        pop2 = pop1-1;
        pop1++;
        for(int i=0;i<n;i++){
            String x = s.substring(0, i) + (s.charAt(i)=='1'?'0':'1') + s.substring(i+1);
            int count = 0;
            int xi = 0;
            int pop = 1;

            if(s.charAt(i)=='1'){
                pop = pop2;
            }else{
                pop = pop1;
            }

            if(pop>0){
                for(int j=0; j<n; j++){
                    if(x.charAt(j)=='1'){
                        xi += Math.pow(2, n-j-1) % pop;
                    }
                }
                xi = xi % pop;
                count++;
            }

            while(xi > 0){
                xi = xi % popCount(xi);
                count++;
            }
            print(count);
        }

        in.close();
    }

    private static int popCount(String s){
        int count = 0;
        for(int i=0; i<s.length(); i++){
            count += s.charAt(i)=='1' ? 1 : 0;
        }
        return count;
    }

    private static int popCount(long n){
        int count = 0;
        while(n>0){
            count += n%2;
            n /= 2;
        }
        return count;
    }

    private static void print(Object obj){
        System.out.println(obj);
    }
} // javac MyTest.java & java MyTest < input.txt > out

Compiler output:
Main.java:4: error: class MyTest is public, should be declared in a file named MyTest.java
public class MyTest {
       ^
1 error
Language: C++

#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    int x[n];
    int count1 = 0;
    int sum = 0;
    int pre_counter = {1, 2, 2, 3, 2, 
                       3, 2, 3, 2, 3, 
                       2, 3, 2, 2, 2, 
                       4};
    for (int i = 0; i < n; i++){
        cin >> x[i];
        if(x[i] == 1){
            count1 += 1;
            sum += 2 ** (n - i - 1);
        }
    }
    for (int i = 0; i < n; i++){
        int num_op = 0;
        int sum_op = sum;
        int count1_op = count1;
        if (x[i]==0){
            sum_op += 2 ** (n - i - 1);
            count1_op += 1;
        }else{
            sum_op -= 2 ** (n - i - 1);
            count1_op -= 1; 
        }
        if (count1_op == 0){
            cout << 0 << endl;
        }else{
            sum_op %= count1_op;
            cout >> pre_counter[sum_op] >> endl;
        }
    }
}





Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: scalar object 'pre_counter' requires one element in initializer
   10 |     int pre_counter = {1, 2, 2, 3, 2,
      |         ^~~~~~~~~~~
a.cc:18:23: error: invalid type argument of unary '*' (have 'int')
   18 |             sum += 2 ** (n - i - 1);
      |                       ^~~~~~~~~~~~~
a.cc:26:26: error: invalid type argument of unary '*' (have 'int')
   26 |             sum_op += 2 ** (n - i - 1);
      |                          ^~~~~~~~~~~~~
a.cc:29:26: error: invalid type argument of unary '*' (have 'int')
   29 |             sum_op -= 2 ** (n - i - 1);
      |                          ^~~~~~~~~~~~~
Language: C++

#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

Vi ans;

int main()
{
	int n;
	cin >> n;
	string x;
	cin >> x;

	ans.resize(n, -1);

	int d1 = 0;
	rep(i, n) {
		if (x[i] == '1') {
			d1++;
		}
	}

	reverse(x.begin(), x.end());

	Vi popx(n, 0);
	rep(i, n) {
		if (x[i] == '1') popx[i] = d1 - 1;
		else popx[i] = d1 + 1;
		if (popx[i] == 0) ans[n - 1 - i] = 0;
	}

	
	Vi mod2(n, 0);
	int A[3] = { 0 };
	for (int i = 0; i < 3; i++) {
		if (d1 == 1 && i == 0) continue;
		int t = 1;
		ll u = 0;
		for (int j = 0; j < n; j++) {
			if (x[j] == '1') {
				u = (u + t) % (d1 - 1 + i);
			}
			t = (t * 2) % (d1 - 1 + i);
		}
		u %= (d1 - 1 + i);
		A[i] = u;
	}

	int t1 = 1, t2 = 1, t3 = 1;
	rep(i, n) {
		int u = popx[i];
		if (u <= 0) continue;
		if (x[i] == '0') {
			if (u == d1 - 1) {
				mod2[i] = (A[0] + t1) % u;
			}
		//	else if (u == d1) {
		//		mod2[i] = (A[1] + t2) % u;
		//	}
		//	else {
		//		mod2[i] = (A[2] + t3) % u;
		//	}
		//}
		//else {
		//	if (u == d1 - 1) {
		//		mod2[i] = (u + A[0] - t1) % u;
		//	}
		//	else if (u == d1) {
		//		mod2[i] = (u + A[1] - t2) % u;
		//	}
		//	else {
		//		mod2[i] = (u + A[2] - t3) % u;
		//	}
		//}
		//if (d1 - 1 > 0) t1 = (t1 * 2) % (d1 - 1);
		//t2 = (t2 * 2) % d1;
		//t3 = (t3 * 2) % (d1 + 1);
	}
	reverse(mod2.begin(), mod2.end());

	rep(i, n) {
		if (ans[i] == 0) continue;
		if (mod2[i] == 0 && ans[i] == -1) {
			ans[i] = 1;
			continue;
		}
		int tans = 1;
		while (mod2[i] > 0) {
			int u = mod2[i];
			bitset<20> t = bitset<20>(u);
			int c = t.count();
			if (c == 0) break;
			mod2[i] %= c;
			tans++;
		}
		ans[i] = tans;
	}

	for (int u : ans) {
		cout << u << endl;
	}

}


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

#include <stdio.h>

struct Data
{
  long value;
  int popcount;
};

Data btoData(char *s, int n)
{
  Data d;
  long value = 0;
  int popcount = 0;
  value += s[0] == '1' ? 1 : 0;
  for (int i = 1; i < n; i++)
  {
    value = value << 1;
    value += s[i] == '1' ? 1 : 0;
    popcount += s[i] == '1' ? 1 : 0;
  }
  d.value = value;
  d.popcount = popcount;
  return d;
}

int getPopcount(long l)
{
  int popcount = 0;
  while (l > 0)
  {
    if (l & 1)
      popcount++;
    l = l >> 1;
  }
  return popcount;
}
int f(Data d)
{
  int res = 0;
  while (d.value > 0)
  {
    d.value = d.value % d.popcount;
    d.popcount = getPopcount(d.value);
    res++;
  }
  return res;
}

int main(int argc, char const *argv[])
{
  int n;
  char s[200000];

  scanf("%d", &n);
  scanf("%s", s);
  for (int i = 0; i < n; i++)
  {
    s[i] = s[i] == '0' ? '1' : '0';
    Data d = btoData(s, n);
    printf("%d\n", f(d));
    s[i] = s[i] == '0' ? '1' : '0';
  }

  return 0;
}


Compiler output:
main.c:9:1: error: unknown type name 'Data'; use 'struct' keyword to refer to the type
    9 | Data btoData(char *s, int n)
      | ^~~~
      | struct 
main.c: In function 'btoData':
main.c:11:3: error: unknown type name 'Data'; use 'struct' keyword to refer to the type
   11 |   Data d;
      |   ^~~~
      |   struct 
main.c:21:4: error: request for member 'value' in something not a structure or union
   21 |   d.value = value;
      |    ^
main.c:22:4: error: request for member 'popcount' in something not a structure or union
   22 |   d.popcount = popcount;
      |    ^
main.c: At top level:
main.c:37:7: error: unknown type name 'Data'
   37 | int f(Data d)
      |       ^~~~
main.c: In function 'main':
main.c:59:5: error: unknown type name 'Data'; use 'struct' keyword to refer to the type
   59 |     Data d = btoData(s, n);
      |     ^~~~
      |     struct 
main.c:60:20: error: implicit declaration of function 'f' [-Wimplicit-function-declaration]
   60 |     printf("%d\n", f(d));
      |                    ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0; i<(n); i++)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n;
    string x;
    cin>>n>>x;
    
    int popx = 0;
    rep(i,n)if(x[i]=='1')popx++;
    
    if(popx==0){
        rep(i,n)cout<<1<<endl;
        return 0;
    }
    
    vi popn(2);
    popn[0] = popx+1;
    popn[1] = popx-1;
    
    vv modpop(2, vi (n, 0));
    
    modpop[0][n-1] = 1%popn[0];
    if(popn[1]!=0)modpop[1][n-1] = 1%popn[1];
    
    for(int i=n-2; i>=0; i--){
        modpop[0][i] = 2*modpop[0][i+1]%popn[0];
        if(popn[1]!=0)modpop[1][i] = 2*modpop[1][i+1]%popn[1];
    }
    
    vi count(2,0);
    
    for(int i=0; i<n; i++){
        if(x[i]=='1'){
            count[0] += modpop[0][i];
            count[1] += modpop[1][i];
            count[0] %= popn[0];
            count[1] %= popn[1];
        }
    }
    
    for(int j=0; j<n; j++){
        int ans = 1;
        int c = 0;
        if(x[j]=='1')c = 1;
        
        if(popn[1]==0 && c==1){
            cout<<0<<endl;
            continue;
        }
        
        int nx = (count[c] + popn[c] + (1-2*c)*modpop[c][j])%popn[c];
        if(nx==0){
            cout<<1<<endl;
            continue;
        }
        
        int num = nx;
        while(num){
            int p = 0;
            int b = num;
            while(b){
                p += (b&1);
                b /= 2;
            }
            num %= p;
            ans++;
        }
        
        cout << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:22: error: 'll' was not declared in this scope
    2 | #define rep(i,n) for(ll i=0; i<(n); i++)
      |                      ^~
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n)if(x[i]=='1')popx++;
      |     ^~~
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     rep(i,n)if(x[i]=='1')popx++;
      |         ^
a.cc:2:30: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(ll i=0; i<(n); i++)
      |                              ^
a.cc:2:22: error: 'll' was not declared in this scope
    2 | #define rep(i,n) for(ll i=0; i<(n); i++)
      |                      ^~
a.cc:16:9: note: in expansion of macro 'rep'
   16 |         rep(i,n)cout<<1<<endl;
      |         ^~~
a.cc:16:13: error: 'i' was not declared in this scope
   16 |         rep(i,n)cout<<1<<endl;
      |             ^
a.cc:2:30: note: in definition of macro 'rep'
    2 | #define rep(i,n) for(ll i=0; i<(n); i++)
      |                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define BITCOUNT(x) __builtin_popcount(x)
using ll = long long;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

//---------------------------------------------------------------------------------------------------
signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  string x;
  cin >> x;
  for (ll i = 0; i < n; i++)
  {
    string s = x;
    if (s[i] == '1')
    {
      s[i] = '0';
    }
    else
    {
      s[i] = '1';
    }
    const char *y = s.data();       // string型をchar配列に変換。不要かも
    Bint xi = stoll(y, nullptr, 2); // 2進数文字列を10進数の整数(long long)に変換。
    ll count = 0;
    while (xi > 0)
    {
      ll c_one = BITCOUNT(xi); // 該当の整数を2進数に変換した場合に1が何個含まれるか計測。
      xi %= c_one;
      count++;
    }
    cout << count << endl;
  }
}


Compiler output:
a.cc:7:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory
    7 | #include <boost/multiprecision/cpp_dec_float.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C

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

int main() {
  
  int n;
  string s;
  cin >> n >> s;
  
  string t;
  REP(i,n) {
    t = s;
    if (t[i] == '0') t[i] = '1';
    else t[i] = '0';
    
    int a = 0;
    REP(j,n) {
      if (t[n-j-1] == '1') a += pow(2,j);
    }
    
    int c = 0, ans = 0;    
    while (1) {
      ans++;
      c = 0;
      REP(k,n) {
        if ((a >> k) & 1) c++;
      }
      a %= c;
      if (a == 0) break;
    }
    cout << ans << endl;
  }
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}


int mx = 0;
int px=0;

vi vx;
vi modcp;
vi modcm;
int n;

void f(int count,int j) {
  int ans = 0;
  int x = 0;
  if(vx.at(n - j)) {
    x = mx - modcm.at(n-j);
    x%=count-1;
    if(x<0) x+= count-1;
  }
  else {
    x = px + modcp.at(n-j);
    x %= count+1;
  }
  ans++;

  while(x!=0) {
    x = x % __builtin_popcount(x);
    ans++;
  }
 cout << ans << endl;
}


int main() {
  cin >> n;
  string s; cin >> s;
  int count = 0;
  rep(i,n) {
    if(s.at(i)=='1') {
      vx.eb(1);
      count++;
    } else vx.eb(0);
  }
  if(count == 0) {
    rep(i,n) cout << 1 << endl;
    return;
  }
  reverse(rng(vx));

  int t = 1 % (count+1);

  rep(i,n) {
    modcp.eb(t);
    t = t << 1;
    t %= count+1;
  }
  rep(i,n) {
    if(vx.at(i)) {
      px+=modcp.at(i)%(count+1);
      px%=count+1;
    }
  }

    t = 1 % (count -1);
    rep(i,n) {
      modcm.eb(t);
      t = t << 1;
      t %= count-1;
    }
    rep(i,n) {
      if(vx.at(i)) {
        mx+=modcm.at(i)%(count-1);
        mx%=(count-1);
      }
    }

  rep(i,n) f(count,i+1);

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:92:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   92 |     return;
      |     ^~~~~~
Language: C++

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

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

int mod_pow(int n, int e, int mod){
    int ans = 1;
    while(e != 0){
        if(e % 2 == 1){
            ans = (ans * n) % mod;
        }
        e /= 2;
        n = (n*n) % mod;
    }
    return ans % mod;
}

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<int> X(N);
    int pc = 0;
    for(int i=0; i<N; i++){
        X[i] = s[i] - '0';
        if(X[i] == 1){
            pc++;
        }
    }

    // rem[0] が 1 引いた後
    int rem[2] = {0, 0};
    for(int j=0; j<N; j++){
        if(pc > 1){
            rem[0] = (rem[0]*2 + X[j]) % (pc-1);
        }
        rem[1] = (rem[1]*2 + X[j]) % (pc+1);
    }

    for(int i=0; i<N; i++){
        X[i] = 1 - X[i];
        pc = pc + 2*X[i]-1;

        if(pc == 0){
            cout << 0 << endl;
            pc = pc - 2*X[i]+1;
            X[i] = 1 - X[i];
            continue;
        }

        int r = rem[X[i]], c = 1;
        // r + (2*X[i] - 1) * 2**(N-1-i)
        int fugou = 1;
        if(X[i] == 0){
            fugou = pc-1;
        }
        r = (r + fugou * mod_pow(2, N-1-i, pc)) % pc;
        while(r != 0){
            c++;
            r = r % popcount(r);
        }
        cout << c << endl;
        
        pc = pc - 2*X[i]+1;
        X[i] = 1 - X[i];
    }
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF 1e18+10  
using ll = long long;

using P = pair<int, int>;
using lP = pair<ll, ll>;
using fP = pair<double, double>;
using PPI = pair<P, int>;
using Ps = pair<int, string>;

using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vd = vector<double>;
using vs = vector<string>;
using vp = vector<P>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<double>>;
using vvc = vector<vector<char>>;
using vvp = vector<vector<P>>;
using vvb = vector<vector<bool>>;
template <typename T>
bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }

//const ll mod=998244353;
//const ll mod=1e9+7;
const ll MAX = 300000;

//////////////////////////////////////
ll modpow(ll a, ll b, int mod) {
    ll r = 1;
    while (b > 0) {
        if (b % 2 == 1)(r *= a) %= mod;
        (a *= a) %= mod;
        b /= 2;
    }
    return r;
}

int f(ll n) {
    int ret = 0;
    while (n > 0) {
        ret += n % 2;
        n /= 2;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt1 = 0;
    rep(i, n) {
        if (s[i] == '1')cnt1++;
    }
    if (cnt1==0||cnt1==1) {
        rep(i, n){
            if(s[i]=='0')cout << 1 << endl;
            else cout<<0<<endl;
        return 0;
    }
    vl a(n);
    vl b(n);
    ll suma = 0, sumb = 0;
    rep(i, n) {
        a[i] = modpow(2, n - 1 - i, cnt1 + 1);
        b[i] = modpow(2, n - 1 - i, cnt1 - 1);
        if (s[i] == '1') {
            suma += a[i];
            sumb += b[i];
        }

    }
    vl ans(n);
    rep(i, n) {
        int cnt = cnt1;
        if (s[i] == '1') {
            ll tmp = sumb - b[i];
            if (cnt>1) {
                tmp %= (cnt - 1);
                ans[i]++;
            }
            while (tmp > 0) {

                cnt = f(tmp);
                tmp %= (cnt);
                ans[i]++;
            }
        }
        else {
            ll tmp = suma + a[i];
            if (tmp > 0) {
                tmp %= (cnt + 1);
                ans[i]++;
            }
            while (tmp > 0) {

                cnt = f(tmp);
                tmp %= (cnt);
                ans[i]++;
            }
        }
    }
    rep(i, n)cout << ans[i] << endl;
    return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

int num_flags(int x) {
    int count = 0;
    for(int i = 0; i < sizeof(int)*8; i++) {
        if(x & (1 << i)) count++;
    }
    return count;
}

int note[200000+2];
int solve(int i) {
    if(i == 0) return 0;
    if(note[i] != -1) return note[i];

    note[i] = solve(i % num_flags(i)) + 1;
    return note[i];
}

int div_note_p[n], div_note_m[n];

int main() {
    int n;
    cin >> n;
    string str;
    cin >> str;

    int counter = 0;
    for(int i = 0; i < str.length(); i++) {
        if(str[i] == '1') counter++;
    }

    for(int i = 0; i < 200000+2; i++) {
        note[i] = -1;
    }
    note[0] = 0;

    int div_p = 0;
    int div_m = 0;
    int div_tmp_p = 1;
    int div_tmp_m = 1;
    for(int i = 0; i < str.length(); i++) {
        div_note_p[i] = div_tmp_p;
        div_note_m[i] = div_tmp_m;
        div_tmp_p *= 2;
        if(counter > 1)div_tmp_m *= 2;
        div_p *= 2;
        if(counter > 1)div_m *= 2;
        if(str[i] == '1') {
            div_p++;
            div_m++;
        }
        div_tmp_p %= (counter + 1);
        if(counter > 1) div_tmp_m %= (counter - 1);
        div_p %= (counter + 1);
        if(counter > 1) div_m %= (counter - 1);
    }

    int r;
    for(int i = 0; i < str.length(); i++) {
        if(str[i] == '0') {
            r = (div_note_p[n-i-1] + div_p) % (counter + 1);
        }else {
            if(counter == 1) {
                cout << 0 << endl;
                continue;
            } else {
                r = (div_note_m[n-i-1] - div_m) % (counter - 1);
            } 
        }

        cout << (solve(r)+1) << endl;
    }
}

Compiler output:
a.cc:22:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   22 | int div_note_p[n], div_note_m[n];
      |                ^
      |                yn
a.cc:22:31: error: 'n' was not declared in this scope; did you mean 'yn'?
   22 | int div_note_p[n], div_note_m[n];
      |                               ^
      |                               yn
a.cc: In function 'int main()':
a.cc:45:9: error: 'div_note_p' was not declared in this scope
   45 |         div_note_p[i] = div_tmp_p;
      |         ^~~~~~~~~~
a.cc:46:9: error: 'div_note_m' was not declared in this scope
   46 |         div_note_m[i] = div_tmp_m;
      |         ^~~~~~~~~~
a.cc:64:18: error: 'div_note_p' was not declared in this scope
   64 |             r = (div_note_p[n-i-1] + div_p) % (counter + 1);
      |                  ^~~~~~~~~~
a.cc:70:22: error: 'div_note_m' was not declared in this scope
   70 |                 r = (div_note_m[n-i-1] - div_m) % (counter - 1);
      |                      ^~~~~~~~~~
Language: C++

def countSetBits(num):
    binary = bin(num)
    setBits = [ones for ones in binary[2:] if ones == '1']
    return len(setBits)
def steps(num):
    count=0
    while num>0:
        num=num%countSetBits(num)
        count=count+1
    return  count

if __name__ == "__main__":
    arr=[]
    for i in range(0, 10000):
        arr.append(2**i)
    n=int(input())
    str=input()
    num=0
    for i in range(0,n):
        if str[i]=='1':
            num+=arr[i]
    temp=num
    for i in range(n-1,-1,-1):
        temp=num
        if str[i]=='0':
            temp=temp+arr[i]
        else:
            temp=temp-arr[i]
        print(steps(temp))

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def countSetBits(num):
      | ^~~
Language: C++

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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff         first
  #define  ss         second
  #define  pb         push_back
  #define  all(x)     (x).begin(), (x).end()
  #define  rep(i,a,b) for(ll i=a ; i<b ; ++i)
  #define  D(x)       cout << #x << " - " << x << endl;
  #define  IOS        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D2(x)      cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  D2p(x)      cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)    fixed<<setprecision(y)<<x

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 2e5+1;
  int cal(int md,int k){
     int cnt=1;
     while(md>0){
       cnt++;
       int a = __builtin_popcount(md);
       md = md%a;
     }
     return cnt;
  }
  void solve(){
     int n;
     cin >> n;
     string s;
     cin >> s;
     int k = count(all(s),'1');
     vector<vector<int>> arr(n+1,vector<int>(2));
     map<int,int> mp;
     mp[-1]=0,mp[1]=1;
     for(int i=0;i<=n;i++){
        for(int x:{-1,1}){
          if(x+o<=0)continue;
           int c = mp[x];
           if(!i){
             arr[i][c]=(1%(o+x));
           }
           else{
              arr[i][c] = ((arr[i-1][c]*2))%(o+x);
           }
        }
     }
      int md0=0,md2=0;
     for(int i=n-1;i>=0;i--){
        if(s[i]=='1'){
          if(k-1>0)
          md0 = (md0+arr[n-i-1][0])%(k-1);
          md2 = (md2+arr[n-i-1][1])%(k+1);
        }
      }

     for(int i=0;i<n;i++){
       if(s[i]=='0'){
          int md = (md2+arr[n-i-1][1])%(k+1);
          cout << cal(md,k+1);
       }
       else{
         if(k-1>0){
         int md = ((md0-arr[n-i-1][0])%(k-1)+(k-1))%(k-1);
         cout << cal(md,k-1);
        }
         else cout << 0;
       }
       cout << '\n';
     }
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Compiler output:
a.cc: In function 'void solve()':
a.cc:46:16: error: 'o' was not declared in this scope
   46 |           if(x+o<=0)continue;
      |                ^
a.cc:49:28: error: 'o' was not declared in this scope
   49 |              arr[i][c]=(1%(o+x));
      |                            ^
a.cc:52:46: error: 'o' was not declared in this scope
   52 |               arr[i][c] = ((arr[i-1][c]*2))%(o+x);
      |                                              ^
Language: C++

#include <stdio.h>

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>

int64_t solve(int64_t t)
{
	int64_t x = t;
	int64_t c = 0;

	while (x != 0)
	{
		x = x % std::bitset<64>(x).count();
		++c;
	}
	return c + 1;
}

int main()
{
	int64_t ta = solve(0b10110111001011011001110);
	int64_t tb = solve(0b01110111001011011001110);
	int64_t tc = solve(0b00010111001011011001110);
	int64_t td = solve(0b00100111001011011001110);
	int64_t te = solve(0b00111111001011011001110);

	int64_t N;
	std::cin >> N;
	std::vector<char> V(N);
	int64_t s = 0;
	for (int64_t n = 0; n < N; ++n)
	{
		char c;
		std::cin >> c;
		if (c == '1') {
			++s;
			V[n] = 1;
		}
		else {
			V[n] = 0;
		}
	}

	std::reverse(V.begin(), V.end());

	std::vector<int64_t> V2_1(N);
	int64_t s1 = 0;
	{
		int64_t c = 1;
		V2_1[0] = c;
		for (int64_t n = 1; n < N; ++n)
		{
			c = (c * 2) % (s + 1);
			V2_1[n] = c;
		}

		for (int64_t n = 0; n < N; ++n)
		{
			if (V[n] == 1) {
				s1 += V2_1[n];
			}
		}
	}

	std::vector<int64_t> V2_2(N);
	if (s != 1)
	{
		int64_t s2 = 0;
		{
			int64_t c = 1;
			V2_2[0] = c;
			for (int64_t n = 1; n < N; ++n)
			{
				c = (c * 2) % (s - 1);
				V2_2[n] = c;
			}

			for (int64_t n = 0; n < N; ++n)
			{
				if (V[n] == 1) {
					s2 += V2_2[n];
				}
			}
		}
	}

	for (int64_t n = N-1; n >= 0; --n)
	{
		if (V[n] == 0) {
			std::cout << solve((s1 + s + 1 + V2_1[n]) % (s + 1) ) << std::endl;
		}
		else {
			std::cout << solve((s2 + s - 1 - V2_2[n]) % (s - 1)) << std::endl;
		}
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:96:45: error: 's2' was not declared in this scope; did you mean 's1'?
   96 |                         std::cout << solve((s2 + s - 1 - V2_2[n]) % (s - 1)) << std::endl;
      |                                             ^~
      |                                             s1
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    string X;
    cin>>N>>X;


    int c=0;
    rep(i,N){
        if(X[i]=='1')c++;
    }
    int cmi=c-1;
    int cma=c+1;
    int dp[N][2]{};
    int sumi=0;
    int suma=0;
    int pi=1;
    int pa=1;
    if(cmi!=0){
        rep(i,N){
            dp[N-1-i][0]=pi%cmi;
            dp[N-1-i][1]=pa%cma;
            pi*=2;
            pa*=2;
            pi%=cmi;
            pa%=cma;
        }
        rep(i,N){
        if(X[i]=='1'){
            sumi+=dp[i][0];
            sumi%=cmi;
            suma+=dp[i][1];
            suma%=cma;
        }
    }
    }else{
        rep(i,N){
            dp[N-1-i][0]=0;
            dp[N-1-i][1]=pa%cma;
            pa*=2;
            pa%=cma;
        }
        rep(i,N){
        if(X[i]=='1'){
                sumi+=dp[i][0];
                suma+=dp[i][1];
                suma%=cma;
            }
        }
    }

    // rep(i,N){
    //     int q=0;
    //     int ans=1;
    //     if(X[i]=='1'){
    //         q=sumi-dp[i][0];
    //         while(q<0)q+=cmi;
    //         q%=cmi;
    //     }else{
    //         q=suma+dp[i][1];
    //         q%=cma;
    //     }
    //     while(q!=0){
    //         int b=__builtin_popcountll(q);
    //         q%=b;
    //         ans++;
    //     }

    //     cout << ans << endl;
        
    }




    



}


Compiler output:
a.cc:93:1: error: expected declaration before '}' token
   93 | }
      | ^
Language: C++

#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

vll M;

ll powermod(ll a,ll b,ll m){
	if(b==0){
		return 1LL;
	}
	if(b%2){
		return (a*powermod(a,b-1LL,m))%m;
	}
	return powermod((a*a)%m,b/2LL,m);
}

ll dfs(ll v){
	if(M[v]>=0) return M[v];

	ll B=__popcnt64(v);

	if(!B){
		M[v]=0;
		return 0;
	}
	if(!(v%B)){
		M[v] = 1;
		return 1;
	}

	ll C = dfs(v%B)+1;
	M[v] = C;
	return C;
}

ll safemod(ll a,ll m){
	return (a%m+m)%m;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	string X=in<string>();
	M.resize(N+1,-1);
	ll C=0;
	REP(i,N){
		if(X[i]=='1'){
			C++;
		}
	}
	ll modP=0,modD=0;
	if(C<N){
		REP(j,N){
			if(X[N-1-j]=='1'){
				modP += powermod(2,j,C+1);
				modP %= (C+1);
			}
		}
	}
	if(C>1){
		REP(j,N){
			if(X[N-1-j]=='1'){
				modD += powermod(2,j,C-1);
				modD %= (C-1);
			}
		}
	}

	ll K[2]={C-1,C+1};
	REP(i,N){
		ll B;
		auto T=X;
		ll mod=0;
		if(T[i]=='0'){
			T[i] = '1';
			B = 1;
			mod = modP;
			mod += powermod(2,N-1-i,K[B]);
			mod %= K[B];
		}
		else{
			T[i] = '0';
			B = 0;
			if(K[B]==0){
				out(0);
				continue;
			}
			mod = modD;
			mod -= powermod(2,N-1-i,K[B]);
			mod = safemod(mod,K[B]);
		}

		ll Z=dfs(mod)+1;
		out(Z);
	}


	return 0;
}


Compiler output:
a.cc: In function 'll dfs(ll)':
a.cc:49:14: error: '__popcnt64' was not declared in this scope; did you mean '__powf64'?
   49 |         ll B=__popcnt64(v);
      |              ^~~~~~~~~~
      |              __powf64
Language: C

#include <iostream> 
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
using namespace std; 
  
int fun(int x)
{
    if(x == 0)
        return 0;
    return 1 + fun(x % __builtin_popcount(x));
}

int main()
{
	int N, X, index; 
	char S[200001];
	scanf("%d", &N);
	scanf("%s", &S);
	X = stoi(S, 0, 2);
	for(index = pow(2,N-1); index > 0; index /= 2)
	    printf("%d\n", fun(X ^ index));
	return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(reader.readLine());
		char[] list = reader.readLine().toCharArray();
		int clip = 0;
		for(int i = 0;i<n;i++){
			if(list[i]=='1') clip++;
		}
		int[][] rems = new int[2][n+1];
		ArrayList<Integer> l = new ArrayList<>();
		l.add(-1);
		l.add(1);	
		for(int i=0;i<2;i++){
			int temp = clip + l.get(i);
			for(int j = 0;j<=n;j++){
				if(temp==0){
					rems[i][j] = 0;
					continue;
				}
				if(j==0) rems[i][j] = 1%temp;
				else rems[i][j] = (rems[i][j-1]*2)%temp;
			}
		}
		int[] remlist = new int[2];
		for(int i = 0;i<2;i++){
			int temp = clip + l.get(i);
			for(int j = 0;j<n;j++){
				if(list[j]=='1'){
					remlist[i] = (remlist[i]+rems[i][n-j-1])%temp; 
				}
			}
		}
		for(int i = 0;i<n;i++){
			if(list[i]=='1'){
				if(clip==1){
					writer.write(0+"\n");
					continue;
				}
				int lp = ((remlist[0] - rems[0][n-i-1]) + (clip-1))%(clip-1);
				writer.write((1+solve(lp))+"\n"); 
			}
			else{
				int lp = (remlist[1] + rems[1][n-i-1])%(clip+1);
				writer.write((1+solve(lp))+"\n");	
			}
		}
		writer.flush();
	}
	public static int solve(int p){
		if(p==0) return 0;
		int temp = p;
		int cnt = 0;
		while(p>0){
			if(p%2==1) cnt++;
			p=p>>1;
		}
		if(cnt==0) return 1; 
		return 1 + solve(temp%cnt);
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

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

double pop(double treat){
    double mole = 0;
    while(treat > 0){
        if(treat % 2 != 0){
            mole++;
        }
        treat /= 2;
    }
    return mole;
}

int main(void){

    long long digit;
    cin >> digit ;
    
    string s ;
    cin >> s ;
    
    double cnt = 0, multi = pow(2, s.size() - 1), give = 0;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == '1'){
            cnt++;
            give += multi;
        }
        multi /= 2;
    }
    
    //cout << cnt << " " << give << endl;
    
    //*
    double ans, mole, treat;
    for(int i = 0; i < s.size(); i++){
        treat = give;
        mole = cnt;
        ans = 0;
        if(s.at(i) == '1'){
            treat -= pow(2, s.size() - 1 - i);
            mole--;
        } else {
            treat += pow(2, s.size() - 1 - i);
            mole++;
        }

        //cout << treat << "☆" << mole << endl;

        while(treat > 0){
            treat %= mole;
            ans++;
            mole = pop(treat);
            //cout << treat << " " << mole << endl;
        }
            
        cout << ans << endl;
        
    }
    //*/
    
    return 0;

}


Compiler output:
a.cc: In function 'double pop(double)':
a.cc:7:18: error: invalid operands of types 'double' and 'int' to binary 'operator%'
    7 |         if(treat % 2 != 0){
      |            ~~~~~ ^ ~
      |            |       |
      |            double  int
a.cc: In function 'int main()':
a.cc:51:19: error: invalid operands of types 'double' and 'double' to binary 'operator%'
   51 |             treat %= mole;
      |             ~~~~~~^~~~~~~
a.cc:51:19: note:   in evaluation of 'operator%=(double, double)'
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <bit>
int main() {

	int N;
	std::cin >> N;
	std::string str;
	std::cin >> N;
	std::cin >> str;
	for (int i = 0; i < N; ++i) {
		std::string _str = str;
		if (_str.at(i) == '0') {
				_str.at(i) = '1';
		}
		else
			_str.at(i) = '0';
		
		unsigned int num = std::stoi(_str, 0, 2);
		int count = 0;
		bool finish;
		do {
			int ones = std::popcount(num);
			num /= ones;
			finish = num %= ones;
			count++;
		} while (!finish);
		std::cout << count << std::endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:41: error: 'popcount' is not a member of 'std'
   25 |                         int ones = std::popcount(num);
      |                                         ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n;
char s[nax];
int f[nax];
int p2[nax][2];
vector <int> ans;

int main () {
    scanf("%d", &n);
    scanf("%s", s);
    reverse(s, s + n);

    for (int i = 0 ; i < nax ; ++ i) {
        int x = i;
        while (x > 0) {
            int p = __builtin_popcount(x);
            x %= p;
            ++ f[i];
        }
    }


    int first = 0;

    for (int i = 0 ; i < n ; ++ i) {
        if (s[i] == '1') ++ first;
    }

    ++ first;
    int second = first - 2;


    p2[0][0] = p2[0][1] = 1;

    for (int i = 1 ; i < nax ; ++ i) {
        p2[i][0] = p2[i - 1][0] * 2 % first;
        if (second > 0)
        p2[i][1] = p2[i - 1][1] * 2 % second;
    }

    int first_sum = 0;
    int second_sum = 0;

    for (int i = 0 ; i < nax ; ++ i) {
        if (s[i] == '1') {
            first_sum += p2[i][0];
            second_sum += p2[i][1];
            first_sum %= first;
            if (second != 0)
            second_sum %= second;
        }
    }

    for (int i = 0 ; i < n ; ++ i) {
        int x;
        if (s[i] == '0') {
            x = (first_sum + p2[i][0]) % first;
            ans.push_back(f[x] + 1);
        } else {
            if (second == 0) {
                ans.push_back(0);
            }
            else {
                x = ((second_sum - p2[i][1]) % second + second) % second
                ans.push_back(f[x] + 1);
            }
        }

    }

    reverse(ans.begin(), ans.end());

    for (int i : ans)
        printf("%d\n", i);
}
/*
    Good Luck
        -Lucina
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:66:73: error: expected ';' before 'ans'
   66 |                 x = ((second_sum - p2[i][1]) % second + second) % second
      |                                                                         ^
      |                                                                         ;
   67 |                 ans.push_back(f[x] + 1);
      |                 ~~~
Language: C++

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

int main() {
  int n, cnt = 0, sum = 0, k, jcnt = 0, res = 0;
  string x;
  cin >> n >> x;
  vector<int> tmp_x(n);
  for (int i = 0; i < n; i++) {
    res = 0;
    for (int j = 0; j < n; j++) {
      if (i == j)
        tmp_x[j] = (x[j] == '0' ? 1 : 0);
      else
        tmp_x[j] = ctoi(x[j]);
    }
    sum = 0;
    k = 1;
    for (int j = n - 1; j >= 0; j--) {
      if (tmp_x[j] == 1) sum += k;
      k *= 2;
    }
    while (sum > 0) {
      jcnt = 0;
      for (int j = 0; j < n; j++)
        if (tmp_x[j] == 1) jcnt++;
      sum %= jcnt;
      res++;
    }
    cout << res << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:20: error: 'ctoi' was not declared in this scope; did you mean 'atoi'?
   16 |         tmp_x[j] = ctoi(x[j]);
      |                    ^~~~
      |                    atoi
Language: C++

#include <bits/stdc++.h>
using namespace std;
//2->10
int bd(int a,int n) {
	int bin=0,b;
	for(int i=n-1;i>=0;i--){
		b=1;
		for(int j=0;j<n;j++)b*=10
		if(a%b==1)
	}

}

int main(void){
	int i,j,b;
	long long int n,x;
	cin >> n >>x;
	vector<long long int> a(n+1),count(n+1);
	
	for(i=n-1;i>=0;i--){
		b=1;
		a.at(i)=x;
		//反転させる
		for(j=0;j<i;j++)b*=10;
		if(x%b==0)a.at(i)+=b;
		else a.at(i)-=b;
		//10進数化
		a.at(i)=bd(a.at(i),n);
		cout <<"10進数科"<< a.at(i)<<endl;
		count.at(i)=0;
		//if(a.at(i) % __builtin_popcount(a.at(i))==0)break;
		while(a.at(i)!=0){
		//bit1の数で割ったあまりに置き換える
		a.at(i)%=__builtin_popcount(a.at(i));
		count.at(i)++;
		//cout <<i<<"　処理中"<<endl;
		}
		cout << count.at(i) <<endl;
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int bd(int, int)':
a.cc:8:42: error: expected ';' before 'if'
    8 |                 for(int j=0;j<n;j++)b*=10
      |                                          ^
      |                                          ;
    9 |                 if(a%b==1)
      |                 ~~                        
a.cc:12:1: warning: no return statement in function returning non-void [-Wreturn-type]
   12 | }
      | ^
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <cassert>

using namespace std;

vector<int> memo;

int dfs(int x) {
	assert(x >= 0);

	if (memo[x] != -1) {
		return memo[x];
	}

	int tmp = __builtin_popcount(x);
	int x2 = x % tmp;
	memo[x] = dfs(x2) + 1;
	return memo[x];
}

vector<int> calc_0to1(string s) {
	int n = s.size();
	vector<int> vals(n, -1);
	int mod = count(s.begin(), s.end(), '1') + 1;

	int x = 0;
	for (int i = 0; i < n; i++) {
		x = x * 2 + (s[i] == '1' ? 1 : 0);
		x %= mod;
	}
	int base_val = x;

	int pow2 = 1;
	for (int i = 0; i < n; i++) {
		int idx = n - i - 1;
		if (s[idx] == '0') {
			vals[idx] = (base_val + pow2) % mod;
		}
		pow2 = pow2 * 2 % mod;
	}

	return vals;
}

vector<int> calc_1to0(string s) {
	int n = s.size();
	vector<int> vals(n, -1);
	int mod = count(s.begin(), s.end(), '1') - 1;
	if (mod == -1) {
		return vals;
	} else if (mod == 0) {
		for (int i = 0; i < n; i++) {
			if (s[n - i - 1] == '1') {
				vals[i] = 0;
			}
		}
		return vals;
	}

	int x = 0;
	for (int i = 0; i < n; i++) {
		x = x * 2 + (s[i] == '1' ? 1 : 0);
		x %= mod;
	}
	int base_val = x;

	int pow2 = 1;
	for (int i = 0; i < n; i++) {
		int idx = n - i - 1;
		if (s[idx] == '1') {
			int val = base_val - pow2;
			if (val < 0) {
				long long tmp = val;
				tmp += 1LL * pow2 * mod;
				tmp %= mod;
				val = tmp;
			}
			vals[idx] = val;
		}
		pow2 = pow2 * 2 % mod;
	}

	return vals;
}


int main() {
	int n;
	string x;
	cin >> n >> x;
	memo.assign(n+1, -1);
	memo[0] = 0;

	int n1 = count(s.begin(), s.end(), '1');

	auto v_0to1 = calc_0to1(x);
	auto v_1to0 = calc_1to0(x);

	// for (int i = 0; i < n; i++) {
	// 	printf("i %2d: 0to1 %3d, 1to0 %3d\n", i, v_0to1[i], v_1to0[i]);
	// }

	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		if (x[i] == '0') {
			ans[i] = dfs(v_0to1[i]) + 1;
		} else {
			if (n1 == 1) {
				ans[i] = 0;
			} else {
				ans[i] = dfs(v_1to0[i]) + 1;
			}
		}
	}

	for (auto z: ans) {
		cout << z << endl;
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:100:24: error: 's' was not declared in this scope
  100 |         int n1 = count(s.begin(), s.end(), '1');
      |                        ^