func_code_string: #include <bits/stdc++.h>   using namespace std;   void z_func(const string &s, vector<int> &z) {     int L = 0, R = 0;     int n = s.length();     z.resize(n);     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--;         }       }     }   }   int main() {     string str;     cin >> str;     vector<int> z;     z_func(str, z);     int maxz = 0, res = 0;     int n = (int)str.length();     for (int i = 0; i < (int)str.length(); i++) {       if (z[i] == n - i) {         if (maxz >= z[i]) res = max(res, z[i]);       }       maxz = max(maxz, z[i]);     }     if (res == 0)       cout <<  Just a legend  << endl;     else       cout << str.substr(0, res) << endl;     return 0;   }   