func_code_string: #include <bits/stdc++.h>   using namespace std;   string get(int n, int m) {     string str;     for (int i = 1; i <= n; i++) str.push_back( 4 );     for (int i = 1; i <= m; i++) str.push_back( 7 );     return str;   }   int32_t main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     string str;     cin >> str;     int n = str.size();     if (n & 1) {       cout << get((n + 1) / 2, (n + 1) / 2) << endl;       return 0;     }     int cnta = 0, cntb = 0, ans = -1, aa = 0, bb = 0;     for (int i = 0; i < n; i++) {       if (cnta + 1 <= n / 2 && str[i] <  7 ) {         ans = i;         aa = cnta;         bb = cntb;       }       if (cntb + 1 <= n / 2 && str[i] <  4 ) {         ans = i;         aa = cnta;         bb = cntb;       }       cnta += str[i] ==  7 ;       cntb += str[i] ==  4 ;       if ((str[i] !=  4  && str[i] !=  7 ) || cnta > n / 2 || cntb > n / 2) break;     }     if (cnta + cntb == n && cnta == cntb) {       cout << str << endl;       return 0;     }     if (ans == -1) {       cout << get((n + 2) / 2, (n + 2) / 2) << endl;       return 0;     }     string x;     for (int i = 0; i < ans; i++) {       x.push_back(str[i]);     }     if (bb + 1 <= n / 2 && str[ans] <  4 ) {       ++bb;       x.push_back( 4 );     } else {       ++aa;       x.push_back( 7 );     }     x += get(n / 2 - bb, n / 2 - aa);     cout << x << endl;   }   