func_code_string: #include <bits/stdc++.h>   using namespace std;   void out() {     cout.flush();     int n;     cin >> n;     exit(0);   }   int tree[1 << 21];   int st = 1 << 20;   void add(int pos, int d) {     pos += st;     for (; pos; pos >>= 1) tree[pos] += d;   }   int findKth(int k) {     int pos = 1;     while (pos < st) {       pos *= 2;       if (tree[pos] < k) {         k -= tree[pos];         pos++;       }     }     return pos - st;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m, q;     cin >> n >> m >> q;     vector<int> kols(m, 0);     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       kols[x - 1]++;     }     vector<pair<int, int> > ps;     for (int i = 0; i < m; ++i) ps.push_back(make_pair(kols[i], i));     sort(ps.begin(), ps.end());     long long inf = 1000;     inf *= inf;     inf = inf * inf * inf;     inf += 1;     vector<long long> starts(m, 0);     for (int i = 1; i < m; ++i)       starts[i] = min(           inf, starts[i - 1] + (long long)i * (ps[i].first - ps[i - 1].first));     starts.push_back(inf + 1);     vector<pair<long long, int> > qs;     for (int i = 0; i < q; ++i) {       long long k;       cin >> k;       qs.push_back(make_pair(k - n - 1, i));     }     sort(qs.begin(), qs.end());     vector<int> anss(q, -1);     memset(tree, 0, sizeof(tree));     int cur = 0;     for (int i = 0; i < q; ++i) {       while (starts[cur] <= qs[i].first) {         add(ps[cur].second, 1);         ++cur;       }       long long k = qs[i].first - starts[cur - 1];       k %= cur;       anss[qs[i].second] = findKth(k + 1);     }     for (int i = 0; i < q; ++i) cout << anss[i] + 1 <<   n ;     out();     return 0;   }   