Queries to count array elements from a given range having a single set bit

#include
using namespace std;

bool check(int N)
{
    if (N == 0)
        return 0;
    return !(N & (N – 1));
}

void build_seg_tree(int ss, int se, int si,
                    int tree[], int arr[])
{
    
    if (ss == se) {

        
        tree[si] = check(arr[ss]);
        return;
    }

    
    int mid = (ss + se) / 2;

    
    build_seg_tree(ss, mid,
                   2 * si + 1, tree, arr);

    
    build_seg_tree(mid + 1, se,
                   2 * si + 2, tree, arr);

    
    tree[si] = tree[2 * si + 1]
               + tree[2 * si + 2];
}

void update(int ss, int se, int si,
            int X, int V, int tree[], int arr[])
{

    if (ss == se) {

        
        if (ss == X) {

            
            arr[X] = V;

            
            tree[si] = check(V);
        }
        return;
    }

    
    int mid = (ss + se) / 2;

    if (X se)
        return 0;

    
    
    if (l = se)
        return tree[si];

    
    int mid = (ss + se) / 2;

    
    
    return query(l, r, ss,
                 mid, 2 * si + 1, tree)
           + query(l, r, mid + 1,
                   se, 2 * si + 2, tree);
}

void Query(int arr[], int N,
           vector Q)
{
    
    int tree[4 * N] = { 0 };

    
    build_seg_tree(0, N – 1, 0, tree, arr);

    
    for (int i = 0; i < (int)Q.size(); i++) {         if (Q[i][0] == 1)             cout