Language: C++

#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
struct node{
    ll answer;
    unordered_map<ll, ll> mp1;
}segtree[2048679];
vl color;
node util(node x, node y)
{
    node ans;
    unordered_map<ll, ll>:: iterator itr;
    for(itr=(x.mp1).begin(); itr!=(x.mp1).end(); itr++)
    {
        ll col=itr->first;
        ans.mp1[col]++;
    }
    for(itr=(y.mp1).begin(); itr!=(y.mp1).end(); itr++)
    {
        ll col=itr->first;
        ans.mp1[col]++;
    }
    ans.answer=(ll)((ans.mp1).size());
    return ans;
}
node Query(ll start, ll end, ll r1, ll r2, ll put)
{
    if(start>=r1&&end<=r2)
    return segtree[put];
    node sex;
    unordered_map<ll, ll> mp10;
    sex.mp1=mp10;
    sex.answer=0;
    if(start>r2||end<r1)
    return sex;
    ll mid=start+(end-start)/2;
    return util(Query(start, mid, r1, r2, 2*put+1), Query(mid+1, end, r1, r2, 2*put+2));
}
node constructTree(ll start, ll end, ll put)
{
    if(start==end)
    {
        unordered_map<ll, ll> fuck;
        fuck[color[start]]++;
        segtree[put].answer=1;
        segtree[put].mp1=fuck;
        return segtree[put];
    }
    ll mid=start+(end-start)/2;
    segtree[put]=util(constructTree(start, mid, 2*put+1), constructTree(mid+1, end, 2*put+2));
    return segtree[put];
}
void solve()
{
    ll n, q;
	cin>>n>>q;
	color.resize(n);
	forr(i, n)
	{
	    cin>>color[i];
	}
	ll x=(ll)ceil((log2(n)));
    x=(ll)pow(2, x);
    constructTree(0, n-1, 0);
	forr(i, q)
	{
	    ll lef, rig;
	    cin>>lef>>rig;
	    --lef;
	    --rig;
	    node lala=Query(0, n-1, lef, rig, 0);
        cout<<lala.answer<<endl;
	}
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Compiler output:
a.cc:34:5: error: 'unordered_map' does not name a type
   34 |     unordered_map<ll, ll> mp1;
      |     ^~~~~~~~~~~~~
a.cc: In function 'node util(node, node)':
a.cc:40:5: error: 'unordered_map' was not declared in this scope
   40 |     unordered_map<ll, ll>:: iterator itr;
      |     ^~~~~~~~~~~~~
a.cc:15:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
   14 | #include<cmath>
  +++ |+#include <unordered_map>
   15 | #define pb push_back
a.cc:21:12: error: expected primary-expression before 'int'
   21 | #define ll int
      |            ^~~
a.cc:40:19: note: in expansion of macro 'll'
   40 |     unordered_map<ll, ll>:: iterator itr;
      |                   ^~
a.cc:41:9: error: 'itr' was not declared in this scope
   41 |     for(itr=(x.mp1).begin(); itr!=(x.mp1).end(); itr++)
      |         ^~~
a.cc:41:16: error: 'struct node' has no member named 'mp1'
   41 |     for(itr=(x.mp1).begin(); itr!=(x.mp1).end(); itr++)
      |                ^~~
a.cc:41:38: error: 'struct node' has no member named 'mp1'
   41 |     for(itr=(x.mp1).begin(); itr!=(x.mp1).end(); itr++)
      |                                      ^~~
a.cc:44:13: error: 'struct node' has no member named 'mp1'
   44 |         ans.mp1[col]++;
      |             ^~~
a.cc:46:9: error: 'itr' was not declared in this scope
   46 |     for(itr=(y.mp1).begin(); itr!=(y.mp1).end(); itr++)
      |         ^~~
a.cc:46:16: error: 'struct node' has no member named 'mp1'
   46 |     for(itr=(y.mp1).begin(); itr!=(y.mp1).end(); itr++)
      |                ^~~
a.cc:46:38: error: 'struct node' has no member named 'mp1'
   46 |     for(itr=(y.mp1).begin(); itr!=(y.mp1).end(); itr++)
      |                                      ^~~
a.cc:49:13: error: 'struct node' has no member named 'mp1'
   49 |         ans.mp1[col]++;
      |             ^~~
a.cc:51:26: error: 'struct node' has no member named 'mp1'
   51 |     ans.answer=(ll)((ans.mp1).size());
      |                          ^~~
a.cc: In function 'node Query(int, int, int, int, int)':
a.cc:59:5: error: 'unordered_map' was not declared in this scope
   59 |     unordered_map<ll, ll> mp10;
      |     ^~~~~~~~~~~~~
a.cc:59:5: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
a.cc:21:12: error: expected primary-expression before 'int'
   21 | #define ll int
      |            ^~~
a.cc:59:19: note: in expansion of macro 'll'
   59 |     unordered_map<ll, ll> mp10;
      |                   ^~
a.cc:60:9: error: 'struct node' has no member named 'mp1'
   60 |     sex.mp1=mp10;
      |         ^~~
a.cc:60:13: error: 'mp10' was not declared in this scope
   60 |     sex.mp1=mp10;
      |             ^~~~
a.cc: In function 'node constructTree(int, int, int)':
a.cc:71:9: error: 'unordered_map' was not declared in this scope
   71 |         unordered_map<ll, ll> fuck;
      |         ^~~~~~~~~~~~~
a.cc:71:9: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
a.cc:21:12: error: expected primary-expression before 'int'
   21 | #define ll int
      |            ^~~
a.cc:71:23: note: in expansion of macro 'll'
   71 |         unordered_map<ll, ll> fuck;
      |                       ^~
a.cc:72:9: error: 'fuck' was not declared in this scope
   72 |         fuck[color[start]]++;
      |         ^~~~
a.cc:74:22: error: 'struct node' has no member named 'mp1'
   74 |         segtree[put].mp1=fuck;
      |                      ^~~