func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 1110;   const long long inf = 1000000007998244353ll;   struct S {     long long l, r;   } a[N * N];   long long si[N][N];   long long tot;   long long n, m, k;   string s;   long long lcp[N][N];   long long dp[N][N];   long long suffix_sum[N];   long long ri[N];   inline long long add(long long a, long long b) {     return a + b > inf ? inf : a + b;   }   long long cnt(long long S) {     for (long long i = 0; i < n; i++) {       ri[i] = i;       while (ri[i] != n && si[i][ri[i]] <= S) {         ri[i]++;       }     }     for (long long i = 0; i < n; i++) {       dp[i][1] = si[i][n - 1] > si[a[S].l][a[S].r] ? 1 : 0;     }     for (long long j = 2; j <= m; j++) {       suffix_sum[n - 1] = dp[n - 1][j - 1];       for (long long i = n - 2; i >= 0; i--) {         suffix_sum[i] = add(dp[i][j - 1], suffix_sum[i + 1]);       }       for (long long i = 0; i < n; i++) {         dp[i][j] = ri[i] == n ? 0 : suffix_sum[ri[i] + 1];       }     }     return dp[0][m];   }   bool cmp(S i, S j) {     long long p = i.l + lcp[i.l][j.l], q = j.l + lcp[i.l][j.l];     if (p > i.r || q > j.r) {       return i.r - i.l < j.r - j.l;     }     return s[p] < s[q];   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     tot = 0;     cin >> n >> m >> k >> s;     for (long long i = 0; i < n; i++) {       for (long long j = i; j < n; j++) {         a[tot].l = i;         a[tot].r = j;         tot++;       }     }     for (long long i = n - 1; i >= 0; i--) {       for (long long j = n - 1; j >= 0; j--) {         lcp[i][j] = s[i] == s[j] ? lcp[i + 1][j + 1] + 1 : 0;       }     }     sort(a, a + tot, cmp);     for (long long i = 0; i < tot; i++) {       si[a[i].l][a[i].r] = i;     }     long long l = 0, r = tot - 1;     while (l < r) {       long long midd = (r + l) / 2;       if (cnt(midd) >= k) {         l = midd + 1;       } else {         r = midd;       }     }     for (long long i = a[r].l; i <= a[r].r; i++) {       cout << s[i];     }     return 0;   }   