func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops )   #pragma GCC optimize( no-stack-protector,fast-math )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   template <class S, class T>   inline S smax(S &l, T r) {     return l = max(l, (S)r);   }   template <class S, class T>   inline S smin(S &l, T r) {     return l = min(l, (S)r);   }   const int N = 1e6 + 10;   int nex[N][26], sz, cnt[N], lvl[N];   inline void In(string &s) {     int now = 0;     for (auto c : s) {       c -=  a ;       if (!nex[now][c]) {         nex[now][c] = ++sz;         lvl[sz] = lvl[now] + 1;       }       now = nex[now][c];     }     cnt[now]++;   }   vector<int> dp[N];   inline int f(int i) { return i * (i - 1) / 2; }   inline void merge(int v, int u) {     vector<int> tmp(dp[v].size() + dp[u].size() - 1);     for (int i = 0; i < (int)dp[v].size(); i++)       for (int j = 0; j < (int)dp[u].size(); j++)         tmp[i + j] = max(tmp[i + j], dp[v][i] + dp[u][j] + i * j * lvl[v]);     dp[v] = tmp;   }   void dfs(int v) {     for (int i = 0; i <= cnt[v]; i++) dp[v].emplace_back(lvl[v] * f(i));     for (int i = 0; i < 26; i++)       if (nex[v][i]) {         dfs(nex[v][i]);         merge(v, nex[v][i]);       }   }   int32_t main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n, k;     cin >> n >> k;     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       In(s);     }     dfs(0);     cout << dp[0][k] << endl;     return 0;   }   