criyle/codenet-compile-errors huggingface dataset:
Language: C++

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2)
#include <bits/stdc++.h>

using namespace std;

#define DEBUG

const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1e9 + 7;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    string sep;
    for (const auto &x : v) os << sep << x, sep = ", ";
    return os << '}';
}

template<typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr) {
    os << '{';
    string sep;
    for (const auto &x : arr) os << sep << x, sep = ", ";
    return os << '}';
}

template<typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }

template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << ' ' << H;
    dbg_out(T...);
}

#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

const int N = 5 * (1e5);

set<int> s[4 * N];
int a[N];

set<int> combine(const set<int> &x, const set<int> &y) {
    set<int> ret = x;
    for (const int &i : y) {
        ret.insert(i);
    }
    return ret;
}

void build(int v, int l, int r) {
    if (l == r) {
        s[v].insert(a[l]);
    } else {
        int m = (l + r) / 2;
        build(v * 2, l, m);
        build(v * 2 + 1, m + 1, r);
        s[v] = combine(s[v * 2], s[v * 2 + 1]);
    }
}

set<int> query(int v, int l, int r, int x, int y) {
    if (l > y || r < x) return set<int>();
    if (l >= x && r <= y) return s[v];
    int m = (l + r) / 2;
    return combine(query(v * 2, l, m, x, y), query(v * 2 + 1, m + 1, r, x, y));
}

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

    int n, q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    build(1, 1, n);
    while (q--) {
        int l, r;
        cin >> l >> r;
        auto ret = query(1, 1, n, l, r);
        cout << ret.size() << '\n';
    }
}

Compiler output:
a.cc:2:20: warning: missing terminating " character
    2 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2)
      |                    ^
a.cc:2:20: error: missing terminating " character
    2 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2)
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:2:70: warning: '#pragma GCC option' is not a string [-Wpragmas]
    2 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2)
      |                                                                      ^
a.cc:2:70: warning: '#pragma GCC option' is not a string [-Wpragmas]
Language: C++

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>

using namespace std;

#define DEBUG

const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1e9 + 7;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    string sep;
    for (const auto &x : v) os << sep << x, sep = ", ";
    return os << '}';
}

template<typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr) {
    os << '{';
    string sep;
    for (const auto &x : arr) os << sep << x, sep = ", ";
    return os << '}';
}

template<typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }

template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << ' ' << H;
    dbg_out(T...);
}

#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

const int N = 5 * (1e5);

set<int> s[4 * N];
int a[N];

set<int> combine(const set<int> &x, const set<int> &y) {
    set<int> ret = x;
    for (const int &i : y) {
        ret.insert(i);
    }
    return ret;
}

void build(int v, int l, int r) {
    if (l == r) {
        s[v].insert(a[l]);
    } else {
        int m = (l + r) / 2;
        build(v * 2, l, m);
        build(v * 2 + 1, m + 1, r);
        s[v] = combine(s[v * 2], s[v * 2 + 1]);
    }
}

set<int> query(int v, int l, int r, int x, int y) {
    if (l > y || r < x) return set<int>();
    if (l >= x && r <= y) return s[v];
    int m = (l + r) / 2;
    return combine(query(v * 2, l, m, x, y), query(v * 2 + 1, m + 1, r, x, y));
}

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

    int n, q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    build(1, 1, n);
    while (q--) {
        int l, r;
        cin >> l >> r;
        auto ret = query(1, 1, n, l, r);
        cout << ret.size() << '\n';
    }
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:3:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_Rb_tree_impl<std::less<int>, true>::~_Rb_tree_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<int>]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:658:16: note: called from here
  658 |         struct _Rb_tree_impl
      |                ^~~~~~~~~~~~~
Language: C

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10 + 5e5;

int n,m,ans[MAXN],t[2*MAXN],ri[MAXN],f[MAXN];
pair < int,int > a[MAXN],c[MAXN];

void Build() 
{
	for (int i = n-1; i > 0; --i)
		t[i] = t[i << 1] + t[i << 1 | 1];
}

void Update(int p) 
{
	for (t[p += n] = 0; p > 1; p >>= 1)
		t[p >> 1] = t[p] + t[p ^ 1];
} 

