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

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second


int count(ll n) {
  int ans = 0;
  while (n != 0) {
    if (n % 2 == 1) ans ++;
    n /= 2;
  }
  return ans;
}

int func(ll n) {
  return n % count(n);
}

int solve(ll n) {
  int ans = 1;
  while (true) {
    ll tmp = func(n);
    n = tmp;
    if (n == 0) break;
    else ans++;
  }
  return ans;
}

int num2num(string s) {
  int tmp = 1, ans = 0;
  REPD(i,SIZE(s)) {
    if (s[i] == '1') ans += tmp;
    tmp *= 2;
  }
  return ans;
}

int main(int argc, char const *argv[]) {
  int n; cin >> n;
  string s; cin >> s;
  REP(i,n) {
    string tmp = s;
    if (tmp[i] == '1') tmp[i] = '0';
    else tmp[i] = '1';
    int num = num2num(tmp);
    cout << solve(num) << endl;
  }

  return 0;
}
(b

Compiler output:
a.cc:69:3: error: expected ')' at end of input
   69 | (b
      | ~ ^
      |   )
Language: C++

#include<iostream> 
#include<string>
using namespace std; 
  
int toggleKthBit(int n, int k,int times) 
{ 
    return (n ^ (1 << (times-k))); 
} 
  
int fvalues(int n){
  int count=0;
  while(n){
	n=n%_builtin__popcount(n);
    count++;
  }
  return count;
	
}
int main(){
string s;
  int times;
  cin>>times;
cin>>s; // Suppose s = "100100101"
int number = stoi(s, 0, 2);
  for(int i=1;i<(times+1);i++)
  {
	int t=toggleKthBit(number, i, times);
    cout<<fvalues(t)<<endl;
  }
}


Compiler output:
a.cc: In function 'int fvalues(int)':
a.cc:13:13: error: '_builtin__popcount' was not declared in this scope; did you mean '__builtin_popcount'?
   13 |         n=n%_builtin__popcount(n);
      |             ^~~~~~~~~~~~~~~~~~
      |             __builtin_popcount
Language: C++

#include<iostream> 
#include<string>
using namespace std; 
  
int toggleKthBit(int n, int k,int times) 
{ 
    return (n ^ (1 << (times-k))); 
} 
  
int fvalues(int n){
  int count=0;
  while(n){
	n=n%__builtin__popcount(n);
    count++;
  }
  return count;
	
}
int main(){
string s;
  int times;
  cin>>times;
cin>>s; // Suppose s = "100100101"
int number = stoi(s, 0, 2);
  for(int i=1;i<(times+1);i++)
  {
	int t=toggleKthBit(number, i, times);
    cout<<fvalues(t)<<endl;
  }
}

Compiler output:
a.cc: In function 'int fvalues(int)':
a.cc:13:13: error: '__builtin__popcount' was not declared in this scope; did you mean '__builtin_popcount'?
   13 |         n=n%__builtin__popcount(n);
      |             ^~~~~~~~~~~~~~~~~~~
      |             __builtin_popcount
Language: C++

#include <bits/stdc++.h>
using namespace std;
int64_t ni(int64_t x){
  int64_t y;
  y=0;
while(x!=0){if(x%2==1){y++;}
           x=x/2;}
  return y;
}
int64_t san(int64_t z){
  int64_t v;
  v=0;
while(z!=0){z=z%ni(z);
           v++;}
  return v;
}

int main() {
int64_t n,a,ans;
  a=0;
  cin>>n;
  vector<char> kari(n);
  vector<int64_t> vec(n);
  vector<int64_t> an(n);
 for(int64_t i=0;i<n;i++){
 cin>>kari.at(i);
 }
 for(int64_t i=0;i<n;i++){
 if(kari.at(i)=='0'){vec.at(i)=0;}
    if(kari.at(i)=='1'){vec.at(i)=1;
                       a++;}
 } 
  int64_t b=a-1;
  int64_t c=a+1;
vector<int64_t> rb(n);
vector<int64_t> rc(n);
  rb.at(n-1)=1;
   rc.at(n-1)=1;
for(int64_t i=0;i<n-1;i++){
rb.at(n-2-i)=(rb.at(n-1-i)*2)%b;
}
for(int64_t i=0;i<n-1;i++){
rc.at(n-2-i)=(rc.at(n-1-i)*2)%c;
} 
for(int64_t i=0;i<n;i++){
  for(int64_t j=0;j<n;j++){
    if(j!=i){an.at(j)=vec.at(i);}
    else{an.at(j)=1-vec.at(i);}
  }
  ans=0;
  if(vec.at(i)==1){
    for(int64_t k=0;k<n;k++){
      if(an.at(k)==1){
        ans=(ans+rb.at(k))%b;
      }
    }
  cout<<san(ans)+1<<endl;
  }
  if(vec.at(i)==0){
    for(int64_t k=0;k<n;k++){
      if(an.at(k)==1){
        ans=(ans+rc.at(k))%c;
      }
    }
  cout<<san(ans)+1<<endl;
  }
}

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

#include <bits/stdc++.h>
#define ll long long
inline ll binToUInt(const std::string& str)
{
    ll val = 0;
    for (int i = 0; i < (int)str.size(); ++i) {
        switch (str[i]) {
        case '0':
            val *= 2;
            break;
        case '1':
            val = val * 2 + 1;
            break;
        }
    }
    return val;
}
int main()
{
    ll n;
    ll x;
    std::string y;
    std::cin >> n >> y;


    //std::cout << y << std::endl;


    x = binToUInt(y);
    //std::cout << x << std::endl;
    inline auto rev = [&](const ll& i) {
        if (x & (1 << i)) {
            return x - static_cast<ll>(std::pow<ll>(2, i));
        } else {
            return x + static_cast<ll>(std::pow<ll>(2, i));
        }
    };
    inline auto popcount = [&](const ll& rever) {
        ll temp_1 = 0;
        for (ll i = 0; i < n; ++i) {
            if (rever & (1 << i)) {
                ++temp_1;
            }
        }
        return temp_1;
    };
    for (ll i = 1; i <= n; ++i) {
        ll temp_0 = rev(n - i);
        //std::cout << "f0"<< " " << temp_0 << std::endl;
        ll temp_2 = 0;
        while (temp_0 > 0) {
            temp_0 = temp_0 % popcount(temp_0);
            ++temp_2;
            // std::cout << "f" << temp_2 << " " << temp_0 << std::endl;
        }
        std::cout << temp_2 << std::endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:5: error: 'inline' specifier invalid for variable 'rev' declared at block scope
   31 |     inline auto rev = [&](const ll& i) {
      |     ^~~~~~
a.cc:38:5: error: 'inline' specifier invalid for variable 'popcount' declared at block scope
   38 |     inline auto popcount = [&](const ll& rever) {
      |     ^~~~~~
Language: C++

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

string binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return to_string(ans);
}

void f(string x, int p){
  int c=0;
  x.at(p) = (x.at(p)+1)%2;  
  while(x!="0"){
    int l = 0,cc=0;
		for (int i= 0; i<x.length(); i++) {
 			 l *= 2;
 			 l = l + x.at(i);
          if(x.at(i)=='1')	cc++;
		}
    x = binary(l%cc)
    c++;
  }
  cout << c << endl;
}

int main() {
  int n;
  cin >> n;
  string x;
  cin >> x;
  for(int i=0;i<n;i++){
    f(x,i);
  }
  return 0;
}

Compiler output:
a.cc: In function 'void f(std::string, int)':
a.cc:24:21: error: expected ';' before 'c'
   24 |     x = binary(l%cc)
      |                     ^
      |                     ;
   25 |     c++;
      |     ~
Language: Java

import java.lang.*;
import java.util.scanner.*;
public class task{

   public static void main(String[] args) {
scanner sc=new scanner(system.in);
     
      int n=sc.nextInt();
     int count=0;
 
      System.out.println(Integer.toBinaryString(n)); 
      System.out.println(Integer.bitCount(n)); 
     do(n--!=0){
       int remainder=Integer.toBinaryString(i)/Integer.bitCount(i);
       count++;
       while(remainder==0);
       system.out.println(count);
   } 
} 

Compiler output:
Main.java:13: error: not a statement
     do(n--!=0){
       ^
Main.java:13: error: ';' expected
     do(n--!=0){
               ^
Main.java:19: error: reached end of file while parsing
} 
 ^
3 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)

ll modpow(ll a, ll n, ll modd = 1e9 + 7) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % modd;
        a = a * a % modd;
        n >>= 1;
    }
    return res;
}

int popcnt(int num) {
    int ans = 0;
    while (num > 0) {
        num &= num - 1;
        ans++;
    }
    return ans;
}

int filler(int num, int modd) {
    if (modd == 0) {
        return 0;
    }
    int res = num % modd;
    return filler(res, popcnt(res)) + 1;
}

int main() {
    int n;
    string x;
    cin >> n >> x;
    int basemod = 0;
    int onebase = 0;
    int zerobase = 0;
    rep(i, n) if (x[i] == '1') basemod++;
    if(basemod == 0){
        rep(i,n){
            cout << 1 << endl;
        }
        return 0;
    }
    rep(i, n) {
        if (x[i] == '1') {
            onebase += modpow(2, n - i - 1, basemod + 1);
            zerobase += modpow(2, n - i - 1, basemod - 1);
        }
    }
    rep(i, n) {
        int modthis = basemod;
        if (x[i] == '1') {
            int before = zerobase;
            modthis--;
            if(modthis == 0){
                cout << 0 << endl;
                continue;
            }
            if(modthis == 1){
                cout << 1 << endl;
                continue;
            }
            toadd = modpow(2, n - i - 1, modthis);
            zerobase -= toadd;
            if (zerobase < 0) zerobase += modthis;
            cout << filler(zerobase, modthis) << endl;
            zerobase = before;
        } else {
            int before = onebase;
            modthis++;
            if(modthis == 1){
                cout << 1 << endl;
                continue;
            }
            toadd = modpow(2, n - i - 1, modthis);
            onebase += toadd;
            onebase %= modthis;
            cout << filler(onebase, modthis) << endl;
            onebase = before;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:13: error: 'toadd' was not declared in this scope
   67 |             toadd = modpow(2, n - i - 1, modthis);
      |             ^~~~~
a.cc:79:13: error: 'toadd' was not declared in this scope
   79 |             toadd = modpow(2, n - i - 1, modthis);
      |             ^~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Rec(int x){  
  static int mem[200001];
  static int used[200001];
  if(used[x])return mem[x];
  used[x] = 1;
  if(x == 0)return 0;
  int cnt = __builtin_popcount(x);
  return mem[x]=Rec(x%cnt)+1;
}


int main(){
  int n;
  cin >> n;
  string s; cin >> s;
  int cnt = 0;
  for(int i = 0; i < n; ++i)cnt += s[i] == '1';
  int cnti = cnt+1;
  int cntd = cnt-1;
  int xi = 0,xd = 0, yi = 1 , yd = 1;
  int xx = 0,yy = 1;
  for(int i = n-1; i >= 0; --i){
    if(s[i] == '1'){
      xx += yy;
      xi = (xi+yi)%cnti;
      (cntd>0)xd = (xd+yd)%cntd;
    }
    yi = (yi*2)%cnti;
    (cntd>0)yd = (yd*2)%cntd;
    yy = yy*2;
  }
  yi = yd = 1;
  vector<int>ans; 
  for(int i = n-1; i >= 0; --i){
    if(s[i] == '1'){
      if(cntd == 0){
	ans.push_back(0);
      }else{
	int x = (xd + cntd - yd)%cntd;
	ans.push_back(Rec(x)+1);
      }
    }else{
      int x = (xi + yi)%cnti;
      ans.push_back(Rec(x)+1);
    }
    yi = (yi*2)%cnti;
    yd = (yd*2)%cntd;
  }
  for(int i = n-1; i >= 0; --i){
    cout << ans[i] << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:15: error: expected ';' before 'xd'
   63 |       (cntd>0)xd = (xd+yd)%cntd;
      |               ^~
      |               ;
a.cc:66:13: error: expected ';' before 'yd'
   66 |     (cntd>0)yd = (yd*2)%cntd;
      |             ^~
      |             ;
Language: C++

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


int main() {
  int64_t N;
  string X;
  cin>>N>>X;
  int64_t sum=0;
  for(int i=1;i<=N;i++){
    int64_t a=X.at(N-i)-'0';
    sum+=a*pow(2,i-1);
  }
  for(int i=0;i<N;i++){
    int64_t moto=sum;
    if(X.at(i)-'0'==0) moto+=(int64_t)pow(2,N-i-1);
    else moto-=(int64_t)pow(2,N-i-1);
    int64_t kai=0;
    while(moto!=0){
        int64_t t = moto;
    	t -= (t >> 1) & 0x55555555;
    	t = (t & 0x33333333) + ((t >> 2) & 0x33333333);
    	t = (t + (t >> 4)) & 0x0f0f0f0f;
    	t += t >> 8;
    	t += t >> 16;
    	t &= 0x3f;
    	moto=moto%t;
   	    kai++;
    }
    cout<<kai<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:31:4: error: expected '}' at end of input
   31 |   }
      |    ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

 
#ifndef ONLINE_JUDGE
#define trace(...) _f(#__VA_ARGS_, _VA_ARGS_)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
const int N = 4e5 + 5;
const int MAX = 250000 + 5;
const int M = 3e5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e18;
const int LG = 21;
vector<int> v;
int cache[N];
int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int f(int no)
{
	if(no == 0) return 0;
	int ret = 0;
	for(int i = 0; i < v.size(); i++)
	{
		ret += v[i] * pow(2, v.size() - i - 1, no);
		ret %= no;
	}
	return ret;
}
int dp(int no)
{
	if(no == 0)
	{
		return 0;
	}
	if(cache[no] != -1)
	{
		return cache[no];
	}
	int tot = __builtin_popcount(no);
	return cache[no] = 1 + dp(no % tot);
}
void solve()
{
	int n;
	cin >> n;
	int cnt = 0;
	memset(cache, -1, sizeof(cache));
	int no = 0;
	for(int i = 0; i < n; i++)
	{
		char ch;
		cin >> ch;
		v.push_back(ch - '0');
		cnt += v.back();
		if(ch == '0') continue;
	}
	int plus = cnt + 1;
	int minus = max(cnt - 1, 0LL);
	int plusans = f(plus);
	int minusans = f(minus);
	for(int i = 0; i < n; i++)
	{
		if(v[i] == 0)
		{
			int curr = plusans + pow(2, n - i - 1, plus) + plus;
			curr %= plus;
			cout << 1 + dp(curr) << endl;
		}
		else
		{
			if(minus == 0LL)
			{
				cout << 0 << endl;
				continue;
			}
			int curr = minusans - pow(2, n - i - 1, minus) + minus;
			curr %= minus;
			cout << 1 + dp(curr) << endl;
		}
	}
}
int32_t main() 
{	
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Compiler output:
a.cc:18:18: error: '#' is not followed by a macro parameter
   18 | #define trace(...) _f(#__VA_ARGS_, _VA_ARGS_)
      |                  ^
Language: C++

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

long long binary(long long bina){
    long long ans = 0;
    for (long long i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

long long main() {
    long long n,count =0,ans = 0;
    string a;
    cin >> n >>a;
    string b = a;
    for (long long i = 0; i < n; i++){
        a = b;
        ans = 0;
        if(a.at(i) == '0')a.at(i) = '1';
        else if(a.at(i) == '1')a.at(i) = '0';
        bool flag = 0;
        for (long long i = 0; i < a.size(); i++){
            if(a.at(i) == '1'){
                flag = 0;
                break;
            }
            flag = 1;    
        }
        if(flag){
            cout << 0 << endl;
            continue;
        }
        long long x = stoi(a , 0, 2);
        while(1){
            for (long long i = 0; i < a.size(); i++){
                if(a.at(i) == '1')count ++;
            }
            x %= count;
            ans++;
            count = 0;
            if(x == 0)break;
            a = to_string(binary(x));
        }
        cout << ans << endl;
    }
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
ll A=0,B=0,N,x;
ll Q(ll&i,string&S,vector<ll>&F,vector<ll>&G){
  if(S.at(i)=='0')return (A+F.at(i))%(x+1);
  return ((B-G.at(i))%(x-1)+x-1)%(x-1);
}
ll f(ll m){
  if(m==0)return 0;
  ll i=0,n=m;
  while(n>0){
    if(n%2==1)i++;
    n/=2;
  }
  return 1+f(m%i);
}
signed main(){
  ll i,s=1;string S,T;cin>>N>>S;
  T=S;sort(ALL(T));
  x=upper_bound(ALL(T),'0')-T.begin();
  x=N-x;vector<ll>F(N);
  REP(i,N){
    F.at(N-1-i)=s;
    if(S.at(N-1-i)=='1')A+=s;
    s*=2;s%=x+1;A%=x+1;
  }
  s=1;vector<ll>G(N);
  if(x<=1){
    REP(i,N)G.at(i)=-1;
  }
 else REP(i,N){
    G.at(N-1-i)=s;
    if(S.at(N-1-i)=='1')B+=s;
    s*=2;s%=x-1;B%=x-1;
  }
  REP(i,N){
    if(x==1&&S.at(i)=='0')cout<<0<<endl;
    else{
      ll RES=Q(i,S,F,G);
      cout<<1+f(RES)<<endl;
    }
  }
  return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:50:12: error: expected '}' at end of input
   50 |   return 0;
      |            ^
a.cc:24:14: note: to match this '{'
   24 | signed main(){
      |              ^
Language: C++

def pop(x):
    c = 0
    while x != 0:
        b = sum(i == '1' for i in format(x,'b'))
        x = x%b
        c += 1
    return c

n = int(input())
x = input()
for i in range(n):
    a = x[:i] + '1' + x[i+1:] if x[i] == '0' else x[:i] + '0' + x[i+1:]
    print(pop(int(a,2)))


Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def pop(x):
      | ^~~
Language: C++

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

int main(){
    int N;
    string X;
    cin >> N >> X;
    for (int i=0; i<N; i++) {
      int twocount = 0;
      int num = 0;
      for (int j=0; j<N; j++) {
        if (X.at(j)=='1' || (i==j && X.at(j)=='0')) {
          int twos = 1;
          for (int k=0; k<j ; k++) {
            twos *= 2;
            twocount++;
          }
          num += twos;
        }
      }
      int fn = 0;
      while(num!=0) {
        num %= twocount;
        fn++;
      }
      cout << fn << endl;
}

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

#include <bits/stdc++.h>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000



void solve_abc_d() {
	ll n, m;
	//ll a, b;
	ll x, y;
	ll k;
	string s;
	ll l_ans = 0;

	cin >> n >> s;

	bitset<200005> bs(s);


	bitset<200005> bs_conv;
	V ans(n);

	ll cnt;
	ll xc;
	rep(i, n) {
		bs_conv = bs;
		bs_conv[i] = !bs_conv[i];

		cnt = 0;
		xc = bs_conv.to_ullong();
		while (1) {
			xc = xc % bs_conv.count();
			cnt++;
			if (xc == 0) {
				ans[i] = cnt;
				break;
			}
			bs_conv = bitset<20005>(xc);
		}
	}

	reverse(ALL(ans));
	rep(i, n) {
		cout << ans[i] << "\n";
	}

	return;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_d();

	return 0;
}


Compiler output:
a.cc: In function 'void solve_abc_d()':
a.cc:52:51: error: no match for 'operator=' (operand types are 'std::bitset<200005>' and 'std::bitset<20005>')
   52 |                         bs_conv = bitset<20005>(xc);
      |                                                   ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bitset:804:11: note: candidate: 'constexpr std::bitset<200005>& std::bitset<200005>::operator=(const std::bitset<200005>&)'
  804 |     class bitset
      |           ^~~~~~
/usr/include/c++/14/bitset:804:11: note:   no known conversion for argument 1 from 'std::bitset<20005>' to 'const std::bitset<200005>&'
/usr/include/c++/14/bitset:804:11: note: candidate: 'constexpr std::bitset<200005>& std::bitset<200005>::operator=(std::bitset<200005>&&)'
/usr/include/c++/14/bitset:804:11: note:   no known conversion for argument 1 from 'std::bitset<20005>' to 'std::bitset<200005>&&'
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <sstream>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int sto(string str) {
	int ret;
	stringstream ss;
	ss << str;
	ss >> ret;
	return ret;
}

int popcounter(int i) {
	stringstream ss;
	ss << bitset<sizeof(int) * CHAR_BIT>(i);
	string s = ss.str();
	return count(s.begin(), s.end(), '1');
}

int main() {

	int n;
	string x;
	cin >> n >> x;

	string y = x;

	for (int i = 0;i < x.size();i++) {
		string tmp = x;
		if (tmp[i] == '0')tmp[i] = '1';
		else tmp[i] = '0';
		//cout << tmp << endl;
		int popcount = count(tmp.begin(), tmp.end(), '1');
		int p = stoi(tmp,0,2);
		int ans = 0;

		
		//cout << popcount << endl;
		//cout << p << endl;
		while (1) {
			ans++;
			p = p % popcounter(p);
			if (p == 0)break;
		}
		cout << ans << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int popcounter(int)':
a.cc:27:36: error: 'CHAR_BIT' was not declared in this scope
   27 |         ss << bitset<sizeof(int) * CHAR_BIT>(i);
      |                                    ^~~~~~~~
a.cc:13:1: note: 'CHAR_BIT' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <bitset>
  +++ |+#include <climits>
   13 | #define rep(i,n) for(int i=0;i<(n);i++)
a.cc:27:44: error: template argument 1 is invalid
   27 |         ss << bitset<sizeof(int) * CHAR_BIT>(i);
      |                                            ^
Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <bit>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

const int MAX_N = 200011;
vector<int> C;

int divide(string &X, int m) {
    int ans = 0;
    rep(i, X.size()) {
        ans *= 2;
        ans += X[i] - '0';
        ans %= m;
    }
    return ans;
}

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    string X;
    cin >> N >> X;
    
    C.assign(MAX_N, -1);
    C[0] = 0;
    rep(i, 1, MAX_N) {
        int pcnt = (int)bitset<32>(i).count();
        C[i] = 1 + C[i % pcnt];
    }
    
    auto x = bitset<MAX_N>(X);
    int xpcnt = (int)x.count();
    
    int mod_neg = 0;
    if (xpcnt > 0) mod_neg = divide(X, xpcnt - 1);
    int mod_pos = divide(X, xpcnt + 1);
    
    for(int i = N - 1; i >= 0; i--){
        if(x[i] == 0) {
            int m = (mod_pos + pow_mod(2, i, xpcnt + 1)) % (xpcnt + 1);
            output(1 + C[m]);
        }
        else {
            int m = (mod_neg - pow_mod(2, i, xpcnt - 1) + xpcnt - 1) % (xpcnt - 1);
            output(1 + C[m]);
        }
        
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:25: error: 'bitset' was not declared in this scope
   69 |         int pcnt = (int)bitset<32>(i).count();
      |                         ^~~~~~
a.cc:12:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   11 | #include <map>
  +++ |+#include <bitset>
   12 | #include <sstream>
a.cc:69:39: error: request for member 'count' in 'i', which is of non-class type 'int'
   69 |         int pcnt = (int)bitset<32>(i).count();
      |                                       ^~~~~
a.cc:73:14: error: 'bitset' was not declared in this scope
   73 |     auto x = bitset<MAX_N>(X);
      |              ^~~~~~
a.cc:73:14: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
ll A=0,B=0,N,x;
ll Q(ll&i,string&S,vector<ll>&F,vector<ll>&G){
  string T=S;
  sort(ALL(T));
  if(T.at(N-1)=='0')return -1;
  if(S.at(i)=='0')return (A+F.at(i))%(x+1);
  if(G.at(i)==-1)return 0;
  return ((B-G.at(i))%(x-1)+x-1)%(x-1);
}
ll f(ll m){
  if(m==0)return 0;
  ll i=0,n=m;
  while(n>0){
    if(n%2==1)i++;
    n/=2;
  }
  return 1+f(m%i);
}
signed main(){
  ll i,s=1;string S,T;cin>>N>>S;
  T=S;sort(ALL(T));
  x=upper_bound(ALL(T),'0')-T.begin();
  x=N-x;vector<ll>F(N);
  REP(i,N){
    F.at(N-1-i)=s;
    if(S.at(N-1-i)=='1')A+=s;
    s*=2;s%=x+1;A%=x+1;
  }
  s=1;vector<ll>G(N);
  else if(x<=1){
    REP(i,N)G.at(i)=-1;
  }
  else REP(i,N){
    G.at(N-1-i)=s;
    if(S.at(N-1-i)=='1')B+=s;
    s*=2;s%=x-1;B%=x-1;
  }
  REP(i,N){
    ll RES=Q(i,S,F,G);
    cout<<1+f(RES)<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:3: error: 'else' without a previous 'if'
   39 |   else if(x<=1){
      |   ^~~~
Language: C++

n = int(input())
inx = input()
x = int('0b'+inx,0)
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f

for i in range(n):
    rev = 1<<(n-1-i)
    cnt = 0
    y = x^rev
    while y != 0:
        # print("itr" + str(cnt))
        # print(popcount(y))
        # print(y)
        y = y % popcount(y)
        cnt += 1
    print(cnt)



Compiler output:
a.cc:3:9: warning: multi-character character constant [-Wmultichar]
    3 | x = int('0b'+inx,0)
      |         ^~~~
a.cc:5:5: error: empty character constant
    5 |     '''xの立っているビット数をカウントする関数
      |     ^~
a.cc:5:7: warning: missing terminating ' character
    5 |     '''xの立っているビット数をカウントする関数
      |       ^
a.cc:5:7: error: missing terminating ' character
    5 |     '''xの立っているビット数をカウントする関数
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:6:19: error: empty character constant
    6 |     (xは64bit整数)'''
      |                   ^~
a.cc:6:21: warning: missing terminating ' character
    6 |     (xは64bit整数)'''
      |                     ^
a.cc:6:21: error: missing terminating ' character
a.cc:8:7: error: extended character 、 is not valid in an identifier
    8 |     # 2bitごとの組に分け、立っているビット数を2bitで表現する
      |       ^
a.cc:8:7: error: "2bitごとの組に分け、立っているビット数を2bitで表現する" after # is not a positive integer
    8 |     # 2bitごとの組に分け、立っているビット数を2bitで表現する
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:7: error: "4bit整数に" after # is not a positive integer
   11 |     # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
      |       ^~~~~~~~~~
a.cc:14:45: error: stray '#' in program
   14 |     x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
      |                                             ^
a.cc:15:22: error: stray '#' in program
   15 |     x = x + (x >> 8) # 16bitごと
      |                      ^
a.cc:16:23: error: stray '#' in program
   16 |     x = x + (x >> 16) # 32bitごと
      |                       ^
a.cc:17:23: error: stray '#' in program
   17 |     x = x + (x >> 32) # 64bitごと = 全部の合計
      |                       ^
a.cc:25:11: error: invalid preprocessing directive #print
   25 |         # print("itr" + str(cnt))
      |           ^~~~~
a.cc:26:11: error: invalid preprocessing directive #print
   26 |         # print(popcount(y))
      |           ^~~~~
a.cc:27:11: error: invalid preprocessing directive #print
   27 |         # print(y)
      |           ^~~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

import sys
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(input())
x = str(input())

def popcnt(n):
    return bin(n).count("1")

for i in range(n):
    if x[i]=='0':
        y=x[:i]+'1'+x[i+1:]
    else:
        y=x[:i]+'0'+x[i+1:]
    z=int(y, 2)
    cnt=0
    while z!=0:
        z=z%popcnt(z)
        cnt+=1
    print(cnt)


Compiler output:
a.cc:2:3: warning: #import is a deprecated GCC extension [-Wdeprecated]
    2 | # import numpy as np
      |   ^~~~~~
a.cc:2:10: error: #import expects "FILENAME" or <FILENAME>
    2 | # import numpy as np
      |          ^~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 200005;
ll dp[MAXN+10][2]={0};
char s[MAXN+10];
int ans[MAXN+1000]={0};
ll quickmod(ll a,ll b,ll mod){
    ll dd = 1;
    while(b){
        if(b&1) dd = dd*a%mod;
        a= a*a%mod;
        b/=2;
    }
    return ans%mod;
}
int dfs(int num){
    if(num==0||ans[num])
        return ans[num];
    int cnt = 0 ;
    int temp=num;
    while(temp){
        if(temp&1)cnt++;
        temp/=2;
    }
    ans[num]=1+dfs(num%cnt);
    return ans[num];
}
int getnum(int num){
    return ans[num];
}
int main()
{
    //cout << quickmod(2,2,14) << endl;
    int n;
    cin >> n;
    cin >> s;
    int cnt = 0 ;
    for(int i=MAXN-1;i>0;i--){
        dfs(i);
    }
    for(int i=0;i<n;i++){
        if(s[i]=='1')
            cnt++;
    }
    int num1 =0;
    int num2= 0 ;
    for(int i=0;i<n;i++){
        num1=(num1*2+s[i]-'0')%(cnt-1);
        num2=(num2*2+s[i]-'0')%(cnt+1);
    }
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            cout << 1+getnum((num1-quickmod(2,n-i-1,cnt-1)+cnt-1)%(cnt-1)%(cnt-1)) << endl;
        }
        else{
            cout << 1+getnum((num2+(quickmod(2,n-i-1,cnt+1))%(cnt+1))%(cnt+1)) << endl;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'll quickmod(ll, ll, ll)':
a.cc:17:15: error: invalid operands of types 'int [201005]' and 'll' {aka 'long long int'} to binary 'operator%'
   17 |     return ans%mod;
      |            ~~~^~~~
      |            |   |
      |            |   ll {aka long long int}
      |            int [201005]
Language: Java

import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),f,ans;
    char[] c=sc.next().toCharArray();
    for(int i=0;i<n;i++){
      if(c[i]=='1'){
        f++;
      }
    }
    int d;
    for(int i=0;i<n;i++){
      d=f;
      if(c[i]=='1'){
        c[i]='0';
        d--;
      }else{
        c[i]='1';
        d++;
      }
      if(c[n-1]=='1'&&f>1){
        System.out.println(2);
      }else{
        System.out.println(1);
      }
    }
  }
}


Compiler output:
Main.java:11: error: variable f might not have been initialized
        f++;
        ^
Main.java:16: error: variable f might not have been initialized
      d=f;
        ^
2 errors
Language: Java

import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),f,ans;
    char[] c=sc.next().toCharArray();
    for(int i=0;i<n;i++){
      if(c[i]=='1'){
        f++;
      }
    }
    int d;
    for(int i=0;i<n;i++){
      d=f;
      if(c[i]=='1'){
        c[i]='0';
        d--;
      }else(c[i]=='0'){
        c[i]='1';
        d++;
      }
      if(c[n-1]=='1'&&f>1){
        System.out.println(2);
      }else{
        System.out.println(1);
      }
    }
  }
}


Compiler output:
Main.java:20: error: not a statement
      }else(c[i]=='0'){
           ^
Main.java:20: error: ';' expected
      }else(c[i]=='0'){
                      ^
2 errors
Language: Java

import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int n=sc.nextInt(),f,ans;
    char[] c=sc.next().toCharArray();
    for(int i=0;i<n;i++){
      if(c[i]=='1'){
        f++;
      }
    }
    int d;
    for(int i=0;i<n;i++){
      d=f;
      if(c[i]=='1'){
        c[i]=='0';
        d--;
      }else(c[i]=='0'){
        c[i]=='1';
        d++;
      }
      if(c[n-1]=='1'&&f>1){
        System.out.println(2);
      }else{
        System.out.println(1);
      }
    }
  }
}


Compiler output:
Main.java:18: error: not a statement
        c[i]=='0';
            ^
Main.java:20: error: not a statement
      }else(c[i]=='0'){
           ^
Main.java:20: error: ';' expected
      }else(c[i]=='0'){
                      ^
Main.java:21: error: not a statement
        c[i]=='1';
            ^
4 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

int mod(int val,int M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

int RS(int N, int P, int M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count = 0;
    for(int i = 0;i < N;i++) {
        if(S.at(i) == '1') {
            count++;
        }
    }
    if(count == 1) {
        int count1 = 0;
        int cnt1 = 1;
        reverse(S.begin(),S.end());
        for(int i = 0;i < N;i++) {
            if(S.at(i) == '1') {
                count1 = (count1 + cnt1) % (count + 1);
            }
            cnt1 = cnt1 * 2 % (count + 1);
        }
        reverse(S.begin(),S.end());
        for(int i = 0;i < N;i++) {
            int cnt3 = 0;
            int ret = 1;
            if(S.at(i) == '1') {
                cout << 0 << endl;
                continue;
            }
            else {
                cnt3 = (count1 + RS(2,N - (i + 1),count + 1)) % (count + 1);
            }
            while(cnt3 != 0) {
                int cnt4 = cnt3;
                int cnt5 = 0;
                while(cnt4 > 0) {
                    cnt5 += cnt4 % 2;
                    cnt4 /= 2;
                }
                cnt3 = cnt3 % cnt5;
            }
            cout << ret << endl;
        }
        return 0;
    }
    int count1 = 0;
    int count2 = 0;
    int cnt1 = 1;
    int cnt2 = 1;
    reverse(S.begin(),S.end());
    for(int i = 0;i < N;i++) {
        if(S.at(i) == '1') {
            count1 = (count1 + cnt1) % (count + 1);
            count2 = (count2 + cnt2) % (count - 1);
        }
        cnt1 = cnt1 * 2 % (count + 1);
        cnt2 = cnt2 * 2 % (count - 1);
    }
    reverse(S.begin(),S.end());
    for(int i = 0;i < N;i++) {
        int cnt3 = 0;
        int ret = 1;
        if(S.at(i) == '1') {
            cnt3 = mod(count2 - RS(2,N - (i + 1),count - 1),count - 1);
        }
        else {
            cnt3 = (count1 + RS(2,N - (i + 1),count + 1)) % (count + 1);
        }
        while(cnt3 != 0) {
            ret++;
            int cnt4 = cnt3;
            int cnt5 = 0;
            while(cnt4 > 0) {
                cnt5 += cnt4 % 2;
                cnt4 /= 2;
            }
            cnt3 = cnt3 % cnt5;
        }
        cout << ret << endl;
    }
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

from sys import stdin, stdout

def popcount(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n = n >> 1
    return cnt

def main():
    n = int(input())
    s = stdin.readline()
    x = 0
    ones = 0
    for i in reversed(s):
        x *= 2
        if i == '1':
            x += 1
            ones += 1

    if ones == 0:
        for i in range(n):
            stdout.write('1 ')
        stdout.write('\n')
        return
    elif ones == 1:
        for i in range(n):
            if s[i] == '1':
                stdout.write('0 ')
            else:
                if i + 1 == n:
                    stdout.write('2 ')
                else:
                    stdout.write('1 ')
        stdout.write('\n')
        return

    ans = []

    plus = x % (ones + 1)
    minus = x % (ones - 1)

    for i in range(n):
        if s[n - i - 1] == '1':
            y = minus
            y -= 1 << i
            y %= ones - 1
            if y < 0:
                y += ones - 1
            cnt = 1
            while y > 0:
                cnt += 1
                y = y % popcount(y)
            ans.append(cnt)
        else:
            y = plus
            y += 1 << i
            y %= ones + 1
            cnt = 1
            while y > 0:
                cnt += 1
                y = y % popcount(y)
            ans.append(cnt)

    for i in reversed(ans):
        stdout.write(str(i) + ' ')
    stdout.write('\n')

main()


Compiler output:
a.cc:23:26: warning: multi-character character constant [-Wmultichar]
   23 |             stdout.write('1 ')
      |                          ^~~~
a.cc:29:30: warning: multi-character character constant [-Wmultichar]
   29 |                 stdout.write('0 ')
      |                              ^~~~
a.cc:32:34: warning: multi-character character constant [-Wmultichar]
   32 |                     stdout.write('2 ')
      |                                  ^~~~
a.cc:34:34: warning: multi-character character constant [-Wmultichar]
   34 |                     stdout.write('1 ')
      |                                  ^~~~
a.cc:1:1: error: 'from' does not name a type
    1 | from sys import stdin, stdout
      | ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll f(ll n) {
  ll res = 0;
  while (n) {
    n = n % (__popcntd(n));
    res++;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  ll val[3];
  memset(val, 0, sizeof(val));

  string s;
  cin >> s;

  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (s[i] == '1')
      cnt++;
  }

  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < 3; j++) {

      ll sign = j - 1;
      ll cnt1 = cnt + sign;
      if (cnt1 <= 0)
        continue;
      val[j] = (val[j] + (s[i] == '1') * power(2, n - i - 1, cnt1)) % cnt1;
    }
  }

  for (ll i = 0; i < n; i++) {
    if (s[i] == '0') {
      ll res = (val[2] + power(2, n - i - 1, cnt + 1)) % (cnt + 1);

      cout << 1 + f(res) << en;
    } else {

      if ((cnt - 1) <= 0) {
        cout << 0 << en;
        continue;
      }

      ll res = (val[0] - power(2, n - i - 1, cnt - 1) + (cnt - 1)) % (cnt - 1);
      cout << 1 + f(res) << en;
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'll f(ll)':
a.cc:25:14: error: '__popcntd' was not declared in this scope
   25 |     n = n % (__popcntd(n));
      |              ^~~~~~~~~
Language: C++

n = int(input())
s = input()

def bin_to_num(st):
    r = 0
    for x in st:
        r *= 2
        if x == '1': r+=1
    return r

def popcount(num):
    x = num
    ret = 0
    while x>0:
        ret += x%2
        x//=2
    return ret

for i in range(n):
    if s[i] == '0': s = s[:i]+'1'+s[i+1:]
    else: s = s[:i]+'0'+s[i+1:]
    num = bin_to_num(s)
    ans = 0
    while num:
        pc = popcount(num)
        num %= pc
        ans += 1
    print(ans)
    if s[i] == '0': s = s[:i]+'1'+s[i+1:]
    else: s = s[:i]+'0'+s[i+1:]

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

ll Solve(){
    ll N; cin>>N;
    ll ans=0;
    vector<P> A,B;
    rep(i,N){
        ll K,L,R; cin>>K>>L>>R; 
        ans+=min(L,R);
        if(L>R) A.pb(mp(K,L-R));
        else B.pb(mp(N-K,R-L));
    }
    ll a=A.size(), b=B.size();
    //cout<<a<<':'<<b<<endl;
    priority_queue<ll> Q,R;
    sort(ALL(A)); sort(ALL(B));
    reverse(ALL(A)); reverse(ALL(B));
    ll c=0;
    for(int i=a;i>0;i--){
        while(c<a){
            if(A[c].first<i) break; 
            Q.push(A[c].second);
            c++;
            if(c==a) break;
        }
        if(!Q.empty()){
            ans+=Q.top();
            Q.pop();
        }
    }
    c=0;
    for(int i=b;i>0;i--){
        while(c<b){
            if(B[c].first<i) break; 
            R.push(B[c].second);
            c++;
            if(c==b) break;
        }
        if(!RLIMIT_AS.empty()){
            ans+=R.top();
            R.pop();
        }
    }
    return ans;
}

int main(){
    ll T; cin>>T;
    vec a(T);
    rep(i,T) a[i]=Solve();
    rep(i,T) cout<<a[i]<<endl;
}

Compiler output:
a.cc: In function 'll Solve()':
a.cc:67:13: error: 'RLIMIT_AS' was not declared in this scope
   67 |         if(!RLIMIT_AS.empty()){
      |             ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
//	Table is the complete reverse of dp
//	Always think of the pattern (LCM, GCD)
//	Be careful of unsigned
//	double epsilon = FLT_EPSILON;
//	Think of a solution that gets TLE and optimize it
struct ele{
	int k, l, r;
	bool operator<(const ele& other) const
	{
		return abs(l - r) . abs(other.l - other.r);
	}
};
bool cmp(const ele& x, const ele& y)
{
	return x.k < y.k;
}
int main()
{
    cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
    int t, n;
    cin >> t;
    while(t--)
    {
    	cin >> n;
    	vector<ele> big, small;
    	ll ans = 0;
    	for(int i = 0; i < n; i++)
    	{
    		ele tmp;
    		cin >> tmp.k >> tmp.l >> tmp.r;
    		if(tmp.k < n && tmp.l != tmp.r)
    		{
    			if(tmp.l > tmp.r)
					big.push_back(tmp);
				else
					small.push_back(tmp);
    		}
    		else
    			ans += tmp.l;
    	}
    	sort(big.begin(), big.end(), cmp);
    	priority_queue<ele> q;
    	for(ele &x: big)
    	{
			q.push(x);
			if(x.k < q.size())
			{
				ans += q.top().r;
				q.pop();
			}
    	}
    	while(!q.empty())
		{
    		ans += q.top().l;
    		q.pop();
		}
    	sort(small.rbegin(), small.rend(), cmp);
    	for(ele &x: small)
		{
			q.push(x);
			if(n - x.k < q.size())
			{
				ans += q.top().l;
				q.pop();
			}
		}
		while(!q.empty())
		{
			ans += q.top().r;
			q.pop();
		}
    	cout << ans << endl;
    }
}

Compiler output:
a.cc: In member function 'bool ele::operator<(const ele&) const':
a.cc:14:37: error: request for member 'abs' in 'abs((((int)((const ele*)this)->ele::l) - ((int)((const ele*)this)->ele::r)))', which is of non-class type 'int'
   14 |                 return abs(l - r) . abs(other.l - other.r);
      |                                     ^~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>

int main()
{
    int t;
    for (scanf("%d", &t); t--;)
    {
        int n;
        scanf("%d", &n);
        struct camel { int k, l, r; camel(const int& k, const int& l, const int& r) :k(k), l(l), r(r) {} };
        std::vector<camel> a, b;
        for (int i = 0; i < n; i++)
        {
            int k, l, r;
            scanf("%d %d %d", &k, &l, &r);
            auto& v = l >= r ? a : b;
            v.emplace_back(k, l, r);
        }
        sort(a.begin(), a.end(), [](const camel& l, const camel& r) { return l.k > r.k; });
        sort(b.begin(), b.end(), [](const camel& l, const camel& r) { return l.k < r.k; });
        long long h = 0;
        for (auto& i : a) h += i.r;
        for (auto& i : b) h += i.l;
        {
            std::priority_queue<int> q;
            for (int i = (int)a.size(), j = 0; i >= 1; i--)
            {
                while (j < (int)a.size() && a[j].k >= i)
                {
                    q.emplace(a[j].l - a[j].r);
                    j++;
                }
                if (!q.empty())
                {
                    h += q.top();
                    q.pop();
                }
            }
        }
        {
            std::priority_queue<int> q;
            for (int i = (int)a.size() + 1, j = 0; i <= n; i++)
            {
                while (j < (int)b.size() && b[j].k < i)
                {
                    q.emplace(b[j].r - b[j].l);
                    j++;
                }
                if (!q.empty())
                {
                    h += q.top();
                    q.pop();
                }
            }
        }
        printf("%lld\n", h);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   21 |         sort(a.begin(), a.end(), [](const camel& l, const camel& r) { return l.k > r.k; });
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using Z=long;
Z A=0,q,n,S=0,k,l,r;
Z G(vector<pair<Z,Z>> a){
sort(a.begin(),a.end());A=0;
priority_queue<int,vector<int>,greater<>> Q;
for(auto [k,d]:a){
Q.emplace(d);A+=d;
while(Q.size()>k)A-=Q.top(),Q.pop();
}return A;}
int main(){cin>>q;
rep(_,q){cin>>n;vector<pair<Z,Z>> L,R;
rep(i,n){cin>>k>>l>>r;
if(l>r)L.emplace_back(k,l-r),S+=r;
else if(r>l) R.emplace_back(n-k,r-l),S+=l;
else S+=l;}cout<<sum+G(L)+G(R)<<endl;}}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: 'sum' was not declared in this scope
   18 | else S+=l;}cout<<sum+G(L)+G(R)<<endl;}}
      |                  ^~~