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

#include <iostream>
#include <algorithm>
#include <cstdio>
#define f first
#define s second
 
using namespace std;
const int N=500009
pair <int, pair <int, int> > q[N];
int n, m, a[N], ans[N];
int st[5*N], used[5*N];
int cmp(pair <int, pair <int, int> > a, pair <int, pair <int, int> > b)
{
    if (a.s.f != b.s.f)
        return a.s.f < b.s.f;
    return a.f < b.f;
}
void update(int v, int l, int r, int x, int d)
{
    if (l == r)
    {
        st[v] = d;
        return;
    }
    int mid = (l + r) / 2;
    if (x <= mid)
        update(v * 2, l, mid, x, d);
    else
        update(v * 2 + 1, mid + 1, r, x, d);
    st[v] = st[v * 2] + st[v * 2 + 1];
}
int Find(int v, int A, int B, int l, int r)
{
    if (l > B || r < A)
        return 0;
    if (A == l && B == r)
        return st[v];
    int mid = (A + B) / 2;
    return Find(v * 2, A, mid, l, min(mid, r)) + Find(v * 2 + 1, mid + 1, B, max(mid + 1, l), r);
}
 
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    scanf("%d", &m);
    for (int i = 1; i <= m; i++)
        scanf("%d %d", &q[i].f, &q[i].s.f), q[i].s.s = i;
    sort(q + 1, q + m + 1, cmp);
    int j = 1;
    for (int i = 1; i <= m; i++)
    {
        while(j <= q[i].s.f)
        {
            if (!used[a[j]])
            {
                update(1, 1, n, j, 1);
                used[a[j]] = j;
            }
            else
            {
                update(1, 1, n, used[a[j]], 0);
                update(1, 1, n, j, 1);
                used[a[j]] = j;
            }
            j++;
        }
        ans[q[i].s.s] = Find(1, 1, n, q[i].f, q[i].s.f);
    }
    for (int i = 1; i <= m; i++)
        printf("%d\n", ans[i]);
 
    return 0;
}


Compiler output:
a.cc:9:1: error: expected ',' or ';' before 'pair'
    9 | pair <int, pair <int, int> > q[N];
      | ^~~~
a.cc: In function 'int main()':
a.cc:49:25: error: 'q' was not declared in this scope
   49 |         scanf("%d %d", &q[i].f, &q[i].s.f), q[i].s.s = i;
      |                         ^
a.cc:50:10: error: 'q' was not declared in this scope
   50 |     sort(q + 1, q + m + 1, cmp);
      |          ^
Language: C++

#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int c[500010],last[500010];
pair<int,int> p[500010];
int n,seg[1000010];
void update(int p,int val){
    for(seg[p += n] = val;p>1;p>>=1){
        seg[p>>1] = seg[p] + seg[p^1];
    }
}

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

int main(){
    int i,n,q; cin >> n >> q;
    for(i=0;i<n;i++){
        cin >> c[i]; c[i]--; last[i] = -1;
    }
    for(i=0;i<q;i++){
        int l,r; cin >> l >> r; l--; r--;
        p[i] = {r,l};
    }
    sort(p,p + q);
    int r = 0;
    for(i=0;i<q;i++){
        while(r<=q.first){
            if(l[c[i]]!=-1) update(l[c[i]],0);
            update(r,1);
            l[c[i]] = r;
            r++;
        }
        cout << query(q.second,q.first) << endl;
    }
}