int Query(int l,int r)
{
	int res = 0;
	for (l += n, r += n; l < r; l >>= 1, r >>= 1) 
	{
		if (l&1) res += t[l++];
    	if (r&1) res += t[--r];	
	}
	
	return res;
}

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> m;
	memset(f, -1, sizeof f);
	for (int i = 0; i < n; ++i)
	{		
		int x;
		cin >> x;
		c[i].first = f[x];
		c[i].second = i;
		f[x] = i;
	}
	

	sort(c,c+n);

	for (int i = 0; i < m; ++i) 
	{
		int x;
		cin >> a[i].first >> x;
		a[i].second = i;
		ri[i] = x;
	}
		
		for (int i = 0; i < n; ++i) t[n+i] = 1;
		
		Build();
		
	sort(a,a+m);
	
	
	for (int i = 0; i < m; ++i) 
	{
		int k = 0;
		if (k < n) while (c[k].first < a[i].first-1) Update(c[k++].second); 
	
		ans[a[i].second] = ri[a[i].second] - a[i].first - Query(a[i].first-1,ri[a[i].second]) + 1;
		
	}

	for(int i = 0; i < m; ++i)
		cout << ans[i] << "\n";
	
	return 0;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;

int n,q,count=0;
cin>>n,q;
int a[n],b[100]={0};
int x,y;
for(int i=0;i<q;i++){
  cin>>x>>y;
  for(int j=x-1;j<=y-1;j++){
    b[a[j]]++;
  }
  for(int k=0;k<100;k++){
    if(b[k]>0)
      count++;
  }
  cout<<count<<endl;
}
  



Compiler output:
a.cc:5:1: error: 'cin' does not name a type
    5 | cin>>n,q;
      | ^~~
a.cc:6:7: error: size of array 'a' is not an integral constant-expression
    6 | int a[n],b[100]={0};
      |       ^
