Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

#include<climits>

#include<vector>

#include<iterator>

using namespace std;



void sortColumns(vector<vector<long long>>& matrix) {

    // Get the number of rows and columns

    long long  rows = matrix.size();

    long long cols = matrix[0].size();



    // Sort each column individually

    for (int j = 0; j < cols; ++j) {

        // Create a temporary vector to store the j-th column

        vector<int> temp;



        // Copy the j-th column into the temporary vector

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

            temp.push_back(matrix[i][j]);

        }



        // Sort the temporary vector in ascending order

        sort(temp.begin(), temp.end());



        // Copy the sorted values back to the j-th column of the matrix

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

            matrix[i][j] = temp[i];

        }

    }

}



int bs(vector<int> &b,int search)

{

    int n=b.size();

     long long l=0;

 long long h=n-1;

    while(l<=h)

    {

        int mid=(l+h)/2;

        if(b[mid]==search)

        return mid;

        else if(b[mid]>search)

        {

            h=mid-1;



        }

        else

        {

            l=mid+1;

        }

        

    }

}



bool compare(const vector<int>& a, const vector<int>& b) {

    return a.size() > b.size(); // Compare vectors by their lengths in decreasing order

}



bool asce(const vector<int>& a, const vector<int>& b) {

    return a.size() > b.size(); // Compare vectors by their lengths in decreasing order

}





bool fdiv(int i,int n)

{

    if(n%i==0 || (n%(n-i))==0)

    return true;

    else

    {

        return false;

    }

}



bool f(long long mid,vector<int> a,int n)

{

    long long cnt=0;

    int x=0;

    int end=n-1;

    for(int i=0;i<end;i++)

    {

        if(x>=a[end])

        {

            cnt++;

            x-=a[end];

            a[end]=0;

            end--;

        }

        

        if(a[i]>1)

        {

            cnt+=(a[i]/2);

            cnt+=1;

            a[i]=0;



        }

        else if(a[i]==1)

        {

            cnt++;

            x++;

            a[i]=0;



        }

    }

    if( a[end]>0 )

    {

        if(x>0)

        cnt++;

        a[end]-=x;

        // cnt++;

        if(a[end]>=1)

        {

            cnt+=(a[end]/2);

            cnt+=1;

            a[end]=0;



        }

        

    }

    if(cnt<=mid)

    return true;

    else

    return false;

}





bool isBitSet(int num, int bitPosition) {

    // Create a bit mask by shifting 1 to the left by bitPosition

    int mask = 1 << bitPosition;



    // Perform bitwise AND and check if the result is non-zero

    return (num & mask) != 0;

}

































long long f(int i,vector<int> &a,int n,vector<long long> &dp,long long &ans)

{

    if(i<0)

    {

        return 0;

    }

    // if(dp[i]!=-1)

    // return dp[i];

    long long pick=f(i-1,a,n,dp,ans);

    long long no=abs(a[i]+(pick));

    ans=max(ans,pick+a[i]);

    ans=max(ans,no);



    return dp[i]=(pick+a[i]);

}









void dfs(int i,map<int,vector<int>> &adj,vector<int> &vis,int c,int &ans)

{

    vis[i]=1;

    ans=max(ans,c);

    for(auto it:adj[c])

    {

        if(!vis[it])

        {

            dfs(it,adj,vis,c+1,ans);

        }

    }

}





bool f(long long n)

{

    while(n>0)

    {

        int r=n%10;

        if(r==7)

        return true;

        n=n/10;

    }

    return false;

}

int main() {

    int t;

    cin >> t;

    while (t--) 

    {

        

        int n,l,r;

        cin>>n>>l>>r;

        int k=r-l+1;

        vector<int> a(n);

        for(int i=0;i<n;i++)

        cin>>a[i];

        sort(a.begin(),a.end());

        int ans=0;

        for(int i=0;i<k;i++)

        {

            ans+=a[i];

        }

        cout<<ans<<endl;

        

        



       

    }

}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

