Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll norm(ll x){
  if(x == 0) return 0;
  if(x == -1 || x == 1) return 1;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    if(n ==0){} cout << 0<<endl; return 0}
    vl v;
    ll phase = 1;
    if(n < 0) phase = -1;
    while(n != 0){
      if(phase == 1){
        v.pb(norm(n%2));
        n = n/2; n *=-1;
        phase = -1;
      } else if(phase == -1){
        v.pb(norm(n%2));
        n = (n-norm((n%2)))/2; n *=-1;
        phase = 1;
      }
    }
    for (auto it = v.crbegin(); it != v.crend(); it++) {
      cout <<*it;
    }

    cout << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Compiler output:
a.cc: In function 'int main()':
a.cc:57:42: error: expected ';' before '}' token
   57 |     if(n ==0){} cout << 0<<endl; return 0}
      |                                          ^
      |                                          ;
a.cc: At global scope:
a.cc:60:5: error: expected unqualified-id before 'if'
   60 |     if(n < 0) phase = -1;
      |     ^~
a.cc:61:5: error: expected unqualified-id before 'while'
   61 |     while(n != 0){
      |     ^~~~~
a.cc:72:5: error: expected unqualified-id before 'for'
   72 |     for (auto it = v.crbegin(); it != v.crend(); it++) {
      |     ^~~
a.cc:72:33: error: 'it' does not name a type; did you mean 'int'?
   72 |     for (auto it = v.crbegin(); it != v.crend(); it++) {
      |                                 ^~
      |                                 int
a.cc:72:50: error: 'it' does not name a type; did you mean 'int'?
   72 |     for (auto it = v.crbegin(); it != v.crend(); it++) {
      |                                                  ^~
      |                                                  int
a.cc:76:5: error: 'cout' does not name a type
   76 |     cout << endl;
      |     ^~~~
a.cc:79:5: error: expected unqualified-id before 'return'
   79 |     return 0;
      |     ^~~~~~
a.cc:80:1: error: expected declaration before '}' token
   80 | }
      | ^
a.cc: In function 'll norm(ll)':
a.cc:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^