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


#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template<class _T> static void getint(_T& a) {
	if (sizeof(_T) > sizeof(int)) {
		scanf("%lld", &a);
	}
	else {
		scanf("%d", &a);
	}
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	get(N);

	std::string str;
	get(str);

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

	std::vector<int> num(N);
	for (int i = 0; i < N; i++) {
		num[i] = str[i] - '0';
	}

	LLONG bitCount = std::accumulate(num.begin(), num.end(), 0LL);

	LLONG plusMod = 0;
	LLONG minusMod = 0;
	LLONG twoFactor1 = 1;
	LLONG twoFactor2 = 1;
	for (int i = 0; i < N; i++) {
		plusMod += (num[i] % (bitCount + 1)) * (twoFactor1 % (bitCount + 1LL));
		plusMod %= (bitCount + 1LL);
		twoFactor1 = twoFactor1 * 2LL % (bitCount + 1LL);
		if (bitCount > 1) {
			minusMod += (num[i] % (bitCount - 1)) * (twoFactor2 % (bitCount - 1));
			minusMod %= (bitCount - 1);
			twoFactor2 = twoFactor2 * 2LL % (bitCount - 1);
		}
		else minusMod = 0;
	}
	std::vector<int> ans(N, 0LL);
	for (int i = 0; i < N; i++) {
		int cnt = 1;
		LLONG n = 0;
		LLONG mod = 0;
		if (num[N - 1 - i]) {
			mod = bitCount - 1;
			if (mod <= 0) {
				n = cnt = 0;
			}
			else {
				n = (minusMod - tp_modpow<LLONG>(2, N - i - 1, mod)) % mod;
				if (n < 0) {
					n += mod;
				}
			}
		}
		else {
			mod = bitCount + 1;
			n = (plusMod + tp_modpow<LLONG>(2, N - i - 1, mod)) % mod;
		}
		while (n) {
			cnt++;

			mod = std::bitset<32>(n).count();
			n = n % mod;
		}
		ans[N - 1 - i] = cnt;
	}

	for (int i = N - 1; i >= 0; i--) {
		printf("%d\n", ans[i]);
	}
}


Compiler output:
a.cc: In function 'void exec()':
a.cc:97:49: error: 'tp_modpow' was not declared in this scope
   97 |                                 n = (minusMod - tp_modpow<LLONG>(2, N - i - 1, mod)) % mod;
      |                                                 ^~~~~~~~~
a.cc:97:64: error: expected primary-expression before '>' token
   97 |                                 n = (minusMod - tp_modpow<LLONG>(2, N - i - 1, mod)) % mod;
      |                                                                ^
a.cc:105:40: error: 'tp_modpow' was not declared in this scope
  105 |                         n = (plusMod + tp_modpow<LLONG>(2, N - i - 1, mod)) % mod;
      |                                        ^~~~~~~~~
a.cc:105:55: error: expected primary-expression before '>' token
  105 |                         n = (plusMod + tp_modpow<LLONG>(2, N - i - 1, mod)) % mod;
      |                                                       ^
Language: C++

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#pragma GCC optimize "trapv"
#define _GLIBCXX_DEBUG
#define ll long long int
#define ld long double
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define MOD 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll		// this is 1e18 long long 
#define np next_permutation
#define PI acos(-1)
#define DEB(x) cout<<#x<<" "<<x<<endl;
#define rotate_left(vec,amt) rotate(vec.begin(),vec.begin()+amt,vec.end());
#define rotate_right(vec,amt) rotate(vec.begin(),vec.begin()+vec.size()-amt,vec.end());
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x,0,sizeof(x))
using namespace std;
ll add(ll a,ll b,ll mod)
{
  ll temp=a+b;
  if(temp<0)
    temp=temp+mod;
  if(temp>mod)
    temp=temp-mod;
  return temp;
}
ll po(ll a,ll n,ll mod)
{
    ll res=1;
    a=a % mod;
    if(a==0 )
    return 0;
    while(n)
    {
        if(n%2)
        {
            res = (res*a) % mod;
            n--;
        }
        else
        {
            res = ( res*res ) % mod;
            n=n/2;
        }        
    }
    return res;
}


