func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /stack:100000000 )   using namespace std;   const int N = 155;   const int INF = 1000000000;   struct Edge {     int to, flow, cap, cost;     Edge() {}     Edge(int to, int flow, int cap, int cost)         : to(to), flow(flow), cap(cap), cost(cost) {}   };   vector<Edge> g[N];   void add_edge(int from, int to, int cap, int cost) {     g[from].push_back(Edge(to, 0, cap, cost));     g[to].push_back(Edge(from, cap, cap, -cost));   }   int* count_letters(string s) {     int* a = new int[26];     memset(a, 0, 26 * sizeof(int));     for (int(i) = 0; (i) < ((int)(s).size()); (i)++) a[s[i] -  a ]++;     return a;   }   int d[N], p[N], id[N];   void find_flow(int src, int goal, int need) {     int flow = 0, n = goal + 1, cost = 0;     while (flow < need) {       for (int(i) = 0; (i) < (n); (i)++) d[i] = INF, p[i] = id[i] = -1;       d[src] = 0;       for (int(i) = 0; (i) < (n - 1); (i)++) {         for (int(a) = 0; (a) < (n); (a)++) {           for (int(j) = 0; (j) < ((int)(g[a]).size()); (j)++) {             int b = g[a][j].to;             if (g[a][j].flow < g[a][j].cap && d[b] > d[a] + g[a][j].cost) {               d[b] = d[a] + g[a][j].cost;               p[b] = a;               id[b] = j;             }           }         }       }       if (d[goal] == INF) {         puts( -1 );         return;       }       int push = INF, cur = goal;       while (cur != src) {         push = min(push, g[p[cur]][id[cur]].cap - g[p[cur]][id[cur]].flow);         cur = p[cur];       }       cur = goal;       flow += push;       while (cur != src) {         g[p[cur]][id[cur]].flow += push;         cost += push * g[p[cur]][id[cur]].cost;         for (int(i) = 0; (i) < ((int)(g[cur]).size()); (i)++) {           if (g[cur][i].to == p[cur]) {             g[cur][i].flow -= push;             break;           }         }         cur = p[cur];       }     }     printf( %d n , cost);   }   int main() {     string t;     cin >> t;     int* a = count_letters(t);     int n;     cin >> n;     for (int(i) = 0; (i) < (26); (i)++) add_edge(n + 1 + i, n + 27, a[i], 0);     for (int(i) = 0; (i) < (n); (i)++) {       string s;       int cap;       cin >> s >> cap;       int* b = count_letters(s);       add_edge(0, i + 1, cap, i + 1);       for (int(j) = 0; (j) < (26); (j)++) add_edge(i + 1, n + 1 + j, b[j], 0);     }     find_flow(0, n + 27, (int)(t).size());     return 0;   }   