Language: C++

#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;
typedef vector<int> vi;

int cnt[202020] = {0};

ll mlpow(ll x, ll p, ll mod) { //x^p(long long)%MOD
    ll tmp = 1;
    if(p == 0) return 1;
    //繰り返し二乗法
    while(p != 0) {
        if(p & 1) tmp = tmp*x % mod;
        x = x*x % mod;
        p = p >> 1;
    }
    return tmp;
}

int main() {
    int N; cin >> N;
    string X; cin >> X;
    queue<ll> ans;

    cnt[0] = 0; cnt[1] = 1;
    int pcnt = 0;
    ll ssum = 0, dsum = 0;
    rep(i, N-1) cnt[i+2] = cnt[(i+2)%__builtin_popcount(i+2)]+1;
    rep(i, N) if(X[i] == '1') pcnt++;

    if(pcnt == 0){
        rep(i,N) ans.push(1);
    }else if(pcnt == 1){
        rep(i,N) if(X[i] == '1') ssum = mlpow(2, N-1-i, 2);
        rep(i,N){
            if(X[i] == '1') ans.push(0);
            else{
                ans.push(cnt[(ssum+mlpow(2, N-1-i, 2))%2]+1);
            }
        }
    }else{
        rep(i,N){
            if(X[i] == '1') {
                ssum += mlpow(2, N-1-i, pcnt+1);
                ssum %= pcnt+1;
                dsum += mlpow(2, N-1-i, pcnt-1);
                dsum %= pcnt-1;
            }     
        }
        rep(i,N){
            if(X[i] == '1'){
                ans.push(cnt[(dsum-mlpow(2, N-1-i, pcnt-1)+pcnt-1)%(pcnt-1)]+1);
            }else{
                ans.push(cnt[(ssum+mlpow(2, N-1-i, pcnt+1))%(pcnt+1)]+1);
            }
        }
    }

    while(!ans.empty()) {
        cout << ans.front() << "\n";
        ans.pop();
    }
    return 0;
}


