func_code_string: #include <bits/stdc++.h>   using namespace std;   string s[2005];   char str[2005][2005];   int a[2005][2005];   int v[2005][2005];   long long dp[8005][2005];   int pool[8005], top = 0;   int child[8005];   int ID = 0, n;   int getID() { return pool[--top]; }   void pre() {     for (int i = 8000; i >= 0; i--) pool[top++] = i;   }   void delID(int x) { pool[top++] = x; }   int K;   int combine(int me, int you, int D) {     int ret = getID();     child[ret] = min(K, child[me] + child[you]);     for (int i = 0; i <= child[ret]; i++) dp[ret][i] = 0;     for (int i = 0; i <= child[me]; i++)       for (int j = 0; j <= child[you] && i + j <= K; j++)         dp[ret][i + j] = max(dp[ret][i + j], dp[me][i] + dp[you][j] + i * j * D);     return ret;   }   int go(int L, int R, int D) {     int me = getID();     int c = 0;     while (L <= R && str[L][D] ==   0 ) ++c, ++L;     child[me] = c;     for (int i = 0; i <= c; i++) dp[me][i] = i * (i - 1) / 2 * D;     for (int i = L, j = L; i <= R; i = j) {       for (j = i; j <= R && str[i][D] == str[j][D]; j++)         ;       int you = go(i, j - 1, D + 1);       int nxt = combine(me, you, D);       delID(me);       delID(you);       me = nxt;     }     return me;   }   int main(void) {     pre();     scanf( %d%d , &n, &K);     for (int i = 1; i <= n; i++) cin >> s[i];     sort(s + 1, s + 1 + n);     for (int i = 1; i <= n; i++) strcpy(str[i], s[i].c_str());     int me = go(1, n, 0);     printf( %I64d n , dp[me][K]);     return 0;   }   