#include<climits>

#include<vector>

#include<iterator>

using namespace std;



void sortColumns(vector<vector<long long>>& matrix) {

    // Get the number of rows and columns

    long long  rows = matrix.size();

    long long cols = matrix[0].size();



    // Sort each column individually

    for (int j = 0; j < cols; ++j) {

        // Create a temporary vector to store the j-th column

        vector<int> temp;



        // Copy the j-th column into the temporary vector

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

            temp.push_back(matrix[i][j]);

        }



        // Sort the temporary vector in ascending order

        sort(temp.begin(), temp.end());



        // Copy the sorted values back to the j-th column of the matrix

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

            matrix[i][j] = temp[i];

        }

    }

}



int bs(vector<int> &b,int search)

{

    int n=b.size();

     long long l=0;

 long long h=n-1;

    while(l<=h)

    {

        int mid=(l+h)/2;

        if(b[mid]==search)

        return mid;

        else if(b[mid]>search)

        {

            h=mid-1;



        }

        else

        {

            l=mid+1;

        }

        

    }

}



bool compare(const vector<int>& a, const vector<int>& b) {

    return a.size() > b.size(); // Compare vectors by their lengths in decreasing order

}



bool asce(const vector<int>& a, const vector<int>& b) {

    return a.size() > b.size(); // Compare vectors by their lengths in decreasing order

}





bool fdiv(int i,int n)

{

    if(n%i==0 || (n%(n-i))==0)

    return true;

    else

    {

        return false;

    }

}



bool f(long long mid,vector<int> a,int n)

{

    long long cnt=0;

    int x=0;

    int end=n-1;

    for(int i=0;i<end;i++)

    {

        if(x>=a[end])

        {

            cnt++;

            x-=a[end];

            a[end]=0;

            end--;

        }

        

        if(a[i]>1)

        {

            cnt+=(a[i]/2);

            cnt+=1;

            a[i]=0;



        }

        else if(a[i]==1)

        {

            cnt++;

            x++;

            a[i]=0;



        }

    }

    if( a[end]>0 )

    {

        if(x>0)

        cnt++;

        a[end]-=x;

        // cnt++;

        if(a[end]>=1)

        {

            cnt+=(a[end]/2);

            cnt+=1;

            a[end]=0;



        }

        

    }

    if(cnt<=mid)

    return true;

    else

    return false;

}





bool isBitSet(int num, int bitPosition) {

    // Create a bit mask by shifting 1 to the left by bitPosition

    int mask = 1 << bitPosition;



    // Perform bitwise AND and check if the result is non-zero

    return (num & mask) != 0;

}

































long long f(int i,vector<int> &a,int n,vector<long long> &dp,long long &ans)

{

    if(i<0)

    {

        return 0;

    }

    // if(dp[i]!=-1)

    // return dp[i];

    long long pick=f(i-1,a,n,dp,ans);

    long long no=abs(a[i]+(pick));

    ans=max(ans,pick+a[i]);

    ans=max(ans,no);



    return dp[i]=(pick+a[i]);

}









void dfs(int i,map<int,vector<int>> &adj,vector<int> &vis,int c,int &ans)

{

    vis[i]=1;

    ans=max(ans,c);

    for(auto it:adj[c])

    {

        if(!vis[it])

        {

            dfs(it,adj,vis,c+1,ans);

        }

    }

}





bool f(long long n)

{

    while(n>0)

    {

        int r=n%10;

        if(r==7)

        return true;

        n=n/10;

    }

    return false;

}

int main() {

    int t;

    cin >> t;

    while (t--) 

    {

        

        long long n,l,r;

        cin>>n>>l>>r;

        long long k=r-l+1;

        vector<long long> a(n);

        for(long long i=0;i<n;i++)

        cin>>a[i];

        sort(a.begin(),a.end());

        long long ans=0;

        for(int i=0;i<k;i++)

        {

            ans+=a[i];

        }

        cout<<ans<<endl;

        

        



       

    }

}