Language: C++

/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=2000000+6;
#define M_PI           3.14159265358979323846



// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
// int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
// int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
// int x2[]={-2,-2,-1,-1,+1,+1,+2,+2};
// int y2[]={-1,+1,-2,+2,-2,+2,-1,+1};
ll n,q;
vector< int > v;
set< int > stree[N];
void build(int node,int l,int r)
{
    if(l==r)
    {
      stree[node].insert(v[l]);
    }
    else
    {
      int mid=(l+r)/2;
      build(node*2,l,mid);
      build(node*2+1,mid+1,r);
      stree[node].insert(stree[node*2].begin(),stree[node*2].end());
      stree[node].insert(stree[node*2+1].begin(),stree[node*2+1].end());
    }
    
}
set<int>  query(int node,int s,int e,int l,int r)
{
    if(r<s or e<l)
    return;
    else if(l<=s and e<=r)
    {
      return stree[node];
    }
    else
    {
      int mid=(s+e)/2;
      
      set<int> left=query(node*2,s,mid,l,r);
      set<int> right=query(node*2+1,mid+1,e,l,r);
      set<int > result;
      result.insert(left.begin(),left.end());
      result.insert(right.begin(),right.end());
      return result;
    }
    
}
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    cin>>n>>q;
    v.resize(n+5);
    f(i,1,n+1)
    {
      cin>>v[i];
    }
       build(1,1,n);

   while(q--)
   {
     ll l,r;cin>>l>>r;
    
     set<int > ss=query(1,1,n,l,r);
     cout<<ss.size()<<endl;
   }

        
} 


Compiler output:
a.cc: In function 'std::set<int> query(int, int, int, int, int)':
a.cc:93:5: error: return-statement with no value, in function returning 'std::set<int>' [-fpermissive]
   93 |     return;
      |     ^~~~~~