Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#define INF 111111111
#define MAXN 33333
#define MAXM 2e6
using namespace std;
int n, tot, q, a[MAXN];
int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
int nxt[MAXN], b[MAXN];
int build(int l, int r)
{
    int rt = tot++;
    val[rt] = 0;
    int m = (l + r) >> 1;
    if(l != r)
    {
        lson[rt] = build(l, m);
        rson[rt] = build(m + 1, r);
    }
    return rt;
}
int update(int rt, int pos, int v)
{
    int newrt = tot++, tmp = newrt;
    int l = 1, r = n;
    val[newrt] = val[rt] + v;
    while(l < r)
    {
        int m = (l + r) >> 1;
        if(pos <= m)
        {
            lson[newrt] = tot++;
            rson[newrt] = rson[rt];
            newrt = lson[newrt];
            rt = lson[rt];
            r = m;
        }
        else
        {
            rson[newrt] = tot++;
            lson[newrt] = lson[rt];
            newrt = rson[newrt];
            rt = rson[rt];
            l = m + 1;
        }
        val[newrt] = val[rt] + v;
    }
    return tmp;
}
 
int query(int rt, int pos)
{
    int ret = 0;
    int l = 1, r = n;
    while(pos > l)
    {
        int m = (l + r) >> 1;
        if(pos <= m)
        {
            ret += val[rson[rt]];
            rt = lson[rt];
            r = m;
        }
        else
        {
            l = m + 1;
            rt = rson[rt];
        }
    }
    return ret + val[rt];
}
int main()
{
    while(scanf("%d", &n) != EOF)
    {
        tot = 0;
        memset(nxt, -1, sizeof(nxt));
        for(int i = 1; i <= n; i++)
        {
            scanf("%d", &a[i]);
            b[i - 1] = a[i];
        }
        sort(b, b + n);
        int cnt = unique(b, b + n) - b;
        T[0] = build(1, n);
        for(int i = 1; i <= n; i++)
        {
            int id = lower_bound(b, b + cnt, a[i]) - b;
            if(nxt[id] == -1)
                T[i] = update(T[i - 1], i, 1);
            else
            {
                int t = update(T[i - 1], nxt[id], -1);
                T[i] = update(t, i, 1);
            }
            nxt[id] = i;
        }
        scanf("%d", &q);
        while(q--)
        {
            int l, r;
            scanf("%d%d", &l, &r);
            printf("%d\n", query(T[r], l));
        }
    }
    return 0;
}


Compiler output:
a.cc:11:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   11 | #define MAXM 2e6
      |              ^~~
a.cc:14:7: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |       ^~~~
a.cc:11:14: error: could not convert '2.0e+6' from 'double' to 'long unsigned int'
   11 | #define MAXM 2e6
      |              ^~~
      |              |
      |              double
a.cc:14:7: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |       ^~~~
a.cc:11:14: error: size of array 'T' has non-integral type 'double'
   11 | #define MAXM 2e6
      |              ^~~
a.cc:14:7: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |       ^~~~
a.cc:11:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   11 | #define MAXM 2e6
      |              ^~~
a.cc:14:19: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                   ^~~~
a.cc:11:14: error: could not convert '2.0e+6' from 'double' to 'long unsigned int'
   11 | #define MAXM 2e6
      |              ^~~
      |              |
      |              double
a.cc:14:19: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                   ^~~~
a.cc:11:14: error: size of array 'lson' has non-integral type 'double'
   11 | #define MAXM 2e6
      |              ^~~
a.cc:14:19: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                   ^~~~
a.cc:11:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   11 | #define MAXM 2e6
      |              ^~~
a.cc:14:31: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                               ^~~~
a.cc:11:14: error: could not convert '2.0e+6' from 'double' to 'long unsigned int'
   11 | #define MAXM 2e6
      |              ^~~
      |              |
      |              double
a.cc:14:31: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                               ^~~~
a.cc:11:14: error: size of array 'rson' has non-integral type 'double'
   11 | #define MAXM 2e6
      |              ^~~
a.cc:14:31: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                               ^~~~
a.cc:11:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   11 | #define MAXM 2e6
      |              ^~~
a.cc:14:42: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                                          ^~~~
a.cc:11:14: error: could not convert '2.0e+6' from 'double' to 'long unsigned int'
   11 | #define MAXM 2e6
      |              ^~~
      |              |
      |              double
a.cc:14:42: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                                          ^~~~
a.cc:11:14: error: size of array 'val' has non-integral type 'double'
   11 | #define MAXM 2e6
      |              ^~~
a.cc:14:42: note: in expansion of macro 'MAXM'
   14 | int T[MAXM], lson[MAXM], rson[MAXM], val[MAXM];
      |                                          ^~~~