func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   bool remin(T &a, const T &b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class T>   bool remax(T &a, const T &b) {     if (a < b) {       a = b;       return true;     }     return false;   }   int nxt() {     int first;     scanf( %  PRId32, &first);     return first;   }   long long nxtll() {     long long first;     scanf( %  PRId64, &first);     return first;   }   long long gcd(long long a, long long b) {     a = abs(a);     b = abs(b);     while (b) {       a %= b;       swap(a, b);     }     return a;   }   struct Q {     long long n, d;     Q(long long a = 0) : n(a), d(1) {}     Q(long long nn, long long dd) : n(nn), d(dd) { norm(); }     void norm() {       long long g = gcd(abs(n), abs(d));       n /= g;       d /= g;       if (d < 0) {         n *= -1;         d *= -1;       }     }     Q operator+(const Q &r) const { return Q(n * r.d + d * r.n, d * r.d); }     Q operator-(const Q &r) const { return Q(n * r.d - d * r.n, d * r.d); }     Q operator*(const Q &r) const { return Q(n * r.n, d * r.d); }     Q operator/(const Q &r) const { return Q(n * r.d, d * r.n); }     long long value(const Q &r) const { return n * r.d - d * r.n; }     double vald(const Q &r) const { return n * 1.0 * r.d - d * 1.0 * r.n; }     bool operator<(const Q &r) const {       double vv = vald(r);       if (vv < -1e10) {         return true;       }       if (vv > 1e10) {         return false;       }       return value(r) < 0;     }     bool operator>(const Q &r) const {       double vv = vald(r);       if (vv < -1e10) {         return false;       }       if (vv > 1e10) {         return true;       }       return value(r) > 0;     }     bool operator!=(const Q &r) const { return !(*this == r); }     bool operator>=(const Q &r) const { return *this > r || *this == r; }     bool operator<=(const Q &r) const { return *this < r || *this == r; }     bool operator==(const Q &r) const {       double vv = vald(r);       if (vv < -1e10) {         return false;       }       if (vv > 1e10) {         return false;       }       return value(r) == 0;     }     double getValue() const { return n / (double)d; }   };   ostream &operator<<(ostream &os, const Q &p) { return os << p.n <<  /  << p.d; }   struct pt {     double first, second;     pt() = default;     pt(long double first, long double second) : first(first), second(second) {}     inline pt operator-(const pt &r) const {       return pt(first - r.first, second - r.second);     }     inline pt operator+(const pt &r) const {       return pt(first + r.first, second + r.second);     }     inline pt operator*(const long double &r) const {       return pt(first * r, second * r);     }     inline pt operator-() const { return pt(-first, -second); }     inline long double sqlen() const {       return fabsl(first * first + second * second);     }   };   ostream &operator<<(ostream &os, const pt &p) {     return os <<  (  << p.first <<  ,  << p.second <<  ) ;   }   ostream &operator<<(ostream &os, const pair<long long, long long> &p) {     return os <<  (  << p.first <<  ,  << p.second <<  ) ;   }   pair<long long, long long> operator-(const pair<long long, long long> &l,                                        const pair<long long, long long> &r) {     return pair<long long, long long>(l.first - r.first, l.second - r.second);   }   pair<long long, long long> operator+(const pair<long long, long long> &l,                                        const pair<long long, long long> &r) {     return pair<long long, long long>(l.first + r.first, l.second + r.second);   }   inline double cross(const pt &l, const pt &r) {     return l.first * r.second - l.second * r.first;   }   inline double dot(const pt &l, const pt &r) {     return l.first * r.first + l.second * r.second;   }   inline long long cross(const pair<long long, long long> &l,                          const pair<long long, long long> &r) {     return l.first * r.second - l.second * r.first;   }   inline long long dot(const pair<long long, long long> &l,                        const pair<long long, long long> &r) {     return l.first * r.first + l.second * r.second;   }   long long pwmod(long long a, long long n, long long mod) {     long long ret = 1;     while (n) {       if (n & 1) ret = ret * a % mod;       a = a * a % mod;       n >>= 1;     }     return ret;   }   template <typename T>   inline T sqr(T first) {     return first * first;   }   inline bool is_prime(unsigned long long first) {     for (unsigned long long i = 2; i * i <= first; ++i) {       if (first % i == 0) {         return false;       }     }     return true;   }   bool is_sq(long long first) {     for (long long i = 1; i * i <= first; ++i) {       if (i * i == first) return true;     }     return false;   }   int n;   string solve(const multiset<char> &a, const multiset<char> &b, int d = 0,                const string &cur = string(n,  ? )) {     if (d == n) {       return cur;     }     if (d & 1) {       string res =   ;       set<char> bl(b.begin(), b.end());       for (char c : bl) {         multiset<char> bb = b;         bb.erase(bb.find(c));         for (int i = 0; i < n; ++i) {           if (cur[i] !=  ? ) continue;           string cc = cur;           cc[i] = c;           res = max(res, solve(a, bb, d + 1, cc));         }       }       return res;     } else {       string res = string(n,  z  + 1);       set<char> al(a.begin(), a.end());       for (char c : al) {         multiset<char> aa = a;         aa.erase(aa.find(c));         for (int i = 0; i < n; ++i) {           if (cur[i] !=  ? ) continue;           string cc = cur;           cc[i] = c;           res = min(res, solve(aa, b, d + 1, cc));         }       }       return res;     }   }   string solve(const string &a, const string &b) {     n = a.length();     return solve(multiset<char>(a.begin(), a.end()),                  multiset<char>(b.begin(), b.end()));   }   const int N = 300 * 1000 + 10;   char a[N];   char b[N];   string solve2(string a, string b) {     sort(a.begin(), a.end());     sort(b.begin(), b.end());     int n = a.length();     int l = 0, r = n - 1;     int L = 0, R = n;     string s(n,  . );     int move = 0;     while (L < R) {       if (move & 1) {         if (a[l] < b[r] || L + 1 == R) {           s[L] = b[r];           --r;           ++L;         } else {           if (!((R - L) & 1)) {             for (int i = L; i < R; i += 2) {               s[i] = a[l++];             }             for (int i = L + 1; i < R; i += 2) {               s[i] = b[r--];             }           } else {             for (int i = L + 1; i < R; i += 2) {               s[i] = a[l++];             }             for (int i = L; i < R; i += 2) {               s[i] = b[r--];             }           }           L = R;         }       } else {         if (a[l] < b[r] || L + 1 == R) {           s[L] = a[l];           ++l;           ++L;         } else {           if (!((R - L) & 1)) {             for (int i = L + 1; i < R; i += 2) {               s[i] = a[l++];             }             for (int i = L; i < R; i += 2) {               s[i] = b[r--];             }           } else {             for (int i = L; i < R; i += 2) {               s[i] = a[l++];             }             for (int i = L + 1; i < R; i += 2) {               s[i] = b[r--];             }           }           L = R;         }       }       ++move;     }     return s;   }   void solve() {     scanf( %s , a);     scanf( %s , b);     cout << solve2(a, b) <<   n ;   }   void prepare() {     return;     while (true) {       n = rand() % 5 + 1;       string a(n,  . );       string b(n,  . );       for (int i = 0; i < (int)(n); i++) {         a[i] = rand() % 5 +  a ;         b[i] = rand() % 5 +  a ;       }       if (solve(a, b) != solve2(a, b)) {         cout << a <<   n ;         cout << b <<   n ;         return;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     prepare();     int t = 1;     for (int i = 0; i < (int)(t); i++) {       solve();     }     cerr <<  Time   << clock() / (double)CLOCKS_PER_SEC << endl;     return 0;   }   