a.cc:8:1: error: expected unqualified-id before 'for'
    8 | for(int i=0;i<q;i++){
      | ^~~
a.cc:8:13: error: 'i' does not name a type
    8 | for(int i=0;i<q;i++){
      |             ^
a.cc:8:17: error: 'i' does not name a type
    8 | for(int i=0;i<q;i++){
      |                 ^
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>
#include <set>
#include <unordered_set>
#include <bitset>
#include <string>

using namespace std;


//x の最も下の立っているビットは，x & -x で取り 出せる
template <class T> class BIT{
    public:
    vector<T> array;
    const int n;
    
    public:
    //constractor
    BIT(int _n) : array(_n + 1, 0), n(_n){}
    
    //sum [0,i]
    T sum(int i){
        T s = 0;
        while(i > 0){
            s += array[i];
            i -= i & -i;
        }
        return s;
    }

    //sum [i,j]
    T sum(int i, int j){
        T ret_i = sum(i -1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // 1-index
    void add(int i, T x){
        while(i <= n){
            array[i] += x;
            i += i & -i;
        }
    }
};

N = 500100;

int main(){
    int n, Q; cin >> n >> Q;
    BIT<int> bit(N);

    vector<int> a(N+1,0);
    vector<vector<int>> ql(N+1);
    vector<vector<int>> qid(N+1);
    vector<int> ans(N+1, 0);

    vector<int> C(N+1);
    for(int i=1; i<=N; ++i){
        cin >> C[i];
    }

    for(int i=1; i<=Q; ++i){
        int l, r;
        cin >> l >> r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }

    for(int i=1; i<=n; ++i){
        if(a[C[i]] > 0) bit.add(a[C[i]], -1);
        bit.add(i, +1);
        a[C[i]] = i;
        for(int j=0; j<ql[i].size(); ++j){
            ans[qid[i][j]] = bit.sum(ql[i][j], i);
        }
    }

    for(int i=1; i<=Q; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}


Compiler output:
a.cc:50:1: error: 'N' does not name a type
   50 | N = 500100;
      | ^
a.cc: In function 'int main()':
a.cc:54:18: error: 'N' was not declared in this scope
   54 |     BIT<int> bit(N);
      |                  ^
Language: C

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>
#include <set>
#include <unordered_set>
#include <bitset>
#include <string>

using namespace std;


//x の最も下の立っているビットは，x & -x で取り 出せる
template <class T> class BIT{
    public:
    vector<T> array;
    const int n;
    
    public:
    //constractor
    BIT(int _n) : array(_n + 1, 0), n(_n){}
    
    //sum [0,i]
    T sum(int i){
        T s = 0;
        while(i > 0){
            s += array[i];
            i -= i & -i;
        }
        return s;
    }

    //sum [i,j]
    T sum(int i, int j){
        T ret_i = sum(i -1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    // 1-index
    void add(int i, T x){
        while(i <= n){
            array[i] += x;
            i += i & -i;
        }
    }
};


int main(){
    int N, Q; cin >> N >> Q;
    BIT<int> bit(N);

    vector<int> a(N+1, 0);
    vector<vector<int>> ql(N+1);
    vector<vector<int>> qid(N+1);
    vector<int> ans(N+1, 0);

    vector<int> C(N+1);
    for(int i=1; i<=N; ++i){
        cin >> C[i];
    }

    for(int i=1; i<=Q; ++i){
        int l, r;
        cin >> l >> r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }

    for(int i=1; i<=N; ++i){
        if(a[C[i]] > 0) bit.add(a[C[i]], -1);
        bit.add(i, +1);
        a[C[i]] = i;
        for(int j=0; j<ql[i].size(); ++j){
            ans[qid[i][j]] = bit.sum(ql[i][j], i);
        }
    }

    for(int i=1; i<=Q; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
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,prfchw,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 'adcx' is unknown
cc1plus: error: attribute 'target' argument 'adcx' is unknown
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 'adcx' is unknown
cc1plus: error: attribute 'target' argument 'prefetchw' is unknown
cc1plus: error: attribute 'target' argument 'adcx' is unknown
cc1plus: error: attribute 'target' argument 'prefetchw' is unknown
Language: C++

#pragma GCC target ("arch=skylake")
#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:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:2:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#pragma GCC target ("arch=skylake-avx512")
#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:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:2:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;

template <typename T>
struct BIT
{
    int n;
    vector<T> bit;
    
    BIT(){}
    
    BIT(int n) : n(n){
        bit.resize(n + 1);
    }
    
    T sum(int i){   // sum of [0, i)
        T res = 0;
        while(i){
            res += bit[i];
            i -= (i & -i);
        }
        return res;
    }
    
    void add(int i, T x){
        i++;
        while(i <= n){
            bit[i] += x;
            i += (i & -i);
        }
    }
};

int c[500005];
int b[500005];
int l[500005];
PP p[500005];
int ans[500005];

int main()
{
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; i++){
        b[i] = -1;
        l[i] = -1;
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
        c[i]--;
        if(b[c[i]] != -1){
            l[i] = b[c[i]];
        }
        b[c[i]] = i;
    }
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--;
        p[i] = PP(P(r, l), i);
    }
    sort(p, p + q);
    int j = 0;
    BIT<int> bit(n);
    for(int i = 0; i < q; i++){
        for(; j < p[i].first.first; j++){
            bit.add(j, 1);
            if(l[j] != -1){
                bit.add(l[j], -1);
            }
        }
        ans[p[i].second] = bit.sum(p[i].first.first) - bit.sum(p[i].first.second);
    }
    for(int i = 0; i < q; i++){
        cout << ans[i] << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   65 |     sort(p, p + q);
      |     ^~~~
      |     short
Language: C++

N, Q = inputInt(), inputInt()
c[:N] = inputInt() - 1
LR[:Q] = inputInt() - 1, inputInt() - 1, $1
LR.rsort()
bit = BIT!(int)(N)
D[:N] = 0
ans[:Q] = 0
n = N - 1
for l, r, q in LR:
    while l <= n:
        # if D[c[n]]!=-1:
        #    --bit[D[c[n]]]
        bit[D[c[n]]] = 0
        D[c[n]] = n
        bit[n] = 1
        --n
    ans[q] = bit.sum(l, r + 1)
print(ans[:Q])


Compiler output:
a.cc:11:15: error: token "[" is not valid in preprocessor expressions
   11 |         # if D[c[n]]!=-1:
      |               ^
a.cc:11: error: unterminated #if
   11 |         # if D[c[n]]!=-1:
a.cc:1:1: error: 'N' does not name a type
    1 | N, Q = inputInt(), inputInt()
      | ^
Language: C++

#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#include <cmath>

#define ll long long

using namespace std;


const int N = 5e5 + 7;


struct Node
{
	int l;
	int r;
	int id;
};


Node tree[500001];

bool comp(Node& p, Node& q)
{
	return p.r < q.r;
}

int N = 500001;
vector<int> bit(N, 0);
ll last[500001];

void update(int x, int i, int n)
{
	for (; i <= n; i = i + (i & -i))
	{
		bit[i] += x;
	}
}

int query(int i)
{
	int sum = 0;
	for (; i > 0; i = i - (i & -i))
	{
		sum += bit[i];
	}
	return sum;
}

bool cmp(Node a, Node b) {
	return a.r < b.r;
}




int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n, q;

	cin >> n >> q;

	vector<ll> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}


	vector<ll>ans(q);
	int left, right;

	for (int i = 0; i < q; i++) {

		cin >> tree[i].l >> tree[i].r;
		tree[i].id = i;
	}

	sort(tree, tree + q, comp);
	int p = 0;
	

	for (int i = 0; i < n; ++i)
	{
		if (last[a[i]] != -1)
		{
			update(-1, last[a[i]] + 1, n);
		}
		last[a[i]] = i;
		update(1, i + 1, n);
		while (p < q && tree[p].r == i + 1)
		{
			ans[tree[p].id] = query(tree[p].r) - query(tree[p].l - 1);
			p++;
		}
	}

	for (int i = 0; i < q; ++i)
	{
		cout << ans[i] << endl;
	}


	
	return 0;
}


Compiler output:
a.cc:29:5: error: conflicting declaration 'int N'
   29 | int N = 500001;
      |     ^
a.cc:11:11: note: previous declaration as 'const int N'
   11 | const int N = 5e5 + 7;
      |           ^
Language: Java

import java.util.*;
import java.util.function.BinaryOperator;
import java.util.function.UnaryOperator;

public class Main {
    static int SIZE = 500001;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < q; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        
        List<int[]>[] queries = new List[n];
        for (int i = 0; i < n; i++) {
            queries[i] = new ArrayList<int[]>();
        }
        for (int i = 0; i < q; i++) {
            queries[l[i]].add(new int[]{r[i], i});
        }
        
        List<Integer>[] rights = new List[n];
        for (int i = 0; i < n; i++) {
            rights[i] = new ArrayList<Integer>();
        }
        int[] last_app = new int[SIZE];
        Arrays.fill(last_app, -1);
        for (int i = 0; i < n; i++) {
            int num = array[i];
            if (last_app[num] != -1) {
                rights[last_app[num]].add(i);
            }
            last_app[num] = i;
        }
        
        BIT bit = new BIT(SIZE);
        
        int[] ans = new int[q];
        for (int i = n - 1; i >= 0; i--) {
            for (Integer right : rights[i]) {
                bit.add(right, 1);
            }
            
            for (int[] query : queries[i]) {
                int left = i;
                int right = query[0];
                int q_idx = query[1];
                ans[q_idx] = right - left + 1 - (int)bit.sum(right);
            }
        }
      
        PrintWriter out = new PrintWriter(System.out);
        for (Integer a : ans) {
            out.println(a);
        }
        out.flush();
        // for (Integer a : ans) {
        //     System.out.println(a);
        // }
    }
}

class BIT {
    int n;
    int[] d;

    // 単位元で埋めて新規作成
    public BIT(int n) {
        this.n = n;
        this.d = new int[n + 1];
    }
    
    public void add(int i, int x) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }
    
    public int sum(int i) {
        int x = 0;
        for (i++; i > 0; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    
    public int sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
}

Compiler output:
Main.java:63: error: cannot find symbol
        PrintWriter out = new PrintWriter(System.out);
        ^
  symbol:   class PrintWriter
  location: class Main
Main.java:63: error: cannot find symbol
        PrintWriter out = new PrintWriter(System.out);
                              ^
  symbol:   class PrintWriter
  location: class Main
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
Language: C++

#include <iostream>
#include <vector>
#include <numeric>
#define Nfor(N) for(int i=0;i<N;++i)
using namespace std;

int main(){
  	int N, Q;
  	cin >> N >> Q;
  	vector<int> c(N);
  	Nfor(N) cin >> c(i);
  	Nfor(Q){
      	int l, r;
      	cin >> l >> r;
      	vector<int> flag(N);
      	for(int j=l;j<=r;j++){
          	flag[c[j]] = 1;
        }
      	cout << accumulate(flag.begin(), flag.end()) << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: no match for call to '(std::vector<int>) (int&)'
   11 |         Nfor(N) cin >> c(i);
      |                        ~^~~
a.cc:19:27: error: no matching function for call to 'accumulate(std::vector<int>::iterator, std::vector<int>::iterator)'
   19 |         cout << accumulate(flag.begin(), flag.end()) << endl;
      |                 ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <queue>

using namespace std;

class BIT
{
 public:
  vector<int> bit;
  int M;

  BIT(int M):
      bit(vector<int>(M+1, 0)), M(M) {}

  int sum(int i) {
    if (!i) return 0;
    return bit[i] + sum(i-(i&-i));
  }

  void add(int i, int x) {
    if (i > M) return;
    bit[i] += x;
    add(i+(i&-i), x);
  }
};

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<int> C;
  for (int i = 0; i < N; i++) {
    int c;
    cin >> c;
    C.push_back(c);
  }

  vector<pair<int, int>> queries;
  for (int q = 0; q < Q; q++) {
    int l, r;
    cin >> l >> r;
    queries.push_back(make_pair(l-1, r-1));
  }
  vector<pair<int, int>> sorted_queries(queries);
  sort(sorted_queries.begin(), sorted_queries.end(),
       [](const pair<int, int> &a,
          const pair<int, int> &b) {
         if (a.second < b.second) return 1;
         return 0;
       });
  map<pair<int, int>, int> query2ans;
  vector<int> rightmost(N, -1);
  BIT bit(N);
  int start = 0;
  for (pair<int, int> query : sorted_queries) {
    for (int i = start; i <= query.second; i++) {
      if (rightmost[C[i]] >= 0) {
        bit.add(rightmost[C[i]]+1, -1);
      }
      rightmost[C[i]] = i;
      bit.add(i+1, 1);
    }
    query2ans[query] = bit.sum(query.second+1)-bit.sum(query.first-1+1);
    start = query.second + 1;
  }
  for (pair<int, int> query : queries) {
    cout << query2ans[query] << endl;
  }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:46:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   46 |   sort(sorted_queries.begin(), sorted_queries.end(),
      |   ^~~~
      |   short
Language: C++

#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

#include"../proconLib/DataStructure/BIT.cpp"

using namespace ProconLib;

struct Query{
    int l,r;
    int id;
};

int main(){
    int n,q;
    cin>>n>>q;
    
    vector<int> c(n);
    for(int i=0;i<n;i++) cin>>c[i],c[i]--;

    vector<vector<Query>> query(n);
    for(int i=0;i<q;i++){
        int l,r; cin>>l>>r;
        l--;
        query[l].push_back(Query{l,r,i});
    }

    BIT<int> bit(n+1);
    bit.add(n,n);
    vector<int> lst(n,n);

    vector<int> ans(q);

    for(int i=n-1;i>=0;i--){
        bit.add(lst[c[i]],-1);
        bit.add(i,1);
        lst[c[i]]=i;
        for(auto que:query[i]){
            ans[que.id] = bit.sum(que.l,que.r);
        }
    }

    for(int i=0;i<q;i++) cout<<ans[i]<<endl;
    return 0;
}

Compiler output:
a.cc:28:9: fatal error: ../proconLib/DataStructure/BIT.cpp: No such file or directory
   28 | #include"../proconLib/DataStructure/BIT.cpp"
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

#include"../proconLib/DataStructure/BIT.cpp"

using namespace ProconLib;

struct Query{
    int l,r;
    int id;
};

int main(){
    int n,q;
    cin>>n>>q;
    
    vector<int> c(n);
    for(int i=0;i<n;i++) cin>>c[i],c[i]--;

    vector<vector<Query>> query(n);
    for(int i=0;i<q;i++){
        int l,r; cin>>l>>r;
        l--;
        query[l].push_back(Query{l,r,i});
    }

    BIT<int> bit(n+1);
    bit.add(n,n);
    vector<int> lst(n,n);

    vector<int> ans(q);

    for(int i=n-1;i>=0;i--){
        bit.add(lst[c[i]],-1);
        bit.add(i,1);
        lst[c[i]]=i;
        for(auto que:query[i]){
            ans[que.id] = bit.sum(que.l,que.r);
        }
    }

    for(int i=0;i<n;i++) cout<<ans[i]<<endl;
    return 0;
}

Compiler output:
a.cc:28:9: fatal error: ../proconLib/DataStructure/BIT.cpp: No such file or directory
   28 | #include"../proconLib/DataStructure/BIT.cpp"
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

#include"../proconLib/DataStructure/BIT.cpp"

using namespace ProconLib;

struct Query{
    int l,r;
    int id;
};

int main(){
    int n,q;
    cin>>n>>q;
    
    vector<int> c(n);
    for(int i=0;i<n;i++) cin>>c[i],c[i]--;

    vector<vector<Query>> query(n);
    for(int i=0;i<q;i++){
        int l,r; cin>>l>>r;
        l--;
        query[l].push_back(Query{l,r,i});
    }

    BIT<int> bit(n+1);
    bit.add(n,n);
    vector<int> lst(n,n);

    vector<int> ans(n);

    for(int i=n-1;i>=0;i--){
        bit.add(lst[c[i]],-1);
        bit.add(i,1);
        lst[c[i]]=i;
        for(auto que:query[i]){
            ans[que.id] = bit.sum(que.l,que.r);
        }
    }

    for(int i=0;i<n;i++) cout<<ans[i]<<endl;
    return 0;
}

Compiler output:
a.cc:28:9: fatal error: ../proconLib/DataStructure/BIT.cpp: No such file or directory
   28 | #include"../proconLib/DataStructure/BIT.cpp"
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<cstring>
using namespace std;
const int BUF = 500005;


class SegTree{
public:
  int v[BUF*4];

  SegTree(){ 
    memset(v,0,sizeof(v));
  }
  
  int init(int node, int L, int R, int a[BUF]){
    if(L==R) return v[node] = a[L];
    int s = init(node*2+1,L,(L+R)/2,a);
    int t = init(node*2+2,(L+R)/2+1,R,a);
    return v[node] = s + t;
  }

  int get(int node, int L, int R, int LQ, int RQ){
    if(R<LQ || RQ<L) return 0;
    if(LQ<=L && R<=RQ) return v[node];
    int s = get(node*2+1,L,(L+R)/2,LQ,RQ);
    int t = get(node*2+2,(L+R)/2+1,R,LQ,RQ);
    return s + t;
  }
  
  int update(int node, int L, int R, int Q, int chVal){
    if(R<Q || Q<L) return v[node];
    if(L==R) return v[node] = chVal;
    int s = update(node*2+1,L,(L+R)/2,Q,chVal);
    int t = update(node*2+2,(L+R)/2+1,R,Q,chVal);
    return v[node] = s + t;
  }
};


class Query {
public:
    int id;
    int l, r;
    Query(){}
    Query(int id, int l, int r): id(id), l(l), r(r) {}

    bool operator< (const Query &opp) const {
        return r < opp.r;
    }
};


int nVal, nQuery;
int val[BUF];
Query query[BUF];


void read() {
    cin >> nVal >> nQuery;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
        --val[i];
    }
    for (int i = 0; i < nQuery; ++i) {
        query[i].id = i;
        cin >> query[i].l >> query[i].r;
        --query[i].l;
        --query[i].r;
    }
}


void work() {
    sort(query, query + nQuery);

    static SegTree stree;
    memset(stree.v, 0, sizeof(stree.v));

    int queryId2ans[BUF];
    
    int v2lastIdx[BUF];
    memset(v2lastIdx, -1, sizeof(v2lastIdx));

    int queryIdx = 0;
    for (int valIdx = 0; valIdx < nVal; ++valIdx) {
        int &v = val[valIdx];

        if (v2lastIdx[v] != -1) {
            stree.update(0, 0, nVal - 1, v2lastIdx[v], 0);
        }
        stree.update(0, 0, nVal - 1, valIdx, 1);
        v2lastIdx[v] = valIdx;

        while (queryIdx < nQuery && query[queryIdx].r == valIdx) {
            int ans = stree.get(0, 0, nVal - 1, query[queryIdx].l, query[queryIdx].r);
            queryId2ans[query[queryIdx].id] = ans;
            ++queryIdx;
        }
    }

    for (int i = 0; i < nQuery; ++i) {
        cout << queryId2ans[i] << endl;
    }
}


int main() {
    read();
    work();
    return 0;
}


Compiler output:
a.cc: In function 'void work()':
a.cc:74:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   74 |     sort(query, query + nQuery);
      |     ^~~~
      |     short
Language: C++

#include<iostream>
using namespace std;
const int BUF = 500005;


class SegTree{
public:
  int v[BUF*4];

  SegTree(){ 
    memset(v,0,sizeof(v));
  }
  
  int init(int node, int L, int R, int a[BUF]){
    if(L==R) return v[node] = a[L];
    int s = init(node*2+1,L,(L+R)/2,a);
    int t = init(node*2+2,(L+R)/2+1,R,a);
    return v[node] = s + t;
  }

  int get(int node, int L, int R, int LQ, int RQ){
    if(R<LQ || RQ<L) return 0;
    if(LQ<=L && R<=RQ) return v[node];
    int s = get(node*2+1,L,(L+R)/2,LQ,RQ);
    int t = get(node*2+2,(L+R)/2+1,R,LQ,RQ);
    return s + t;
  }
  
  int update(int node, int L, int R, int Q, int chVal){
    if(R<Q || Q<L) return v[node];
    if(L==R) return v[node] = chVal;
    int s = update(node*2+1,L,(L+R)/2,Q,chVal);
    int t = update(node*2+2,(L+R)/2+1,R,Q,chVal);
    return v[node] = s + t;
  }
};


class Query {
public:
    int id;
    int l, r;
    Query(){}
    Query(int id, int l, int r): id(id), l(l), r(r) {}

    bool operator< (const Query &opp) const {
        return r < opp.r;
    }
};


int nVal, nQuery;
int val[BUF];
Query query[BUF];


void read() {
    cin >> nVal >> nQuery;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
        --val[i];
    }
    for (int i = 0; i < nQuery; ++i) {
        query[i].id = i;
        cin >> query[i].l >> query[i].r;
        --query[i].l;
        --query[i].r;
    }
}


void work() {
    sort(query, query + nQuery);

    static SegTree stree;
    memset(stree.v, 0, sizeof(stree.v));

    int queryId2ans[BUF];
    
    int v2lastIdx[BUF];
    memset(v2lastIdx, -1, sizeof(v2lastIdx));

    int queryIdx = 0;
    for (int valIdx = 0; valIdx < nVal; ++valIdx) {
        int &v = val[valIdx];

        if (v2lastIdx[v] != -1) {
            stree.update(0, 0, nVal - 1, v2lastIdx[v], 0);
        }
        stree.update(0, 0, nVal - 1, valIdx, 1);
        v2lastIdx[v] = valIdx;

        while (queryIdx < nQuery && query[queryIdx].r == valIdx) {
            int ans = stree.get(0, 0, nVal - 1, query[queryIdx].l, query[queryIdx].r);
            queryId2ans[query[queryIdx].id] = ans;
            ++queryIdx;
        }
    }

    for (int i = 0; i < nQuery; ++i) {
        cout << queryId2ans[i] << endl;
    }
}


int main() {
    read();
    work();
    return 0;
}


Compiler output:
a.cc: In constructor 'SegTree::SegTree()':
a.cc:11:5: error: 'memset' was not declared in this scope
   11 |     memset(v,0,sizeof(v));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
a.cc: In function 'void work()':
a.cc:73:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   73 |     sort(query, query + nQuery);
      |     ^~~~
      |     short
a.cc:76:5: error: 'memset' was not declared in this scope
   76 |     memset(stree.v, 0, sizeof(stree.v));
      |     ^~~~~~
a.cc:76:5: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
Language: C++

// F - Range Set Query

#include<cstdio>
#include<map>

using namespace std;

const int Maxn = 5e5;

int N,Q;
int color[Maxn];
pair<int,int> query[Maxn];
int idx[Maxn];
int res[Maxn];
int c[Maxn];
int pre[Maxn];

inline int lowbit(int x) {
    return x & -x;
}

void add(int x,int k){
    while(x <= N) {
        c[x] += k;
        x += lowbit(x);
    }
}

int get(int x){
    int ans = 0;
    while(x >= 1) {
        ans += c[x];
        x = x - lowbit(x);
    }
    return ans;
}


int main(){
    freopen("in","r",stdin);
    scanf("%d%d",&N,&Q); 
    for(int i = 1; i <= N;i++){
        scanf("%d",&color[i]);
    }
    for(int i = 1;i <= Q;i++){
        int l,r; 
        scanf("%d%d",&l,&r);
        query[i].first = l, query[i].second = r;
        idx[i] = i;
    }
    sort(idx+1,idx+Q+1,[](const int& l,const int& r)->bool{
        return query[l].second < query[r].second;
    });
    int q = 1;
    for(int i = 1;i <= N;i++){
        add(i,1);
        if(pre[color[i]] > 0){
            add(pre[color[i]],-1);
        }
        pre[color[i]] = i;
        while(q <= Q && query[idx[q]].second == i) {
            res[idx[q]] = get(query[idx[q]].second) - get(query[idx[q]].first-1);
            q++;
        } 
    }
    for(int i = 1;i <= Q;i++){
        printf("%d\n",res[i]);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   51 |     sort(idx+1,idx+Q+1,[](const int& l,const int& r)->bool{
      |     ^~~~
      |     short
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long ans = 0;
  int n, q;
  cin >> n >> q;
  vector < int > ans(n + 3, 0);
  set < int > dp;
  for(int i = 1 ; i <= n ; ++i) {
   	int p;
    cin >> p;
    dp.insert(p);
    ans[i] = dp.size();
  }
  while(q--) {
   	int l, r;
    cin >> l >> r;
    cout << ans[r] - ans[l - 1] << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: conflicting declaration 'std::vector<int> ans'
    9 |   vector < int > ans(n + 3, 0);
      |                  ^~~
a.cc:6:13: note: previous declaration as 'long long int ans'
    6 |   long long ans = 0;
      |             ^~~
a.cc:15:8: error: invalid types 'long long int[int]' for array subscript
   15 |     ans[i] = dp.size();
      |        ^
a.cc:20:16: error: invalid types 'long long int[int]' for array subscript
   20 |     cout << ans[r] - ans[l - 1] << endl;
      |                ^
a.cc:20:25: error: invalid types 'long long int[int]' for array subscript
   20 |     cout << ans[r] - ans[l - 1] << endl;
      |                         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long ans = 0;
  int n, q;
  cin >> n >> q;
  vector < int > ans(n + 3, 0);
  set < int > dp;
  for(int i = 1 ; i <= n ; ++i) {
   	int p;
    dp.insert(p);
    ans[i] = dp.size();
  }
  while(q--) {
   	int l, r;
    cin >> l >> r;
    cout << ans[r] - ans[l - 1] << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: conflicting declaration 'std::vector<int> ans'
    9 |   vector < int > ans(n + 3, 0);
      |                  ^~~
a.cc:6:13: note: previous declaration as 'long long int ans'
    6 |   long long ans = 0;
      |             ^~~
a.cc:14:8: error: invalid types 'long long int[int]' for array subscript
   14 |     ans[i] = dp.size();
      |        ^
a.cc:19:16: error: invalid types 'long long int[int]' for array subscript
   19 |     cout << ans[r] - ans[l - 1] << endl;
      |                ^
a.cc:19:25: error: invalid types 'long long int[int]' for array subscript
   19 |     cout << ans[r] - ans[l - 1] << endl;
      |                         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define endl '\n'
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int siz = 5e5 + 7;
consrt int block_size=710;
vector<int>v;
int answer;
vector<int>ans;
vector<int>m(siz);
struct node {
  int l, r, idx;
};
bool comp(node a, node b) {
  if (a.l / block_size != b.l / block_size)
    return (b.l / block_size > a.l / block_size);
  return (b.r > a.r);
}
void add(int index) {
  m[v[index]]++;
  if (m[v[index]] == 1)answer++;
}
void remove(int index) {
  m[v[index]]--;
  if (m[v[index]] == 0)answer--;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, query;
  scanf("%d", &n);
  scanf("%d", &query);
  v.resize(n + 1);
  ans.resize(query + 1);
  for (int i = 1; i <=  n; i++) {
    scanf("%d", &v[i]);
  }
  vector<node>q(query + 1);
  for (int i = 1; i <= query; i++) {
    scanf("%d%d", &q[i].l, &q[i].r);
    q[i].idx = i;
  }
  sort(q.begin() + 1, q.end(), comp);
  int mo_left = 0, mo_right = 0;
  for (int i = 1; i <= query; i++) {
    int u = q[i].l;
    int r = q[i].r;
    while (u >  mo_left) {
      remove(mo_left);
      mo_left++;
    }
    while (u < mo_left) {
      mo_left--;
      add(mo_left);
    }
    while (r > mo_right) {
      mo_right++;
      add(mo_right);
    }
    while (mo_right > r) {
      remove(mo_right);
      mo_right--;
    }
    ans[q[i].idx] = answer;
  }
  for (int i = 1; i <= query; i++) {
    printf("%d\n", ans[i]);
  }
  for (int i = 0; i < siz; i++) {
    m[i] = 0;
  }
  answer = 0;
}



Compiler output:
a.cc:13:1: error: 'consrt' does not name a type; did you mean 'const'?
   13 | consrt int block_size=710;
      | ^~~~~~
      | const
a.cc: In function 'bool comp(node, node)':
a.cc:22:13: error: 'block_size' was not declared in this scope
   22 |   if (a.l / block_size != b.l / block_size)
      |             ^~~~~~~~~~
Language: C++

import sys

def main():
	n, q = map(int, sys.stdin.readline().split())
	c = list(map(int, sys.stdin.readline().split()))
	fenwick = [0] * n
	
	def add(i, v):
		while i < n:
			fenwick[i] += v
			i = (i | (i + 1))
	
	def get(r):
		res = 0
		while r >= 0:
			res += fenwick[r]
			r = (r & (r + 1)) - 1
		return res
	
	def get_seg(l, r):
		return get(r) - get(l - 1)
		
	by_r = [[] for i in range(n)]
	for t in range(q):
		l, r = map(int, sys.stdin.readline().split())
		l, r = l - 1, r - 1
		by_r[r].append((l, t))
	last_ent = [-1] * (n + 1)
	ans = [0] * q
	for r in range(n):
		p = last_ent[c[r]]
		if p != -1:
			add(p, -1)	
		last_ent[c[r]] = r
		add(r, 1)
		for quer in by_r[r]:
			l, num = quer
			ans[num] = get_seg(l, r)
	print('\n'.join([str(x) for x in ans]))
	
main()



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

struct BIT{
    ll n;
    vector<ll> d;
    BIT(ll n=0): n(n),d(n+1) {}

    void add(ll i, ll x=1){
        for(i++; i<=n; i+=i&-i){
            d[i]+=x;
        }
    }

    ll sum(ll i){
        ll x=0;
        for(i++; i; i-=i&-i){
            x+=d[i];
        }
        return x;
    }
};

int main(){
    ll n,q;
    cin>>n>>q;
    vector<ll> c(n);
    for(ll i=0;i<n;i++) cin>>c[i];
    vector<ll> pi(n+1,-1);
    vector<vector<ll> > ps(n);
    for(ll i=0;i<n;i++){
        ll l=pi[c[i]];
        if(l != -1){
            ps[l].push_back(i);
        }
        pi[c[i]]=i;
    }

    vector<vector<P> > qs(n);
    vector<ll> ans(q,0);

    for(ll i=0;i<q;i++){
        ll l,r;
        cin>>l>>r;
        l--; r--;
        qs[l].__emplace_back(make_pair(r,i));
        ans[i]=r-l+1;
    }

    struct BIT d(n);
    for(ll x=n-1;x>=0;x--){
        for(ll y:ps[x]) d.add(y,1);
        for(P q:qs[x]){
            ll r=q.first;
            ll i=q.second;
            ans[i]-=d.sum(r);
        }
    }

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:15: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<long long int, long long int> > >, std::vector<std::pair<long long int, long long int> > >::value_type' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named '__emplace_back'; did you mean 'emplace_back'?
   75 |         qs[l].__emplace_back(make_pair(r,i));
      |               ^~~~~~~~~~~~~~
      |               emplace_back