func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   const double PI = acos(-1.);   const double eps = 1e-9;   char s[1000005];   char t[1000005];   int fs[11];   int ft[11];   int fx[11];   char y[1000005];   int main() {     int i, j, k, _T;     while (~scanf( %s%s , s, t)) {       if (strcmp(s,  01 ) == 0 || strcmp(s,  10 ) == 0) {         printf( 0 n );         continue;       }       memset(fs, 0, sizeof fs);       memset(ft, 0, sizeof ft);       for (i = 0; s[i]; i++) fs[s[i] -  0 ]++;       for (i = 0; t[i]; i++) ft[t[i] -  0 ]++;       int ls = strlen(s);       int lt = strlen(t);       for (int len = lt; len <= ls; len++) {         char x[15];         memset(fx, 0, sizeof fx);         memset(x, 0, sizeof x);         sprintf(x,  %d , len);         int lx = strlen(x);         for (i = 0; x[i]; i++) fx[x[i] -  0 ]++;         int fail = 0;         for (i = 0; i <= 9; i++)           if (fs[i] < ft[i] + fx[i]) {             fail = 1;           }         if (fail || ls - lx != len) continue;         int flag = 0;         for (i = 1; i <= 9; i++) flag |= fs[i] > fx[i] + ft[i];         if (t[0] ==  0  && !flag) continue;         if (!flag) {           printf( %s , t);           for (i = 0; i <= 9; i++)             for (j = 0; j < fs[i] - fx[i] - ft[i]; j++) putchar( 0  + i);           putchar(  n );           break;         }         int id = 0, fi = -1;         for (i = 1; i <= 9; i++)           if (fs[i] > fx[i] + ft[i]) {             fi = i;             break;           }         fs[fi]--;         y[id++] =  0  + fi;         for (i = 0; i <= 9; i++) {           if (t[0] ==  0  + i) {             int big = 0;             for (j = 1; j < lt; j++) {               if (t[j] != t[0]) {                 if (t[j] > t[0]) big = 1;                 break;               }             }             if (!big) {               for (j = 0; j < lt; j++) y[id++] = t[j];             }             for (j = 0; j < fs[i] - fx[i] - ft[i]; j++) y[id++] =  0  + i;             if (big) {               for (j = 0; j < lt; j++) y[id++] = t[j];             }           } else             for (j = 0; j < fs[i] - fx[i] - ft[i]; j++) y[id++] =  0  + i;         }         int ly = id;         fs[fi]++;         id = lt;         for (i = 0; i <= 9; i++)           for (j = 0; j < fs[i] - fx[i] - ft[i]; j++) t[id++] =  0  + i;         int uset = 0;         for (i = 0; i < ly; i++) {           if (y[i] != t[i]) {             if (y[i] > t[i]) uset = 1;             break;           }         }         if (uset && t[0] !=  0 ) {           for (i = 0; i < ly; i++) putchar(t[i]);           putchar(  n );         } else {           for (i = 0; i < ly; i++) putchar(y[i]);           putchar(  n );         }         break;       }     }     return 0;   }   