Language: C++

int main() {
    int N;
    cin >> N;

    if (N==0) {
        cout << 0 << endl;
    }
    
    if (N>0) {
        int m = 0;
        int max = 0;
        while (true) {
            max += pow(4,m);
            if (N<=max) {
                max += 1 - pow(4,m);
                break;
            }
            m += 1;
        }
        m += 1;
        m = 2*m-1; // m桁目が1で確定
        
        // N-maxをm-1桁の2進数に変換
        N -= max;
        //cout << N << " " << m << endl;
        vector<int> data(m, 0);
        //trans(N, m-1);
        data[0] = 1;
        m -= 1;
        for (int i=0;i<m;i++) {
            if (N>=pow(2,m-1-i)) {
                if (i%2!=0) {
                    data[i+1] = 1;
                }
                N -= pow(2,m-1-i);
            }
            else {
                if (i%2==0) {
                    data[i+1] = 1;
                }
            }
        }
    
        for (int i=0;i<m+1;i++) {
            cout << data[i];
        }
        cout << endl;
    }
    
    if (N<0) {
        N = -N;
        int m = 0;
        int max = 0;
        while (true) {
            max += 2*pow(4,m);
            if (N<=max) {
                max += 1 - 2*pow(4,m);
                break;
            }
            m += 1;
        }
        m += 1;
        m = 2*m; // m桁目が1で確定
        
        // N-maxをm-1桁の2進数に変換
        N -= max;
        //cout << N << " " << m << endl;
        vector<int> data(m, 0);
        //trans(N, m-1);
        data[0] = 1;
        m -= 1;
        for (int i=0;i<m;i++) {
            if (N>=pow(2,m-1-i)) {
                if (i%2!=0) {
                    data[i+1] = 1;
                }
                N -= pow(2,m-1-i);
            }
            else {
                if (i%2==0) {
                    data[i+1] = 1;
                }
            }
        }
        
        for (int i=0;i<m+1;i++) {
            cout << data[i];
        }
        cout << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> N;
      |     ^~~
a.cc:6:9: error: 'cout' was not declared in this scope
    6 |         cout << 0 << endl;
      |         ^~~~
a.cc:6:22: error: 'endl' was not declared in this scope
    6 |         cout << 0 << endl;
      |                      ^~~~
a.cc:13:20: error: 'pow' was not declared in this scope
   13 |             max += pow(4,m);
      |                    ^~~
a.cc:26:9: error: 'vector' was not declared in this scope
   26 |         vector<int> data(m, 0);
      |         ^~~~~~
a.cc:26:16: error: expected primary-expression before 'int'
   26 |         vector<int> data(m, 0);
      |                ^~~
a.cc:28:9: error: 'data' was not declared in this scope
   28 |         data[0] = 1;
      |         ^~~~
a.cc:31:20: error: 'pow' was not declared in this scope
   31 |             if (N>=pow(2,m-1-i)) {
      |                    ^~~
a.cc:45:13: error: 'cout' was not declared in this scope
   45 |             cout << data[i];
      |             ^~~~
a.cc:47:9: error: 'cout' was not declared in this scope
   47 |         cout << endl;
      |         ^~~~
a.cc:47:17: error: 'endl' was not declared in this scope
   47 |         cout << endl;
      |                 ^~~~
a.cc:55:22: error: 'pow' was not declared in this scope
   55 |             max += 2*pow(4,m);
      |                      ^~~
a.cc:68:9: error: 'vector' was not declared in this scope
   68 |         vector<int> data(m, 0);
      |         ^~~~~~
a.cc:68:16: error: expected primary-expression before 'int'
   68 |         vector<int> data(m, 0);
      |                ^~~
a.cc:70:9: error: 'data' was not declared in this scope
   70 |         data[0] = 1;
      |         ^~~~
a.cc:73:20: error: 'pow' was not declared in this scope
   73 |             if (N>=pow(2,m-1-i)) {
      |                    ^~~
a.cc:87:13: error: 'cout' was not declared in this scope
   87 |             cout << data[i];
      |             ^~~~
a.cc:89:9: error: 'cout' was not declared in this scope
   89 |         cout << endl;
      |         ^~~~
a.cc:89:17: error: 'endl' was not declared in this scope
   89 |         cout << endl;
      |                 ^~~~