ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    //4 5 4 5 4 5 4 5
    //0 1 4 5 4 5 4 5
    //0 0 3 5 4 5 4 5
    //0  0 0 2 4 5 4 5
    // 0 0 0 0 2 5  4 5
    //0 0 0 0 0 3 4 5
    int n;
    cin>>n;
    vector<int>a(n+100);
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int>last(n+100);
    last[n]=true;
    for(int i=n-1;i>=1;i--)
    {
        if(a[i+1]>=a[i])
        {
            last[i]=true;
        }
        else 
        break;
    }
    int flag=false;
    for(int i=1;i<=n;i++)
    {
        if(last[i])
        {
            flag=true;
            break;
        }
        if(min(a[i],a[i+1])==0)
        {
            if((a[i]<=a[i+1]))
            {
                flag|=last[i+1];
            }
            break;
        }
        if(a[i]>a[i+1])
        {
            flag=false;
            break;
        }
        int t=min(a[i],a[i+1]);
        a[i]-=t;
        a[i+1]-=t;
    }
    if(flag)
    cout<<"YES\n";
    else cout<<"NO\n";
}
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("d.in","a+",stdin);
    #endif 
    int T;
    cin>>T;
    while(T--)solve();
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    //4 5 4 5 4 5 4 5
    //0 1 4 5 4 5 4 5
    //0 0 3 5 4 5 4 5
    //0  0 0 2 4 5 4 5
    // 0 0 0 0 2 5  4 5
    //0 0 0 0 0 3 4 5
    int n;
    cin>>n;
    vector<int>a(n+100);
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int>last(n+100);
    last[n]=true;
    for(int i=n-1;i>=1;i--)
    {
        if(a[i+1]>=a[i])
        {
            last[i]=true;
        }
        else 
        break;
    }
    int flag=true;
    int pre;
    for(int i=1;i<=n-1;i++)
    {

        
        if(a[i]<=a[i+1])
        {
            int t=min(a[i],a[i+1]);
            a[i]-=t;
            a[i+1]-=t;
        }
        else if(a[i]>a[i+1])
        {
            flag=false;
            break;
        }
        
    }
    if(flag)
    cout<<"YES\n";
    else cout<<"NO\n";
}
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("d.in","a+",stdin);
    #endif 
    int T;
    cin>>T;
    while(T--)solve();
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    //4 5 4 5 4 5 4 5
    //0 1 4 5 4 5 4 5
    //0 0 3 5 4 5 4 5
    //0  0 0 2 4 5 4 5
    // 0 0 0 0 2 5  4 5
    //0 0 0 0 0 3 4 5
    int n;
    cin>>n;
    vector<int>a(n+100);
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int>last(n+100);
    last[n]=true;
    for(int i=n-1;i>=1;i--)
    {
        if(a[i+1]>=a[i])
        {
            last[i]=true;
        }
        else 
        break;
    }
    int flag=false;
    for(int i=1;i<=n;i++)
    {
        if(last[i])
        {
            flag=true;
            break;
        }
        if(min(a[i],a[i+1])==0)
        {
            if((a[i]<=a[i+1]))
            {
                flag|=last[i+1];
            }
            break;
        }
        int t=min(a[i],a[i+1]);
        a[i]-=t;
        a[i+1]-=t;
    }
    if(flag)
    cout<<"YES\n";
    else cout<<"NO\n";
}
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("d.in","a+",stdin);
    #endif 
    int T;
    cin>>T;
    while(T--)solve();
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    //4 5 4 5 4 5 4 5
    //0 1 4 5 4 5 4 5
    //0 0 3 5 4 5 4 5
    //0  0 0 2 4 5 4 5
    // 0 0 0 0 2 5  4 5
    //0 0 0 0 0 3 4 5
    int n;
    cin>>n;
    vector<int>a(n+100);
    for(int i=1;i<=n;i++)cin>>a[i];
    vector<int>last(n+100);
    last[n]=true;
    for(int i=n-1;i>=1;i--)
    {
        if(a[i+1]>=a[i])
        {
            last[i]=true;
        }
        else 
        break;
    }
    int flag=false;
    for(int i=1;i<=n;i++)
    {
        if(last[i])
        {
            flag=true;
            break;
        }
        if(min(a[i],a[i+1])==0)
        {
            if((a[i]<=a[i+1]))
            {
                flag|=last[i+1];
            }
            break;
        }
        if(a[i]>a[i+1])
        {
            flag=false;
            break;
        }
        int t=min(a[i],a[i+1]);
        a[i]-=t;
        a[i+1]-=t;
    }
    if(flag)
    cout<<"YES\n";
    else cout<<"NO\n";
}
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("d.in","a+",stdin);
    #endif 
    int T;
    cin>>T;
    while(T--)solve();
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

