func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1000000;   int z[N];   void computeZ(char s[]) {     int n = strlen(s), L = 0, R = 0;     for (int i = 1; i < n; i++) {       if (i > R) {         L = R = i;         while (R < n && s[R - L] == s[R]) R++;         z[i] = R - L;         R--;       } else {         int k = i - L;         if (z[k] < R - i + 1)           z[i] = z[k];         else {           L = i;           while (R < n && s[R - L] == s[R]) R++;           z[i] = R - L;           R--;         }       }     }   }   char s[N + 1];   int suffix[N + 1], size;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> s;     computeZ(s);     int n = strlen(s), mx = 0;     int size = 0;     for (int i = 1; i < n; ++i)       if (z[i] == n - i) suffix[z[i]]++;     for (int i = 1; i < n; ++i) {       if (suffix[i])         suffix[i] = i;       else         suffix[i] = suffix[i - 1];     }     for (int i = 1; i < n; ++i) {       int len = z[i] - (z[i] == n - i);       mx = max(mx, suffix[len]);     }     if (mx == 0)       cout <<  Just a legend  << endl;     else {       s[mx] =   0 ;       cout << s << endl;     }   }   