func_code_string: #include <bits/stdc++.h>   const int N = 1000001;   using namespace std;   char sub[N], s[N], l[N];   int a[10];   int main() {     scanf( %s , s);     int i, j, len1, len2;     len1 = strlen(s);     for (i = 0; i < len1; i++) a[s[i] -  0 ]++;     scanf( %s , sub);     len2 = strlen(sub);     for (i = 0; i < len2; i++) a[sub[i] -  0 ]--;     int lt = 1, rt = 1000000, mid, t, w;     while (lt <= rt) {       mid = (lt + rt) >> 1;       t = mid;       w = 0;       while (t > 0) {         w++;         t /= 10;       }       if (mid + w == len1)         break;       else if (mid + w < len1)         lt = mid + 1;       else         rt = mid - 1;     }     t = mid;     while (t > 0) {       a[t % 10]--;       t /= 10;     }     bool ok = true;     if (a[0] > 0 || sub[0] ==  0 ) {       ok = false;       for (i = 1; i < 10; i++)         if (a[i] > 0) break;       if (i < 10) {         ok = true;         if (i < sub[0] -  0 ) {           a[i]--;           printf( %d , i);         } else if (i > sub[0] -  0 ) {           if (sub[0] !=  0 ) {             printf( %s , sub);             for (i = 0; i < 10; i++)               for (j = 1; j <= a[i]; j++) printf( %d , i);             return 0;           }           printf( %d , i);           a[i]--;         } else {           int p = 0, q;           a[i]--;           l[p++] = (char)(i +  0 );           for (i = 0; i < 10; i++)             for (j = 1; j <= a[i]; j++) l[p++] = (char)(i +  0 );           q = p;           if (p < len2) {             for (i = 0; p < len2; i++) l[p++] = sub[i];           }           for (i = 0; i < len2; i++)             if (l[i] != sub[i]) break;           if (i < len2 && sub[i] < l[i]) {             l[q] =   0 ;             sort(l, l + q);             printf( %s%s , sub, l);             return 0;           }           printf( %c , sub[0]);         }       }     }     int p = 0, q;     for (i = 0; i < 10; i++)       for (j = 1; j <= a[i]; j++) l[p++] = (char)(i +  0 );     l[p] =   0 ;     if (!ok) {       printf( %s%s , sub, l);       return 0;     }     if (p == 0) {       printf( %s , sub);       return 0;     }     for (i = 0; i < p; i++) {       if (l[i] < sub[0]) {         printf( %c , l[i]);         continue;       }       if (l[i] > sub[0]) {         printf( %s , sub);         printf( %s , l + i);         return 0;       }       for (j = 1; j < len2; j++)         if (sub[j] != sub[0]) break;       if (j == len2 || sub[j] < sub[0]) {         printf( %s , sub);         printf( %s , l + i);         return 0;       } else {         for (; l[i] == sub[0]; i++) printf( %c , l[i]);         printf( %s , sub);         printf( %s , l + i);         return 0;       }     }     printf( %s , sub);     return 0;   }   