func_code_string: #include <bits/stdc++.h>   using namespace std;   int ben[11];   int n, k;   int mem[505][505 * 11];   int arr[505 * 505];   int freqFav[100005];   int freqCards[100005];   int solve(int num, int rem) {     if (rem == 0 || num == 0) return 0;     int &ret = mem[num][rem];     if (~ret) return ret;     for (int i = 0; i < min(k, rem); i++) {       ret = max(ret, ben[i] + solve(num - 1, rem - i - 1));     }     return ret;   }   int main() {     memset(mem, -1, sizeof(mem));     scanf( %d %d , &n, &k);     for (int i = 0; i < k * n; i++) {       scanf( %d , arr + i);       freqCards[arr[i]]++;     }     for (int i = 0; i < n; i++) {       int fav;       scanf( %d , &fav);       freqFav[fav]++;     }     for (int i = 0; i < k; i++) {       scanf( %d , ben + i);     }     int res = 0;     for (int i = 0; i < 100005; i++) {       res += solve(freqFav[i], freqCards[i]);     }     printf( %d n , res);     return 0;   }   