Language: C++

#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll N;
ll X;
ll bit2[base10_6]={};

ll mod_p[base10_6]={};
ll mod_m[base10_6]={};
ll popcount[base10_6]={};

ll getIntSubstr(string s,ll start_index,ll length){
    return atoi(s.substr(start_index,length).c_str());
}

ll ltmp;
string stmp;
double dtmp;

ll getPower(ll value,ll shisu,ll mod){
    ll ans = 1;
    ll cnt = shisu;
    while(cnt>0){
        if(cnt%2==1){
            ans = ans * value % mod;
        }
        value = value * value % mod;
        cnt = cnt/2;
    }
    return ans;
}

getMod(ll value,ll mod){
    return (value + mod) % mod;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;

    string S;
    cin >> S;
    ll base_pop=0;
    ll basev= 1;

    basev=1;
    for( ll ni = 1 ; ni <=N*2 ; ni=ni*2 ){
        popcount[ni]=1;
    }
    for( ll ni = 1 ; ni <=N*2 ; ni++ ){
        if(popcount[ni]==1){
            basev = ni;
        }else{
            popcount[ni]= 1 + popcount[ ni % basev  ]; 
        }
    }

    rep(ni,N){
        bit2[ni] = getIntSubstr(S,ni,1);
        //bit2[ni] = 1;
        base_pop+=bit2[ni];
    }

    ll base_pop_p;
    ll base_pop_m;

    base_pop_p = base_pop+1;
    base_pop_m = base_pop-1;
    if(base_pop_m==0) base_pop_m=1;

    basev = 1;
    ltmp = 1;
    for( ll keta = 1 ; keta <=N*2 ; keta++ ){
        mod_p[keta] = basev;

        basev = basev * 2;
        basev = getMod(basev,base_pop_p); 
    }

    basev = 1;
    for( ll keta = 1 ; keta <= N * 2 ; keta++ ){
        mod_m[keta] = basev;
        basev = basev * 2;
        basev = getMod(basev,base_pop_m); 
    }

    ll f1_p = 0;
    ll f1_m = 0;
    for( ll keta = 1 ; keta <=N ; keta++ ){
        ll ind = N -keta;
        f1_p += mod_p[keta] * bit2[ind];
        f1_m += mod_m[keta] * bit2[ind];

        f1_p = getMod(f1_p, base_pop_p );
        f1_m = getMod(f1_m,base_pop_m );
    }

    ll base_pop_tmp;
    for( ll ind = 0 ; ind <N ; ind++ ){
        ll keta = N - ind;
        ll value;
        ll cnt = 1;
        if(bit2[ind]==1){
            base_pop_tmp = base_pop -1;
            if(base_pop==0){
                cout << 0 << endl;
                break;
            }else{
                value = f1_m - mod_m[keta];
                value = getMod(value,base_pop_tmp);
            }
        }else{
            base_pop_tmp = base_pop +1;
            value = f1_p + mod_p[keta];
            value = getMod(value,base_pop_tmp);
        }

        while(value>0){
            cnt++;
            value = value % popcount[value];
        }
        cout << cnt << endl;
    }




    

}

Compiler output:
a.cc:66:1: error: ISO C++ forbids declaration of 'getMod' with no type [-fpermissive]
   66 | getMod(ll value,ll mod){
      | ^~~~~~