Language: C++

#include<iostream>

// change
const int MOD = 1000000007;

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    /*
    n>>=1;
    */
   n/=2;
  }

  return ans;
}

void Solve();


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}



/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はN-1
void Solve(){
  int n;
  scanf("%d",&n);
  char s[n+10];
  scanf("%s",s);
 
  int count=0;
  for(int i=n-1;i>=0;i--){
    if(s[i]=='1'){
      count++;
    }
  }
 
  int prep=0;
  int prem=0;
 
  int now=1;
  for(int i=n-1;i>=0;i--){
    int a=s[i]-'0';
    prep+=now*a;
    prep%=(count+1);
    now*=2;
    now%=(count+1);
  }
  now=1;
 
  if(count>1){
    for(int i=n-1;i>=0;i--){
      int a=s[i]-'0';
      prem+=now*a;
      prem%=(count-1);
      now*=2;
      now%=(count-1);
    }
  }
 
  for(int i=0;i<n;i++){
    int x=0;
    int ans=1;
    if(s[i]=='0'){
      x=prep;
      x+=modpow(2,n-1-i,count+1);
      x%=(count+1);
    }
    else if(count==1 && s[i]=='1'){
      printf("0\n");
      continue;
    }
    else{
      x=prem;
      x-=modpow(2,n-1-i,count-1);
      x+=2*(count-1);
      x%=(count-1);
    }
 
    int past=x;
    int cnt=0;
    while(past!=0){
      cnt=0;
      x=past;
      while(x!=0){
        if(x%2==1){
          cnt++;
        }
        x/=2;
      }
 
      if(cnt==0){
        ans++;
        break;
      }
      past=past%cnt;
      ans++;
    }
 
    printf("%d\n",ans);
  }
}

Compiler output:
a.cc:6:1: error: 'll' does not name a type
    6 | ll modpow(ll a,ll n,ll mod){
      | ^~
a.cc: In function 'int main()':
a.cc:27:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   27 |   cin.tie(0);
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:28:3: error: 'ios' has not been declared
   28 |   ios::sync_with_stdio(false);
      |   ^~~
a.cc:29:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |   cout<<setprecision(20)<<fixed;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:29:9: error: 'setprecision' was not declared in this scope
   29 |   cout<<setprecision(20)<<fixed;
      |         ^~~~~~~~~~~~
a.cc:29:27: error: 'fixed' was not declared in this scope; did you mean 'std::fixed'?
   29 |   cout<<setprecision(20)<<fixed;
      |                           ^~~~~
      |                           std::fixed
In file included from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/ios_base.h:1104:3: note: 'std::fixed' declared here
 1104 |   fixed(ios_base& __base)
      |   ^~~~~
a.cc: In function 'void Solve()':
a.cc:82:10: error: 'modpow' was not declared in this scope
   82 |       x+=modpow(2,n-1-i,count+1);
      |          ^~~~~~
a.cc:91:10: error: 'modpow' was not declared in this scope
   91 |       x-=modpow(2,n-1-i,count-1);
      |          ^~~~~~