void solve(){
    int n;
    cin >> n;
    long long a[n + 1];

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    if(n == 1)
        cout << a[1];
    else{
        long long m = 0;

        while(n > 1){
            long long sum = a[n];
            for(int i = 1; i < n; i++){
                sum += a[i];
                a[i] = a[i + 1] - a[i];
            }

            if(m < sum)
                m = sum;
            n--;
        }
        cout << max(m, abs(a[1]));
    }
    cout << '\n';
}

int main() {
    int t;
    cin >> t;

    while(t--){
        solve();
    }
    return 0;
}


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

void solve(){
    int n;
    cin >> n;
    long long a[n + 1];

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    if(n == 1)
        cout << a[1];
    else{
        long long m = 0;
        for(int i = 1; i <= n; i++)
            m += a[i];
        bool ok = false;
        while(n > 1){
            long long sum = a[n];
            for(int i = 1; i < n; i++){
                sum += a[i];
                a[i] = a[i + 1] - a[i];
            }

            if(m < sum || m < abs(a[1]))
                m = sum, ok = true;
            n--;
        }
        if(ok)
            cout << max(m, abs(a[1]));
        else cout << m;
    }
    cout << '\n';
}

int main() {
    int t;
    cin >> t;

    while(t--){
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

void solve(){
    int n;
    cin >> n;
    long long a[n + 1];

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    if(n == 1)
        cout << a[1];
    else{
        long long m = -1e18;
        bool ok = false;
        while(n > 1){
            long long sum = a[n];
            for(int i = 1; i < n; i++){
                sum += a[i];
                a[i] = a[i + 1] - a[i];
            }

            if(m < sum || m < abs(a[1]))
                m = sum, ok = true;
            n--;
        }
        if(ok)
            cout << max(m, abs(a[1]));
        else cout << m;
    }
    cout << '\n';
}

int main() {
    int t;
    cin >> t;

    while(t--){
        solve();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

void solve(){
    int n, aux;
    cin >> n;
    aux = n;
    long long a[n + 1];

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    if(n == 1)
        cout << a[1];
    else{
        long long m = -1e18;
        while(n > 1){
            long long sum = a[n];
            for(int i = 1; i < n; i++){
                sum += a[i];
                a[i] = a[i + 1] - a[i];
            }
            if(aux == n)
                m = max(m, sum);
            else m = max(m, abs(sum));
            n--;
        }
        m = max(m, abs(a[1]));
        cout << m;
    }
    cout << '\n';
}

int main() {
    int t;
    cin >> t;

    while(t--){
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

void solve(){
    int n;
    cin >> n;
    long long a[n + 1];

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    if(n == 1)
        cout << a[1];
    else{
        long long m = 0;

        while(n > 1){
            long long sum = a[n];
            for(int i = 1; i < n; i++){
                sum += a[i];
                a[i] = a[i + 1] - a[i];
            }

            if(m < sum)
                m = sum;
            n--;
        }
        cout << max(m, abs(a[1]));
    }
    cout << '\n';
}

int main() {
    int t;
    cin >> t;

    while(t--){
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

void solve(){
    int n;
    cin >> n;
    long long a[n + 1];

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    if(n == 1)
        cout << a[1];
    else{
        long long m = 0;
        for(int i = 1; i <= n; i++)
            m += a[i];
        bool ok = false;
        while(n > 1){
            long long sum = a[n];
            for(int i = 1; i < n; i++){
                sum += a[i];
                a[i] = a[i + 1] - a[i];
            }

            if(m < sum || m < abs(a[1]))
                m = sum, ok = true;
            n--;
        }
        if(ok)
            cout << max(m, abs(a[1]));
        else cout << m;
    }
    cout << '\n';
}

int main() {
    int t;
    cin >> t;

    while(t--){
        solve();
    }
    return 0;
}


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

void solve(){
    int n;
    cin >> n;
    long long a[n + 1];

    for(int i = 1; i <= n; i++)
        cin >> a[i];

    if(n == 1)
        cout << a[1];
    else{
        long long m = -1e18;
        bool ok = false;
        while(n > 1){
            long long sum = a[n];
            for(int i = 1; i < n; i++){
                sum += a[i];
                a[i] = a[i + 1] - a[i];
            }

            if(m < sum || m < abs(a[1]))
                m = sum, ok = true;
            n--;
        }
        if(ok)
            cout << max(m, abs(a[1]));
        else cout << m;
    }
    cout << '\n';
}

int main() {
    int t;
    cin >> t;

    while(t--){
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int,int>> ans;
    int an=0;
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        a[i]=j;
    }
    int back=0;
    unordered_set<int> bks;
    for(int i=n-1;i>0;i--){
        int l=a[i]+i-1-back;//going all the way left&back to pos
        an+=l;
        int cur=back+1;
        while(cur>0){
            if(bks.find(cur)==bks.end() && cur!=a[i]){
                ans.push_back(make_pair(a[i],cur));
                cur--;
            }else{
                cur--;
            }
        }
        cur=1;
        while(cur<=i+1){
            if(bks.find(cur)==bks.end()&&cur!=a[i]){
                ans.push_back(make_pair(cur,a[i]));
                cur++;
            }else{
                cur++;
            }
        }
        back++;
        bks.emplace(a[i]);
    }
    cout << an;
    cout << "\n";
    for(auto& [a,b]:ans){
        cout << a << " " << b << "\n";
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 9):
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int,int>> ans;
    int an=0;
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        a[i]=j;
    }
    int back=0;//inflation at back
    unordered_set<int> bks;
    for(int i=n-1;i>0;i--){
        if(bks.find(i+1)!=bks.end())back--;
        int l=a[i]+i-1-back;//going all the way left&back to pos
        an+=l;
        int cur=a[i]-1;
        while(cur>0){
            if(bks.find(cur)==bks.end() && cur!=a[i]){
                ans.push_back(make_pair(a[i],cur));
                cur--;
            }else{
                cur--;
            }
        }
        cur=1;
        while(cur<=n){
            if(bks.find(cur)==bks.end()&&cur!=a[i]){
                ans.push_back(make_pair(cur,a[i]));
                cur++;
            }else{
                cur++;
            }
        }
        if(a[i]<i+1)back++;
        bks.emplace(a[i]);
    }
    cout << an;
    cout << "\n";
    for(auto& [a,b]:ans){
        cout << a << " " << b << "\n";
    }
    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int,int>> ans;
    int an=0;
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        a[i]=j;
    }
    unordered_set<int> bks;
    for(int i=n-1;i>0;i--){
        int cur=a[i]-1;
        while(cur>0){
            if(bks.find(cur)==bks.end() && cur!=a[i]){
                ans.push_back(make_pair(a[i],cur));
                cur--;
            }else{
                cur--;
            }
        }
        cur=1;
        while(cur<=n){
            if(bks.find(cur)==bks.end()&&cur!=a[i]){
                ans.push_back(make_pair(cur,a[i]));
                cur++;
            }else{
                cur++;
            }
        }
        bks.emplace(a[i]);
    }
    cout << ans.size();
    cout << "\n";
    for(auto& [a,b]:ans){
        cout << a << " " << b << "\n";
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 4):
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int,int>> ans;
    int an=0;
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        a[i]=j;
    }
    int back=0;
    unordered_set<int> bks;
    for(int i=n-1;i>0;i--){
        int l=a[i]+i-1-back;//going all the way left&back to pos
        an+=l;
        int cur=back+1;
        while(cur>0){
            if(bks.find(cur)==bks.end() && cur!=a[i]){
                ans.push_back(make_pair(a[i],cur));
                cur--;
            }else{
                cur--;
            }
        }
        cur=1;
        while(cur<=i+1){
            if(bks.find(cur)==bks.end()&&cur!=a[i]){
                ans.push_back(make_pair(cur,a[i]));
                cur++;
            }else{
                cur++;
            }
        }
        back++;
        bks.emplace(a[i]);
    }
    cout << an;
    cout << "\n";
    for(auto& [a,b]:ans){
        cout << a << " " << b << "\n";
    }
    return 0;
}


Submission (verdict: Wrong answer on test 5):
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int,int>> ans;
    int an=0;
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        a[i]=j;
    }
    int back=0;//inflation at back
    unordered_set<int> bks;
    for(int i=n-1;i>0;i--){
        if(bks.find(i+1)!=bks.end())back--;
        int l=a[i]+i-1-back;//going all the way left&back to pos
        an+=l;
        int cur=a[i]-1;
        while(cur>0){
            if(bks.find(cur)==bks.end() && cur!=a[i]){
                ans.push_back(make_pair(a[i],cur));
                cur--;
            }else{
                cur--;
            }
        }
        cur=1;
        while(cur<=i+1){
            if(bks.find(cur)==bks.end()&&cur!=a[i]){
                ans.push_back(make_pair(cur,a[i]));
                cur++;
            }else{
                cur++;
            }
        }
        if(a[i]<i+1)back++;
        bks.emplace(a[i]);
    }
    cout << an;
    cout << "\n";
    for(auto& [a,b]:ans){
        cout << a << " " << b << "\n";
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int,int>> ans;
    int an=0;
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        a[i]=j;
    }
    int back=0;//inflation at back
    unordered_set<int> bks;
    for(int i=n-1;i>0;i--){
        if(bks.find(i+1)!=bks.end())back--;
        int l=a[i]+i-1-back;//going all the way left&back to pos
        an+=l;
        int cur=a[i]-1;
        while(cur>0){
            if(bks.find(cur)==bks.end() && cur!=a[i]){
                ans.push_back(make_pair(a[i],cur));
                cur--;
            }else{
                cur--;
            }
        }
        cur=1;
        while(cur<=i+1){
            if(bks.find(cur)==bks.end()&&cur!=a[i]){
                ans.push_back(make_pair(cur,a[i]));
                cur++;
            }else{
                cur++;
            }
        }
        if(a[i]<i+1)back++;
        bks.emplace(a[i]);
    }
    cout << an;
    cout << "\n";
    for(auto& [a,b]:ans){
        cout << a << " " << b << "\n";
    }
    return 0;
}


Submission (verdict: Wrong answer on test 9):
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<pair<int,int>> ans;
    int an=0;
    for(int i=0;i<n;i++){
        int j;
        cin >> j;
        a[i]=j;
    }
    int back=0;//inflation at back
    unordered_set<int> bks;
    for(int i=n-1;i>0;i--){
        if(bks.find(i+1)!=bks.end())back--;
        int l=a[i]+i-1-back;//going all the way left&back to pos
        an+=l;
        int cur=a[i]-1;
        while(cur>0){
            if(bks.find(cur)==bks.end() && cur!=a[i]){
                ans.push_back(make_pair(a[i],cur));
                cur--;
            }else{
                cur--;
            }
        }
        cur=1;
        while(cur<=n){
            if(bks.find(cur)==bks.end()&&cur!=a[i]){
                ans.push_back(make_pair(cur,a[i]));
                cur++;
            }else{
                cur++;
            }
        }
        if(a[i]<i+1)back++;
        bks.emplace(a[i]);
    }
    cout << an;
    cout << "\n";
    for(auto& [a,b]:ans){
        cout << a << " " << b << "\n";
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
using ll=long long;

int main(){
    ios::sync_with_stdio(false);
	cin.tie(nullptr);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n+1,0);
        vector<vector<int>> adj(n+1);
        ll mx=0,cur=0;
        for(int i=1;i<n;i++){
            int u,v;
            cin >> u >> v;
            a[u]++;
            a[v]++;
            if(a[u]>cur)cur=a[u],mx=u;
            if(a[v]>cur)cur=a[v],mx=v;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        ll ans=a[mx];
        a[mx]=-1;
        for(auto& vert:adj[mx]){
            a[vert]--;
        }
        mx=0,cur=0;
        for(int i=0;i<n+1;i++){
            if(a[i]>cur)cur=a[i],mx=i;
            
        }
        ans+=cur-1;
        cout << ans << "\n";
    }
}



Submission (verdict: Wrong answer on test 26):
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
using ll=long long;

int main(){
    ios::sync_with_stdio(false);
	cin.tie(nullptr);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n+1,0);
        vector<vector<int>> adj(n+1);
        ll mx=0,cur=0;
        
        vector<int> pos;
        for(int i=1;i<n;i++){
            int u,v;
            cin >> u >> v;
            a[u]++;
            a[v]++;
            if(a[u]>cur){
                cur=a[u],mx=u;
                pos.clear();
                pos.push_back(u);
            }else if(a[u]==cur){
                pos.push_back(u);
            }
            if(a[v]>cur){
                cur=a[v],mx=v;
                pos.clear();
                pos.push_back(v);
            }else if(a[v]==cur){
                pos.push_back(v);
            }
            adj[u].push_back(v);
            adj[v].push_back(u);
        }

        ll ans=a[mx];
        vector<int> singles(pos.size(),0);
        for(int i=0;i<pos.size();i++){
            for(auto& ver:adj[pos[i]]){
                if(a[ver]==1) singles[i]++;
            }
        }
        int most=-1;
        for(int i=0;i<pos.size();i++){
            if(singles[i]>most) mx=pos[i],most=singles[i];
        }
        a[mx]=0;
        for(auto& vert:adj[mx]){
            a[vert]--;
        }
        mx=0,cur=0;
        for(int i=0;i<n+1;i++){
            if(a[i]>cur){
                cur=a[i],mx=i;
            }
        }
        ans+=cur-1;
        cout << ans << "\n";
    }
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
using ll=long long;

int main(){
    ios::sync_with_stdio(false);
	cin.tie(nullptr);
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n+1,0);
        vector<vector<int>> adj(n+1);
        ll mx=0,cur=0;
        for(int i=1;i<n;i++){
            int u,v;
            cin >> u >> v;
            a[u]++;
            a[v]++;
            if(a[u]>cur)cur=a[u],mx=u;
            if(a[v]>cur)cur=a[v],mx=v;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        ll ans=a[mx];
        a[mx]=-1;
        for(auto& vert:adj[mx]){
            a[vert]--;
        }
        mx=0,cur=0;
        for(int i=0;i<n+1;i++){
            if(a[i]>cur)cur=a[i],mx=i;
            
        }
        ans+=cur-1;
        cout << ans << "\n";
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;

int main()

{

    int t;

    cin>>t;

    while(t--)

    {

        int n,l,r;

        cin>>n>>l>>r;

        int count=r-l+1;

        vector<int>v(n);

        for(auto &i:v)

            cin>>i;

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

        int sum=0;

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

            sum+=v[i];

        cout<<sum<<"\n";

    }

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

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

using namespace std;

int main()

{

    int t;

    cin>>t;

    while(t--)

    {

        int n,l,r;

        cin>>n>>l>>r;

        int count=r-l+1;

        vector<int>v(n);

        for(auto &i:v)

            cin>>i;

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

        int sum=0;

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

            sum+=v[i];

        cout<<sum<<"\n";

    }

}





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

using namespace std;

int main()

{

    int t;

    cin>>t;

    while(t--)

    {

        int n,l,r;

        cin>>n>>l>>r;

        vector<int>v(n);

        for(auto &i:v)

            cin>>i;

        sort(v.begin(),v.begin()+l-1);

        sort(v.begin()+l-1,v.begin()+r);

        sort(v.begin()+r,v.end());

        // for(auto ele:v)

        //     cout<<ele<<" ";

        // cout<<"\n";

        int sum=accumulate(v.begin()+l-1,v.begin()+r,0);

        int i=0,j=r-1,sum1=sum;

        while(v[i]<=v[j] and i<l-1 and j>=l-1)

        {

            sum1-=v[j];

            sum1+=v[i];

            i++;

            j--;

        }

        i=r-1,j=r;

        while(v[i]>=v[j] and i>=l-1 and j<n)

        {

            sum-=v[i];

            sum+=v[j];

            i--;

            j++;

        }

        cout<<min(sum1,sum)<<"\n";

    }

}