func_code_string: #include <bits/stdc++.h>   #pragma warning(disable : 4786)   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   char str[1000005];   int Z[1000005], n;   void Zfunction() {     int L, R, r, i, j, k;     L = 0;     R = 0;     Z[0] = 0;     for (i = 1; i < n; i++) {       if (i > R) {         L = i;         R = i;         while (R < n && str[R - L] == str[R]) R++;         Z[i] = R - L;         R--;       } else {         r = i - L;         if (Z[r] < R - i + 1)           Z[i] = Z[r];         else {           L = i;           while (R < n && str[R - L] == str[R]) R++;           Z[i] = R - L;           R--;         }       }     }   }   int max(int a, int b) {     if (a > b) return a;     return b;   }   int main() {     int i, j, k, maxr, res;     while (scanf( %s , str) != EOF) {       n = strlen(str);       maxr = 0;       res = 0;       Zfunction();       for (i = 0; i < n; i++) {         if (Z[i] == n - i) {           if (maxr >= n - i) {             res = n - i;             break;           }         }         maxr = max(maxr, Z[i]);       }       if (res == 0 || n <= 2)         printf( Just a legend n );       else {         for (i = 0; i < res; i++) printf( %c , str[i]);         printf(  n );       }     }     return 0;   }   