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

/*在线求区间内不同的数的个数：从头到尾添加到线段树（不是权值线段树，是存值的线段树）中
如果此数之前出现过就先减去，接着再加，最后在区间(l,r)中找到root[r]这个历史版本*/
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define dir(a,b) (a>>b)
const int Max=500010;
int root[Max],tot,val[Max];
using namespace std;
struct node
{
    int lef,rig,sum;
}msegtr[Max*40];
map<int,int> mp;
void Init()
{
    tot=0;
    msegtr[0].lef=msegtr[0].rig=msegtr[0].sum=0;
    root[0]=0;
    mp.clear();
    return;
}
void Create(int sta,int enn,int &x,int y,int pos,int aad)
{
    msegtr[++tot]=msegtr[y];
    msegtr[tot].sum+=aad;
    x=tot;
    if(sta==enn)
        return;
    int mid=dir(sta+enn,1);
    if(mid>=pos)
        Create(sta,mid,msegtr[x].lef,msegtr[y].lef,pos,aad);
    else
        Create(mid+1,enn,msegtr[x].rig,msegtr[y].rig,pos,aad);
    return;
}
int Query(int sta,int enn,int x,int y)//只有左边有界限
{
    if(sta>=y)
        return msegtr[x].sum;
    int mid=dir(sta+enn,1);
    if(mid>=y)
        return Query(sta,mid,msegtr[x].lef,y)+msegtr[msegtr[x].rig].sum;
    else
        return Query(mid+1,enn,msegtr[x].rig,y);
}
int main()
{
    int n,m,temp;
    int lef,rig;
    cin>>n>>m;
        Init();
        for(int i=1;i<=n;++i)
        {
            scanf("%d",&val[i]);
            if(!mp.count(val[i]))//直接加
            {
                Create(1,n,root[i],root[i-1],i,1);//注意是在i这个位置加1，不是权值线段树的val[i]位置加1
            }
            else
            {
                Create(1,n,temp,root[i-1],mp[val[i]],-1);//先在原位置减去1
                Create(1,n,root[i],temp,i,1);
            }
            mp[val[i]]=i;
        }
        
        for(int i=0;i<m;++i)
        {
            scanf("%d %d",&lef,&rig);
            printf("%d\n",Query(1,n,root[rig],lef));//在rig的历史版本上找(lef,rig)的值
        }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:5: error: 'cin' was not declared in this scope
   53 |     cin>>n>>m;
      |     ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    6 | #include<algorithm>
  +++ |+#include <iostream>
    7 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
// #define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/


ll sz=1;
vector<set<ll> > ar;
vector<ll> a;

void build( ll x, ll lx, ll rx){
    if(rx-lx==1){
        if(lx<a.size()){
            ar[x].insert(a[lx]);
        }
        return;
    }
    ll m = (lx+rx)/2;
    build(2*x+1, lx, m);
    build(2*x+2, m, rx);
    for(auto it:ar[2*x+1])
        ar[x].insert(it);
    for(auto it:ar[2*x+2])
        ar[x].insert(it);
}

set<ll> query(ll l, ll r, ll x, ll lx, ll rx){
    set<ll> s1;
    if(r<=lx || l>=rx)
        return s1;
    if(lx>=l && rx<=r)
        return ar[x];
    ll m = (lx+rx)/2;
    s1 = query(l, r, 2*x+1, lx, m);
    set<ll> s2 = query(l, r, 2*x+2, m, rx);
    for(auto it:s1)
        s2.insert(it);
    return s2;
}

ll main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    ll n, q;
    cin>>n>>q;
    a.resize(n);
    for(ll i=0;i<n;i++)
        cin>>a[i];
    while(sz<n)
        sz*=2;
    ar.resize(2*sz);
    build(0, 0, sz);
    /*for(ll i=0;i<ar.size();i++){
        for(auto j:ar[i])
            cout<<j<<" ";
        cout<<endl;
    }*/
    while(q--){
        ll l, r;
        cin>>l>>r;
        set<ll> an = query(l-1, r, 0, 0, sz);
        cout<<an.size()<<endl;
    }
    return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

const int MAXN = 2e5 + 10;
int n,k;
int a[MAXN];

inline bool check(int m)
{
    int ans = 0;
    rep(i,1,n) {
        if (a[i] != m) ans += a[i] / m;
        if (ans > k) return 0;
    }
    return ans <= k;
}

int main()
{
    scanf("%d%d",&n,&k);
    int l = 1;
    int r = -1;
    rep(i,1,n) {
        scanf("%d",a + i);
        if (i == 1) {
            r = a[i];
        } else {
            
            r = max(r,a[i]);
        }
    }
    
//    rep(i,1,r) {
//        printf("%d: %d\n",i,check(i));
//    }
    
//    if (k == 0) {
//        printf("%d\n",r);
//        return 0;
//    }
    int m;
    int ans = 1;

    while (l < r) {

        m = (l + r) / 2;
        if (check(m)) {
            r = m;
            ans = m;
        } else l = m + 1;
    }
    printf("%d\n",r);
    return 0;
}


Compiler output:
a.cc: In function 'bool check(int)':
a.cc:8:9: error: 'i' was not declared in this scope
    8 |     rep(i,1,n) {
      |         ^
a.cc:8:5: error: 'rep' was not declared in this scope
    8 |     rep(i,1,n) {
      |     ^~~
a.cc: In function 'int main()':
a.cc:17:5: error: 'scanf' was not declared in this scope
   17 |     scanf("%d%d",&n,&k);
      |     ^~~~~
a.cc:20:9: error: 'i' was not declared in this scope
   20 |     rep(i,1,n) {
      |         ^
a.cc:20:5: error: 'rep' was not declared in this scope
   20 |     rep(i,1,n) {
      |     ^~~
a.cc:49:5: error: 'printf' was not declared in this scope
   49 |     printf("%d\n",r);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | const int MAXN = 2e5 + 10;
Language: C++

#include <bits/stdc++.h>
#include "../lib/data_structure/bit.hpp"

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, q; cin >> n >> q;
  vi c(n);
  REP(i, n) {
    cin >> c[i];
  }

  vector<pair<P, int>> v(q);
  REP(i, q) {
    cin >> v[i].first.second >> v[i].first.first;
    v[i].second = i;
  }

  sort(ALL(v));
  REP(i, q) swap(v[i].first.first, v[i].first.second);

  vi last(n+1, -1);
  BIT<ll> bit(n+1);
  int nowr = 0;
  vi ans(q);
  REP(i, q) {
    int nxtr = v[i].first.second;
    while(nowr < nxtr) {
      if(last[c[nowr]] != -1) {
        bit.add(last[c[nowr]], -1);
      }
      bit.add(nowr, 1);
      last[c[nowr]] = nowr;
      nowr++;
    }
    ans[v[i].second] = bit.sum(v[i].first.second-1) - (v[i].first.first == 1 ? 0 : bit.sum(v[i].first.first-2));
  }
  REP(i, q) {
    cout << ans[i] << "\n";
  }




}








Compiler output:
a.cc:2:10: fatal error: ../lib/data_structure/bit.hpp: No such file or directory
    2 | #include "../lib/data_structure/bit.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
#define N 400000+100
using namespace std;
struct {
	int left;
	int right;
	int delta;
	int pained;
}tree[N];
int n,q;
vector<int>c;
void pushdown(int p)
{
	if (tree[p].delta)
	{
		tree[p * 2].delta = tree[p * 2 + 1].delta = tree[p].delta;
		tree[p * 2].pained = tree[p * 2 + 1].pained = (1 << tree[p].delta);
		tree[p].delta = 0;
	}
}
int cou(int x)
{
	int sum = 0;
	while (x)
	{
		if (x&1)
			++sum;
		x >>= 1;
	}
	return sum;
}
void build(int p, int l, int r)
{
	tree[p].pained = 2;
	tree[p].left = l;
	tree[p].right = r;
	if (l == r)
		return;
	int mid = (l + r) / 2;
	build(p * 2, l, mid);
	build(p * 2 + 1, mid + 1, r);
}
int getsum(int p, int l, int r)/
{
	if (tree[p].left == l && tree[p].right == r)return tree[p].pained;
	pushdown(p);
       
	int mid = (tree[p].left + tree[p].right) / 2;
	if (r <= mid)return getsum(2 * p, l, r);
	if (l>mid)return getsum(2 * p + 1, l, r);
	return getsum(2 * p, l, mid) | getsum(2 * p + 1, mid + 1, r);
}
void updata(int p, int l, int r, int data)
{
	if (tree[p].left == l && tree[p].right == r)
	{
		tree[p].pained = (1 << data);
		tree[p].delta = data;
		return;
	}
	pushdown(p);//向下更新
	int mid = (tree[p].left + tree[p].right) / 2;
	if (r <= mid)updata(p * 2, l, r, data);
	else if (l>mid)updata(p * 2 + 1, l, r, data);
	else
	{
		updata(p * 2, l, mid, data);
		updata(p * 2 + 1, mid + 1, r, data);
	}
	tree[p].pained = tree[2 * p].pained | tree[2 * p + 1].pained;
}

int main(void)
{
    cin>>n>>q;
	build(1, 1, n);
    c.resize(n);
    rep(i,n){
        cin>>c[i];
        updata(1, i+1, i+1, c[i]);
        }
	while (q--)
	{
        int l,r;
        cin>>l>>r;
	   printf("%d\n", cou(getsum(1, l, r)));
	}
	return 0;
}

Compiler output:
a.cc:52:32: error: expected initializer before '/' token
   52 | int getsum(int p, int l, int r)/
      |                                ^
a.cc: In function 'int main()':
a.cc:95:31: error: 'getsum' was not declared in this scope; did you mean 'getsid'?
   95 |            printf("%d\n", cou(getsum(1, l, r)));
      |                               ^~~~~~
      |                               getsid
Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
int main()
{
	int N, Q;
	std::cin >> N >> Q;
	std::vector<int> c(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> c[i];
	}
	char* flags = new char[N];
	std::vector<int> ans;
	for (int i = 0; i < Q; ++i) {
		int l, r;
		std::cin >> l >> r;
		int count = 0;
		memset(flags, 0, N);
		for (int i = l - 1; i <= r - 1; ++i) {
			if (flags[c[i]] == 0) {
				++count;
				flags[c[i]] = 1;
			}
		}
		ans.push_back(count);
	}
	for (int i = 0; i < Q; ++i) {
		std::cout << ans[i] << std::endl;
	}
	delete[] flags;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'memset' was not declared in this scope
   24 |                 memset(flags, 0, N);
      |                 ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    9 | #include <cmath>
  +++ |+#include <cstring>
   10 | int main()
Language: Java

import data_structure.fenwick.FenwickTree;

import java.util.Arrays;

public class CountRangeCoveringRange {
    /**
     * Counts how many ranges in [l,r).
     * Answers multiple query.
     *
     * O((n+q)log(n+q) where q = query.length, n = ranges.length
     *
     * @param ranges array of [l,r)
     * @param query answerCountQuery query
     * @return answers to the queries
     */
    public static int[] answerCountQuery(int[][] ranges, int[][] query) {
        int n = ranges.length;
        int q = query.length;
        int[][] qinfo = new int[n+q][3];
        for (int i = 0; i < q ; i++) {
            qinfo[i] = new int[]{ query[i][0], query[i][1], i };
        }
        for (int i = 0; i < n ; i++) {
            qinfo[q+i] = new int[]{ ranges[i][0], ranges[i][1], -1 };
        }

        Arrays.sort(qinfo, (a, b) -> (a[1] == b[1]) ? a[2] - b[2] : a[1] - b[1]);

        // it may need value compression.
        FenwickTree bit = new FenwickTree(1000010);
        int[] ans = new int[q];
        int head = 0;
        for (int i = 0; i < n+q ; i++) {
            if (qinfo[i][2] == -1) {
                // target range
                bit.add(qinfo[i][0]+1, 1);
            } else {
                // query range
                ans[qinfo[i][2]] = (int)bit.range(qinfo[i][0]+1, qinfo[i][1]);
            }
        }
        return ans;
    }
}

Compiler output:
Main.java:5: error: class CountRangeCoveringRange is public, should be declared in a file named CountRangeCoveringRange.java
public class CountRangeCoveringRange {
       ^
Main.java:1: error: package data_structure.fenwick does not exist
import data_structure.fenwick.FenwickTree;
                             ^
Main.java:30: error: cannot find symbol
        FenwickTree bit = new FenwickTree(1000010);
        ^
  symbol:   class FenwickTree
  location: class CountRangeCoveringRange
Main.java:30: error: cannot find symbol
        FenwickTree bit = new FenwickTree(1000010);
                              ^
  symbol:   class FenwickTree
  location: class CountRangeCoveringRange
4 errors
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

  int n, q;
  cin >> n >> q;

  vector<int> a(n);
  for (int c = 0; c < n; ++c) {
    cin >> a[i];
  }
  for (int i = 0; i < q; ++i) {
    int l, r;
    set<int> s;
    cin >> l >> r;
    for (int j = l; j <= r; ++j) {
      s.insert(a[j - 1]);
    }
    cout << s.size() << '\n';
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:14: error: 'i' was not declared in this scope
   15 |     cin >> a[i];
      |              ^
Language: C++


    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        queries[i].l=x;
        queries[i].r=y;
        queries[i].idx=i;
    }
    sort(queries, queries+q, cmp);
    answeringQueries(n, queries, q);
    return 0;
}


Compiler output:
a.cc:2:5: error: expected unqualified-id before 'for'
    2 |     for(int i=0;i<q;i++){
      |     ^~~
a.cc:2:17: error: 'i' does not name a type
    2 |     for(int i=0;i<q;i++){
      |                 ^
a.cc:2:21: error: 'i' does not name a type
    2 |     for(int i=0;i<q;i++){
      |                     ^
a.cc:10:9: error: expected constructor, destructor, or type conversion before '(' token
   10 |     sort(queries, queries+q, cmp);
      |         ^
a.cc:11:21: error: expected constructor, destructor, or type conversion before '(' token
   11 |     answeringQueries(n, queries, q);
      |                     ^
a.cc:12:5: error: expected unqualified-id before 'return'
   12 |     return 0;
      |     ^~~~~~
a.cc:13:1: error: expected declaration before '}' token
   13 | }
      | ^
Language: C++

#import<iostream>
#import<algorithm>
#define endl '\n'
using namespace std;
struct H{int i,s,x,y;};
int i,j,k,l,m,n,q,r,s,x,y,a[100005],p[1000005],z[100005];
H w[100005];
int C(H a,H b){return a.s<b.s||a.s==b.s&&a.y<b.y;}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>q;
	for(s=sqrt(n);i++<n;)cin>>a[i];
	for(i=0;i++<q;)
	{
		cin>>w[i].x>>w[i].y;
		w[i].i=i;
		w[i].s=x/s;
	}
	sort(w,w+i,C);
	l=w[1].x;
	r=l-1;
	for(i=0;i++<q;)
	{
		x=w[i].x;
		y=w[i].y;
		for(;l<x;)k-=!--p[a[l++]];
		for(;l>x;)k+=!p[a[--l]]++;
		for(;r<y;)k+=!p[a[++r]]++;
		for(;r>y;)k-=!--p[a[r--]];
		z[w[i].i]=k;
	}
	for(i=0;i++<q;)cout<<z[i]<<endl;
}

Compiler output:
a.cc:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    1 | #import<iostream>
      |  ^~~~~~
a.cc:2:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    2 | #import<algorithm>
      |  ^~~~~~
a.cc:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:15:15: error: 'sqrt' was not declared in this scope
   15 |         for(s=sqrt(n);i++<n;)cin>>a[i];
      |               ^~~~
Language: C++

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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

const int N = 5e5 + 1;
bitset<N> a[N], E;
// bitset<N> tree[N];
vector<bitset<N>> tree;

#define lc (i<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)


bitset<N> merge(bitset<N> x, bitset<N> y) { return x|y; }

void build(int i,int l,int r){
    if(l == r){
        tree[i] = a[l];return;
    }
    build(lc,l,mid);build(rc,mid+1,r);
    tree[i] = merge(tree[lc],tree[rc]);
}

bitset<N> query(int i, int l, int r, int ql, int qr) {
  if(r < ql || l > qr) return E;
  if(ql <= l && r <= qr) return tree[i];
  bitset<N> q1 = query(lc, l, mid, ql, qr);
  bitset<N> q2 = query(rc, mid+1, r, ql, qr);
  return merge(q1, q2);
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, q;
    cin >> n >> q;
    tree.resize(4 * n);
    int c[n+1];
    for(int i = 1; i <= n; i++) {
        cin >> c[i];
        a[i][c[i]] = 1;
    }
    build(1, 1, n);
    while(q--) {
        int l, r;
        cin >> l >> r;
        bitset<N> b = query(1, 1, n, l, r);
        cout << b.count() << endl;
    }
    return 0;
}



Compiler output:
/tmp/ccvEm2so.o: in function `build(long long, long long, long long)':
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `tree' defined in .bss section in /tmp/ccvEm2so.o
a.cc:(.text+0x12a): relocation truncated to fit: R_X86_64_PC32 against symbol `tree' defined in .bss section in /tmp/ccvEm2so.o
a.cc:(.text+0x149): relocation truncated to fit: R_X86_64_PC32 against symbol `tree' defined in .bss section in /tmp/ccvEm2so.o
a.cc:(.text+0x1bd): relocation truncated to fit: R_X86_64_PC32 against symbol `tree' defined in .bss section in /tmp/ccvEm2so.o
/tmp/ccvEm2so.o: in function `query(long long, long long, long long, long long, long long)':
a.cc:(.text+0x251): relocation truncated to fit: R_X86_64_PC32 against symbol `E' defined in .bss section in /tmp/ccvEm2so.o
a.cc:(.text+0x297): relocation truncated to fit: R_X86_64_PC32 against symbol `tree' defined in .bss section in /tmp/ccvEm2so.o
/tmp/ccvEm2so.o: in function `main':
a.cc:(.text+0x455): relocation truncated to fit: R_X86_64_PC32 against symbol `tree' defined in .bss section in /tmp/ccvEm2so.o
/tmp/ccvEm2so.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x612): relocation truncated to fit: R_X86_64_PC32 against symbol `tree' defined in .bss section in /tmp/ccvEm2so.o
a.cc:(.text+0x62b): relocation truncated to fit: R_X86_64_PC32 against symbol `tree' defined in .bss section in /tmp/ccvEm2so.o
collect2: error: ld returned 1 exit status
Language: C++

n,q = map(int, input().split())
c = list(map(int, input().split()))
for _ in range(q):
    l,r = map(int, input().split())
    print(len(set(c[l:r+1])))


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,q = map(int, input().split())
      | ^
Language: C

#include <stdio.h>
#include <bits/stdc++.h>
struct Mo
{
  vector< int > left, right, order;
  vector< bool > v;
  int width;
  int nl, nr, ptr;

  Mo(int n) : width((int) sqrt(n)), nl(0), nr(0), ptr(0), v(n) {}

  void insert(int l, int r) /* [l, r) */
  {
    left.push_back(l);
    right.push_back(r);
  }

  /* ソート */
  void build()
  {
    order.resize(left.size());
    iota(begin(order), end(order), 0);
    sort(begin(order), end(order), [&](int a, int b)
    {
      if(left[a] / width != left[b] / width) return left[a] < left[b];
      return right[a] < right[b];
    });
  }

  /* クエリを 1 つぶんすすめて, クエリのidを返す */
  int process()
  {
    if(ptr == order.size()) return (-1);
    const auto id = order[ptr];
    while(nl > left[id]) distribute(--nl);
    while(nr < right[id]) distribute(nr++);
    while(nl < left[id]) distribute(nl++);
    while(nr > right[id]) distribute(--nr);
    return (order[ptr++]);
  }

  inline void distribute(int idx)
  {
    v[idx].flip();
    if(v[idx]) add(idx);
    else del(idx);
  }

  void add(int idx);

  void del(int idx);
};

int N, A[300000], Q;
int ans[200000];
int cnt[1000001], sum;

void Mo::add(int idx)
{
  if(cnt[A[idx]]++ == 0) ++sum;
}

void Mo::del(int idx)
{
  if(--cnt[A[idx]] == 0) --sum;
}

int main()
{
  scanf("%d", &N);
  scanf("%d", &Q);
  for(int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  Mo mo(N);
  for(int i = 0; i < Q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    mo.insert(--a, b);
  }
  mo.build();
  for(int i = 0; i < Q; i++) {
    ans[mo.process()] = sum;
  }
  for(int i = 0; i < Q; i++) {
    printf("%d\n", ans[i]);
  }
}

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

import java.io.*; 
import java.util.*; 
  
class Main
{ 
  
   
    static HashSet<Integer>[] segment; 
  
   
    static void build(int i, int s, int e, int[] arr) 
    { 
  
       
        if (s == e) 
        { 
            segment[i].add(arr[s]); 
            return; 
        } 
  
        
        build(2 * i, s, (s + e) / 2, arr); 
        build(1 + 2 * i, 1 + (s + e) / 2, e, arr); 
  
       
        segment[i].addAll(segment[2 * i]); 
        segment[i].addAll(segment[2 * i + 1]); 
    } 
  
   
    static HashSet<Integer> query(int node, int l,  
                                int r, int a, int b) 
    { 
        HashSet<Integer> left = new HashSet<>(); 
        HashSet<Integer> right = new HashSet<>(); 
        HashSet<Integer> result = new HashSet<>(); 
  
        if (b < l || a > r) 
            return result; 
  
        
        if (a <= l && r <= b) 
            return segment[node]; 
  
        left = query(2 * node, l, (l + r) / 2, a, b); 
        result.addAll(left); 
  
        right = query(1 + 2 * node, 1 + (l + r) / 2, r, a, b); 
        result.addAll(right); 
  
    \\
        return result; 
    } 
  
    // Initialize the segment tree 
    @SuppressWarnings("unchecked") 
    static void init(int n)  
    { 
  
        // Get the height of the segment tree 
        int h = (int) Math.ceil(Math.log(n) / Math.log(2)); 
        h = (int) (2 * Math.pow(2, h)) - 1; 
  
        // Initialize the segment tree 
        segment = new HashSet[h]; 
        for (int i = 0; i < h; i++) 
            segment[i] = new HashSet<>(); 
    } 
  
    // Function to get the result for the 
    // subarray from arr[l] to arr[r] 
    static void getDistinct(int l, int r, int n) 
    { 
  
        // Query for the range set 
        HashSet<Integer> ans = query(1, 0, n - 1, l, r); 
  
        System.out.println(ans.size()); 
    } 
  
    // Driver Code 
    public static void main(String[] args) 
    { 
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int q = sc.nextInt();
        int[] arr = new int[n];
        
        for(int i = 0;i<n;i++)
        	arr[i] = sc.nextInt();
        
        init(n); 
  
        // Bulid the segment tree 
        build(1, 0, n - 1, arr); 
  
        while(q-- >0)
       getDistinct(sc.nextInt(), sc.nextInt(), n); 
    }
} 

Compiler output:
Main.java:51: error: illegal character: '\'
    \\
    ^
Main.java:51: error: illegal character: '\'
    \\
     ^
2 errors
Language: C++

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

#define ll int
#define f first
#define s second
#define sd(x)           scanf("%d",&x)
#define schar(x)        scanf("%c\n",&x)
#define slld(x)         scanf("%lld",&x)
#define sf(x)           scanf("%lf",&x)
#define pb              push_back
#define pll             pair<int,int>
#define FOR(i,m)        for(i=0;i<m;i++)
#define ROF(i,m)        for(i=m;i>=0;i--)
#define FILL(v, p)      memset(v,p,sizeof v)
#define CASE(x)         printf("Case %d: ",x)
#define all(x)          x.begin(),x.end()
#define endl            "\n"
#define NL              printf("\n")
#define print(x)        printf("%d\n",x)
#define PI              2*acos(0.0)
#define EPS             0.000000000000001
#define INF             1LL<<62
#define MAX             500005

ll l=-1, r=-1, a[MAX];
ll cnt[MAX], ans=0;
ll color[MAX], an[MAX];

bool cmp(pair<pll,int> &a, pair<pll,int> &b)
{
    int blka=a.first.second/k, blkb=b.first.second/k;
    if(blka!=blkb) return blka < blkb;

    return a.first.first < b.first.first;
}

void add(ll x)
{
    if(cnt[color[x]] == 0) ans++;
    cnt[color[x]]++;
}

void del(ll x)
{
    if(cnt[color[x]]) cnt[color[x]]--;
    if(cnt[color[x]] == 0) ans--;
}

int main()
{
    //freopen("in.txt","r",stdin);

    ll n, m, i;
    sd(n); sd(m);

    FOR(i,n) sd(color[i]);

    vector< pair<pll,int> > vec;

    FOR(i,m) sd(l), sd(r), l--, r--, vec.push_back({{r,l}, i});

    k=sqrt(m);

    l=0, r=-1;

    sort(vec.begin(),vec.end(),cmp);

    FOR(i,m)
    {
        while(l>vec[i].first.second)    add(--l);
        while(r<vec[i].first.first)     add(++r);
        while(l<vec[i].first.second)    del(l++);
        while(r>vec[i].first.first)     del(r--);

        an[vec[i].second]= ans;
    }

    FOR(i,m) printf("%d\n",an[i]);

    return 0;
}

Compiler output:
a.cc: In function 'bool cmp(std::pair<std::pair<int, int>, int>&, std::pair<std::pair<int, int>, int>&)':
a.cc:32:29: error: 'k' was not declared in this scope
   32 |     int blka=a.first.second/k, blkb=b.first.second/k;
      |                             ^
a.cc:33:14: error: 'blkb' was not declared in this scope; did you mean 'blka'?
   33 |     if(blka!=blkb) return blka < blkb;
      |              ^~~~
      |              blka
a.cc: In function 'int main()':
a.cc:63:5: error: 'k' was not declared in this scope
   63 |     k=sqrt(m);
      |     ^
Language: C++

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn=5e5+10;
int n,m,kin,l,r,c;
struct Node
{
    int l,r;
    ll lazy,x;
} node[maxn<<2];
void build(int k,int l,int r)
{
    node[k].l=l;
    node[k].r=r;
    node[k].lazy=0;
    node[k].x=0;
    if(l==r) return ;
    int mid=(l+r)>>1;
    build(k<<1,l,mid);
    build(k<<1|1,mid+1,r);
}
void up(int k,int l,int r,ll c)
{
    node[k].x|=(1ll<<c);
    if(node[k].l==l&&node[k].r==r)
    {
        node[k].lazy|=(1ll<<c);
        return ;
    }
    int mid=(node[k].l+node[k].r)>>1;
    if(r<=mid) up(k<<1,l,r,c);
    else if(l>mid) up(k<<1|1,l,r,c);
    else
    {
        up(k<<1,l,mid,c),up(k<<1|1,mid+1,r,c);
    }
}
ll query(int k,int l,int r)
{
    if(node[k].l==l&&node[k].r==r)
    {
        return node[k].x;
    }
    int mid=(node[k].l+node[k].r)>>1;
    ll le=node[k].lazy;
    if(r<=mid ) return le|query(k<<1,l,r);
    else if(l>mid) return le|query(k<<1|1,l,r);
    else return le|query(k<<1,l,mid)|query(k<<1|1,mid+1,r);
}
int find(ll t)
{
    int cnt=0;
    while(t)
    {
        cnt++;
        t&=(t-1);
    }
    return cnt;
}
int main()
{
    int i,j;
    scanf("%d%d",&n,&m)

    build(1,1,n);

    for(int i=1; i<=n; i++)
    {
        int tmp;
        scanf("%d",&tmp);
        up(1,i,i,tmp);
    }
    for(int i=1; i<=m; i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        int ans=query(1,l,r);
        printf("%d\n",find(ans));
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:24: error: expected ';' before 'build'
   65 |     scanf("%d%d",&n,&m)
      |                        ^
      |                        ;
   66 | 
   67 |     build(1,1,n);
      |     ~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int nmax = 5e5 + 3;
int n, q, usu[nmax], sol, v[nmax];
struct Query {
	int l, r, idx;

	inline pair<int, int> toPair() const {
		return make_pair(l / sqrt(n), ((l / sqrt(n)) & 1) ? -r : +r);
	}
}t[nmax];

int ap[nmax];

inline bool operator<(const Query &a, const Query &b) {
	return a.toPair() < b.toPair();
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> q;
    for(int i = 1; i <= n; ++i) cin >> v[i];
    for(int i = 1; i <= q; ++i)
    {
        cin >> t[i].l >> t[i].r;
        t[i].idx = i;
    }
    sort(t + 1, t + q + 1);

    int st = 0;
    int dr = 0;

    for(int i = 1; i <= q; ++i)
    {
        //cout << t[i].l << ' ' << t[i].r << '\n';

        if(t[i].l > dr || t[i].r < st)
        {
            for(int j = st; j <= dr; ++j) ap[v[j]] = 0;
            st = t[i].l;
            dr = st;
            sol = 1;
            ++ap[v[st]];
        }

        while(dr < t[i].r)
        {
            ap[v[++dr]]++;
            if(ap[v[dr]] == 1) ++sol;
        }

        while(st > t[i].l)
        {
            ap[v[--st]]++;
            if(ap[v[st]] == 1) ++sol;
        }

        while(st < t[i].l)
        {
            ap[v[st++]]--;
            if(ap[v[st - 1]] == 0) --sol;
        }

        while(dr > t[i].r)
        {
            ap[v[dr--]]--;
            if(ap[v[dr + 1]] == 0) --sol;
        }

        usu[t[i].idx] = sol;
    }

    for(int i = 1; i <= q; ++i) cout << usu[i] << '\n';
    return 0;
}


Compiler output:
a.cc: In member function 'std::pair<int, int> Query::toPair() const':
a.cc:11:62: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'} and 'int' to binary 'operator&'
   11 |                 return make_pair(l / sqrt(n), ((l / sqrt(n)) & 1) ? -r : +r);
      |                                                ~~~~~~~~~~~~~ ^ ~
      |                                                   |            |
      |                                                   |            int
      |                                                   __gnu_cxx::__enable_if<true, double>::__type {aka double}
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
using iii = tuple<int, int, int>;
using mii = map<int, int>;
using vi = vector<int>;
using viii = vector<iii>;
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q, a, b;
  cin >> n >> q;
  vi x(n);
  mii m;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    if (m.count(y)) x[i] = m[y];
    else x[i] = m.size(), m[y] = x[i];
  }
  viii y(q);
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    y[i] = {a-1, b, i};
  }
  int k = sqrt(n);
  sort(y.begin(), y.end(), [&](iii x, iii y) -> bool {
    int a1, b1, i1, a2, b2, i2;
    tie(a1, b1, i1) = x;
    tie(a2, b2, i2) = y;
    int a1q = a1/k, a2q = a2/k;
    if (a1q < a2q) return true;
    if (a1q > a2q) return false;
    return b1 < b2;
  });
  vi res(q);
  vi count(m.size());
  int l = 0, r = 0, ans = 0;
  for (iii z : y) {
    int i;
    tie(a, b, i) = z;
    while (r <a b) if (++count[x[r++]] == 1) ans++;
    while (r > b) if (--count[x[--r]] == 0) ans--;
    while (l < a) if (--count[x[l++]] == 0) ans--;
    while (l > a) if (++count[x[--l]] == 1) ans++;
    res[i] = ans;
  }
  for (int z : res) cout << z << '\n';
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:16: error: expected ')' before 'b'
   43 |     while (r <a b) if (++count[x[r++]] == 1) ans++;
      |           ~    ^~
      |                )
a.cc:43:18: error: expected ';' before ')' token
   43 |     while (r <a b) if (++count[x[r++]] == 1) ans++;
      |                  ^
      |                  ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
void buildtree(vector<int> &arr,vector<unordered_set<int> > &v,int low,int high,int index){
	if(low>high)
	return;
	if(low==high){
		v[index].insert(arr[low]);
		return;
	}
	int mid=low+high;
	mid=mid/2;
	buildtree(arr,v,low,mid,2*index+1);
	buildtree(arr,v,mid+1,high,2*index+2);
	v[index].insert(v[2*index+1].begin(),v[2*index+1].end());
	v[index].insert(v[2*index+2].begin(),v[2*index+2].end());
}
unordered_set<int> sum(vector<unordered_set<int> > &v,int low,int high,int left,int right,int index){
	unordered_set<int> temp;
	if(low>right||high<left||low>high)
	return temp;
	if(low>=left&&right>=high){
		return v[index];
	}
	int mid=(low+high)/2;
	unordered_set<int> lef=sum(v,low,mid,left,right,2*index+1);
	unordered_set<int> righ=sum(v,mid+1,high,left,right,2*index+2);
	temp.insert(lef.begin(),lef.end());
	temp.insert(righ.begin(),righ.end());
	return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,q;
   cin>>n>>q;
   vector<int> arr(n);
   for(int i=0;i<n;i++){
   	cin>>arr[i];
   }
   int h = (int)ceil(log2(n)); 
    h = (2 * (pow(2, h))) - 1; 
  vector<unordered_set<int> > v(h);
    buildtree(arr,v,0,n-1,0);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	set<int> p=sum(v,0,n-1,l-1,r-1,0);
    	cout<<p.size()<<"\n";
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:23: error: conversion from 'std::unordered_set<int>' to non-scalar type 'std::set<int>' requested
   48 |         set<int> p=sum(v,0,n-1,l-1,r-1,0);
      |                    ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
  int N, Q;
  cin >> N, Q;
}
  if (N, Q = ) {
  N, Q = 4, 3;
         1, 2, 1, 3;
         1, 3;
         2, 4;
         3, 3;
  }
  cout << N, Q << 2, 3, 1 << endl;
}


Compiler output:
a.cc:8:3: error: expected unqualified-id before 'if'
    8 |   if (N, Q = ) {
      |   ^~
a.cc:15:3: error: 'cout' does not name a type
   15 |   cout << N, Q << 2, 3, 1 << endl;
      |   ^~~~
a.cc:16:1: error: expected declaration before '}' token
   16 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
void buildtree(vector<int> &arr,vector<unordered_set<int> > &v,int low,int high,int index){
	if(low>high)
	return;
	if(low==high){
		v[index].insert(arr[low]);
		return;
	}
	int mid=low+high;
	mid=mid/2;
	buildtree(arr,v,low,mid,2*index+1);
	buildtree(arr,v,mid+1,high,2*index+2);
	v[index].insert(v[2*index+1].begin(),v[2*index+1].end());
	v[index].insert(v[2*index+2].begin(),v[2*index+2].end());
}
unordered_set<int> sum(vector<unordered_set<int> > &v,int low,int high,int left,int right,int index){
	set<int> temp;
	if(low>right||high<left||low>high)
	return temp;
	if(low>=left&&right>=high){
		return v[index];
	}
	int mid=(low+high)/2;
	set<int> lef=sum(v,low,mid,left,right,2*index+1);
	set<int> righ=sum(v,mid+1,high,left,right,2*index+2);
	temp.insert(lef.begin(),lef.end());
	temp.insert(righ.begin(),righ.end());
	return temp;
}
int main()
{
	ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,q;
   cin>>n>>q;
   vector<int> arr(n);
   for(int i=0;i<n;i++){
   	cin>>arr[i];
   }
   int h = (int)ceil(log2(n)); 
    h = (2 * (pow(2, h))) - 1; 
  vector<unordered_set<int> > v(h);
    buildtree(arr,v,0,n-1,0);
    while(q--){
    	int l,r;
    	cin>>l>>r;
    	set<int> p=sum(v,0,n-1,l-1,r-1,0);
    	cout<<p.size()<<"\n";
	}
}


Compiler output:
a.cc: In function 'std::unordered_set<int> sum(std::vector<std::unordered_set<int> >&, int, int, int, int, int)':
a.cc:20:16: error: could not convert 'temp' from 'std::set<int>' to 'std::unordered_set<int>'
   20 |         return temp;
      |                ^~~~
      |                |
      |                std::set<int>
a.cc:25:25: error: conversion from 'std::unordered_set<int>' to non-scalar type 'std::set<int>' requested
   25 |         set<int> lef=sum(v,low,mid,left,right,2*index+1);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:26:26: error: conversion from 'std::unordered_set<int>' to non-scalar type 'std::set<int>' requested
   26 |         set<int> righ=sum(v,mid+1,high,left,right,2*index+2);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:16: error: could not convert 'temp' from 'std::set<int>' to 'std::unordered_set<int>'
   29 |         return temp;
      |                ^~~~
      |                |
      |                std::set<int>
a.cc: In function 'int main()':
a.cc:48:23: error: conversion from 'std::unordered_set<int>' to non-scalar type 'std::set<int>' requested
   48 |         set<int> p=sum(v,0,n-1,l-1,r-1,0);
      |                    ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=5e5+9;
int a[N],Block,value,m[N];
bool ok[N];
struct query
{
    int l,r,i;
};
query q[N];
bool f(query a, query b)
{
    if(a.l / Block != b.l / Block)
        return a.l < b.l;
    return a.l / Block % 2 ? a.r < b.r : a.r > b.r;
}
add(int pos)
{
    int val=a[pos];
    m[val]++;
    if (m[val]==1)
    {
        value++;
    }
    else if (!m[val])
    {
        value--;
    }
}
void remove(int pos)
{
    int val=a[pos];
    m[val]--;
    if (!m[val])
    {
        value--;
    }
}
int main()
{
    FASTINOUT;
    int x,t;
    scanf("%d%d",&x,&t);
    Block=sqrtl(x);
    for (int i=0; i<x; i++)
        scanf("%d",&a[i]);
    for (int j=0; j<t; j++)
    {
        scanf("%d%d",&q[j].l,&q[j].r);
        q[j].l--;
        q[j].r--;
        q[j].i=j;
    }
    sort(q,q+t,f);
    int start=0,end=-1;
    vector<int>ans(t);
    for (int i=0; i<t; i++)
    {
        int L=q[i].l, R=q[i].r;

        while (start > L)
            start--,add(start);

        while (end < R)
            end++, add(end);

        while (start < L)
            remove(start),start++;

        while (end > R)
            remove(end),end--;

        ans[q[i].i]=value;
    }
    for (int j:ans)
        printf("%d\n",j);
    return 0;
}


Compiler output:
a.cc:20:1: error: ISO C++ forbids declaration of 'add' with no type [-fpermissive]
   20 | add(int pos)
      | ^~~
a.cc: In function 'int add(int)':
a.cc:32:1: warning: no return statement in function returning non-void [-Wreturn-type]
   32 | }
      | ^
Language: Java

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    scan.nextLine(); // N と Q の行読み飛ばし
    String str = scan.nextLine();
    String[] array = str.split(" ");
    List<String> list = Arrays.asList(array);

    while (scan.hasNext()) {
      str = scan.nextLine();
      String[] strs = str.split(" ");
      int l = Integer.parseInt(strs[0]);
      int r = Integer.parseInt(strs[1]);

      List<String> sbList = list.subList(l-1, r);
      System.out.println(new HashSet<>(sbList).size());
    }
  }

Compiler output:
Main.java:23: error: reached end of file while parsing
  }
   ^
1 error
Language: C++

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

int main() {
  int N, Q;
  cin >> N, Q;
  if (N, Q = )
  N, Q = 4, 3
         1, 2, 1, 3;
         1, 3;
         2, 4;
         3, 3;
  cout << N, Q << 2, 3, 1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:14: error: expected primary-expression before ')' token
    7 |   if (N, Q = )
      |              ^
a.cc:8:14: error: expected ';' before numeric constant
    8 |   N, Q = 4, 3
      |              ^
      |              ;
    9 |          1, 2, 1, 3;
      |          ~    
a.cc:13:27: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   13 |   cout << N, Q << 2, 3, 1 << endl;
      |                         ~~^~~~~~~
Language: C++

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

const int N = 2e5 + 5;
struct que{
    int l,r,i;
};
int x;
bool comp(que a, que b){
    if(a.l/x!=b.l/x) return a.l/x<b.l/x;
    else return a.r<b.r;
}
int m[1000005]={};
int32_t main()
{
    IOS;
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n,q; cin>>n>>q;
        int a[n];
        x=sqrt(n);
        for (int i = 0; i < n; ++i)
        {
            cin>>a[i];
        }
        int ans[q]={};
        vector<que> v;
        for (int i = 0; i < q; ++i)
        {
            int l,r; cin>>l>>r;
            l--; r--;
            v.pb({l,r,i});
        }
        sort(v.begin(), v.end(),comp);
        int curl=0,curr=-1;
        int cnt=0;
        for (int i = 0; i < q; ++i)
        {
            int l=v[i].l,r=v[i].r;
            // cout<<l<<" "<<r<<"\n";
            while(curl>l){
                curl--;
                m[a[curl]]++;
                if(m[a[curl]]==1) cnt++;
            }
            while(curr<r){
                curr++;
                m[a[curr]]++;
                if(m[a[curr]]==1) cnt++;
            }
            while(curl<l){
                m[a[curl]]--;
                if(m[a[curl]]==0) cnt--;
                curl++;
            }
            while(curr>r){
                m[a[curr]]--;
                if(m[a[curr]]==0) cnt--;
                curr--;
            }
            // cout<<curl<<" "<<curr<<"\n";
            ans[v[i].i]=cnt;
        }
        for (int i = 0; i < q; ++i)
        {
            cout<<ans[i]<<"\n";
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:37:15: error: 'class std::vector<que>' has no member named 'pb'
   37 |             v.pb({l,r,i});
      |               ^~
Language: C++

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

int main() {
  int N, Q;
  cin >> N, Q;
  
  N, Q = 4, 3
         1, 2, 1, 3
         1, 3
         2, 4
         3, 3;
  cout << N, Q << 2, 3, 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: expected ';' before numeric constant
    8 |   N, Q = 4, 3
      |              ^
      |              ;
    9 |          1, 2, 1, 3
      |          ~    
a.cc:13:27: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   13 |   cout << N, Q << 2, 3, 1 << endl;
      |                         ~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

void solve()
{
    ll n,q;
  cin>>n>>q;
  vi a(n),col(n,0),lef(n),rig(n);
  fo(i,0,n) cin>>a(n);
  int k=0;
  fo(i,0,n)
  {
    if(!col[a[i]-1]) { col[a[i]-1]++; k++; }
    lef[i]=k;
  }
  fo(i,0,n) col[i]=0;
  k=0;
  rfo(i,n-1,0)
  {
    if(!col[a[i]-1]) { col[a[i]-1]++; k++; }
    rig[i]=k;
  }
  while(q--)
  {
    int l,r;
    cin>>l>>r;
    l--; r--;
    cout<<max(lef[r]-lef[l], rig[l]-rig[r]) +1<<"\n";
  }
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    {
        solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:24:19: error: no match for call to '(std::vector<int>) (int64_t&)'
   24 |   fo(i,0,n) cin>>a(n);
      |                  ~^~~
Language: Java

import java.util.*;

public class Main{
	public static void main(String args[]){
     	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int q = sc.nextInt();
        int ar[] = new int[n+1];
        HashSet<Integer> set = new HashSet<>();
        for(int i =0;i<n;i++){
         	set.add(s.nextInt());
           ar[i+1] = set.size();
        }
      for(int i =0;i<q;i++){
      	 int a = sc.nextInt();
        int b = sc.nextInt();
        if(a==b)
          System.out.println(1);
        else{
          System.out.println(ar[b]-ar[a-1]);
        }
           
        }
    }
}


Compiler output:
Main.java:11: error: cannot find symbol
         	set.add(s.nextInt());
         	        ^
  symbol:   variable s
  location: class Main
1 error
Language: C++

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

#include "../../../lib/SegmentTree/SegmentTree.hpp"

struct Monoid{
  using value_t=i64;
  constexpr static value_t id=0;
  constexpr static value_t op(value_t a,value_t b){
    return a+b;
  }
};

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

  i64 n,q;
  std::cin>>n>>q;

  std::vector<i64> c(n);
  for(auto&& e:c){
    std::cin>>e;
    e--;
  }

  struct Query{
    i64 l,r,index;
  };

  using P=std::pair<i64,i64>;
  std::vector<Query> seg(q);
  rep(i,0,q){
    std::cin>>seg[i].l>>seg[i].r;
    seg[i].l--;
    seg[i].index=i;
  }

  auto comp=[](const Query& a,const Query& b){
    return a.r<b.r;
  };

  std::sort(all(seg),comp);

  std::vector<i64> ans(q);
  std::vector<i64> last(n,-1);

  SegmentTree<Monoid> rsq(n);

  auto itr=seg.begin();
  rep(i,0,n){
    {
      i64 num=c[i];
      if(last[num]!=-1)rsq.update(last[num],-1,false);
      rsq.update(i,1,false);
      last[num]=i;
    }
    while(itr!=seg.end()&&itr->r<=i+1){
      ans[itr->index]=rsq.fold(itr->l,itr->r);
      itr++;
    }
  }

  rep(i,0,q)std::cout<<ans[i]<<"\n";
  
  return 0;
}

Compiler output:
a.cc:84:10: fatal error: ../../../lib/SegmentTree/SegmentTree.hpp: No such file or directory
   84 | #include "../../../lib/SegmentTree/SegmentTree.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.