func_code_string: #include <bits/stdc++.h>   using namespace std;   inline char gc() {     static char now[1 << 16], *S, *T;     if (T == S) {       T = (S = now) + fread(now, 1, 1 << 16, stdin);       if (T == S) return EOF;     }     return *S++;   }   inline long long read() {     register long long x = 0, f = 1;     char ch = gc();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = gc();     }     while (isdigit(ch)) {       x = (x << 3) + (x << 1) + ch -  0 ;       ch = gc();     }     return (f == 1) ? x : -x;   }   struct node {     long long l, r, sz, rd, w;   } g[1200001];   inline void pushup(long long rt) {     g[rt].sz = g[g[rt].l].sz + g[g[rt].r].sz + 1;   }   long long tot;   inline long long news(long long w) {     g[++tot].sz = 1;     g[tot].w = w;     g[tot].rd = rand();     g[tot].l = g[tot].r = 0;     return tot;   }   void split(long long rt, long long &a, long long &b, long long w) {     if (!rt) return (void)(a = b = 0);     if (g[rt].w <= w) {       a = rt;       split(g[a].r, g[a].r, b, w);       pushup(a);     } else {       b = rt;       split(g[b].l, a, g[b].l, w);       pushup(b);     }   }   long long merge(long long a, long long b) {     if (a * b == 0) return a + b;     if (g[a].rd <= g[b].rd) {       g[a].r = merge(g[a].r, b);       pushup(a);       return a;     } else {       g[b].l = merge(a, g[b].l);       pushup(b);       return b;     }   }   long long root;   inline void insert(long long w) {     long long a = 0, b = 0, c = 0;     split(root, a, b, w);     root = merge(merge(a, news(w)), b);   }   inline long long rank_x(long long rt, long long ra) {     while (rt) {       if (g[g[rt].l].sz + 1 == ra)         return g[rt].w;       else if (g[g[rt].l].sz + 1 > ra)         rt = g[rt].l;       else         ra -= g[g[rt].l].sz + 1, rt = g[rt].r;     }     return -1;   }   struct QUE {     long long id, pos, opt, wht;   } q[2000001];   long long ans[1000001], n, m, Q, qcnt;   inline bool cmp(QUE a, QUE b) {     if (a.pos == b.pos) return a.opt < b.opt;     return a.pos < b.pos;   }   long long sum[1000001];   signed main() {     n = read(), m = read(), Q = read();     for (long long i = 1; i <= n; i++) {       sum[read()]++;     }     for (long long i = 1; i <= m; i++) {       q[++qcnt].opt = 2;       q[qcnt].pos = sum[i];       q[qcnt].id = i;     }     sort(q + 1, q + 1 + qcnt, cmp);     long long SUM = 0;     for (long long i = 1; i <= m; i++) {       SUM += sum[q[i].id];       q[i].pos = sum[q[i].id] * i - SUM;     }     sort(q + 1, q + 1 + qcnt, cmp);     for (long long i = 1; i <= Q; i++) {       long long sb = read() - n;       q[++qcnt].id = i;       q[qcnt].pos = sb;       q[qcnt].opt = 1;       q[qcnt].wht = sb;     }     sort(q + m + 1, q + qcnt + 1, cmp);     long long tmp = 0;     for (long long i = m + 1; i <= qcnt; i++) {       long long sb = q[i].wht;       while (tmp < m && q[tmp + 1].pos < sb) tmp++;       q[i].wht = ((sb - q[tmp].pos) % tmp ? (sb - q[tmp].pos) % tmp : tmp);     }     sort(q + 1, q + 1 + qcnt, cmp);     for (long long i = 1; i <= qcnt; i++) {       if (q[i].opt == 1) {         ans[q[i].id] = rank_x(root, q[i].wht);       } else {         insert(q[i].id);       }     }     for (long long i = 1; i <= Q; i++) printf( %lld n , ans[i]);     return 0;   }   