int main()
{
    speed;
  	ll n;
  	cin>>n;
  	string s;
  	cin>>s;
  	ll cnt=0;
  	rep(i,0,n)
      if(s[i]=='1')
        cnt++;
  	if(cnt==0)
    {
      cout<<0<<endl;
      continue;
    }
  	ll val1=0,val2=0;
  	rep(i,0,n)
    {
      val1=add(val1,po(2,n-i+1,cnt+1),cnt+1);
      if(cnt>1)
      	val2=add(val2,po(2,n-i+1,cnt-1),cnt-1);
    }
  	rep(i,0,n)
    {
      if(s[i]=='1')
      {
        if(cnt==1)
        {
          cout<<1<<endl;
          continue;
        }
        ll l=add(val2,-po(2,n-i+1,cnt-1),cnt-1);
        while(l<0)
        {
          l=l-cnt-1;
        }
        ll ans=1;
        while(l)
        {
          ans++;
          l=l%(__builtin_popcount(l));
        }
         cout<<ans<<endl;
      }else
       {
         ll l=add(val1,po(2,n-i+1,cnt+1),cnt+1);
         while(l<0)
           l+=cnt+1;
         ll ans=1;
         while(l)
         {
           ans++;
           l=l%(__builtin_popcount(l));
         }
        	cout<<ans<<endl;
       }	
                	
    }
    return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define pi pair<ll,ll>
#define maxn 1000002
#define mod 1000000007

//vector<ll>adj[maxn];
//ll vis[maxn];
//ll cc[maxn];

//ll curr_cc;

ll arr[1000001];

ll f(ll x){
	ll res=0;
    while(x){
        res++;
        ll z=__builtin_popcount(x);
        x%=z;
    }
    return res;
}

int main(){
	ll n,cnt=0;
	string s;
	cin>>n>>s;
	
	for(int i=0;i<n;i++){
		cnt+=s[i]=='1';
	}
	
	vector<ll>a1(n+1,1),a2(n+1,1);
	
	for(int i=1;i<=n;i++){
		a1[i]  =  (a1[i-1]*2LL)%(cnt+1);
		if(cnt>1)
		a2[i] = (a2[i-1]*2LL)%(cnt-1);
	}
	ll x1=0,x2=0;
	for(int i=0;i<n;i++){
		x1 = (x1*2LL + (s[i] == '1'a))%(cnt+1);
		
		if(cnt>1){
			x2 = (x2*2LL + (s[i] == '1'))%(cnt-1);
		}
	}
	
	for(int i=0;i<n;i++){
		if(s[i] == '1'){
			if(cnt == 1){
				cout<<"0\n";
				continue;
			}
			else{
				ll res = (x2 - a2[n-i-1] +cnt-1)%(cnt-1);
				cout<<1+ f(res)<<'\n';
			}
		}
		else{
			ll res = (x1 +a1[n-i-1])%(cnt+1);
			cout<<1+f(res)<<"\n";
		}
	}

}
	
	
	
	



Compiler output:
a.cc: In function 'int main()':
a.cc:47:41: error: unable to find character literal operator 'operator""a' with 'char' argument
   47 |                 x1 = (x1*2LL + (s[i] == '1'a))%(cnt+1);
      |                                         ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

// bitの数を数える
int pcnt(int x)
{
    return __builtin_popcount(x);
}

int f(int x)
{
    if (x == 0)
    {
        return 0;
    }
    return f(x % pcnt(x)) + 1;
}

int main()
{
    int n;
    cin >> n;
    string s;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        x[i] = s[i] - '0';
    }
    vector<int> ans(n);
    for (int b = 0; i < 2; b++)
    {
        int npc = pc;
        if (b == 0)
        {
            npc++;
        }
        else
        {
            npc--;
        }
        if (npc <= 0)
        {
            continue;
        }
        int r0 = 0;
        for (int i = 0; i < n; i++)
        {
            r0 = (r0 * 2) % npc;
            r0 += x[i];
        }
        int k = 1;
        for (int i = n - 1; i >= 0; --i)
        {
            if (x[i] == b)
            {
                int r = r0;
                if (b == 0)
                {
                    r = (r + k) % npc;
                }
                else
                {
                    r = (r - k + npc) % npc;
                }
            }
            k = (k * 2) % npc;
        }
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:21: error: 'i' was not declared in this scope
   39 |     for (int b = 0; i < 2; b++)
      |                     ^
a.cc:41:19: error: 'pc' was not declared in this scope; did you mean 'npc'?
   41 |         int npc = pc;
      |                   ^~
      |                   npc
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <bitset>
#include <cstdint>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
ll repPow(ll x, ll n, ll m)
{
	// x^n % mを高速に求めるアルゴリズム
	if (n == 0) return 1;
	if (n % 2 == 0) return repPow(x * x % m, n / 2, m);
	else return x * repPow(x, n - 1, m) % m;
}
int pcnt(int x)
{
	return __popcnt(x);
}
int f(int x)
{
	if (x == 0) return 0;
	return f(x % pcnt(x)) + 1;
}
int main()
{
	ll n; string s;
	cin >> n >> s;
	vector<int> x(n);
	rep(i, n) x[i] = s[i] - '0';
	int pc = 0;
	rep(i, n) pc += x[i];
	vector<int> ans(n);
	rep(b, 2) {
		// b == 0 : 0 → 1に変更
		// b == 1 : 1 → 0に変更
		int npc = pc;
		if (b == 0) npc++; else npc--;
		if (npc <= 0) continue;	// npc == 0の時は必ずans == 0. また, 0徐算が起こるためcontinueする.
		// 変更前の値(mod npc)を求めておく
		int r0 = 0;
		rep(i, n) {
			r0 = (r0 * 2) % npc;
			r0 += x[i];
		}
		// r0に変更分を足し引きする
		// kを計算しやすくするために下の桁から計算していく
		int k = 1;
		for (int i = n - 1; i >= 0; --i) {
			if (x[i] == b) {
				int r = r0;
				if (b == 0) r = (r + k) % npc;
				else r = (r - k + npc) % npc; // ()内が負にならないようにnpcを足す
				ans[i] = f(r) + 1;
			}
			k = (k * 2) % npc;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int pcnt(int)':
a.cc:26:16: error: '__popcnt' was not declared in this scope
   26 |         return __popcnt(x);
      |                ^~~~~~~~
Language: C++

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

long long countSetBits(long long n)
{
	long long count = 0; 
	while (n) { 
		count += n & 1; 
		n >>= 1; 
	} 
	return count; 
}

int arr[200003]=0;
int arr2[200003]=0;

long long getans(long long ans){
	long long result=0;
	if(ans==0) return result;
	while(ans){
		ans%=countSetBits(ans);
		result++;
	}
	return result;
}

long long modpow(long long x, long long n, long long m) {
	if (n == 0) return 1%m;
	long long u = modpow(x,n/2,m);
	u = (u*u)%m;
	if (n%2 == 1) u = (u*x)%m;
	return u;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n; cin>>n;
	string s; cin>>s;
	long long count=0;
	for(long long i=0;i<n;i++){
		if(s[i]=='1'){
			count++;
		}
	}
	arr[0]=1%(count+1),arr2[0]=1%(count-1);
	for(int i=1;i<200003;i++){
		arr[i]=(arr[i-1])*(2%(count+1));
		arr[i]%=(count+1);
		arr2[i]=(arr2[i-1])*(2%(count-1));
		arr2[i]%=(count-1);
	}
	long long ans=0,ans2=0;
	long long tempans;
	for(long long i=0;i<n;i++){
		//ans+=pow(2*(s[i]-'0'), n-i-1);
		if(s[i]=='1'){
			ans+=arr[n-i-1];
			ans%=count+1;
			ans2+=arr2[n-i-1];
			ans2%=(count-1);
		}
	}
	//cout<<ans<<" "<<count;
	for(long long i=0;i<n;i++){
		if(s[i]=='1'){
			tempans=ans2-modpow(2, n-i-1 ,count-1);
			tempans=(tempans%(count-1)+count-1)%(count-1);
			//cout<<tempans<<endl;
			tempans=getans(tempans);
			cout<<tempans+1<<"\n";
		}else{
			tempans=ans+modpow(2, n-i-1 ,count+1);
			tempans=tempans%(count+1);
			tempans=getans(tempans);
			cout<<tempans+1<<"\n";
		}
	}
}

Compiler output:
a.cc:14:17: error: array must be initialized with a brace-enclosed initializer
   14 | int arr[200003]=0;
      |                 ^
a.cc:15:18: error: array must be initialized with a brace-enclosed initializer
   15 | int arr2[200003]=0;
      |                  ^
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int f(int n, int m) {
  n %= m;
  while (n < 0) n += m;
  int ret = 1;
  while (n) n = n % __builtin_popcount(n), ret++;
  return ret;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  int cnt = count(S.begin(), S.end(), '1');
  int mod1 = max(1, cnt - 1);
  int mod2 = cnt + 1;
  vector<int> V1(N), V2(N), X(N), Y(N);
  int acc1 = 0, acc2 = 0;
  for (int i = N - 1, now1 = 1, now2 = 1; i >= 0; i--, (now1 *= 2) %= mod1, (now2 *= 2) %= mod2) {
    (acc1 += (V1.at(i) = (S.at(i) - '0') * now1) %= mod1) %= mod1;
    (acc2 += (V2.at(i) = (S.at(i) - '0') * now2) %= mod2) %= mod2;
    X.at(i) = now1 % mod1;
    Y.at(i) = now2 % mod2;
  }
  for (int i = 0; i < N; i++) {
    int ans;
    if (S.at(i) == '1' && cnt == 1) ans = 0;
    else if (S.at(i) == '1') ans = f(acc1 - X.at(i), mod1);
    else ans = f(acc2 + Y.at(i), mod2);
    cout << ans << "\n";
  }
}


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:3:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:186:14: note: called from here
  186 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~
Language: C++

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

#define MAXN 200005

int mod1[MAXN], mod2[MAXN];

int num(int a){
    int res = 0;
    while(a){
        if(a&1) ++res;
        a >>= 1;
    }
    return res;
}

int main(void)
{
    int n; cin>>n;
    string s; cin>>s;
    int cnt = 0;
    for(int i=0;i<n;++i)
        if(s[i]=='1') ++cnt;
    int cnt1 = cnt-1, cnt2 = cnt+1;
    if(cnt1) mod1[n-1] = 1%cnt1;
    else mod1[n-1] = 0;
    mod2[n-1] = 1%cnt2;
    for(int i=n-2;i>=0;--i){
        if(cnt1) mod1[i] = mod1[i+1]*2 % cnt1;
        else mod1[i] = 0;
        mod2[i] = mod2[i+1]*2 % cnt2;
    }
    int sum1 = 0, sum2 = 0;
    for(int i=0;i<n;++i){
        if(s[i]=='1'){
            sum1 += mod1[i]; //sum1 %= cnt1;
            sum2 += mod2[i]; //sum2 %= cnt2;
    }
    for(int i=0;i<n;++i){
        int sum;
        if(s[i]=='1'){
            if(cnt1==0){
                cout<<0<<'\n';
                continue;
            }
            sum = (sum1 - mod1[i]) % cnt1;
        }
        else sum = (sum2 + mod2[i]) % cnt2;
        int ans = 1;
        while(sum){
            sum = sum % num(sum);
            ++ans;
        }
        cout<<ans<<'\n';
    }
    return 0;
}

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

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

long modpow(long a, long n, long m){
  long r = 1;
  while(n){
    if(n & 1)  r = r * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return r;
}

int main(){
  int n;  cin >> n;
  string x;  cin >> x;
  int orig = 0;
  for(int i=0; i<x.size(); i++)  if(x[i]=='1') orig++;
  long upmod = 0, downmod = 0, twou = 1, twod = 1;
  for(int i=n-1; i>=0; i--){
    if(x[i] == '1'){
      upmod = (upmod + twou) % (orig+1);
      downmod = (downmod + twod);
      if(orig >= 2)  downmod %= (orig-1);
    }
    twou = twou * 2 % (orig + 1);
    twod = twod * 2;
    if(orig >= 2)  twod %= (orig - 1);
  }
  
  vector<int> popnum(orig+22, 0);
  for(int i=1; i<=orig+10; i++){
    int cnt = 0;
    for(int b=1; b<=i; b<<=1)
      if(i & b)  cnt++;
    popnum[i] = popnum[i%cnt] + 1;
  }

  long twos = 1;
  for(long i=0; i<n; i++){
    long ans = 0;
    if(x[i] == '1'){
      if(orig >= 2)
	ans = popnum[(downmod - modpow(2, n-1-i, orig-1) + orig - 1)%(orig-1)] + 1;
      else
	ans = popnum[downmod - modpow(2, n-1-i, orig-1) orig + 1] + 1; // + orig - 1)%(orig-1)] + 1;
    }else{
      ans = popnum[(upmod + modpow(2, n-1-i, orig+1) + orig + 1)%(orig+1)] + 1;
    }
    cout << ans << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:56: error: expected ']' before 'orig'
   46 |         ans = popnum[downmod - modpow(2, n-1-i, orig-1) orig + 1] + 1; // + orig - 1)%(orig-1)] + 1;
      |                                                        ^~~~~
      |                                                        ]
a.cc:46:56: error: expected ';' before 'orig'
   46 |         ans = popnum[downmod - modpow(2, n-1-i, orig-1) orig + 1] + 1; // + orig - 1)%(orig-1)] + 1;
      |                                                        ^~~~~
      |                                                        ;
Language: C++

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

long modpow(long a, long n, long m){
  long r = 1;
  while(n){
    if(n & 1)  r = r * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return r;
}

int main(){
  int n;  cin >> n;
  string x;  cin >> x;
  int orig = 0;
  for(int i=0; i<x.size(); i++)  if(x[i]=='1') orig++;
  long upmod = 0, downmod = 0, twou = 1, twod = 1;
  for(int i=n-1; i>=0; i--){
    if(x[i] == '1'){
      upmod = (upmod + twou) % (orig+1);
      downmod = (downmod + twod);
      if(orig >= 2)  downmod %= (orig-1);
    }
    twou = twou * 2 % (orig + 1);
    twod = twod * 2;
    if(orig >= 2)  twod %= (orig - 1);
  }
  
  vector<int> popnum(orig+22, 0);
  for(int i=1; i<=orig+10; i++){
    int cnt = 0;
    for(int b=1; b<=i; b<<=1)
      if(i & b)  cnt++;
    popnum[i] = popnum[i%cnt] + 1;
  }

  long twos = 1;
  for(long i=0; i<n; i++){
    long ans = 0;
    if(x[i] == '1'){
      if(orig >= 2)
	ans = popnum[(downmod - modpow(2, n-1-i, orig-1) + orig - 1)%(orig-1)] + 1;
      else
	ans = popnum[(downmod - modpow(2, n-1-i, orig-1) orig + 1] + 1; // + orig - 1)%(orig-1)] + 1;
    }else{
      ans = popnum[(upmod + modpow(2, n-1-i, orig+1) + orig + 1)%(orig+1)] + 1;
    }
    cout << ans << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:57: error: expected ')' before 'orig'
   46 |         ans = popnum[(downmod - modpow(2, n-1-i, orig-1) orig + 1] + 1; // + orig - 1)%(orig-1)] + 1;
      |                      ~                                  ^~~~~
      |                                                         )
a.cc:46:71: error: expected ']' before ';' token
   46 |         ans = popnum[(downmod - modpow(2, n-1-i, orig-1) orig + 1] + 1; // + orig - 1)%(orig-1)] + 1;
      |                                                                       ^
      |                                                                       ]
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    ll n;cin >> n;
    string s;cin >> s;
    vector<ll>pre(n+10,0);

    for(ll i = 1;i<=n;i++){
        ll ii = i;
        while(ii){
            ii %= __builtin_popcount(ii);
            pre[i]++;
        }
    }

   ll cnt = 0;
   for(ll i = n-1;i>=0;i--) cnt += s[i]=='1';
   ll m1 = 0;ll m2 = 0;

   if(!cnt){
    for(ll i = 0;i<n;i++)
        cout << 1 <<endl;
    return;
   }

   for(ll i = 0;i<n;i++)if(s[i]=='1'){
    m1 = (m1+modpow(2,n-i-1,cnt+1))%(cnt+1);
    if(cnt>1)m2 = (m2+modpow(2,n-i-1,cnt-1))%(cnt-1);
   }

   for(ll i = 0;i<n;i++){
    if(s[i]=='1'&&cnt==1){
        cout << 0 <<endl;
        continue;
    }
    ll c1 = modpow(2,n-i-1,cnt+1);
    if(cnt>1)ll c2 = modpow(2,n-i-1,cnt-1);
    else c2 = -1;
    if(s[i]=='0') cout << pre[(m1+c1)%(cnt+1)]+1 <<endl;
    else cout << pre[((m2-c2)+(cnt-1))%(cnt-1)]+1 <<endl;
   }
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:59:10: error: 'c2' was not declared in this scope; did you mean 'c1'?
   59 |     else c2 = -1;
      |          ^~
      |          c1
a.cc:61:27: error: 'c2' was not declared in this scope; did you mean 'c1'?
   61 |     else cout << pre[((m2-c2)+(cnt-1))%(cnt-1)]+1 <<endl;
      |                           ^~
      |                           c1
Language: C++

#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ

//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π

using namespace std;

//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//#include "./lib/generic/search.h"

int pcnt(int x){ //ポップカウントの計算
    return __builtin_popcount(x); 
}

int f(int x){
    if(x==0) return 0;
    return f(x%pcnt(x))+1;
}

int main(){
    int n, x;
    cin >> n >> x;
    string s;
    cin >> s;
    vector<int> x(n);
    rep(i,n) x[i] = s[i]-'0';
    int pc = 0;
    rep(i, n) pc += x[i]; //1の数なので
    vector<int> ans(n);
    rep(b, 2){
        int npc = pc;
        if(b==0) npc++; //元のビットが0なら1に変換されるのでポップカウントが1増える
        else npc--; //元のビットが1なら0に変換されるのでポップカウントが1減る
        int r=0;
        rep(i,n){ //2進数を10進数に変換
            r0 = (r*2)%npc; //11を整数に直すなら1桁進むごとに2かかる量が増えていくので2をかける。そこに余りを求める処理も追加
            r0 += x[i]; //11なら2桁目は2*1+1なので下の桁数と足している
        }
        int k = 1;
        for(int i=n-1; i>=0; i--){
            if(x[i]==b){ //反転させたビットのとき
                int r = r0;
                if(b == 0) r = (r+k)%npc; //元が0なら1に反転して増えるのでr+k
                else r = (r-k+npc)%npc //元が1なら0に反転して減るのでr-k。負の値になる可能性があるのでnpcをたす
                ans[k] = f(r)+1;
            }
            k = (k*2)%npc;
        }
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:17: error: conflicting declaration 'std::vector<int> x'
   35 |     vector<int> x(n);
      |                 ^
a.cc:31:12: note: previous declaration as 'int x'
   31 |     int n, x;
      |            ^
a.cc:36:15: error: invalid types 'int[int]' for array subscript
   36 |     rep(i,n) x[i] = s[i]-'0';
      |               ^
a.cc:38:22: error: invalid types 'int[int]' for array subscript
   38 |     rep(i, n) pc += x[i]; //1の数なので
      |                      ^
a.cc:46:13: error: 'r0' was not declared in this scope; did you mean 'r'?
   46 |             r0 = (r*2)%npc; //11を整数に直すなら1桁進むごとに2かかる量が増えていくので2をかける。そこに余りを求める処理も追加
      |             ^~
      |             r
a.cc:47:20: error: invalid types 'int[int]' for array subscript
   47 |             r0 += x[i]; //11なら2桁目は2*1+1なので下の桁数と足している
      |                    ^
a.cc:51:17: error: invalid types 'int[int]' for array subscript
   51 |             if(x[i]==b){ //反転させたビットのとき
      |                 ^
a.cc:52:25: error: 'r0' was not declared in this scope; did you mean 'r'?
   52 |                 int r = r0;
      |                         ^~
      |                         r
a.cc:54:39: error: expected ';' before 'ans'
   54 |                 else r = (r-k+npc)%npc //元が1なら0に反転して減るのでr-k。負の値になる可能性があるのでnpcをたす
      |                                       ^
      |                                       ;
   55 |                 ans[k] = f(r)+1;
      |                 ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;
vector<int> v;
ll f(ll x) {
    if (v[x] != -1)
        return v[x];
    return v[x] = f(x % __builtin_popcount(x)) + 1;
}
int main() {
    int N;
    string s;
    cin >> N >> s;
    ll x = stoi(s, nullptr, 2);
    v = vector<ll>(pow(2, N + 1), -1);
    v[0] = 0;
    for (int i = N - 1; i >= 0; i--) {
        ll xi = x ^ (1 << i);
        cout << f(xi) << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:37: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
   21 |     v = vector<ll>(pow(2, N + 1), -1);
      |                                     ^
In file included from /usr/include/c++/14/vector:72,
                 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/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Language: C++

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn pcnt(x: i32) -> i32 {
    x.count_ones() as i32
}
fn f(x: i32) -> i32 {
    if x == 0 {
        return 0;
    }
    f(x % pcnt(x)) + 1
}
fn main() {
    let n: usize = read();
    let s: String = read();
    let mut s: Vec<char> = s.chars().collect();
    let mut x: Vec<i32> = vec![0; n];
    for i in 0..n {
        x[i] = s[i] as i32 - '0' as i32;
    }
    let mut pc = 0;
    for i in 0..n {
        pc += x[i];
    }
    let mut ans: Vec<i32> = vec![0; n];
    for b in 0..2 {
        let mut npc = pc;
        if b == 0 {
            npc += 1;
        } else {
            npc -= 1;
        }
        if npc <= 0 {
            continue;
        }
        let mut r0 = 0;
        for i in 0..n {
            r0 = (r0 * 2) % npc;
            r0 += x[i];
        }
        let mut k = 1;
        for i in 0..n {
            if x[n - 1 - i] == b {
                let mut r = r0;
                if (b == 0) {
                    r = (r + k) % npc;
                } else {
                    r = (r - k + npc) % npc;
                }
                ans[n - 1 - i] = f(r) + 1;
            }
            k = (k * 2) % npc
        }
    }
    for i in 0..n {
        println!("{}", ans[i]);
    }
}


Compiler output:
a.cc:30:14: error: too many decimal points in number
   30 |     for i in 0..n {
      |              ^~~~
a.cc:34:14: error: too many decimal points in number
   34 |     for i in 0..n {
      |              ^~~~
a.cc:38:14: error: too many decimal points in number
   38 |     for b in 0..2 {
      |              ^~~~
a.cc:49:18: error: too many decimal points in number
   49 |         for i in 0..n {
      |                  ^~~~
a.cc:54:18: error: too many decimal points in number
   54 |         for i in 0..n {
      |                  ^~~~
a.cc:67:14: error: too many decimal points in number
   67 |     for i in 0..n {
      |              ^~~~
a.cc:1:1: error: 'use' does not name a type
    1 | use std::cmp::*;
      | ^~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::collections::*;
      | ^~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::io::*;
      | ^~~
a.cc:4:1: error: 'use' does not name a type
    4 | use std::str::FromStr;
      | ^~~
a.cc:5:1: error: 'fn' does not name a type
    5 | fn read<T: FromStr>() -> T {
      | ^~
a.cc:16:1: error: 'fn' does not name a type
   16 | fn pcnt(x: i32) -> i32 {
      | ^~
a.cc:19:1: error: 'fn' does not name a type
   19 | fn f(x: i32) -> i32 {
      | ^~
a.cc:25:1: error: 'fn' does not name a type
   25 | fn main() {
      | ^~
Language: C++

// AISing.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>
#include<intrin.h>
#include<bit>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;

////int f(int pop) {
////
////}
//ll rui(int n,int pop) {
//    if (n == 0)return 1;
//    ll x = rui(n / 2,pop);
//    if (n % 2 == 1)x *= 2;
//    return x%pop;
//}
//int main()
//{
//    int n;
//    string x;
//    cin >> n;
//    cin >> x;
// //   cout << x << endl;
//    int cnt = 0;
//    for (int i = 0; i < n; i++) {
//        if (x[i]=='1' )cnt++;
//    }
//
//    vector<int>v1(n + 1);
//    vector<int>v2(n + 1);
//
//    for (int i = 0; i < n; i++) {
//        v1[i] = rui(i, cnt - 1);
//        v2[i] = rui(i, cnt + 1);
//    }
//    long long v1sum = 0;
//    long long v2sum = 0;
//
//    for (int i = 0; i < n; i++) {
//        if (x[i] == '1') {
//            v2sum = (v2sum + v2[n-1-i]) % (cnt + 1);
//            v1sum = (v1sum + v1[n-1-i]) % (cnt - 1);
//        }
//    }
//    for (int i = 0; i < n; i++) {
//        int first;
//        if (x[i] == '1') {
//            first = (v1sum - v1[n - 1 - i]) % (cnt - 1);
//            if (first < 0)first += (cnt - 1);
//        }
//        else {
//            first = (v2sum + v2[n - 1 - i]) % (cnt + 1);
//        }
//        int ans = 1;
//
//        while (first) {
//            int key = 0;
//            int pop = 0;
//            int an = 0;
//            while (first << key) {
//                if (first << key & 1)pop++;
//                key++;
//            }
//            int key2 = 0;
//            while (first << key2) {
//                if (first << key2 & 1)an = (an + rui(key2, pop) )% pop;
//                key2++;
//            }
//            first = an;
//            ans++;
//        }
//
//        cout << ans << endl;
//
//    }
//  //  cout << cnt << endl;
//}
int pcnt(int x) {
	return __popcnt(x);
}
int f(int x) {
	if (x == 0)return 0;
	return f(x % pcnt(x)) + 1;
}

int main() {
	int n;

	cin >> n;

	string s;

	cin >> s;

	vector<int>x(n);
	rep(i, n)x[i] = s[i] - '0';
	int pc = 0;
	rep(i, n)pc += x[i];
	vector<int> ans(n);
	rep(b, 2) {
		int npc = pc;
		if (b == 0)npc++; else npc--;
		int r0 = 0;
		rep(i, n) {
			r0 = (r0 * 2) % npc;
			r0 += x[i];
		}
		int k = 1;
		for (int i = n - 1; i >= 0; --i) {
			if (x[i] == b) {
				int r = r0;
				if (b == 0)r = (r + k) % npc;
				else r = (r - k + npc) % npc;
				ans[i] = f(r) + 1;
			}
			k = (k * 2) % npc;
		}
	}

	rep(i, n)cout << ans[i] << endl;

	return 0;

	
}


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

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

typedef long long ll;

int solve(int x)
{
    int ans = 0;
    while (x > 0)
    {
        int p = 0, tmp = x;
        while (tmp > 0)
        {
            p += (tmp % 2);
            tmp /= 2;
        }
        x %= p;
        ans++;
    }
    return ans;
}

int main()
{
    int N;
    cin >> N;
    string X;
    cin >> X;
    int pcnt = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (X[i] == '1')
            pcnt++;
    }
    bool isZero = pcnt==1;
     ll xrem1 = 0, xrem2 = 0;
    vint rem1(N), rem2(N); // rem1[i] := 2^i % (pcnt-1) , rem2[i] := 2^i % (pcnt+1)
    if (pcnt != 1)
    {
        rem1[0] = 1 % (pcnt - 1);
        for (size_t i = 0; i < N; i++)
        {
            rem1[i + 1] = (rem1[i] * 2) % (pcnt - 1);
        }
        for (int i = N - 1; i >= 0; i--)
    {
        if (X[i] == '1')
        {
            xrem1 =(xrem1 + rem1[(N-1)-i])%(pcnt-1);
        }
    }
    }
    rem2[0] = 1 % (pcnt + 1);
    for (size_t i = 0; i < N; i++)
    {
        rem2[i + 1] = (rem2[i] * 2) % (pcnt + 1);
    }
    
   
    for (int i = N - 1; i >= 0; i--)
    {
        if (X[i] == '1')
        {
            xrem2 = (xrem2 + rem2[(N-1)-i]) % (pcnt+1);
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (X[i] == '1' and !isZero)
        {
            int newP = pcnt - 1;
            ll nrem = ((xrem1 - rem1[N-1-i])%newP + newP)%newP;
            cout<<solve(nrem)+1<<"\n";
        }
        else if(X[i]=='1' and isZero)
        {
            cout<<0<<endl;
        }
        else
        {
            int newP = pcnt + 1;
            ll nrem = (xrem2 + rem2[N-1-i])%newP;
            cout<<solve(nrem)+1<<"\n";
        }
        
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'vint' was not declared in this scope; did you mean 'uint'?
   37 |     vint rem1(N), rem2(N); // rem1[i] := 2^i % (pcnt-1) , rem2[i] := 2^i % (pcnt+1)
      |     ^~~~
      |     uint
a.cc:40:9: error: 'rem1' was not declared in this scope; did you mean 'xrem1'?
   40 |         rem1[0] = 1 % (pcnt - 1);
      |         ^~~~
      |         xrem1
a.cc:53:5: error: 'rem2' was not declared in this scope; did you mean 'xrem2'?
   53 |     rem2[0] = 1 % (pcnt + 1);
      |     ^~~~
      |     xrem2
a.cc:73:33: error: 'rem1' was not declared in this scope; did you mean 'xrem1'?
   73 |             ll nrem = ((xrem1 - rem1[N-1-i])%newP + newP)%newP;
      |                                 ^~~~
      |                                 xrem1
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String X = sc.next();
      
      for(int i=0;i<N;i++){
        int count=0;
        
        String input = "";
        //ビット反転
        if(input.substring(i,i+1)equals("0")){
          input = X.substring(0,i).concat("1").concat(i+1,X.length());
        } else {
          input = X.substring(0,i).concat("0").concat(i+1,X.length());
        }
        
        int fn = Integer.parseInt(input, 2);
        int popcount = input.split("1").length - 1;
        
        while(fn>0){
          fn = fn % popcount;
          count++;
          popcount = Integer.toBinaryString(fn).split("1").length - 1;
        }
        System.out.println(String.valueOf(count));
      }
    }
}
        
        

Compiler output:
Main.java:14: error: ')' expected
        if(input.substring(i,i+1)equals("0")){
                                 ^
Main.java:14: error: ';' expected
        if(input.substring(i,i+1)equals("0")){
                                            ^
Main.java:16: error: 'else' without 'if'
        } else {
          ^
3 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    int pc = 0;
    rep(i, n) pc += (s[i] == '1');
    
    vector<int> v(n+1), u(n+1);
    ll a = 1, b = 1;
    rep(i, n){
        v[i] = a;
        a *= 2;
        a %= (pc+1);

        u[i] = b;
        b *= 2;
        b %= max(pc-1, 1);
    }

    ll x = 0, y = 0;
    rep(i, n){
        if(s[i] == '1') x += v[i], y += u[i];
    }

    rep(i, n){
        int ans = 1;
        int nex;
        if(s[i] == '0') nex = (x + v[n-i-1])%(pc+1);
        else if(pc-1 == 0) ans = 0, nex = 0;
        else{
            nex = (y - u[n-i-1])%(pc-1);
            if(nex < 0) cur += (pc-1);
        } 

        while(nex > 0){
            ans++;
            nex %= __builtin_popcount(nex);
        }

        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:25: error: 'cur' was not declared in this scope
   46 |             if(nex < 0) cur += (pc-1);
      |                         ^~~
Language: C

#include<stdio.h>
#include<string.h>
#include<math.h>

char in_bit[200001];
int org_bit[200001];//先頭が最下位bit

long long int q_list[200001];//10進数
int divid_list[200001];//q_listの余りから入れていく
int a_list[200001];//q_listの対

int main()
{
	int n, org_b = 0;
    long long int x = 0;

	scanf("%d", &n);
	scanf("%s", in_bit);

	for (int i = 0; i<n; i++)
	{
		if (in_bit[(n - 1) - i] == '0')
		{
			org_bit[i] = 0;
			q_list[i] = (long long int)pow(2, i);
		}
		else {
			org_bit[i] = 1;
			q_list[i] = -(long long int))pow(2, i);
			org_b++;

			x += (long long int))pow(2, i);
		}
		
	}

	for (int i = 0; i<n; i++)
	{
		long long int target, answer = 0, tmp_bit;

		tmp_bit = org_b + 1 - 2 * org_bit[i];

        if (tmp_bit == 0)
        {
            target = 0;
        } else {
            target = ((q_list[i] + x) % (tmp_bit));
		    answer++;
        }

		while (target != 0)
		{
			int tmp_tmp_bit = 0;
            long long int tmp_tmp_target = target;

			for (int j = 1; tmp_tmp_target > 0; j++)
			{
				tmp_tmp_bit += (1)&(tmp_tmp_target);
                tmp_tmp_target = tmp_tmp_target >> j;
			}

			target = target % tmp_tmp_bit;
			answer++;
			tmp_bit = tmp_tmp_bit;
		}

		a_list[i] = answer;

	}


	for (int i = (n - 1); i >= 0; i--)
	{
		printf("%d\n", a_list[i]);
	}


	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:29:53: error: expected expression before ')' token
   29 |                         q_list[i] = -(long long int))pow(2, i);
      |                                                     ^
main.c:29:53: error: expected statement before ')' token
main.c:32:45: error: expected expression before ')' token
   32 |                         x += (long long int))pow(2, i);
      |                                             ^
main.c:32:45: error: expected statement before ')' token
Language: C++

#include<bits/stdc++.h>
#include <cctype>
#define ll          long long int
#define PB          push_back
#define GO          ll t; cin>>t; while(t--)
#define G(t)        cin>>t; while(t--)
#define ALLR(x)     x.rbegin(), x.rend()
#define PII         pair<ll ,ll >
#define VI          vector<ll >
#define ALL(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define PI          3.141592653589793238
#define SZ(x)       (ll )x.size()
#define hell2        998244353
#define hell        1000000007
#define FO(i,a,b)    for(i=a;i<b;i++)
#define FOREV(i,a,b)    for(i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define BS          binary_search
#define MP          make_pair
#define ARR(n,i,a)    ll n,i;cin>>n;ll a[n];FO(i,0,n)cin>>a[i];
#define ARRK(k,n,i,a) int n,k,i;scanf("%d%d",&n,&k);ll a[n];FO(i,0,n)scanf("%lld",&a[i]);
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
int main()
{
    fio
    ll i,n;
  string s;
  cin>>n>>s;
  ll num=0,c=0,p=1,cnt=0;
  for(i=n-1;i>=0;i--)
  {
    if(cnt==64)break;
    num+=p*(s[i]-'0');
    if(cnt<63)p*=2;
    c+=(s[i]-'0');
    cnt++;
  }
  ll y=1;
  cnt=0;p=1;
  int a[n]={0};
  FOREV(i,n-1,0)
  {
    y=1;
    if(cnt<64)
    {
      if(s[i]=='0')
       {r=num+p;h=c+1;}
      else
       {r=num-p;h=c-1;}
      r=r%h;
      while(r!=0)
      {
        r=r%h;
        u=r;h=0;
        while(u!=0)
        {h+=(u%2);u/=2;}
        y++;
      }
    }
    else
    {
      h=c+1;
      p=(p%h * 2%h)%h;
      r=(num%h + p)%h;
       while(r!=0)
      {
        r=r%h;
        u=r;h=0;
        while(u!=0)
        {h+=(u%2);u/=2;}
        y++;
      }
    }
      a[i]=y;
      if(cnt<63)p*=2;
      cnt++;
  }
  FO(i,0,n)
    cout<<a[i]<<"\n";
  
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:9: error: 'r' was not declared in this scope
   51 |        {r=num+p;h=c+1;}
      |         ^
a.cc:51:17: error: 'h' was not declared in this scope
   51 |        {r=num+p;h=c+1;}
      |                 ^
a.cc:53:9: error: 'r' was not declared in this scope
   53 |        {r=num-p;h=c-1;}
      |         ^
a.cc:53:17: error: 'h' was not declared in this scope
   53 |        {r=num-p;h=c-1;}
      |                 ^
a.cc:54:7: error: 'r' was not declared in this scope
   54 |       r=r%h;
      |       ^
a.cc:54:11: error: 'h' was not declared in this scope
   54 |       r=r%h;
      |           ^
a.cc:58:9: error: 'u' was not declared in this scope
   58 |         u=r;h=0;
      |         ^
a.cc:66:7: error: 'h' was not declared in this scope
   66 |       h=c+1;
      |       ^
a.cc:68:7: error: 'r' was not declared in this scope
   68 |       r=(num%h + p)%h;
      |       ^
a.cc:72:9: error: 'u' was not declared in this scope
   72 |         u=r;h=0;
      |         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    string X;
    cin >> N >> X;
    int twocount = 0;
    int num = 0;
    int number, ntwo;
    for (int i=0; i<N; i++) {
      if (X.at(i)=='1') {
        int twos = 1;
        for (int j=0; j<N-i; j++) {
          twos *= 2;
        }
        num += twos;
        twocount++;
      }
    }
    for (int i=0; i<N; i++) {
      twos = 1;
      for (int j=0; j<N-i; j++) {
        twos *= 2;
      }
      if (X.at(i)=='1') {
        number = num + twos;
        ntwo = twocount + 1;
      }
      else {
        number = num - twos;
        ntwo = twocount - 1;
      }  
      int fn = 0;
      while (number!=0) {
        number = number % ntwo;
        fn++;
      }
      cout << fn << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:7: error: 'twos' was not declared in this scope
   22 |       twos = 1;
      |       ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    string X;
    cin >> N >> X;
    int twocount = 0;
    int num = 0;
    for (int i=0; i<N; i++) {
      if (X.at(i)=='1') {
        twos = 1;
        for (int j=0; j<N-i; j++) {
          twos *= 2;
        }
        num += twos;
        twocount++;
      }
    }
    for (int i=0; i<N; i++) {
      twos = 1;
      for (int j=0; j<N-i; j++) {
        twos *= 2;
      }
      if (X.at(i)=='1') {
        number = num + twos;
        ntwo = twocount + 1;
      }
      else {
        number = num - twos;
        ntwo = twocount - 1;
      }  
      fn = 0;
      while (number!=0) {
        number = number % ntwo;
        fn++;
      }
      cout << fn << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'twos' was not declared in this scope
   12 |         twos = 1;
      |         ^~~~
a.cc:21:7: error: 'twos' was not declared in this scope
   21 |       twos = 1;
      |       ^~~~
a.cc:26:9: error: 'number' was not declared in this scope
   26 |         number = num + twos;
      |         ^~~~~~
a.cc:27:9: error: 'ntwo' was not declared in this scope
   27 |         ntwo = twocount + 1;
      |         ^~~~
a.cc:30:9: error: 'number' was not declared in this scope
   30 |         number = num - twos;
      |         ^~~~~~
a.cc:31:9: error: 'ntwo' was not declared in this scope
   31 |         ntwo = twocount - 1;
      |         ^~~~
a.cc:33:7: error: 'fn' was not declared in this scope; did you mean 'yn'?
   33 |       fn = 0;
      |       ^~
      |       yn
a.cc:34:14: error: 'number' was not declared in this scope
   34 |       while (number!=0) {
      |              ^~~~~~
a.cc:35:27: error: 'ntwo' was not declared in this scope
   35 |         number = number % ntwo;
      |                           ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    string X;
    cin >> N >> X;
    int twocount = 0;
    int num = 0;
    for (int i=0; i<N; i++) {
      if (X.at(i)=='1') {
        twos = 1;
        for (int j=0; j<N-i; j++) {
          twos *= 2;
        }
        num += twos;
        twocount++;
      }
    }
    for (int i=0; i<N; i++) {
      twos = 1;
      for (int j=0; j<N-i; j++) {
        twos *= 2;
      }
      if (X.at(i)=='1') {
        number = num + twos;
        ntwo = twocount + 1;
      }
      else {
        number = num - twos;
        ntwo = twocount - 1;
      }  
      fn = 0;
      while (number!=0) {
        number = number % ntwo;
        fn++;
      }
      cout << fn << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'twos' was not declared in this scope
   12 |         twos = 1;
      |         ^~~~
a.cc:21:7: error: 'twos' was not declared in this scope
   21 |       twos = 1;
      |       ^~~~
a.cc:26:9: error: 'number' was not declared in this scope
   26 |         number = num + twos;
      |         ^~~~~~
a.cc:27:9: error: 'ntwo' was not declared in this scope
   27 |         ntwo = twocount + 1;
      |         ^~~~
a.cc:30:9: error: 'number' was not declared in this scope
   30 |         number = num - twos;
      |         ^~~~~~
a.cc:31:9: error: 'ntwo' was not declared in this scope
   31 |         ntwo = twocount - 1;
      |         ^~~~
a.cc:33:7: error: 'fn' was not declared in this scope; did you mean 'yn'?
   33 |       fn = 0;
      |       ^~
      |       yn
a.cc:34:14: error: 'number' was not declared in this scope
   34 |       while (number!=0) {
      |              ^~~~~~
a.cc:35:27: error: 'ntwo' was not declared in this scope
   35 |         number = number % ntwo;
      |                           ^~~~
a.cc:39:2: error: expected '}' at end of input
   39 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^