Language: C++

//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);

vi vt;

int operation(int a,int b){
  return a+b;
}

void st(int curr,int l,int r,int idx,int val){
  if(l==r){
    if(l==idx) vt[curr]+=val;
    vt[curr]=max(vt[curr],0ll);
    return ;
  }
  int mid=(l+r)/2;
  if(idx>mid) st(2*curr+2,mid+1,r,idx,val);
  else st(2*curr+1,l,mid,idx,val);
  vt[curr]=operation(vt[2*curr+1],vt[2*curr+2]);
}


int gt(int curr,int l,int r,int lx,int rx){
  if(l==r){
    if(l>=lx && l<=rx) return vt[curr];
    return 0;
  }
  if(l>=lx && r<=rx) return vt[curr];
  if(r<lx || l>rx) return 0;
  int mid=(l+r)/2;
  return gt(2*curr+1,l,mid,lx,rx) + gt(2*curr+2,mid+1,r,lx,rx);
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int n; cin>>n; 
  int a[n]; f(i,0,n) cin>>a[i];
  set<int> st,sst;
  f(i,0,n) st.insert(a[i]);
  int dis=sz(st);
  int cnt=0;
  int l=0,r=0;
  int curr=sz(sst);
  while(r<n){
    if(curr<dis){
      sst.insert(a[r]); ++r;
      curr=sz(sst);
    }
  }

  cout<<cnt;
  return 0;
}
// check for overflows dummy !!!
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);

vi vt;

int operation(int a,int b){
  return a+b;
}

void st(int curr,int l,int r,int idx,int val){
  if(l==r){
    if(l==idx) vt[curr]+=val;
    vt[curr]=max(vt[curr],0ll);
    return ;
  }
  int mid=(l+r)/2;
  if(idx>mid) st(2*curr+2,mid+1,r,idx,val);
  else st(2*curr+1,l,mid,idx,val);
  vt[curr]=operation(vt[2*curr+1],vt[2*curr+2]);
}


int gt(int curr,int l,int r,int lx,int rx){
  if(l==r){
    if(l>=lx && l<=rx) return vt[curr];
    return 0;
  }
  if(l>=lx && r<=rx) return vt[curr];
  if(r<lx || l>rx) return 0;
  int mid=(l+r)/2;
  return gt(2*curr+1,l,mid,lx,rx) + gt(2*curr+2,mid+1,r,lx,rx);
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int x,y; cin>>x>>y;
  if(x==y) cout<<"-1";
  else cout<<x;
  return 0;
}
// check for overflows dummy !!!


Compiler output:
a.cc:107:4: error: redefinition of 'long double pie'
  107 | ld pie=3.141592653589;
      |    ^~~
a.cc:20:4: note: 'long double pie' previously defined here
   20 | ld pie=3.141592653589;
      |    ^~~
a.cc:108:5: error: redefinition of 'long long int mod'
  108 | int mod=1e9+7;
      |     ^~~
a.cc:21:5: note: 'long long int mod' previously defined here
   21 | int mod=1e9+7;
      |     ^~~
a.cc:110:6: error: redefinition of 'bool Compare(std::pair<long long int, long long int>, std::pair<long long int, long long int>)'
  110 | bool Compare(pair<int,int> a, pair<int,int> b)
      |      ^~~~~~~
a.cc:23:6: note: 'bool Compare(std::pair<long long int, long long int>, std::pair<long long int, long long int>)' previously defined here
   23 | bool Compare(pair<int,int> a, pair<int,int> b)
      |      ^~~~~~~
a.cc:117:75: error: redefinition of 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::function<bool(std::pair<long long int, long long int>, std::pair<long long int, long long int>)> > pq'
  117 | std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);
      |                                                                           ^~
a.cc:30:75: note: 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::function<bool(std::pair<long long int, long long int>, std::pair<long long int, long long int>)> > pq' previously declared here
   30 | std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);
      |                                                                           ^~
a.cc:119:4: error: redefinition of 'std::vector<long long int> vt'
  119 | vi vt;
      |    ^~
a.cc:32:4: note: 'std::vector<long long int> vt' previously declared here
   32 | vi vt;
      |    ^~
a.cc:121:5: error: redefinition of 'long long int operation(long long int, long long int)'
  121 | int operation(int a,int b){
      |     ^~~~~~~~~
a.cc:34:5: note: 'long long int operation(long long int, long long int)' previously defined here
   34 | int operation(int a,int b){
      |     ^~~~~~~~~
a.cc:125:6: error: redefinition of 'void st(long long int, long long int, long long int, long long int, long long int)'
  125 | void st(int curr,int l,int r,int idx,int val){
      |      ^~
a.cc:38:6: note: 'void st(long long int, long long int, long long int, long long int, long long int)' previously defined here
   38 | void st(int curr,int l,int r,int idx,int val){
      |      ^~
a.cc:138:5: error: redefinition of 'long long int gt(long long int, long long int, long long int, long long int, long long int)'
  138 | int gt(int curr,int l,int r,int lx,int rx){
      |     ^~
a.cc:51:5: note: 'long long int gt(long long int, long long int, long long int, long long int, long long int)' previously defined here
   51 | int gt(int curr,int l,int r,int lx,int rx){
      |     ^~
a.cc:150:9: error: redefinition of 'int32_t main()'
  150 | int32_t main(){
      |         ^~~~
a.cc:63:9: note: 'int32_t main()' previously defined here
   63 | int32_t main(){
      |         ^~~~