#include #include #include #include #include #include using namespace std; struct Bird { int id; int occurance; }; int numInVector(vector types, int compareint) { int index = -1, counter = 0; for (int i = 0; i < types.size(); i++) { if (types[i].id == compareint) { index = counter; break; } else { counter++; } } return index; } int greatestOccurrance(vector birds) { int greatest = 0, type = 0; for (int i = 0; i < birds.size(); i++) { if (birds[i].occurance > greatest) { greatest = birds[i].occurance; type = birds[i].id; } else if (birds[i].occurance == greatest) { if (birds[i].id < type) type = birds[i].id; } else { i += 0; } } return type; } int findCommonBird(vector Birds) { vector typeBirds; for (int i = 0; i < Birds.size(); i++) { int type = Birds[i]; int indexfound = numInVector(typeBirds, type); if (indexfound == -1) { Bird newBird; newBird.id = type, newBird.occurance = 1; typeBirds.push_back(newBird); } else { typeBirds[indexfound].occurance++; } } return greatestOccurrance(typeBirds); } vector getInput() { int size = 0, num = 0; vector inputnums; cin >> size; while (cin >> num){ inputnums.push_back(num); } return inputnums; } void print(int type) { cout << type << endl; } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ print(findCommonBird(getInput())); return 0; }