func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long inf = 1000000000000000000LL;   const double EPS = 1e-9;   const long long mod = 1000000007ll;   const int maxn = 500500;   int longestP[1000500];   char pat[1000500];   void KMP() {     for (int i = 1, k = 0; pat[i]; i++) {       while (k > 0 && pat[i] != pat[k]) k = longestP[k - 1];       if (pat[i] == pat[k])         longestP[i] = ++k;       else         longestP[i] = k;     }   }   int main() {     scanf( %s , pat);     int n = strlen(pat);     KMP();     if (longestP[n - 1] == 0) {       puts( Just a legend );       return 0;     }     for (int i = 0; i + 1 < n; i++)       if (longestP[n - 1] == longestP[i]) {         for (int j = 0; j < longestP[i]; j++) putchar(pat[j]);         return 0;       }     if (longestP[longestP[n - 1] - 1] == 0) {       puts( Just a legend );       return 0;     }     for (int j = 0; j < longestP[longestP[n - 1] - 1]; j++) putchar(pat[j]);   }   