In this HackerEarth Shil and Birthday present problem solution Shil got an array of N integers as a present on his birthday. But he didn't liked it. Shil wants to make this array beautiful. Shil considers an array A1,A2,A3 . . . AN beautiful if A1 > AN. Inorder to make it beautiful Shil can swap any two numbers in the array. Also Shil can perform this operation any number of times on any adjacent pairs of integers in the array A.Find the number of ways in which Shil can make this array beautiful.Two ways are considered same if resulting array after making all the swaps have same A1 and AN.

## HackerEarth Shil and Birthday present problem solution.

`#include<bits/stdc++.h>using namespace std;#define ll  int#define pi pair<ll,ll>#define pii pair<ll,pi>#define mp make_pair#define mod 1000000007#define f first#define s second#define pb emplace_back#define fr freopen("input-10.txt","r",stdin)#define fo freopen("output-10.txt","w",stdout)ll freq;int main(){ ll n; scanf("%d",&n); ll x; long long int t=0; for(int i=1;i<=n;i++){    scanf("%d",&x);    freq[x]++;    if(freq[x]==1){        t++;    } } long long int ans=t*(t-1); ans/=2; cout<<ans;}`

### Second solution

`#include <bits/stdc++.h>using namespace std ;#define LL long long intint N ;vector<int> A ;int main(){    cin >> N ;    assert(N <= 1000000 && N >= 1) ;    A.resize(N) ;    for(int i=0;i<N;i++){        cin >> A[i] ;        assert(A[i] <= 1000000 && A[i] >= 1) ;    }    sort(A.begin(),A.end()) ;    int i = 0 , distinct = 0 ;    LL ans ;    while(i < N){        distinct ++ ;        int x = A[i] ;        while(i < N && x == A[i]){            i ++ ;        }     }    ans = (1LL * distinct * (distinct-1) / 2) ;    cout << ans << endl ;    return 0 ;}`
{"ft_lang_label":"__label__en","ft_lang_prob":0.64760834,"math_prob":0.98855174,"size":1644,"snap":"2022-27-2022-33","text_gpt3_token_len":476,"char_repetition_ratio":0.11768293,"word_repetition_ratio":0.014035088,"special_character_ratio":0.3582725,"punctuation_ratio":0.17486338,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98176056,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-18T13:25:05Z\",\"WARC-Record-ID\":\"<urn:uuid:c8cd4e68-6733-4b42-a404-a2af93f27c87>\",\"Content-Length\":\"196734\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:27871f21-721a-4e36-a836-b7ce047c6ec1>\",\"WARC-Concurrent-To\":\"<urn:uuid:442ec224-f903-4f5d-9795-7fff2c1c9ff2>\",\"WARC-IP-Address\":\"172.253.122.121\",\"WARC-Target-URI\":\"https://programs.programmingoneonone.com/2022/04/hackerearth-shil-and-birthday-present-problem-solution.html\",\"WARC-Payload-Digest\":\"sha1:4TQUWHPGJ3J4YSM5SY5775GOI4JK5BC7\",\"WARC-Block-Digest\":\"sha1:F33DILHQ2L2DS5FXKF7KQ2DFWRHPQYEU\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882573197.34_warc_CC-MAIN-20220818124424-20220818154424-00511.warc.gz\"}"}