func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, q;   const int max_w = 100;   vector<pair<int, int>> cnt_sort(vector<pair<int, int>>& a) {     vector<int> cnt(n * max_w + 5);     for (int i = 0; i < a.size(); ++i) {       ++cnt[a[i].first + 1];     }     for (int i = 1; i < cnt.size(); ++i) {       cnt[i] += cnt[i - 1];     }     vector<pair<int, int>> res(a.size());     for (int i = 0; i < a.size(); ++i) {       res[cnt[a[i].first]++] = a[i];     }     return res;   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m >> q;     vector<int> w(n);     for (int i = 0; i < n; ++i) {       cin >> w[i];     }     reverse(w.begin(), w.end());     vector<int> cnt(1 << n, 0);     string s;     for (int i = 0; i < m; ++i) {       cin >> s;       int res = 0;       for (int j = 0; j < n; ++j) {         res <<= 1;         res |= (s[j] ==  1 );       }       ++cnt[res];     }     vector<vector<pair<int, int>>> ans(1 << n, vector<pair<int, int>>());     vector<vector<int>> sum(1 << n, vector<int>(1 << n));     for (int i = 0; i < ans.size(); ++i) {       for (int j = 0; j < cnt.size(); ++j) {         if (cnt[j] == 0) continue;         int kok = i ^ j;         int res = 0;         for (int k = 0; k < n; ++k) {           if (!((kok >> k) & 1)) {             res += w[k];           }         }         ans[i].push_back({res, cnt[j]});       }       ans[i] = cnt_sort(ans[i]);       sum[i][0] = ans[i][0].second;       for (int j = 1; j < ans[i].size(); ++j) {         sum[i][j] = sum[i][j - 1] + ans[i][j].second;       }     }     int k;     while (q--) {       cin >> s >> k;       int res = 0;       for (int j = 0; j < n; ++j) {         res <<= 1;         res |= (s[j] ==  1 );       }       int j =           upper_bound(ans[res].begin(), ans[res].end(), make_pair(k, 100000000)) -           ans[res].begin();       --j;       if (j < 0) {         cout << 0;       } else {         cout << sum[res][j];       }       cout <<   n ;     }   }   