func_code_string: #include <bits/stdc++.h>   using namespace std;   string s;   const int maxN = 1000010;   int len;   int ra[maxN], tra[maxN], sa[maxN], tmpsa[maxN], cnt[maxN];   void countSort(int k) {     int maxr = max(300, len);     memset(cnt, 0, sizeof(cnt[0]) * (maxr + 5));     for (int i = 0; i < len; i++) cnt[sa[i] + k < len ? ra[sa[i] + k] : 0]++;     for (int i = 0, t, sum = 0; i < maxr; i++) t = cnt[i], cnt[i] = sum, sum += t;     for (int i = 0; i < len; i++)       tmpsa[cnt[sa[i] + k < len ? ra[sa[i] + k] : 0]++] = sa[i];     for (int i = 0; i < len; i++) sa[i] = tmpsa[i];   }   void buildsa() {     for (int i = 0; i < len; i++) ra[i] = s[i], sa[i] = i;     for (int k = 1; k < len; k <<= 1) {       countSort(k);       countSort(0);       int r = 0;       tra[sa[0]] = 0;       for (int i = 1; i < len; i++) {         int t1 = (sa[i] + k < len ? ra[sa[i] + k] : 0);         int t2 = (sa[i - 1] + k < len ? ra[sa[i - 1] + k] : 0);         tra[sa[i]] = (ra[sa[i]] == ra[sa[i - 1]] && t1 == t2) ? r : ++r;       }       for (int i = 0; i < len; i++) ra[i] = tra[i];       if (ra[sa[len - 1]] == len - 1) break;     }     string os = s;   }   int phi[maxN], LCP[maxN];   void computeLCP() {     phi[sa[0]] = -1;     for (int i = 1; i < len; i++) phi[sa[i]] = sa[i - 1];     int L = 0;     for (int i = 0; i < len; i++) {       if (phi[i] == -1) {         LCP[ra[i]] = 0;         continue;       }       while (L < len && s[i + L] == s[phi[i] + L]) L++;       int TL = L;       LCP[ra[i]] = TL;       L = max(L - 1, 0);     }   }   int tlft[maxN], trgt[maxN];   void hgram(int data[], int n) {     data[0] = -1;     data[n + 1] = -1;     stack<int> bosta;     bosta.push(0);     for (int i = 1; i <= n + 1; i++) {       while (data[i] < data[bosta.top()]) {         trgt[bosta.top()] = i;         bosta.pop();       }       bosta.push(i);     }     bosta.push(n + 1);     for (int i = n + 1; i >= 0; i--) {       while (data[i] < data[bosta.top()]) {         tlft[bosta.top()] = i;         bosta.pop();       }       bosta.push(i);     }   }   int cross[100100];   long long sum[100010];   vector<pair<long long, pair<long long, long long> > > vv[100010];   void qry(int k) {     for (int i = 1; i < len; i++) {       if (i >= cross[LCP[i]]) {         cross[LCP[i]] = max(cross[LCP[i]], trgt[i]);         long long range = trgt[i] - tlft[i];         long long occ =             min(LCP[i], min(LCP[i] - LCP[tlft[i]], LCP[i] - LCP[trgt[i]]));         long long gain = occ * range;         if (gain) {           vv[tlft[i]].push_back(make_pair(LCP[i] - occ, make_pair(occ, gain)));           sum[tlft[i]] += gain;         }       }     }     long long tot = 0;     for (int i = 1; i < len; i++) {       if (tot + sum[i] >= k) {         sort(vv[i].begin(), vv[i].end());         for (int j = 0; j < vv[i].size(); j++) {           long long cur = vv[i][j].second.second;           if (tot + cur >= k) {             long long st = vv[i][j].first;             long long oc = vv[i][j].second.first;             long long cnt = cur / oc;             long long need = k - tot;             long long pos = ceil(need / (1.00 * cnt));             cout << s.substr(sa[i], st + pos);             return;           }         }         return;       }       tot += sum[i];       long long exgain = len - 1 - sa[i];       long long repitition = LCP[i];       if (i < len - 1) repitition = max(repitition, (long long)LCP[i + 1]);       exgain -= repitition;       if (tot + exgain >= k) {         long long need = k - tot;         cout << s.substr(sa[i], repitition + need) << endl;         return;       }       tot += exgain;     }     cout <<  No such line.  << endl;   }   int main() {     cin >> s;     s +=  & ;     len = s.size();     buildsa();     computeLCP();     hgram(LCP, len - 1);     int k;     cin >> k;     qry(k);   }   