Compiler output:
a.cc:9:1: error: 'll' does not name a type
    9 | ll mlpow(ll x, ll p, ll mod) { //x^p(long long)%MOD
      | ^~
a.cc: In function 'int main()':
a.cc:24:11: error: 'll' was not declared in this scope
   24 |     queue<ll> ans;
      |           ^~
a.cc:24:13: error: template argument 1 is invalid
   24 |     queue<ll> ans;
      |             ^
a.cc:24:13: error: template argument 2 is invalid
a.cc:28:7: error: expected ';' before 'ssum'
   28 |     ll ssum = 0, dsum = 0;
      |       ^~~~~
      |       ;
a.cc:29:9: error: expected ';' before 'i'
   29 |     rep(i, N-1) cnt[i+2] = cnt[(i+2)%__builtin_popcount(i+2)]+1;
      |         ^
a.cc:2:29: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                             ^
a.cc:29:5: note: in expansion of macro 'rep'
   29 |     rep(i, N-1) cnt[i+2] = cnt[(i+2)%__builtin_popcount(i+2)]+1;
      |     ^~~
a.cc:29:9: error: 'i' was not declared in this scope
   29 |     rep(i, N-1) cnt[i+2] = cnt[(i+2)%__builtin_popcount(i+2)]+1;
      |         ^
a.cc:2:36: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                                    ^
a.cc:29:5: note: in expansion of macro 'rep'
   29 |     rep(i, N-1) cnt[i+2] = cnt[(i+2)%__builtin_popcount(i+2)]+1;
      |     ^~~
a.cc:30:9: error: expected ';' before 'i'
   30 |     rep(i, N) if(X[i] == '1') pcnt++;
      |         ^
a.cc:2:29: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                             ^
a.cc:30:5: note: in expansion of macro 'rep'
   30 |     rep(i, N) if(X[i] == '1') pcnt++;
      |     ^~~
a.cc:30:9: error: 'i' was not declared in this scope
   30 |     rep(i, N) if(X[i] == '1') pcnt++;
      |         ^
a.cc:2:36: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                                    ^
a.cc:30:5: note: in expansion of macro 'rep'
   30 |     rep(i, N) if(X[i] == '1') pcnt++;
      |     ^~~
a.cc:33:13: error: expected ';' before 'i'
   33 |         rep(i,N) ans.push(1);
      |             ^
a.cc:2:29: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                             ^
a.cc:33:9: note: in expansion of macro 'rep'
   33 |         rep(i,N) ans.push(1);
      |         ^~~
a.cc:33:13: error: 'i' was not declared in this scope
   33 |         rep(i,N) ans.push(1);
      |             ^
a.cc:2:36: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                                    ^
a.cc:33:9: note: in expansion of macro 'rep'
   33 |         rep(i,N) ans.push(1);
      |         ^~~
a.cc:33:22: error: request for member 'push' in 'ans', which is of non-class type 'int'
   33 |         rep(i,N) ans.push(1);
      |                      ^~~~
a.cc:35:13: error: expected ';' before 'i'
   35 |         rep(i,N) if(X[i] == '1') ssum = mlpow(2, N-1-i, 2);
      |             ^
a.cc:2:29: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                             ^
a.cc:35:9: note: in expansion of macro 'rep'
   35 |         rep(i,N) if(X[i] == '1') ssum = mlpow(2, N-1-i, 2);
      |         ^~~
a.cc:35:13: error: 'i' was not declared in this scope
   35 |         rep(i,N) if(X[i] == '1') ssum = mlpow(2, N-1-i, 2);
      |             ^
a.cc:2:36: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                                    ^
a.cc:35:9: note: in expansion of macro 'rep'
   35 |         rep(i,N) if(X[i] == '1') ssum = mlpow(2, N-1-i, 2);
      |         ^~~
a.cc:35:34: error: 'ssum' was not declared in this scope
   35 |         rep(i,N) if(X[i] == '1') ssum = mlpow(2, N-1-i, 2);
      |                                  ^~~~
a.cc:35:41: error: 'mlpow' was not declared in this scope; did you mean 'pow'?
   35 |         rep(i,N) if(X[i] == '1') ssum = mlpow(2, N-1-i, 2);
      |                                         ^~~~~
      |                                         pow
a.cc:36:13: error: expected ';' before 'i'
   36 |         rep(i,N){
      |             ^
a.cc:2:29: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                             ^
a.cc:36:9: note: in expansion of macro 'rep'
   36 |         rep(i,N){
      |         ^~~
a.cc:36:13: error: 'i' was not declared in this scope
   36 |         rep(i,N){
      |             ^
a.cc:2:36: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                                    ^
a.cc:36:9: note: in expansion of macro 'rep'
   36 |         rep(i,N){
      |         ^~~
a.cc:37:33: error: request for member 'push' in 'ans', which is of non-class type 'int'
   37 |             if(X[i] == '1') ans.push(0);
      |                                 ^~~~
a.cc:39:21: error: request for member 'push' in 'ans', which is of non-class type 'int'
   39 |                 ans.push(cnt[(ssum+mlpow(2, N-1-i, 2))%2]+1);
      |                     ^~~~
a.cc:39:31: error: 'ssum' was not declared in this scope
   39 |                 ans.push(cnt[(ssum+mlpow(2, N-1-i, 2))%2]+1);
      |                               ^~~~
a.cc:39:36: error: 'mlpow' was not declared in this scope; did you mean 'pow'?
   39 |                 ans.push(cnt[(ssum+mlpow(2, N-1-i, 2))%2]+1);
      |                                    ^~~~~
      |                                    pow
a.cc:43:13: error: expected ';' before 'i'
   43 |         rep(i,N){
      |             ^
a.cc:2:29: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                             ^
a.cc:43:9: note: in expansion of macro 'rep'
   43 |         rep(i,N){
      |         ^~~
a.cc:43:13: error: 'i' was not declared in this scope
   43 |         rep(i,N){
      |             ^
a.cc:2:36: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                                    ^
a.cc:43:9: note: in expansion of macro 'rep'
   43 |         rep(i,N){
      |         ^~~
a.cc:45:17: error: 'ssum' was not declared in this scope
   45 |                 ssum += mlpow(2, N-1-i, pcnt+1);
      |                 ^~~~
a.cc:45:25: error: 'mlpow' was not declared in this scope; did you mean 'pow'?
   45 |                 ssum += mlpow(2, N-1-i, pcnt+1);
      |                         ^~~~~
      |                         pow
a.cc:47:17: error: 'dsum' was not declared in this scope
   47 |                 dsum += mlpow(2, N-1-i, pcnt-1);
      |                 ^~~~
a.cc:51:13: error: expected ';' before 'i'
   51 |         rep(i,N){
      |             ^
a.cc:2:29: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                             ^
a.cc:51:9: note: in expansion of macro 'rep'
   51 |         rep(i,N){
      |         ^~~
a.cc:51:13: error: 'i' was not declared in this scope
   51 |         rep(i,N){
      |             ^
a.cc:2:36: note: in definition of macro 'FOR'
    2 | #define FOR(i, l, r) for(ll i = l; i < r; i++)
      |                                    ^
a.cc:51:9: note: in expansion of macro 'rep'
   51 |         rep(i,N){
      |         ^~~
a.cc:53:21: error: request for member 'push' in 'ans', which is of non-class type 'int'
   53 |                 ans.push(cnt[(dsum-mlpow(2, N-1-i, pcnt-1)+pcnt-1)%(pcnt-1)]+1);
      |                     ^~~~
a.cc:53:31: error: 'dsum' was not declared in this scope
   53 |                 ans.push(cnt[(dsum-mlpow(2, N-1-i, pcnt-1)+pcnt-1)%(pcnt-1)]+1);
      |                               ^~~~
a.cc:53:36: error: 'mlpow' was not declared in this scope; did you mean 'pow'?
   53 |                 ans.push(cnt[(dsum-mlpow(2, N-1-i, pcnt-1)+pcnt-1)%(pcnt-1)]+1);
      |                                    ^~~~~
      |                                    pow
a.cc:55:21: error: request for member 'push' in 'ans', which is of non-class type 'int'
   55 |                 ans.push(cnt[(ssum+mlpow(2, N-1-i, pcnt+1))%(pcnt+1)]+1);
      |                     ^~~~
a.cc:55:31: error: 'ssum' was not declared in this scope
   55 |                 ans.push(cnt[(ssum+mlpow(2, N-1-i, pcnt+1))%(pcnt+1)]+1);
      |                               ^~~~
a.cc:55:36: error: 'mlpow' was not declared in this scope; did you mean 'pow'?
   55 |                 ans.push(cnt[(ssum+mlpow(2, N-1-i, pcnt+1))%(pcnt+1)]+1);
      |                                    ^~~~~
      |                                    pow
a.cc:60:16: error: request for member 'empty' in 'ans', which is of non-class type 'int'
   60 |     while(!ans.empty()) {
      |                ^~~~~
a.cc:61:21: error: request for member 'front' in 'ans', which is of non-class type 'int'
   61 |         cout << ans.front() << "\n";
      |                     ^~~~~
a.cc:62:13: error: request for member 'pop' in 'ans', which is of non-class type 'int'
   62 |         ans.pop();
      |             ^~~