Language: C++

#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
#define int long long
#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+10]={};

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

ll f1[base10_6+10]={};

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;
}

ll getMod(ll value,ll mod){
    if(value == 0) return 0;
    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;
    rep(ni,N){
        bit2[ni] = getIntSubstr(S,ni,1);
        //bit2[ni] = 1;
        base_pop+=bit2[ni];
    }

    ll basev= 1;

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


    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 <=base10_6 ; keta++ ){
        mod_p[keta] = basev;
        basev = basev * 2;
        basev = getMod(basev,base_pop_p); 
    }
    basev = 1;
    for( ll keta = 1 ; keta <= base10_6 ; keta++ ){
        mod_m[keta] = basev;
        basev = basev * 2;
        basev = getMod(basev,base_pop_m); 
    }

    ll base_f1_p = 0;
    ll base_f1_m = 0;
    for( ll keta = 1 ; keta <=N ; keta++ ){
        ll ind = N -keta;
        base_f1_p += mod_p[keta] * bit2[ind];
        base_f1_m += mod_m[keta] * bit2[ind];
        base_f1_p = getMod(base_f1_p,base_pop_p );
        base_f1_m = getMod(base_f1_m,base_pop_m );
    }


    base_pop_p = base_pop+1;
    base_pop_m = base_pop-1;

    for( ll ind = 0 ; ind <N ; ind++ ){
        ll keta = N - ind;
        ll value;
        ll cnt = 1;
        if(bit2[ind]==1){
            if(base_pop_m==0){
                cout << 0 << endl;
                continue;
            }else{
                value = base_f1_m - mod_m[keta];
                value = getMod(value,base_pop_m);
            }
        }else{
            value = base_f1_p + mod_p[keta];
            value = getMod(value,base_pop_p);
        }

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

}

Compiler output:
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:7:13: error: expected '}' before 'long'
In file included from /usr/include/c++/14/vector:67,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_bvector.h:73:8: note: to match this '{'
   73 |   enum { _S_word_bit = int(__CHAR_BIT__ * sizeof(_Bit_type)) };
      |        ^
/usr/include/c++/14/bits/stl_bvector.h:73:28: error: expected unqualified-id before numeric constant
   73 |   enum { _S_word_bit = int(__CHAR_BIT__ * sizeof(_Bit_type)) };
      |                            ^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:73:28: error: expected ')' before numeric constant
   73 |   enum { _S_word_bit = int(__CHAR_BIT__ * sizeof(_Bit_type)) };
      |                           ~^
      |                            )
/usr/include/c++/14/bits/stl_bvector.h: In member function 'void _Bit_iterator_base::_M_bump_up()':
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:7:13: error: expected ')' before 'long'
/usr/include/c++/14/bits/stl_bvector.h:203:10: note: to match this '('
  203 |       if (_M_offset++ == int(_S_word_bit) - 1)
      |          ^
