WA in VOTERLIST

#include<bits/stdc++.h>
 using namespace std;

 int main(){
 vector <int> v;
 int A,B,C;
 cin >> A >> B >> C;
for (int i=0; i<A;i++){
int k;
cin >> k;
v.push_back(k);
}
for (int i=0; i<B;i++){
int k;
cin >> k;
v.push_back(k);
}
for (int i=0; i<C;i++){
int k;
cin >> k;
v.push_back(k);
}
cout << "\n";
int z = v.size();
vector <pair<int,int>> p;
vector <int> final;
for (int i=0; i<v.size();i++){
        p.push_back(make_pair(v[i],count(v.begin(),v.end(),v[i])));
        if (p[i].second > 1){
        final.push_back(p[i].first);
    }
}
for (int i=0; i<final.size();i++){
   cout << final[i] << "\n";
  }
return 0;
}

I wrote this code for VOTERLIST, and it is returning the wrong output for given sample input :

Input :
5 6 5
23
30
42
57
90
21
23
35
57
90
92
21
23
30
57
90

Expected Output :
5
21
23
30
57
90

My output :
23
30
57
90
21
23
57
90
21
23
30
57
90

Someone please tell me where I made mistake in my code :pensive:

Someone please help

This happened because you have put all 3 arrays into single one. So, each value which will count in answer will appear again. This is the cause for your repeating values. You can use set or always check if the value is already present in final vector or not