#pragma GCC optimize("O3") //#pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx2") #define io_init cin.tie(0);ios::sync_with_stdio(0);cout< constexpr int INF = 2147483647; constexpr long long int INF_LL = 9223372036854775807; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; using namespace std; typedef long long int ll; typedef unsigned long long int ull; template, typename isEqual = equal_to> struct HashMap { int bsize; // アドレスの数 int msize; // msize > dsize のときリハッシュする int dsize = 0; // データの数 int tombsize = 0; // 削除済みデータの数 struct container { // 0 -> empty 1 -> used 2 -> deleted int used = 0; pair data; }; vector varray; HashMap(int BucketSize = 100000) { bsize = 1 << (32 - __builtin_clz(BucketSize)); msize = bsize * 0.7; varray = vector(bsize); } void resize(int nextsize) { auto tmp = varray; bsize = nextsize; msize = bsize * 0.7; dsize = 0; tombsize = 0; varray = vector(bsize); for (int i = 0; i < tmp.size(); i++) { if (tmp[i].used != 1)continue; insert(tmp[i].data.first, tmp[i].data.second); } } valtype& insert(const keytype& a, const valtype& b) { if (dsize + 1 > msize)resize(bsize << 1); ull Hash = Hasher()(a); while (varray[Hash & (bsize - 1)].used != 0) { if (isEqual()(varray[Hash & (bsize - 1)].data.first, a)) return varray[Hash & (bsize - 1)].data.second; Hash++; } varray[Hash & (bsize - 1)] = { 1,{a,b} }; dsize++; return varray[Hash & (bsize - 1)].data.second; } void erase(const keytype& key) { ull Hash = Hasher()(key); while (varray[Hash & (bsize - 1)].used && !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) Hash++; if (varray[Hash & (bsize - 1)].used != 1 || !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) throw "Not Found"; varray[Hash & (bsize - 1)].used = 2; tombsize++; } valtype& at(const keytype& key) { ull Hash = Hasher()(key); while (varray[Hash & (bsize - 1)].used && !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) Hash++; if (varray[Hash & (bsize - 1)].used != 1 || !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) throw "Not Found"; return varray[Hash & (bsize - 1)].data.second; } valtype& operator[] (keytype key) { ull Hash = Hasher()(key); while (varray[Hash & (bsize - 1)].used && !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) Hash++; if (varray[Hash & (bsize - 1)].used == 0) { if (dsize + 1 > msize)insert(key, valtype()); varray[Hash & (bsize - 1)].used = 1; varray[Hash & (bsize - 1)].data.first = key; dsize++; return varray[Hash & (bsize - 1)].data.second; } else if (varray[Hash & (bsize - 1)].used == 2 || !isEqual()(varray[Hash & (bsize - 1)].data.first, key)) { if (dsize + 1 > msize)insert(key, valtype()); while (varray[Hash & (bsize - 1)].used != 0) Hash++; varray[Hash & (bsize - 1)].used = 1; varray[Hash & (bsize - 1)].data.first = key; dsize++; return varray[Hash & (bsize - 1)].data.second; } return varray[Hash & (bsize - 1)].data.second; } }; int main() { io_init; int N, M; cin >> N >> M; HashMap hm; for (int i = 0; i < N; i++) { ll tmp; cin >> tmp; hm[tmp]++; } for (int i = 0; i < M; i++) { ll tmp; cin >> tmp; cout << hm[tmp] << (i == M ? "\n" : " "); } }