Language: C++

#pragma GCC target ("MOVBE,MMX,SSE,SSE2,SSE3,SSSE3,SSE4.1,SSE4.2,POPCNT,AVX,AVX2,AES,PCLMUL,FSGSBASE,RDRND,FMA,BMI,BMI2,F16C,RDSEED,ADCX,PREFETCHW,CLFLUSHOPT,XSAVEC,XSAVES")
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);

  int n, q; cin >> n >> q;
  VI c(n); rep(i, n) cin >> c[i];
  vector<pair<int, int>> lr(q); rep(i, q) cin >> lr[i].first >> lr[i].second;
  rep(i, q) lr[i].first--;

  const int sq = 10;
  VI ri(q), lri(q);
  VI cnt(n+1);
  rep(i, q) cnt[lr[i].second]++;
  rep(i, n) cnt[i+1] += cnt[i];
  repr(i, q) ri[--cnt[lr[i].second]] = i;
  fill(all(cnt), 0);
  rep(i, q) cnt[lr[i].first >> sq]++;
  rep(i, n) cnt[i+1] += cnt[i];
  repr(i, q) lri[--cnt[lr[ri[i]].first >> sq]] = ri[i];
  fill(all(cnt), 0);

  VI ans(q);

  int prev = -1;
  int lx, rx;
  int sum = 0;
  for (auto i : lri) {
    auto [l, r] = lr[i];
    if (l >> sq != prev) {
      fill(all(cnt), 0);
      lx = rx = r;
      prev = l >> sq;
      sum = 0;
    }
    int cx;
    while (lx > l) if (cnt[cx=c[--lx]]++ == 0) sum += 1;
    while (lx < l) if (--cnt[c[lx++]] == 0) sum -= 1;
    while (rx < r) if (cnt[cx=c[rx++]]++ == 0) sum += 1;
    ans[i] = sum;
  }
  rep(i, q) cout << ans[i] << "\n";
}


Compiler output:
cc1plus: error: attribute 'target' argument 'MOVBE' is unknown
cc1plus: error: attribute 'target' argument 'MMX' is unknown
cc1plus: error: attribute 'target' argument 'SSE' is unknown
cc1plus: error: attribute 'target' argument 'SSE2' is unknown
cc1plus: error: attribute 'target' argument 'SSE3' is unknown
cc1plus: error: attribute 'target' argument 'SSSE3' is unknown
cc1plus: error: attribute 'target' argument 'SSE4.1' is unknown
cc1plus: error: attribute 'target' argument 'SSE4.2' is unknown
cc1plus: error: attribute 'target' argument 'POPCNT' is unknown
cc1plus: error: attribute 'target' argument 'AVX' is unknown
cc1plus: error: attribute 'target' argument 'AVX2' is unknown
cc1plus: error: attribute 'target' argument 'AES' is unknown
cc1plus: error: attribute 'target' argument 'PCLMUL' is unknown
cc1plus: error: attribute 'target' argument 'FSGSBASE' is unknown
cc1plus: error: attribute 'target' argument 'RDRND' is unknown
cc1plus: error: attribute 'target' argument 'FMA' is unknown
cc1plus: error: attribute 'target' argument 'BMI' is unknown
cc1plus: error: attribute 'target' argument 'BMI2' is unknown
cc1plus: error: attribute 'target' argument 'F16C' is unknown
cc1plus: error: attribute 'target' argument 'RDSEED' is unknown
cc1plus: error: attribute 'target' argument 'ADCX' is unknown
cc1plus: error: attribute 'target' argument 'PREFETCHW' is unknown
cc1plus: error: attribute 'target' argument 'CLFLUSHOPT' is unknown
cc1plus: error: attribute 'target' argument 'XSAVEC' is unknown
cc1plus: error: attribute 'target' argument 'XSAVES' is unknown
cc1plus: error: attribute 'target' argument 'MOVBE' is unknown
cc1plus: error: attribute 'target' argument 'MMX' is unknown
cc1plus: error: attribute 'target' argument 'SSE' is unknown
cc1plus: error: attribute 'target' argument 'SSE2' is unknown
cc1plus: error: attribute 'target' argument 'SSE3' is unknown
cc1plus: error: attribute 'target' argument 'SSSE3' is unknown
cc1plus: error: attribute 'target' argument 'SSE4.1' is unknown
cc1plus: error: attribute 'target' argument 'SSE4.2' is unknown
cc1plus: error: attribute 'target' argument 'POPCNT' is unknown
cc1plus: error: attribute 'target' argument 'AVX' is unknown
cc1plus: error: attribute 'target' argument 'AVX2' is unknown
cc1plus: error: attribute 'target' argument 'AES' is unknown
cc1plus: error: attribute 'target' argument 'PCLMUL' is unknown
cc1plus: error: attribute 'target' argument 'FSGSBASE' is unknown
cc1plus: error: attribute 'target' argument 'RDRND' is unknown
cc1plus: error: attribute 'target' argument 'FMA' is unknown
cc1plus: error: attribute 'target' argument 'BMI' is unknown
cc1plus: error: attribute 'target' argument 'BMI2' is unknown
cc1plus: error: attribute 'target' argument 'F16C' is unknown
cc1plus: error: attribute 'target' argument 'RDSEED' is unknown
cc1plus: error: attribute 'target' argument 'ADCX' is unknown
cc1plus: error: attribute 'target' argument 'PREFETCHW' is unknown
cc1plus: error: attribute 'target' argument 'CLFLUSHOPT' is unknown
cc1plus: error: attribute 'target' argument 'XSAVEC' is unknown
cc1plus: error: attribute 'target' argument 'XSAVES' is unknown