func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5, maxlen = 5e5 + 5;   const int inf = 3e6 + 5;   int n, x[maxn], y[maxn];   char s[maxlen];   int ansb, ansn;   bool check(int mid, int ty) {     int xmin = 0, xmax = inf, ymin = 0, ymax = inf, dmin = -inf, dmax = inf;     for (int i = 1; i <= n; i++) {       xmin = max(xmin, x[i] - mid);       xmax = min(xmax, x[i] + mid);       ymin = max(ymin, y[i] - mid);       ymax = min(ymax, y[i] + mid);       dmin = max(dmin, x[i] - y[i] - mid);       dmax = min(dmax, x[i] - y[i] + mid);     }     if (xmin > xmax || ymin > ymax || dmin > dmax) return 0;     ymin = max(ymin, xmin - dmax);     ymax = min(ymax, xmax - dmin);     if (ymin > ymax) return 0;     if (ty) {       for (int x = xmin; x <= xmax; x++) {         int rymin = max(ymin, x - dmax), rymax = min(ymax, x - dmin);         if (rymin <= rymax && (x > 0 || rymax > 0)) {           ansb = x, ansn = (x == 0) ? rymax : rymin;           break;         }       }     }     return 1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %s , s + 1);       int len = strlen(s + 1);       for (int j = 1; j <= len; j++)         if (s[j] ==  B )           x[i]++;         else           y[i]++;     }     int l = 0, r = 2e6;     while (l <= r) {       int mid = (l + r) >> 1;       if (check(mid, 0))         r = mid - 1;       else         l = mid + 1;     }     printf( %d n , ++r);     check(r, 1);     for (int i = 1; i <= ansb; i++) putchar( B );     for (int i = 1; i <= ansn; i++) putchar( N );     return 0;   }   