Compiler output:
a.cc:14:1: error: 'll' does not name a type
   14 | ll query(int l,int r){
      | ^~
a.cc: In function 'int main()':
a.cc:35:20: error: request for member 'first' in 'q', which is of non-class type 'int'
   35 |         while(r<=q.first){
      |                    ^~~~~
a.cc:36:16: error: 'l' was not declared in this scope
   36 |             if(l[c[i]]!=-1) update(l[c[i]],0);
      |                ^
a.cc:38:13: error: 'l' was not declared in this scope
   38 |             l[c[i]] = r;
      |             ^
a.cc:41:25: error: request for member 'second' in 'q', which is of non-class type 'int'
   41 |         cout << query(q.second,q.first) << endl;
      |                         ^~~~~~
a.cc:41:34: error: request for member 'first' in 'q', which is of non-class type 'int'
   41 |         cout << query(q.second,q.first) << endl;
      |                                  ^~~~~
a.cc:41:17: error: 'query' was not declared in this scope
   41 |         cout << query(q.second,q.first) << endl;
      |                 ^~~~~
Language: C

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
typedef long long int LL;

struct node{
  int l;
  int r;
  int id;
}u[311111];

int z;
bool cool(node a,node b)
{
     if(a.l/z<b.l/z)
        return true;
     if(a.l/z>b.l/z)
        return false;
     return a.r<b.r;
}
 int cnt[1111111];
 int ans[311111];
 int v[311111];

int main()
{

     //ios_base:: sync_with_stdio(false); cin.tie(0);
      
   
    // freopen("input.in","r",stdin);
        
        int n;cin>>n;
        int q;cin>>q;
        int fuk=0;
        z=sqrt(n);
      //  vector<int>v(n);
        
        for(int i=0;i<n;i++)
                scanf("%d",&v[i]);
                    
        for(int i=0;i<q;i++)
        {
             int l,r;
             scanf("%d %d",&l,&r);
             node tmp;
             tmp.l=l-1;
             tmp.r=r-1;
             tmp.id=i;
             u[i]=tmp;
        }

         sort(u,u+q,cool);

         int st=0,e=0;fuk=1;cnt[v[0]]++;

        for(int i=0;i<q;i++)
        {
            int l=u[i].l;
            int r=u[i].r;
           // cout<<l<<" "<<r<<" "<<st<<" "<<e<<" "<<fuk<<endl;
            
            while(st<l)
            {
                cnt[v[st]]--;
                if(cnt[v[st]]==0)
                 fuk--;
                 st++;
            }
            while(st>l)
            {
                 st--;
                 cnt[v[st]]++;
                 if(cnt[v[st]]==1)
                 fuk++;
            }
            while(e<r)
            {
                e++;
                cnt[v[e]]++;
                if(cnt[v[e]]==1)
                fuk++;
            }
            while(e>r)
            {
               cnt[v[e]]--;
               if(cnt[v[e]]==0)
               fuk--;
               e--;
            }            
            ans[u[i].id]=fuk;
        }

        for(int i=0;i<q;i++)
            printf("%d\n",ans[i]);

     return 0;
}




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

#include <iostream>
#include <algorithm>
#include <cstdio>
#define f first
#define s second

using namespace std;

pair <int, pair <int, int> > q[200001];
int n, m, a[100001], ans[200001];
int st[5*100001], used[1000001];
int cmp(pair <int, pair <int, int> > a, pair <int, pair <int, int> > b)
{
    if (a.s.f != b.s.f)
        return a.s.f < b.s.f;
    return a.f < b.f;
}
void update(int v, int l, int r, int x, int d)
{
    if (l == r)
    {
        st[v] = d;
        return;
    }
    int mid = (l + r) / 2;
    if (x <= mid)
        update(v * 2, l, mid, x, d);
    else
        update(v * 2 + 1, mid + 1, r, x, d);
    st[v] = st[v * 2] + st[v * 2 + 1];
}
int Find(int v, int A, int B, int l, int r)
{
    if (l > B || r < A)
        return 0;
    if (A == l && B == r)
        return st[v];
    int mid = (A + B) / 2;
    return Find(v * 2, A, mid, l, min(mid, r)) + Find(v * 2 + 1, mid + 1, B, max(mid + 1, l), r);
}

int main()
{
    scanf("%d", &n);
    scanf("%d", &m);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    
    for (int i = 1; i <= m; i++)
        scanf("%d %d", &q[i].f, &q[i].s.f), q[i].s.s = i;
    sort(q + 1, q + m + 1, cmp);
    int j = 1;
    for (int i = 1; i <= m; i++)
    {
        while(j <= q[i].s.f)
        {
            if (!used[a[j]])
            {
                update(1, 1, n, j, 1);
                used[a[j]] = j;
            }
            else
            {
                update(1, 1, n, used[a[j]], 0);
                update(1, 1, n, j, 1);
                used[a[j]] = j;
            }
            j++;
        }
        ans[q[i].s.s] = Find(1, 1, n, q[i].f, q[i].s.f);
    }
    for (int i = 1; i <= m; i++)
        printf("%d\n", ans[i]);

    return 0;
}

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

#include<bits/stdc++.h>
#define ll  long long int
#define scll(x) scanf("%lld",&x)
using namespace std;
ll freq[100000000];
struct boo{
ll l;
ll r;
ll index;
ll result;
};
ll n;
bool comp(boo A,boo B)
{
    ll blocksize=(ll)sqrt(n*1.0);
    if(A.l/blocksize!=B.l/blocksize)
    return A.l/blocksize<B.l/blocksize
      else
        return A.r<B.r;
}
bool comp1(boo A,boo B)
{
    if(A.index<B.index)
        return true;
    else
        return false;
}
void query(ll a[],boo st[],ll siz)
{
   ll currL=0,i;
   ll currR=0;
   ll distinct=0;
   for(i=0;i<siz;i++){
        ll le=st[i].l;
        ll ri=st[i].r;
    while(currL<le)
    {
        freq[a[currL]]--;
        if(!freq[a[currL]])
            distinct--;
            currL++;
    }
    while(currL>le)
    {
        freq[a[currL-1]]++;
        if(freq[a[currL-1]]==1)
            distinct++;
             currL--;
    }
    while(currR<=ri)
    {
        freq[a[currR]]++;
        if(freq[a[currR]]==1)
            distinct++;
        currR++;
    }
    while(currR>ri+1)
    {
        freq[a[currR-1]]--;
        if(!freq[a[currR-1]])
            distinct--;
        currR--;
    }
    st[i].result=distinct;
}
}
int main()
{
    ll i=0,j,m;
    scll(n);
    scll(m);
    ll a[n];
      for(j=0;j<n;j++)
      {
          scll(a[j]);
      }
      //scll(m);
      ll l1,r1;
      struct boo st[m];
      for(i=0;i<m;i++){
          scll(l1);
          scll(r1);
          l1--;
          r1--;
          st[i].l=l1;
          st[i].r=r1;
          st[i].index=i;
      }
sort(st,st+m,comp);
query(a,st,m);
sort(st,st+m,comp1);
for(i=0;i<m;i++)
{
printf("%lld\n",st[i].result);
}
//for(j=0;j<i;j++)
    //cout<<st[j].l<<" "<<st[j].r<<"\n";
return 0;
}



Compiler output:
a.cc: In function 'bool comp(boo, boo)':
a.cc:17:39: error: expected ';' before 'else'
   17 |     return A.l/blocksize<B.l/blocksize
      |                                       ^
      |                                       ;
   18 |       else
      |       ~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){long n,s;cin>>n>>s;
vector<long>a(s);for(int i=0;i<n;i++){cin>>a.at(i);
for(int i=0;i<s;i++){long l,r,q=0;cin>>l>>r;
vector<int>p(n);
 for(long j=l-1;j<r;j++){if(p.at(j)==0){p.at(j)=1;q++;}}cout<<q<<endl;}}}}


Compiler output:
a.cc:7:74: error: expected declaration before '}' token
    7 |  for(long j=l-1;j<r;j++){if(p.at(j)==0){p.at(j)=1;q++;}}cout<<q<<endl;}}}}
      |                                                                          ^
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 [] in = new int [n];
        for(int i=0;i<a;i++){
                             in[i] = sc.nextInt();
                            }
        int [][] minmax = new int [n][2];       
		System.out.println(b);
	}
}