/usr/include/c++/14/bits/stl_bvector.h: In member function 'void _Bit_iterator_base::_M_bump_down()':
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
/usr/include/c++/14/bits/stl_bvector.h: In member function 'void _Bit_iterator_base::_M_incr(ptrdiff_t)':
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
/usr/include/c++/14/bits/stl_bvector.h: In function 'ptrdiff_t operator-(const _Bit_iterator_base&, const _Bit_iterator_base&)':
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:7:13: error: expected ')' before 'long'
/usr/include/c++/14/bits/stl_bvector.h:296:14: note: to match this '('
  296 |       return (int(_S_word_bit) * (__x._M_p - __y._M_p)
      |              ^
/usr/include/c++/14/bits/stl_bvector.h: At global scope:
/usr/include/c++/14/bits/stl_bvector.h:342:5: error: postfix '_Bit_iterator::iterator _Bit_iterator::operator++(long long int)' must have 'int' as its argument
  342 |     operator++(int)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:359:5: error: postfix '_Bit_iterator::iterator _Bit_iterator::operator--(long long int)' must have 'int' as its argument
  359 |     operator--(int)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:430:31: error: reference to '_Bit_iterator' is ambiguous
  430 |     _Bit_const_iterator(const _Bit_iterator& __x)
      |                               ^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:465:10: note: candidates are: 'struct std::_Bit_iterator'
  465 |   struct _Bit_iterator;
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:302:10: note:                 'struct _Bit_iterator'
  302 |   struct _Bit_iterator : public _Bit_iterator_base
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:434:5: error: reference to '_Bit_iterator' is ambiguous
  434 |     _Bit_iterator
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:465:10: note: candidates are: 'struct std::_Bit_iterator'
  465 |   struct _Bit_iterator;
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:302:10: note:                 'struct _Bit_iterator'
  302 |   struct _Bit_iterator : public _Bit_iterator_base
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:456:5: error: postfix '_Bit_const_iterator::const_iterator _Bit_const_iterator::operator++(long long int)' must have 'int' as its argument
  456 |     operator++(int)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:473:5: error: postfix '_Bit_const_iterator::const_iterator _Bit_const_iterator::operator--(long long int)' must have 'int' as its argument
  473 |     operator--(int)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h: In constructor '_Bit_const_iterator::_Bit_const_iterator(const int&)':
/usr/include/c++/14/bits/stl_bvector.h:431:30: error: request for member '_M_p' in '__x', which is of non-class type 'const int'
  431 |     : _Bit_iterator_base(__x._M_p, __x._M_offset) { }
      |                              ^~~~
/usr/include/c++/14/bits/stl_bvector.h:431:40: error: request for member '_M_offset' in '__x', which is of non-class type 'const int'
  431 |     : _Bit_iterator_base(__x._M_p, __x._M_offset) { }
      |                                        ^~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h: At global scope:
/usr/include/c++/14/bits/stl_bvector.h:537:9: error: reference to '_Bit_iterator' is ambiguous
  537 |         _Bit_iterator   _M_start;
      |         ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:465:10: note: candidates are: 'struct std::_Bit_iterator'
  465 |   struct _Bit_iterator;
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:302:10: note:                 'struct _Bit_iterator'
  302 |   struct _Bit_iterator : public _Bit_iterator_base
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:547:9: error: reference to '_Bit_iterator' is ambiguous
  547 |         _Bit_iterator   _M_finish;
      |         ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:465:10: note: candidates are: 'struct std::_Bit_iterator'
  465 |   struct _Bit_iterator;
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:302:10: note:                 'struct _Bit_iterator'
  302 |   struct _Bit_iterator : public _Bit_iterator_base
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h: In constructor '_Bvector_base<_Alloc>::_Bvector_impl_data::_Bvector_impl_data()':
/usr/include/c++/14/bits/stl_bvector.h:552:11: error: class '_Bvector_base<_Alloc>::_Bvector_impl_data' does not have any field named '_M_start'
  552 |         : _M_start(), _M_finish(), _M_end_of_storage()
      |           ^~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:552:23: error: class '_Bvector_base<_Alloc>::_Bvector_impl_data' does not have any field named '_M_finish'
  552 |         : _M_start(), _M_finish(), _M_end_of_storage()
      |                       ^~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h: In static member function 'static constexpr size_t _Bvector_base<_Alloc>::_S_nword(size_t)':
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:7:13: error: expected ')' before 'long'
/usr/include/c++/14/bits/stl_bvector.h:715:16: note: to match this '('
  715 |       { return (__n + int(_S_word_bit) - 1) / int(_S_word_bit); }
      |                ^
/usr/include/c++/14/bits/stl_bvector.h: At global scope:
/usr/include/c++/14/bits/stl_bvector.h:996:7: error: return type 'std::vector<bool, _Alloc>::iterator' is incomplete
  996 |       { return iterator(this->_M_impl._M_start._M_p, 0); }
      |       ^
/usr/include/c++/14/bits/stl_bvector.h:1006:7: error: return type 'std::vector<bool, _Alloc>::iterator' is incomplete
 1006 |       { return this->_M_impl._M_finish; }
      |       ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h: In instantiation of 'class std::reverse_iterator<std::_Bit_iterator>':
/usr/include/c++/14/bits/stl_bvector.h:1016:7:   required from here
 1016 |       { return reverse_iterator(end()); }
      |       ^
/usr/include/c++/14/bits/stl_iterator.h:129:11: error: no type named 'iterator_category' in 'struct std::iterator_traits<std::_Bit_iterator>'
  129 |     class reverse_iterator
      |           ^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:148:17: error: 'std::reverse_iterator<_Iterator>::current' has incomplete type
  148 |       _Iterator current;
      |                 ^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:465:10: note: forward declaration of 'struct std::_Bit_iterator'
  465 |   struct _Bit_iterator;
      |          ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:154:57: error: no type named 'pointer' in 'std::reverse_iterator<std::_Bit_iterator>::__traits_type' {aka 'struct std::iterator_traits<std::_Bit_iterator>'}
  154 |       typedef typename __traits_type::pointer           pointer;
      |                                                         ^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:156:57: error: no type named 'difference_type' in 'std::reverse_iterator<std::_Bit_iterator>::__traits_type' {aka 'struct std::iterator_traits<std::_Bit_iterator>'}
  156 |       typedef typename __traits_type::difference_type   difference_type;
      |                                                         ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:157:57: error: no type named 'reference' in 'std::reverse_iterator<std::_Bit_iterator>::__traits_type' {aka 'struct std::iterator_traits<std::_Bit_iterator>'}
  157 |       typedef typename __traits_type::reference         reference;
      |                                                         ^~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h: In member function 'std::vector<bool, _Alloc>::size_type std::vector<bool, _Alloc>::max_size() const':
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:7:13: error: expected primary-expression before 'long'
    7 | #define int long long
      |             ^~~~
a.cc:7:13: error: expected ')' before 'long'
/u