func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   string tos(T a) {     stringstream ss;     string ret;     ss << a;     ss >> ret;     return ret;   }   string st;   int l, memo[1000009][2];   int get(int pos, int carry) {     if (pos < 0) return carry;     int &ret = memo[pos][carry];     if (ret != -1) return ret;     ret = 9999999;     if (carry == 0) {       if (st[pos] ==  0 )         return ret = get(pos - 1, 0);       else {         int ra = get(pos - 1, carry) + 1;         int rb = get(pos - 1, 1 - carry) + 1;         ret = min(ra, rb);         return ret;       }     } else {       if (st[pos] ==  1 )         return ret = get(pos - 1, carry);       else {         int ra = get(pos - 1, 0) + 1;         int rb = get(pos - 1, 1) + 1;         ret = min(ra, rb);         return ret;       }     }   }   int print_path(int pos, int carry) {     if (pos < 0) {       if (carry) printf( +2^%d n , l - pos - 1);       return 0;     }     if (carry == 0) {       if (st[pos] ==  0 )         return print_path(pos - 1, 0);       else {         int ra = get(pos - 1, carry) + 1;         if (ra == memo[pos][carry]) {           printf( +2^%d n , l - pos - 1);           return print_path(pos - 1, carry);         } else {           printf( -2^%d n , l - pos - 1);           return print_path(pos - 1, 1 - carry);         }       }     } else {       if (st[pos] ==  1 )         return print_path(pos - 1, carry);       else {         int ra = get(pos - 1, 0) + 1;         if (ra == memo[pos][carry]) {           printf( +2^%d n , l - pos - 1);           return print_path(pos - 1, 0);         } else {           printf( -2^%d n , l - pos - 1);           return print_path(pos - 1, 1);         }       }     }   }   int main() {     while (cin >> st) {       memset(memo, -1, sizeof memo);       ;       l = st.size();       cout << get(l - 1, 0) << endl;       print_path(l - 1, 0);     }     return 0;   }   