Compiler output:
Main.java:8: error: cannot find symbol
        for(int i=0;i<a;i++){
                      ^
  symbol:   variable a
  location: class Main
Main.java:12: error: cannot find symbol
		System.out.println(b);
		                   ^
  symbol:   variable b
  location: class Main
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef  int  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;
struct query{
    ll l,r,idx;
    bool operator< (const query &x ) const {
            if(l/BS != x.l/BS) return make_pair(l,r) < make_pair(x.l, x.r);
            return (l/BS & 1) ? (r < x.r) : (r > x.r);
        }
}qu[500005];
set<ll> se;
ll ans=0;
void add(ll num){
    se.insert(num);
    ans=se.size();
}
void remove(ll num){
    se.erase(se.find(num));
    ans=se.size();
}
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n,q;cin>>n>>q;
        // ll arr[n];
        BS=ceil(1.0*sqrt(n));ll arr[n],a,b;
        for(ll i=0;i<n;i++){
        cin>>arr[i];
        }
        for(ll i=0;i<q;i++){
            cin>>a>>b;
            qu[i].l=a-1;
            qu[i].r=b-1;
            qu[i].idx=i;
        }
        sort(qu,qu+n);
        // for(ll i=0;i<n;i++)
        // struct query
        ll left,right;
        ll mo_left = 0, mo_right = -1;
        ll anss[q];
        for(ll i=0;i<q;i++){
            left=qu[i].l;
            right=qu[i].r;
        while(mo_right < right) {
                    mo_right++;
                    mp[(arr[mo_right])]++;
                    if(mp[(arr[mo_right])]==1)
                    ans++;
                }
                while(mo_right > right) {

                    mp[(arr[mo_right])]--;
                    if(mp[(arr[mo_right])]==0)
                    ans--;
                    mo_right--;
                }
                while(mo_left < left) {
                    // remove(arr[mo_left]);
                    mp[(arr[mo_left])]++;
                    if(mp[(arr[mo_left])]==0)
                    ans--;
                    mo_left++;
                }
                while(mo_left > left) {
                    mo_left--;
                    mp[(arr[mo_left])]++;
                    if(mp[(arr[mo_left])]==1)
                    ans++;
                }
            anss[qu[i].idx]=ans;
        }
        for(ll i=0;i<q;i++)cout<<anss[i]<<endl;

}


Compiler output:
a.cc:4:8: warning: overflow in conversion from 'long int' to 'll' {aka 'int'} changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
    4 | ll inf=1000000000000000000,mod=1000000007,BS,k;
      |        ^~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:52:21: error: 'mp' was not declared in this scope
   52 |                     mp[(arr[mo_right])]++;
      |                     ^~
a.cc:58:21: error: 'mp' was not declared in this scope
   58 |                     mp[(arr[mo_right])]--;
      |                     ^~
a.cc:65:21: error: 'mp' was not declared in this scope
   65 |                     mp[(arr[mo_left])]++;
      |                     ^~
a.cc:72:21: error: 'mp' was not declared in this scope
   72 |                     mp[(arr[mo_left])]++;
      |                     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 300100;
const int M = MAXN * 100;
int n,q,tot;
int a[MAXN];
int T[M],lson[M],rson[M],c[M];
int build(int l,int r)
{
    int root = tot++;
    c[root] = 0;
    if(l != r)
    {
        int mid = (l+r)>>1;
        lson[root] = build(l,mid);
        rson[root] = build(mid+1,r);
    }
    return root;
}
int update(int root,int pos,int val)
{
    int newroot = tot++, tmp = newroot;
    c[newroot] = c[root] + val;
    int l = 1, r = n;
    while(l < r)
    {
        int mid = (l+r)>>1;
        if(pos <= mid)
        {
            lson[newroot] = tot++; rson[newroot] = rson[root];
            newroot = lson[newroot]; root = lson[root];
            r = mid;
        }
        else
        {
            rson[newroot] = tot++; lson[newroot] = lson[root];
            newroot = rson[newroot]; root = rson[root];
            l = mid+1;
        }
        c[newroot] = c[root] + val;
    }
    return tmp;
}
int query(int root,int pos)
{
    int ret = 0;
    int l = 1, r = n;
    while(pos < r)
    {
        int mid = (l+r)>>1;
        if(pos <= mid)
        {
            r = mid;
            root = lson[root];
        }
        else
        {
            ret += c[lson[root]];
            root = rson[root];
            l = mid+1;
        }
    }
    return ret + c[root];
}
int main()
{
    scanf("%d%d",&n,&q);
    
        tot = 0;
        for(int i = 1;i <= n;i++)
            scanf("%d",&a[i]);
        T[n+1] = build(1,n);//建立一颗空树
        map<int,int>mp;
        for(int i = n;i>= 1;i--)
        {
            if(mp.find(a[i]) == mp.end())
            {
                T[i] = update(T[i+1],i,1);
            }
            else
            {
                int tmp = update(T[i+1],mp[a[i]],-1);
                T[i] = update(tmp,i,1);
            }
            mp[a[i]] = i;
        } 
        while(q--)
        {
            int l,r;
            scanf("%d%d",&l,&r);
            printf("%d\n",query(T[l],r));
        }
    }
    return 0;
}

Compiler output:
a.cc:94:5: error: expected unqualified-id before 'return'
   94 |     return 0;
      |     ^~~~~~
a.cc:95:1: error: expected declaration before '}' token
   95 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

// Bit Indexed Tree
template <typename T>
struct BIT {
  std::vector<T> dat;

  BIT(int n) : dat(n + 1, 0) {}
  void init(int n) { dat.assign(n + 1, 0); }

  inline void add(int a, T x) {
    for (auto i = a; i < dat.size(); i += i & -i) {
      dat[i] += x;
    }
  }

