#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair const int inf = 1000000001; const ll INF = 1e18 * 2; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout<> l >> m >> n; vi a(l), b(m); for (i0 = 0; i0 < l; i0++) { cin >> a[i0]; } for (i0 = 0; i0 < m; i0++) { cin >> b[i0]; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); DEBUG_VEC(a); DEBUG_VEC(b); vl x(n / 64 + 2), y(n / 64 + 2); int ai = 0, bi = 0; for (int i = 0;; i++) { if (i * 64 > n) { break; } for (int j = 0; j < 63; j++) { int z = i * 63 + j; if (ai < l) { if (a[ai] == z) { x[i] |= (1LL << j); } if (a[ai] <= z) { ai++; } } if (bi < m) { if (b[bi] == z) { y[i] |= (1LL << j); } if (b[bi] <= z) { bi++; } } } } DEBUG_VEC(x); DEBUG_VEC(y); vi bitstand(1 << 16); for (i0 = 0; i0 < (1 << 16); i0++) { int cnt = 0; int temp = 1; for (int i = 0; i < 16; i++) { if (i0 & temp) { cnt++; } temp <<= 1; } bitstand[i0] = cnt; } int q; cin >> q; int length = x.size(); for (i0 = 0; i0 < q; i0++) { int i, j; int ans = 0; for (i = 0; i < length; i++) { ll temp = x[i] & y[i]; ll mask = (1 << 16) - 1; for (j = 0; j < 4; j++) { ll bit = temp & mask; ans += bitstand[bit]; temp >>= 16; } } ll mask = 1 << 63; for (i = length - 1; i >= 0; i--) { y[i] <<= 1; if (i != 0) { if (y[i - 1] & mask) { y[i] |= 1; } } } cout << ans << endl; } }