Language: C++

// NK
#include <bits/stdc++.h>
using namespace std;

#define ii pair<int,int>;
#define ll long long;
#define vi vector<int>;
#define vii vector<ii>;
#define vll vector<ll>;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()

int n;
const int MAXS = 5e5;
int fen[MAXS + 3];
int a[MAXS + 3];
queue<int> elems[MAXS + 3];
vii queries[MAXS + 3];
int ans[MAXS+3];

void update(int pos, int delta){
    while(pos <= n){
        fen[pos] += delta;
        pos += pos & (-pos);
    }
}

int query(int pos){
    int answer = 0;
    while(pos){
        answer += fen[pos];
        pos -= pos & (-pos);
    }
    return answer;
}

int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
    cin>>n;
    int q; cin>>q;
    vii arq;
    bool vis[n+2] = {};
    for (int i=1; i<=n; i++){
        cin>>a[i];
        elems[a[i]].push(i);
        if (!vis[a[i]]){
            update(i, 1);
            vis[a[i]] = 1;
        }
    }
    for (int i=0; i<q; i++){
        int l,r; cin>>l>>r;
        queries[l].pb(ii(i, r));
    }
    
    for (int i=1; i<=n; i++){
        //first answer all, then update:
        for (int j=0; j<queries[i].size(); ++j){
            int r = queries[i][j].second;
            int index = queries[i][j].first;
            int cans = query(r);
            ans[index] = cans;
        }
        queries[i].clear();
        int el = a[i];
        int pos = elems[el].front();
        elems[el].pop();
        update(pos, -1);
        if (!elems[el].empty()) update(elems[el].front(), 1);
    }
    for (int i=0; i<q; i++){
        cout<<ans[i]<<'\n';
    }
    
	return 0;
}
/*
NARCO
*/


Compiler output:
a.cc:5:12: error: template argument 1 is invalid
    5 | #define ii pair<int,int>;
      |            ^~~~~~~~~~~~~
a.cc:8:20: note: in expansion of macro 'ii'
    8 | #define vii vector<ii>;
      |                    ^~
a.cc:24:1: note: in expansion of macro 'vii'
   24 | vii queries[MAXS + 3];
      | ^~~
a.cc:5:12: error: template argument 2 is invalid
    5 | #define ii pair<int,int>;
      |            ^~~~~~~~~~~~~
a.cc:8:20: note: in expansion of macro 'ii'
    8 | #define vii vector<ii>;
      |                    ^~
a.cc:24:1: note: in expansion of macro 'vii'
   24 | vii queries[MAXS + 3];
      | ^~~
a.cc:8:22: error: expected unqualified-id before '>' token
    8 | #define vii vector<ii>;
      |                      ^
a.cc:24:1: note: in expansion of macro 'vii'
   24 | vii queries[MAXS + 3];
      | ^~~
a.cc:24:5: error: 'queries' does not name a type
   24 | vii queries[MAXS + 3];
      |     ^~~~~~~
a.cc: In function 'int main()':
a.cc:5:12: error: template argument 1 is invalid
    5 | #define ii pair<int,int>;
      |            ^~~~~~~~~~~~~
a.cc:8:20: note: in expansion of macro 'ii'
    8 | #define vii vector<ii>;
      |                    ^~
a.cc:47:5: note: in expansion of macro 'vii'
   47 |     vii arq;
      |     ^~~
a.cc:5:12: error: template argument 2 is invalid
    5 | #define ii pair<int,int>;
      |            ^~~~~~~~~~~~~
a.cc:8:20: note: in expansion of macro 'ii'
    8 | #define vii vector<ii>;
      |                    ^~
a.cc:47:5: note: in expansion of macro 'vii'
   47 |     vii arq;
      |     ^~~
a.cc:8:22: error: expected primary-expression before '>' token
    8 | #define vii vector<ii>;
      |                      ^
a.cc:47:5: note: in expansion of macro 'vii'
   47 |     vii arq;
      |     ^~~
a.cc:8:23: error: expected primary-expression before ';' token
    8 | #define vii vector<ii>;
      |                       ^
a.cc:47:5: note: in expansion of macro 'vii'
   47 |     vii arq;
      |     ^~~
a.cc:47:9: error: 'arq' was not declared in this scope
   47 |     vii arq;
      |         ^~~
a.cc:59:9: error: 'queries' was not declared in this scope; did you mean 'query'?
   59 |         queries[l].pb(ii(i, r));
      |         ^~~~~~~
      |         query
a.cc:5:25: error: expected primary-expression before ';' token
    5 | #define ii pair<int,int>;
      |                         ^
a.cc:59:23: note: in expansion of macro 'ii'
   59 |         queries[l].pb(ii(i, r));
      |                       ^~
a.cc:59:31: error: expected ';' before ')' token
   59 |         queries[l].pb(ii(i, r));
      |                               ^
      |                               ;
a.cc:64:25: error: 'queries' was not declared in this scope; did you mean 'query'?
   64 |         for (int j=0; j<queries[i].size(); ++j){
      |                         ^~~~~~~
      |                         query
a.cc:70:9: error: 'queries' was not declared in this scope; did you mean 'query'?
   70 |         queries[i].clear();
      |         ^~~~~~~
      |         query