  // partial sum of [1,to) (1-origin).
  inline T sum(int to) {
    T ret{0};
    for (auto i = to; i > 0; i -= i & -i) {
      ret += dat[i];
    }
    return ret;
  }

  // partial sum of [from,to) (1-origin).
  inline T sum(int from, int to) { return sum(to - 1) - sum(from - 1); }

  // find index at which a_1 + ... + a_i >= w
  int lower_bound(T w) {
    if (w <= 0) {
      return 0;
    } else {
      int x = 0, r = 1;
      while (r < dat.size()) r <<= 1;
      for (auto len = r; len; len >>= 1) {
        if(x+len < dat.size() && dat[x+len] < w) {
          w -= dat[x+len];
          x += len;
        }
      }
      return x + 1;
    }    
  }

  // print all 
  void print() {
    for (auto i = 1; i < dat.size(); ++i) {
      std::cout << (i == 1 ? "" : ", ") << sum(i, i + 1);
    }
    std::cout << std::endl;
  }
};


int main() {
  int N, Q, l, r;
  cin >> N >> Q;
  vector<int> c(N);
  for (int i = 0; i < N; i++) {
    cin >> c[i];
  }

  vector<pair<int,int>> q;
  vector<int> ans(Q), ind(Q);
  iota(begin(ind),end(ind),0);
  while (cin >> l >> r) q.emplace_back(l,r);
  sort(begin(ind),end(ind),
       [&q](int x, int y) {return q[x].second < q[y].second;});

  vector<int> last(N,0);
  int lastR{};
  BIT<int> b(N+1);
  for (int i = 0; i != Q; ++i) {
    int R = q[ind[i]].second;
    if (R > lastR) {
      for (int j = lastR; j < R; ++j) {
        if (last[c[j]]) b.add(last[c[j]],-1);
        last[c[j]] = j+1;
        b.add(last[c[j]],1);
      }
    }
    ans[ind[i]] = b.sum(q[ind[i]].first,q[ind[i]].second);
  }
  for (int x: ans) cout << x+1 << endl;
}


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

#include <iostream>
#include <vector>

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  int n, q;
  cin >> n >> q;
  
  int a[n];
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  bool b[n];
  for (int k = 0; k < n; k++) b[k] = false;
  
  int cnt;
  for (int i = 0, l, r; i < q; i++)
  {
    cnt = 0;
    cin >> l >> r;
    for (int j = l - 1; j < r; j++)
      b[a[j]-1] = true;
    
    for (int k = 0; k < n; k++)
      if (b[k]) cnt++, b[k] = false;
    
    cout << cnt << '\n';
  }
  
  return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: Java

     import java.util.*;
class Main{
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+1];
 
         for(int i=0;i<n+1;i++){
           
         arr[i]=sc.nextInt();
         }



 
 

 
   
         for(int i=0;i<q;i++){
 int l=sc.nextInt();
             int r=sc.nextInt();
   HashSet<Integer> m=new HashSet<>();
           for(int i=l;i<=r;i++){
m.add(arr[i])
           }
            System.out.println(m.size());
         }
  
}
    

Compiler output:
Main.java:26: error: ';' expected
m.add(arr[i])
             ^
Main.java:31: error: reached end of file while parsing
}
 ^
2 errors
Language: C++

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

typedef long long ll;
#define f(i,n) for(int i=0;i<n;i++)

int main()
{
    ll n,q;
    cin>>n>>q;
    ll c[n];
    for(ll i=0;i<n;i++)
    {
        cin>>c[i];
    }
    set<ll> difc;
    ll dif[n];
    for(ll i=0;i<n;i++)
    {
        difc.insert(c[i]);
        dif[i]=difc.size();
    }
    set<ll> difc1;
    ll dif1[n];
    for(ll i=n-1;i>=0;i--)
    {
        
            difc1.insert(c[i]);
        dif1[i]=difc1.size();
        
    }
    while(q--){
        ll l,r;
        cin>>l>>r;

        cout<<dif[r-1]-dif[l-1]+dif1[l-1]+dif1[r-1]<<endl;;
    }
    }
}

Compiler output:
a.cc:39:1: error: expected declaration before '}' token
   39 | }
      | ^
Language: C++

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

