/*
Given an array of size N, print the array elements in along with their frequencies
*/

#include <iostream>
#include<map>
using namespace std;
int main() {
    map<int,int> m;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]++;
    }
    for(auto i:m){
        cout<<i.first<<" "<<i.second<<"\n";
    }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: