func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace MincostMaxFlow {   const int maxn(2e5 + 5);   struct Edge {     int to, next, w, f;   };   int first[maxn], cnt, vis[maxn], dis[maxn], S, T, pe[maxn], pv[maxn], maxflow,       mincost;   Edge edge[maxn * 20];   queue<int> Q;   inline void Init(int _S, int _T) {     cnt = mincost = maxflow = 0, S = _S, T = _T;     memset(first, -1, sizeof(first));   }   inline void AddEdge(int u, int v, int w, int f) {     edge[cnt] = (Edge){v, first[u], w, f}, first[u] = cnt++;     edge[cnt] = (Edge){u, first[v], -w, 0}, first[v] = cnt++;   }   inline int SPFA() {     int e, u, v, inf;     memset(dis, 63, sizeof(dis)), inf = dis[0];     Q.push(S), dis[S] = 0, vis[S] = 1;     while (!Q.empty()) {       u = Q.front(), Q.pop();       for (e = first[u]; ~e; e = edge[e].next)         if (edge[e].f && dis[u] + edge[e].w < dis[v = edge[e].to]) {           dis[v] = dis[u] + edge[e].w, pv[v] = u, pe[v] = e;           if (!vis[v]) vis[v] = 1, Q.push(v);         }       vis[u] = 0;     }     if (dis[T] >= 0) return 0;     for (v = T; v ^ S; v = pv[v]) inf = min(inf, edge[pe[v]].f);     maxflow += inf, mincost += dis[T] * inf;     for (v = T; v ^ S; v = pv[v]) edge[pe[v]].f -= inf, edge[pe[v] ^ 1].f += inf;     return 1;   }   inline int MCMF() {     while (SPFA())       ;     return mincost;   }   }  // namespace MincostMaxFlow   using MincostMaxFlow ::AddEdge;   using MincostMaxFlow ::Init;   using MincostMaxFlow ::MCMF;   const int inf(1e7);   int n, k, a[85], c[85], S, T;   int main() {     int i, j, tmp;     scanf( %d%d , &n, &k), k = min(k, n);     for (i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (i = 1; i <= n; ++i) scanf( %d , &c[i]);     Init(S = 0, T = n + n + 2), tmp = n + n + 1, AddEdge(S, tmp, 0, k);     for (i = 1; i <= n; ++i) {       AddEdge(i, i + n, -inf, 1);       for (j = i + 1; j <= n; ++j)         if (a[j] == a[i])           AddEdge(i + n, j, 0, 1);         else           AddEdge(i + n, j, c[a[j]], 1);       AddEdge(i + n, T, 0, 1), AddEdge(tmp, i, c[a[i]], 1);     }     printf( %d n , MCMF() + n * inf);     return 0;   }   