int main() {
int64_t n,q,iti,s,e,it;
cin>>n>>q;
int64_t a=(n+706)/707;
  vector<int64_t> yomi(n);
  for(int64_t i=0;i<n;i++){
  cin>>it;   
    yomi.at(it-1)++;
    }
 vector<vector<int64_t>> data(a, vector<int64_t>(n));  
  for(int64_t i=0;i<n;i++){
    iti=yomi.at(i);
   data.at(i/707).at(iti-1)++;
  }
  for(int64_t i=0;i<q;i++){
  cin>>s>>e;
    for(int64_t j=((s+706)/707);j<((e-706)/707)+1;j++){
    if(-1<j&&j<((n+706)/707)+1){
    vector<int64_t> vec(n);
      for(int64_t k=0;k<n;k++ ){
       vec.at(k)+=data.
      }
      
    }
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:7: error: expected unqualified-id before '}' token
   25 |       }
      |       ^
Language: C++

//author: hitch_hiker42;
#include<bits/stdc++.h>
using namespace std;
 
//solution:
#define int int64_t
#define block(i) i / B
constexpr int N = 100'000, B = 316, p = 31, mod = 1000'000'009;
int a[N]; int ans[N];
 
struct query {
    int s, lo, hi, idx;
    query() {}
    query(int lo, int hi, int idx): lo(lo), hi(hi), idx(idx) {}
    bool operator < (const query& q) {
        return block(lo) < block(q.lo) || (block(lo) == block(q.lo) and hi < q.hi);
    }
} q[N];
 
signed main() {
    int n, m; cin >> n >> m;
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < m; ++i) {
        cin >> q[i].lo >> q[i].hi >> q[i].s;
        q[i].lo--; q[i].hi--; q[i].idx = i;
    }
    sort(q, q + m);
    unordered_map<int, int> f;
    auto insert = [&](int i, int s) {
        f[a[i]]++;
    };
    auto remove = [&](int i, int s) {
        f[a[i]]--;
    };
    int l = 0, r = -1;
    for(int i = 0; i < m; ++i) {
        int lo = q[i].lo, hi = q[i].hi;
        int s = q[i].s;
        while(lo < l) insert(--l);
        while(r < hi) insert(++r);
        while(lo > l) remove(l++);
        while(r > hi) remove(r--);
        ans[q[i].idx] = f[s];
    }
    for(int i = 0; i < m; ++i) cout << ans[i] << "\n";
    return 0;
} //farewell, until we meet again..

Compiler output:
a.cc: In function 'int main()':
a.cc:39:29: error: no match for call to '(main()::<lambda(int64_t, int64_t)>) (int64_t&)'
   39 |         while(lo < l) insert(--l);
      |                       ~~~~~~^~~~~
a.cc:29:19: note: candidate: 'main()::<lambda(int64_t, int64_t)>'
   29 |     auto insert = [&](int i, int s) {
      |                   ^
a.cc:29:19: note:   candidate expects 2 arguments, 1 provided
a.cc:40:29: error: no match for call to '(main()::<lambda(int64_t, int64_t)>) (int64_t&)'
   40 |         while(r < hi) insert(++r);
      |                       ~~~~~~^~~~~
a.cc:29:19: note: candidate: 'main()::<lambda(int64_t, int64_t)>'
   29 |     auto insert = [&](int i, int s) {
      |                   ^
a.cc:29:19: note:   candidate expects 2 arguments, 1 provided
a.cc:41:29: error: no match for call to '(main()::<lambda(int64_t, int64_t)>) (int64_t)'
   41 |         while(lo > l) remove(l++);
      |                       ~~~~~~^~~~~
a.cc:32:19: note: candidate: 'main()::<lambda(int64_t, int64_t)>'
   32 |     auto remove = [&](int i, int s) {
      |                   ^
a.cc:32:19: note:   candidate expects 2 arguments, 1 provided
a.cc:42:29: error: no match for call to '(main()::<lambda(int64_t, int64_t)>) (int64_t)'
   42 |         while(r > hi) remove(r--);
      |                       ~~~~~~^~~~~
a.cc:32:19: note: candidate: 'main()::<lambda(int64_t, int64_t)>'
   32 |     auto remove = [&](int i, int s) {
      |                   ^
a.cc:32:19: note:   candidate expects 2 arguments, 1 provided
Language: C++

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

typedef long long ll;
#define f(i,n) for(int i=0;i<n;i++)

int main()
{
    ll n,q;
    cin>>n>>q;
    ll c[n];
    for(ll i=0;i<n;i++)
    {
        cin>>c[i];
    }
    set<ll> difc;
    ll dif[n];
    for(ll i=0;i<n;i++)
    {
        difc.insert(c[i]);
        dif[i]=difc.size();
    }
    set<ll> difc1;
    ll dif1[n];
    for(ll i=n-1;i>=0;i--)
    {
        
            difc1.insert(c[i]);
        dif1[i]=difc1.size();
        
    }
    while(q--){
        ll l,r;
        cin>>l>>r;

        cout<<dif[r-1]-dif[l-1]+dif1[l-1]+difc1[r-1]<<endl;;
    }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:48: error: no match for 'operator[]' (operand types are 'std::set<long long int>' and 'll' {aka 'long long int'})
   36 |         cout<<dif[r-1]-dif[l-1]+dif1[l-1]+difc1[r-1]<<endl;;
      |                                                ^
a.cc: At global scope:
a.cc:39:1: error: expected declaration before '}' token
   39 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using iset = unordered_set<int>;

int n, q; iset seg[1000001];

void merge(iset &s, int i) {
    for (auto c: seg[i])
        s.insert(c); }

void update(int i, int c) { 
    seg[i += n].insert(c);
    while (i > 1) 
	    i >>= 1, seg[i].insert(c); }

int query(int l, int r) { 
    iset s;
	for (l += n, r += n+1; l < r; l >>= 1, r >>= 1) { 
		if (l&1) 
		    merge(s,l++);  
		if (r&1) 
            merge(s,--r); }       
    return s.size(); } 

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cin >> n >> q; 
    for (int c, i = 0; i < n; ++i)
        cin >> c, upate(i,c);
    for (int l, r; q--; cout << query(l-1,r-1) << '\n')
        cin >> l >> r; }

 

Compiler output:
a.cc: In function 'int main()':
a.cc:28:19: error: 'upate' was not declared in this scope; did you mean 'update'?
   28 |         cin >> c, upate(i,c);
      |                   ^~~~~
      |                   update
Language: C++

// C++ implementation of above approach 
#include <bits/stdc++.h>
#define int long long 
using namespace std; 

// Each segment of the segment tree would be a set 
// to maintain distinct elements 
set<int>* segment; 

// Build the segment tree 
// i denotes current node, s denotes start and 
// e denotes the end of range for current node 

int segment[400050];
void build(int i, int s, int e, int arr[]) 
{ 

	// If start is equal to end then 
	// insert the array element 
	if (s == e) { 
		segment[i].insert(arr[s]); 
		return; 
	} 

	// Else divide the range into two halves 
	// (start to mid) and (mid+1 to end) 
	// first half will be the left node 
	// and the second half will be the right node 
	build(2 * i, s, (s + e) / 2, arr); 
	build(1 + 2 * i, 1 + (s + e) / 2, e, arr); 

	// Insert the sets of right and left 
	// node of the segment tree 
	segment[i].insert(segment[2 * i].begin(), 
					segment[2 * i].end()); 

	segment[i].insert(segment[2 * i + 1].begin(), 
					segment[2 * i + 1].end()); 
} 

// Query in an range a to b 
set<int> query(int node, int l, int r, int a, int b) 
{ 
	set<int> left, right, result; 

	// If the range is out of the bounds 
	// of this segment 
	if (b < l || a > r) 
		return result; 

	// If the range lies in this segment 
	if (a <= l && r <= b) 
		return segment[node]; 

	// Else query for the right and left 
	// leaf node of this subtree 
	// and insert them into the set 
	left = query(2 * node, l, (l + r) / 2, a, b); 
	result.insert(left.begin(), left.end()); 

	right = query(1 + 2 * node, 1 + (l + r) / 2, r, a, b); 
	result.insert(right.begin(), right.end()); 

	// Return the result 
	return result; 
} 

// Initialize the segment tree 

// Function to get the result for the 
// subarray from arr[l] to arr[r] 
void getDistinct(int l, int r, int n) 
{ 
	// Query for the range set 
	set<int> ans = query(1, 0, n - 1, l, r); 

	cout << ans.size() << endl; 
} 

// Driver code 
int32_t main() 
{ 

	int n,q;
	cin >> n >> q;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	//int arr[] = { 1, 1, 2, 1, 3 }; 
	//int n = sizeof(arr) / sizeof(arr[0]); 

	init(n); 

	// Bulid the segment tree 
	build(1, 0, n - 1, arr); 

	// Query in range 0 to 4
	while(q--)
	{ 
		int x,y;
		cin >> x >> y;
		x--;
		y--;
		getDistinct(x, y, n); 
	}
	return 0; 
} 


Compiler output:
a.cc:14:5: error: conflicting declaration 'long long int segment [400050]'
   14 | int segment[400050];
      |     ^~~~~~~
a.cc:8:11: note: previous declaration as 'std::set<long long int>* segment'
    8 | set<int>* segment;
      |           ^~~~~~~
a.cc: In function 'int32_t main()':
a.cc:94:9: error: 'init' was not declared in this scope; did you mean 'int'?
   94 |         init(n);
      |         ^~~~
      |         int
Language: C++

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


int main() {
    int N, Q;
    cin >> N >> Q;

    vector<int> c(N);
    for (int i = 0; i < N; i++) {
        cin >> c.at(i);
    }

    int l;
    int r;
    vector<vector<int>> d(Q, vector<int>(N));
    for (int i = 0; i < Q; i++) {
        cin >> l >> r;
        d.at(i) = vector(c.begin() + l - 1, c.begin() + r);
        sort(d.at(i).begin(), d.at(i).end());

    }

    for (int i = 0; i < Q; i++) {
        d.at(i).erase(unique(d.at(i).begin(), d.at(i).end(), d.at(i).end()));
        cout << d.at(i).size() << endl;
    }
}


Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Iterator2 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]':
/usr/include/c++/14/bits/stl_algo.h:869:20:   required from '_ForwardIterator std::__unique(_ForwardIterator, _ForwardIterator, _BinaryPredicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator<int*, vector<int> >; _BinaryPredicate = __gnu_cxx::__ops::_Iter_comp_iter<__gnu_cxx::__normal_iterator<int*, vector<int> > >]'
  869 |         if (!__binary_pred(__dest, __first))
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:933:27:   required from '_FIter std::unique(_FIter, _FIter, _BinaryPredicate) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >; _BinaryPredicate = __gnu_cxx::__normal_iterator<int*, vector<int> >]'
  933 |       return std::__unique(__first, __last,
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
  934 |                            __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:29:   required from here
   25 |         d.at(i).erase(unique(d.at(i).begin(), d.at(i).end(), d.at(i).end()));
      |                       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(__gnu_cxx::__normal_iterator<int*, std::vector<int> >) (int&, int&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int maxN = 500005;
int arr[maxN];
unordered_set<int> st[4 * maxN];
void build(int si, int ss, int se){
    if(ss == se){
        st[si].insert(arr[ss]);
        return;
    }
    int mid = (ss + se) / 2;
    build(2 * si, ss, mid);
    build(2 * si + 1, mid + 1, se);
    st[si].insert(st[2 * si].begin(), st[2 * si].end());
    st[si].insert(st[2 * si + 1].begin(), st[2 * si + 1].end());
}
// void update(int si, int ss, int se, int qi, int val){
//     if(ss == se){
//         st[si] = val;
//         arr[ss] = val;
//         return;
//     }
//     int mid = (ss + se) / 2;
//     if(qi <= mid) update(2 * si, ss, mid, qi, val);
//     else update(2 * si + 1, mid + 1, se, qi, val);
//     st[si] = merge(st[2 * si], st[2 * si + 1]);
// }
set<int> query(int si, int ss, int se, int qs, int qe){
    set<int> l, r, res;
    if(qs > se || qe < ss) return res;
    if(qs <= ss && qe >= se) return st[si];
    int mid = (ss + se) / 2;
    l = query(2 * si, ss, mid, qs, qe);
    r = query(2 * si + 1, mid + 1, se, qs, qe);
    res.insert(l.begin(), l.end());
    res.insert(r.begin(), r.end());
    return res;
}
int32_t main(){
    SPEED;
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> arr[i];
    build(1, 1, n);
    while(m--){
        int l, r;
        cin >> l >> r;
        unordered_set<int> ans = query(1, 1, n, l, r);
        cout << ans.size() << endl;
    }
}


Compiler output:
a.cc: In function 'std::set<long long int> query(long long int, long long int, long long int, long long int, long long int)':
a.cc:39:42: error: could not convert 'st[si]' from 'std::unordered_set<long long int>' to 'std::set<long long int>'
   39 |     if(qs <= ss && qe >= se) return st[si];
      |                                     ~~~~~^
      |                                          |
      |                                          std::unordered_set<long long int>
a.cc: In function 'int32_t main()':
a.cc:56:39: error: conversion from 'std::set<long long int>' to non-scalar type 'std::unordered_set<long long int>' requested
   56 |         unordered_set<int> ans = query(1, 1, n, l, r);
      |                                  ~~~~~^~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define int long long
using namespace std;

// Function to perform queries in a range 
long long query(int start, int end, int left, int right, 
                int node, long long seg[]) 
{ 
    // No overlap 
    if (end < left || start > right) { 
        return 0; 
    } 
  
    // Totainty Overlap 
    else if (start >= left && end <= right) { 
        return seg[node]; 
    } 
  
    // Parital Overlap 
    else { 
        int mid = (start + end) / 2; 
  
        // Finding the Answer 
        // for the left Child 
        long long leftChild = query(start, mid, left, 
                                    right, 2 * node, seg); 
  
        // Finding the Answer 
        // for the right Child 
        long long rightChild = query(mid + 1, end, left, 
                                     right, 2 * node + 1, seg); 
  
        // Combining the BitMasks 
        return (leftChild | rightChild); 
    } 
} 

// Building the Segment Tree 
void build(int left, int right, int node, int ar[], 
           long long seg[]) 
{ 
    if (left == right) { 
  
        // Building the Initial BitMask 
        seg[node] = (1int << ar[left]); 
  
        return; 
    } 
  
    int mid = (left + right) / 2; 
  
    // Building the left seg tree 
    build(left, mid, 2 * node, ar, seg); 
  
    // Building the right seg tree 
    build(mid + 1, right, 2 * node + 1, ar, seg); 
  
    // Forming the BitMask 
    seg[node] = (seg[2 * node] | seg[2 * node + 1]); 
} 

int a[500005];
int seg[2000005];
int main () {
    //clock_t start = clock();
    // ios_base::sync_with_stdio(false);
    // cin.tie(NUint);
    // cout.tie(NUint);
    int n, q;
    cin >> n >> q;
    memset (a,0,sizeof(a));
    memset (seg,0,sizeof(seg));
    for (int i=0;i<n;i++) {
        cin >> a[i];
    }
    build(0,n-1,1,a,seg);
    while (q--) {
        int x,y;
        cin >> x >> y;
        long long tempMask = query(0, n - 1, x - 1, y - 1, 1, seg); 
  
        int countOfBits = 0; 

        // Counting the set bits which denote the 
        // distinct elements 
        for (int i = 63; i >= 0; i--) { 

            if (tempMask & (1int << i)) { 

                countOfBits++; 
            } 
        } 

        cout << countOfBits << endl; 
    }
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void build(long long int, long long int, long long int, long long int*, long long int*)':
a.cc:52:22: error: unable to find numeric literal operator 'operator""int'
   52 |         seg[node] = (1int << ar[left]);
      |                      ^~~~
At global scope:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:95:29: error: unable to find numeric literal operator 'operator""int'
   95 |             if (tempMask & (1int << i)) {
      |                             ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){long n,s;cin>>n>>s;
vector<long>a(s);for(int i=0;i<n;i++){cin>>a.at(i);
for(int i=0;i<s;i++){long l,r,q=0;cin>>l>>r;
vector<int>p(n);
 for(long j=l-1;j<r;j++){if(p.at(j)==0){p.at(j)=1;q++;}}cout<<q<<endl;}}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:73: error: expected '}' at end of input
    7 |  for(long j=l-1;j<r;j++){if(p.at(j)==0){p.at(j)=1;q++;}}cout<<q<<endl;}}
      |                                                                         ^
a.cc:3:11: note: to match this '{'
    3 | int main(){long n,s;cin>>n>>s;
      |           ^
Language: C++

#include <bits/stdc++.h>

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
vector<int> ve(3006, 0);
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int n,q;
	cin>>n>>q;
	vector<int> v(n+1);
	vector<int> fromleft(n+2);
	set<int> left;
	set<int> right;
	vector<int> fromright(n+2);
	for(int i=1;i<=n;i++){
		cin>>v[i];
	}
	fromleft[0]=0;
	int t=0;
	for(int i=1;i<=n;i++){
		fromleft[i]=t;
		if(left.find(v[i])==left.end()){
			t+=1;

		}
		left.insert(v[i]);
	}
	
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<fromleft[r]-fromleft[l]<<"\n"
	}

}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:52: error: expected ';' before '}' token
   47 |                 cout<<fromleft[r]-fromleft[l]<<"\n"
      |                                                    ^
      |                                                    ;
   48 |         }
      |         ~
Language: C++

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


int main() {
    int N, Q;
    cin >> N >> Q;

    vector<int> c(N);
    for (int i = 0; i < N; i++) {
        cin >> c.at(i);
    }

    int l;
    int r;
    vector<vector<int>> d(Q, vector<int>(N));
    for (int i = 0; i < Q; i++) {
        cin >> l >> r;
        d.at(i) = vector(c.begin() + l - 1, c.begin() + r);
        sort(d.at(i).begin(), d.at(i).end());

    }

    for (int i = 0; i < Q; i++) {
        d.at(i).erase(unique(d.at(i).begin(), d.at(i).end(), d.at(i).end()));
        cout << d.at(i)..size() << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: expected unqualified-id before '.' token
   26 |         cout << d.at(i)..size() << endl;
      |                         ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Iterator2 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]':
/usr/include/c++/14/bits/stl_algo.h:869:20:   required from '_ForwardIterator std::__unique(_ForwardIterator, _ForwardIterator, _BinaryPredicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator<int*, vector<int> >; _BinaryPredicate = __gnu_cxx::__ops::_Iter_comp_iter<__gnu_cxx::__normal_iterator<int*, vector<int> > >]'
  869 |         if (!__binary_pred(__dest, __first))
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:933:27:   required from '_FIter std::unique(_FIter, _FIter, _BinaryPredicate) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >; _BinaryPredicate = __gnu_cxx::__normal_iterator<int*, vector<int> >]'
  933 |       return std::__unique(__first, __last,
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
  934 |                            __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:29:   required from here
   25 |         d.at(i).erase(unique(d.at(i).begin(), d.at(i).end(), d.at(i).end()));
      |                       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(__gnu_cxx::__normal_iterator<int*, std::vector<int> >) (int&, int&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

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

ll vecount(vector<ll> a){
    ll count=0;
    for(ll i:a)if(i)count++;
    return count;
}

ll vemin(vector<ll> a,vector<ll> b){
    ll count=0;
    for(ll i=0;i<a.size();i++){
        count+=(a.at(i)!=b.at(i));
    }
    return c;
}

int main() {
    ll N,Q;
    cin >> N >> Q;
    vector<ll> Color(N);
    vector<vector<ll>> Reco(1,vector<ll>(N,0));
    for(ll i=0;i<N;i++){
        ll sub1;
        cin >> sub1;
        Color[sub1-1]++;
        Reco.push_back(Color);
        
    }
    
    
    while(Q){
        ll sub1,sub2;
        cin >> sub1 >> sub2;
        
        cout << vemin(Reco[sub2], Reco[sub1-1]) << endl;
        
        
        Q--;
    }
    
    
    
}

Compiler output:
a.cc: In function 'll vemin(std::vector<long long int>, std::vector<long long int>)':
a.cc:16:12: error: 'c' was not declared in this scope
   16 |     return c;
      |            ^
Language: C++

// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
    
    int n,k;cin>>n>>k;
    std::vector<int> v;
    for(int i=0;i<n;i++) cin>>v[i];
	//int a[] = {1, 1, 2, 1, 3}; 
//	int n = sizeof(a)/sizeof(a[0]); 
	Query queries[k]; 
	 for(int i=0;i<k;i++){
	    cin>> queries[i].l >> queries[i].r; 
	    queries[i].idx = i; 
	 }
 
	
	int q = sizeof(queries)/sizeof(queries[0]); 
	sort(queries, queries+q, cmp); 
	answeringQueries(v, n, queries, k); 
	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:96:26: error: cannot convert 'std::vector<int>' to 'int*'
   96 |         answeringQueries(v, n, queries, k);
      |                          ^
      |                          |
      |                          std::vector<int>
a.cc:36:27: note:   initializing argument 1 of 'void answeringQueries(int*, int, Query*, int)'
   36 | void answeringQueries(int arr[], int n, Query queries[], int q)
      |                       ~~~~^~~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
const int N = 510010;
const int SN = 1 << 36;
int n;
int arr[N];
int rgt[N];
int lst[N];
int dif[N];
int q;
int l[N] , r[N];
vector < int > v[N];
int bit[N];
int ans[N];
void update(int idx , int val) {
    while (idx <= n) {
        bit[idx] += val;
        idx += idx & -idx;
    }
}
int query(int idx) {
    int res = 0;
    while (idx) {
        res += bit[idx];
        idx -= idx & -idx;
    }
    return res;
}
int segtree[SN];
void update(int l , int r , int node , int idx , int val) {
    if (l == r) {
        segtree[node] = val;
    }
    else {
        int mid = l + r >> 1;
        if (idx <= mid) {
            update(l , mid , node + node , idx , val);
        }
        else {
            update(mid + 1 , r , node + node + 1 , idx , val);
        }
        segtree[node] = max(segtree[node + node] , segtree[node + node + 1]);
    }
}

void update2(int idx , int val) {
    update(1 , n , 1 , idx , val);
}

int query(int l , int r , int node , int ql , int qr) {
    if (l > qr || r < ql) {
        return 0;
    }
    if (l >= ql && r <= qr) {
        return segtree[node];
    }
    int mid = l + r >> 1;
    return max(query(l , mid , node + node , ql , qr) , query(mid + 1 , r , node + node + 1 , ql , qr));
}

int query2(int idx) {
    return query(1 , n , 1 , 1 , idx);
}
int main() {
#ifndef ONLINE_JUDGE
    if (fopen("input.txt", "r"))
    {
        freopen ("input.txt" , "r" , stdin);
        freopen ("output.txt" , "w" , stdout);
    }
#endif
    scanf("%d" , &n);
    scanf("%d" , &q);
    for (int i = 1 ; i <= n ; ++i) {
        scanf("%d" , arr + i);
    }
    for (int i = n ; i >= 1 ; --i) {
        if (lst[arr[i]]) {
            if (dif[arr[i]]) {
                if (lst[arr[i]] - i != dif[arr[i]]) {
                    rgt[i] = lst[arr[i]] + dif[arr[i]] - 1;
                }
                else {
                    rgt[i] = rgt[lst[arr[i]]];
                }
            }
            else {
                rgt[i] = n;
            }
            dif[arr[i]] = lst[arr[i]] - i;
        }
        else {
            rgt[i] = n;
        }
        lst[arr[i]] = i;
    }

    for (int i = 1 ; i <= q ; ++i) {
        scanf("%d %d" , l + i , r + i);
        v[l[i]].emplace_back(i);
    }
    memset(lst , 0 , sizeof(lst));
    for (int i = n ; i >= 1 ; --i) {
        update(i , 1);
        update2(i , rgt[i]);
        if (lst[arr[i]]) {
            update(lst[arr[i]] , -1);
            update2(lst[arr[i]] , -1);
        }
        for (int que : v[i]) {
            int val = query2(r[que]);
            int ans = query(r[que]);
            if (val < r[que]) {
                ++ans;
            }
            ::ans[que] = ans;
        }
        lst[arr[i]] = i;
    }
    for (int i = 1 ; i <= q ; ++i) {
        printf("%d\n" , ans[i]);
    }
}


Compiler output:
a.cc:4:18: warning: left shift count >= width of type [-Wshift-count-overflow]
    4 | const int SN = 1 << 36;
      |                ~~^~~~~
a.cc:29:13: error: size of array 'segtree' is not an integral constant-expression
   29 | int segtree[SN];
      |             ^~