Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
const ll N = 5e5+10;
#define ll long long

struct node{
  ll l;
  ll r;
  ll id;
}u[N];

ll z;
bool cool(node a,node b)
{
     if(a.l/z<b.l/z)
        return true;
     if(a.l/z>b.l/z)
        return false;
     return a.r<b.r;
}
 ll cnt[1111111];
 ll ans[N];
 ll v[N];

int main()
{

     //ios_base:: sync_with_stdio(false); cin.tie(0);
      
   
    // freopen("input.in","r",stdin);
        
        ll n,q;cin>>n>>q;
        ll fuk=0;
        z=sqrt(n);
      //  vector<ll>v(n);
        
        for(ll i=0;i<n;i++) cin >> v[i];
                    
        for(ll i=0;i<q;i++)
        {
             ll l,r;
             cin >> l >> r;
             node tmp;
             tmp.l=l-1;
             tmp.r=r-1;
             tmp.id=i;
             u[i]=tmp;
        }

         sort(u,u+q,cool);

         ll st=0,e=0;fuk=1;cnt[v[0]]++;

        for(ll i=0;i<q;i++)
        {
            ll l=u[i].l;
            ll r=u[i].r;
           // cout<<l<<" "<<r<<" "<<st<<" "<<e<<" "<<fuk<<endl;
            
            while(st<l)
            {
                cnt[v[st]]--;
                if(cnt[v[st]]==0) fuk--;
                 st++;
            }
            while(st>l)
            {
                 st--;
                 cnt[v[st]]++;
                 if(cnt[v[st]]==1) fuk++;
                 
            }
            while(e<r)
            {
                e++;
                cnt[v[e]]++;
                if(cnt[v[e]]==1) fuk++;
            }
            while(e>r)
            {
               cnt[v[e]]--;
               if(cnt[v[e]]==0) fuk--;
               e--;
            }            
            ans[u[i].id]=fuk;
        }

        for(ll i=0;i<q;i++) cout << ans[i] << endl;

     return 0;
}




Compiler output:
a.cc:7:7: error: 'll' does not name a type
    7 | const ll N = 5e5+10;
      |       ^~
a.cc:7:7: note: the macro 'll' had not yet been defined
a.cc:8:9: note: it was later defined here
    8 | #define ll long long
      |         ^~
a.cc:14:4: error: 'N' was not declared in this scope
   14 | }u[N];
      |    ^
a.cc:26:9: error: 'N' was not declared in this scope
   26 |  ll ans[N];
      |         ^
a.cc:27:7: error: 'N' was not declared in this scope
   27 |  ll v[N];
      |       ^
a.cc: In function 'int main()':
a.cc:42:36: error: 'v' was not declared in this scope
   42 |         for(ll i=0;i<n;i++) cin >> v[i];
      |                                    ^
a.cc:52:14: error: 'u' was not declared in this scope
   52 |              u[i]=tmp;
      |              ^
a.cc:55:15: error: 'u' was not declared in this scope
   55 |          sort(u,u+q,cool);
      |               ^
a.cc:57:32: error: 'v' was not declared in this scope
   57 |          ll st=0,e=0;fuk=1;cnt[v[0]]++;
      |                                ^
a.cc:90:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   90 |             ans[u[i].id]=fuk;
      |             ^~~
      |             abs
a.cc:93:37: error: 'ans' was not declared in this scope; did you mean 'abs'?
   93 |         for(ll i=0;i<q;i++) cout << ans[i] << endl;
      |                                     ^~~
      |                                     abs