func_code_string: #include <bits/stdc++.h>   using namespace std;   void dfs(set<int> &temp, list<int> adj[], vector<bool> &v, int s, int &t1,            int &t2, vector<int> b, vector<int> w) {     v[s] = true;     list<int>::iterator it;     for (it = adj[s].begin(); it != adj[s].end(); it++) {       if (!v[*it]) {         temp.insert(*it);         t1 += b[*it];         t2 += w[*it];         dfs(temp, adj, v, *it, t1, t2, b, w);       }     }   }   list<int> adj[1001];   int main() {     int n, m, weight;     cin >> n >> m >> weight;     vector<int> b(n + 1);     vector<int> w(n + 1);     for (int i = 1; i <= n; i++) cin >> w[i];     for (int i = 1; i <= n; i++) cin >> b[i];     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     vector<bool> v(n + 1, false);     vector<set<int> > arr;     vector<int> tw;     vector<int> tb;     for (int i = 1; i <= n; i++) {       if (!v[i]) {         set<int> temp;         temp.insert(i);         int t1 = b[i], t2 = w[i];         dfs(temp, adj, v, i, t1, t2, b, w);         arr.push_back(temp);         tb.push_back(t1);         tw.push_back(t2);       }     }     vector<vector<int> > dp(arr.size() + 1, vector<int>(weight + 1, 0));     for (int i = 1; i <= arr.size(); i++) {       for (int j = 1; j <= weight; j++) {         int max = 0;         if (dp[i - 1][j] > max) max = dp[i - 1][j];         if (j - tw[i - 1] >= 0)           if (dp[i - 1][j - tw[i - 1]] + tb[i - 1] > max)             max = dp[i - 1][j - tw[i - 1]] + tb[i - 1];         set<int>::iterator it;         for (it = arr[i - 1].begin(); it != arr[i - 1].end(); it++) {           if (j - w[*it] >= 0)             if (dp[i - 1][j - w[*it]] + b[*it] > max)               max = dp[i - 1][j - w[*it]] + b[*it];         }         dp[i][j] = max;       }     }     int max = 0;     for (int i = 0; i <= weight; i++)       if (dp[arr.size()][i] > max) max = dp[arr.size()][i];     cout << max;     return 0;   }   