ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
//im in the dark here;

int dx[]{0, 1, 0, -1, 1, 1, -1, -1};
int dy[]{1, 0, -1, 0, 1, -1, -1, 1};

const int N = 2e5 + 5, M = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int i = s.size() - 1;
    while(i) {
        bool alt = 1;
        for (int j = i; j > 0; --j) {
            if (s[j] - 1 > s[j - 1]) {
                alt = 0;
                s[j] -= 1;
                swap(s[j], s[j - 1]);
            }
            else {
                break;
            }
        }
        if (alt) {
            i--;
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
    cin >> t;

    FOR (i, 1, t + 1) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
//im in the dark here;

int dx[]{0, 1, 0, -1, 1, 1, -1, -1};
int dy[]{1, 0, -1, 0, 1, -1, -1, 1};

const int N = 2e5 + 5, M = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    for (int l = 0; l < 10; ++l) {
        int i = s.size() - 1;
        while (i) {
            bool alt = 1;
            for (int j = i; j > 0; --j) {
                if (s[j] - 1 > s[j - 1]) {
                    alt = 0;
                    s[j] -= 1;
                    swap(s[j], s[j - 1]);
                } else {
                    break;
                }
            }
            if (alt) {
                i--;
            }
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
    cin >> t;

    FOR (i, 1, t + 1) {
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
//im in the dark here;

int dx[]{0, 1, 0, -1, 1, 1, -1, -1};
int dy[]{1, 0, -1, 0, 1, -1, -1, 1};

const int N = 2e5 + 5, M = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int i = 1;
    while (i < s.size()) {
        bool alt = 1;
        for (int j = i; j > 0; --j) {
            if (s[j] - 1 > s[j - 1]) {
                alt = 0;
                s[j] -= 1;
                swap(s[j], s[j - 1]);
            } else {
                break;
            }
        }
        i++;
    }

    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
    cin >> t;

    FOR (i, 1, t + 1) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
//im in the dark here;

int dx[]{0, 1, 0, -1, 1, 1, -1, -1};
int dy[]{1, 0, -1, 0, 1, -1, -1, 1};

const int N = 2e5 + 5, M = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int i = s.size() - 1;
    while(i) {
        bool alt = 1;
        for (int j = i; j > max(0, i - (s[j] - 1 - '0')); --j) {
            if (s[j] - 1 > s[j - 1]) {
                alt = 0;
                s[j] -= 1;
                swap(s[j], s[j - 1]);
            }
        }
        if (alt) {
            i--;
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
    cin >> t;

    FOR (i, 1, t + 1) {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
//im in the dark here;

int dx[]{0, 1, 0, -1, 1, 1, -1, -1};
int dy[]{1, 0, -1, 0, 1, -1, -1, 1};

const int N = 2e5 + 5, M = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int i = s.size() - 1;
    while(i) {
        bool alt = 1;
        for (int j = i; j > max(0, (i - s[j] - '0')); --j) {
            if (s[j] - 1 > s[j - 1]) {
                alt = 0;
                s[j] -= 1;
                swap(s[j], s[j - 1]);
            }
        }
        if (alt) {
            i--;
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
    cin >> t;

    FOR (i, 1, t + 1) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
//im in the dark here;

int dx[]{0, 1, 0, -1, 1, 1, -1, -1};
int dy[]{1, 0, -1, 0, 1, -1, -1, 1};

const int N = 2e5 + 5, M = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int i = s.size() - 1;
    while(i) {
        bool alt = 1;
        for (int j = i; j > max(0, (i - s[j] - '0')); --j) {
            if (s[j] - 1 > s[j - 1]) {
                alt = 0;
                s[j] -= 1;
                swap(s[j], s[j - 1]);
            }
        }
        if (alt) {
            i--;
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
    cin >> t;

    FOR (i, 1, t + 1) {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
//im in the dark here;

int dx[]{0, 1, 0, -1, 1, 1, -1, -1};
int dy[]{1, 0, -1, 0, 1, -1, -1, 1};

const int N = 2e5 + 5, M = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    for (int l = 0; l < 10; ++l) {
        int i = s.size() - 1;
        while (i) {
            bool alt = 1;
            for (int j = i; j > 0; --j) {
                if (s[j] - 1 > s[j - 1]) {
                    alt = 0;
                    s[j] -= 1;
                    swap(s[j], s[j - 1]);
                } else {
                    break;
                }
            }
            if (alt) {
                i--;
            }
        }
    }
    cout << s << '\n';
}

int main() {
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt","w", stdout);
#endif

    int t = 1;
    cin >> t;

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


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <deque>
#include <iterator>
#include <queue>
using namespace std;
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

//g++ -o junior junior.cpp -g
typedef set<int>::iterator Iterator;
void solve()
{
    int size;
    std::cin>>size;
    int arr[size];
    for (int i = 0; i < size; i++)
    {
        std::cin>>arr[i];
    }
    ///
    if(size==1){
        std::cout<<arr[0];
        return;
    }
    int sumOver=0;
    while (size!=1)
    {
        size--;
        int sumInner=0;
        for (int i = 0; i < size; i++)
        {
            sumInner+=arr[i];
            arr[i]=arr[i+1]-arr[i];
        }
        sumInner+=arr[size];
        if(sumInner>sumOver)
            sumOver=sumInner;
    }
    std::cout<<max(abs(sumOver),abs(arr[0]));
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
int main()
{
    Fast;
    int test;
    std::cin>>test;    
    while (test--)
    {
        solve();
        std::cout<<endl;   
    } 
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <deque>
#include <iterator>
#include <queue>
using namespace std;
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

//g++ -o junior junior.cpp -g
typedef set<int>::iterator Iterator;
void solve()
{
    int size;
    std::cin>>size;
    int arr[size];
    for (int i = 0; i < size; i++)
    {
        std::cin>>arr[i];
    }
    ///
    if(size==1){
        std::cout<<arr[0];
        return;
    }
    int sumOver=0;
    while (size!=1)
    {
        size--;
        int sumInner=0;
        for (int i = 0; i < size; i++)
        {
            sumInner+=arr[i];
            arr[i]=arr[i+1]-arr[i];
        }
        sumInner+=arr[size];
        sumInner=abs(sumInner);
        if(sumInner>sumOver)
            sumOver=sumInner;
    }
    std::cout<<max(abs(sumOver),abs(arr[0]));
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
int main()
{
    Fast;
    int test;
    std::cin>>test;    
    while (test--)
    {
        solve();
        std::cout<<endl;   
    } 
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <deque>
#include <iterator>
#include <queue>
using namespace std;
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

//g++ -o junior junior.cpp -g
typedef set<int>::iterator Iterator;
void solve()
{
    int size;
    std::cin>>size;
    long long arr[size];
    for (int i = 0; i < size; i++)
    {
        std::cin>>arr[i];
    }
    ///
    if(size==1){
        std::cout<<arr[0];
        return;
    }
    long long sumOver=0;
    while (size!=1)
    {
        size--;
        long long sumInner=0;
        for (int i = 0; i < size; i++)
        {
            sumInner+=arr[i];
            arr[i]=arr[i+1]-arr[i];
        }
        sumInner+=arr[size];
        //sumInner=abs(sumInner);
        if(sumInner>sumOver)
            sumOver=sumInner;
    }
    std::cout<<max(abs(sumOver),abs(arr[0]));
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
int main()
{
    Fast;
    int test;
    std::cin>>test;    
    while (test--)
    {
        solve();
        std::cout<<endl;   
    } 
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <deque>
#include <iterator>
#include <queue>
using namespace std;
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

//g++ -o junior junior.cpp -g
typedef set<int>::iterator Iterator;
void solve()
{
    int size;
    std::cin>>size;
    long long arr[size];
    for (int i = 0; i < size; i++)
    {
        std::cin>>arr[i];
    }
    ///
    if(size==1){
        std::cout<<arr[0];
        return;
    }
    long long sumOver=0;
    while (size!=1)
    {
        size--;
        long long sumInner=0;
        for (int i = 0; i < size; i++)
        {
            sumInner+=arr[i];
            arr[i]=arr[i+1]-arr[i];
        }
        sumInner+=arr[size];
        //sumInner=abs(sumInner);
        if(sumInner>sumOver)
            sumOver=sumInner;
    }
    std::cout<<max(abs(sumOver),abs(arr[0]));
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
int main()
{
    Fast;
    int test;
    std::cin>>test;    
    while (test--)
    {
        solve();
        std::cout<<endl;   
    } 
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <deque>
#include <iterator>
#include <queue>
using namespace std;
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

//g++ -o junior junior.cpp -g
typedef set<int>::iterator Iterator;
void solve()
{
    int size;
    std::cin>>size;
    long long arr[size];
    for (int i = 0; i < size; i++)
    {
        std::cin>>arr[i];
    }
    ///
    long long ans = 0;
    for (int i = 0; i < size; i++)
    {
        ans+=arr[i]; //init ans
    }
    
    while (size != 1)
    {
        long long sum=0;
        for (int i = 0; i < size-1; i++)
        {
            arr[i] = arr[i+1] - arr[i];
            sum+=arr[i];
        }
        sum=abs(sum);
        ans = max(sum,ans);
        size--;
    }
    std::cout<<ans;
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
int main()
{
    Fast;
    int test;
    std::cin>>test;    
    while (test--)
    {
        solve();
        std::cout<<endl;   
    } 
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <deque>
#include <iterator>
#include <queue>
using namespace std;
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

//g++ -o junior junior.cpp -g
typedef set<int>::iterator Iterator;
void solve()
{
    int size;
    std::cin>>size;
    int arr[size];
    for (int i = 0; i < size; i++)
    {
        std::cin>>arr[i];
    }
    ///
    if(size==1){
        std::cout<<arr[0];
        return;
    }
    int sumOver=0;
    while (size!=1)
    {
        size--;
        int sumInner=0;
        for (int i = 0; i < size; i++)
        {
            sumInner+=arr[i];
            arr[i]=arr[i+1]-arr[i];
        }
        sumInner+=arr[size];
        if(sumInner>sumOver)
            sumOver=sumInner;
    }
    std::cout<<max(abs(sumOver),abs(arr[0]));
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
int main()
{
    Fast;
    int test;
    std::cin>>test;    
    while (test--)
    {
        solve();
        std::cout<<endl;   
    } 
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <stack>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <deque>
#include <iterator>
#include <queue>
using namespace std;
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'

//g++ -o junior junior.cpp -g
typedef set<int>::iterator Iterator;
void solve()
{
    int size;
    std::cin>>size;
    int arr[size];
    for (int i = 0; i < size; i++)
    {
        std::cin>>arr[i];
    }
    ///
    if(size==1){
        std::cout<<arr[0];
        return;
    }
    int sumOver=0;
    while (size!=1)
    {
        size--;
        int sumInner=0;
        for (int i = 0; i < size; i++)
        {
            sumInner+=arr[i];
            arr[i]=arr[i+1]-arr[i];
        }
        sumInner+=arr[size];
        sumInner=abs(sumInner);
        if(sumInner>sumOver)
            sumOver=sumInner;
    }
    std::cout<<max(abs(sumOver),abs(arr[0]));
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
int main()
{
    Fast;
    int test;
    std::cin>>test;    
    while (test--)
    {
        solve();
        std::cout<<endl;   
    } 
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: Java 8


Submission (verdict: Runtime error on test 1):
import java.util.*;
public class number{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            int two=0;
            int three=0;
            int temp=n;
            while(temp>0){
                int rem=temp%10;
                if(rem==2)two++;
                if(rem==3)three++;
                temp=temp/10;
            }
            int twolimit=Math.min(8,two+1);
            int threelimit=Math.min(8,three+1);
            boolean flag=false;
            for(int i=0; i<=twolimit; i++){
                for(int j=0; j<=threelimit; j++){
                    if(((i*2 + j*6)%9)==0){
                        flag=true;
                        break;
                    }
                }
            }
            if(flag) System.out.println("YES");
            else {System.out.println("NO");}
        }
    }
}
Problem: 2050C - Uninteresting Number
Language: Java 8

Previous submission (verdict: Runtime error on test 1):
import java.util.*;
public class number{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            int two=0;
            int three=0;
            int temp=n;
            while(temp>0){
                int rem=temp%10;
                if(rem==2)two++;
                if(rem==3)three++;
                temp=temp/10;
            }
            int twolimit=Math.min(8,two+1);
            int threelimit=Math.min(8,three+1);
            boolean flag=false;
            for(int i=0; i<=twolimit; i++){
                for(int j=0; j<=threelimit; j++){
                    if(((i*2 + j*6)%9)==0){
                        flag=true;
                        break;
                    }
                }
            }
            if(flag) System.out.println("YES");
            else {System.out.println("NO");}
        }
    }
}

Submission (verdict: Runtime error on test 1):
import java.util.*;
public class number{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            int sum=0;
            int two=0;
            int three=0;
            int temp=n;
            while(temp>0){
                int rem=temp%10;
                sum+=rem;
                if(rem==2)two++;
                if(rem==3)three++;
                temp=temp/10;
            }
            int twolimit=Math.min(8,two+1);
            int threelimit=Math.min(8,three+1);
            boolean flag=false;
            for(int i=0; i<=twolimit; i++){
                for(int j=0; j<=threelimit; j++){
                    if(((sum + i*2 + j*6)%9)==0){
                        flag=true;
                        break;
                    }
                }
                if(flag) break;
            }
            if(flag) System.out.println("YES");
            else {System.out.println("NO");}
        }
    }
}
Problem: 2050C - Uninteresting Number
Language: Java 8

Previous submission (verdict: Runtime error on test 1):
import java.util.*;
public class number{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            int n=sc.nextInt();
            int sum=0;
            int two=0;
            int three=0;
            int temp=n;
            while(temp>0){
                int rem=temp%10;
                sum+=rem;
                if(rem==2)two++;
                if(rem==3)three++;
                temp=temp/10;
            }
            int twolimit=Math.min(8,two+1);
            int threelimit=Math.min(8,three+1);
            boolean flag=false;
            for(int i=0; i<=twolimit; i++){
                for(int j=0; j<=threelimit; j++){
                    if(((sum + i*2 + j*6)%9)==0){
                        flag=true;
                        break;
                    }
                }
                if(flag) break;
            }
            if(flag) System.out.println("YES");
            else {System.out.println("NO");}
        }
    }
}

Submission (verdict: Accepted):
import java.util.*;

public class number {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            String n = sc.next(); 
            int[] digits = new int[n.length()];
            int sum = 0;
            int twocount = 0;
            int threecount = 0;

            for (int i = 0; i < n.length(); i++) {
                digits[i] = n.charAt(i) - '0';
                sum += digits[i];
                if (digits[i] == 2) twocount++;
                if (digits[i] == 3) threecount++;
            }
            boolean flag=false;
            for (int i = 0; i <= Math.min(8, twocount); i++) {
                for (int j = 0; j <= Math.min(8, threecount); j++) {
                    if ((sum + i * 2 + j * 6) % 9 == 0) {
                        flag=true;
                        break;
                    }
                }
            }
            System.out.println(flag?"YES":"NO");
        }
    }
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define int long long

#define endl '\n'

#define optimize() ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()

{

	optimize();

	int t;

	cin>>t;

	while(t--){

		int n,l,r;

		cin>>n>>l>>r;

		vector<int>v(n);

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

			cin>>v[i];

		}

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

		int d=r-l+1;

		int sum=accumulate(v.begin(),v.begin()+d,0);

		cout<<sum<<endl;

		

	}

}



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

using namespace std;

#define int long long

#define endl '\n'

#define optimize() ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()

{

	optimize();

	int t;

	cin>>t;

	while(t--){

		int n,l,r;

		cin>>n>>l>>r;

		vector<int>v(n);

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

			cin>>v[i];

		} 

		vector<int>v1=v;

		sort(v1.begin(),v1.begin()+r);

		int sum1=accumulate(v1.begin(),v1.begin()+r-l+1,0);

		vector<int>v2=v;

		sort(v2.begin()+l-1,v2.end());

		int sum2=accumulate(v2.begin()+l-1,v2.begin()+r,0);

		cout<<min(sum1,sum2)<<endl;

	}

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define int long long

#define endl '\n'

#define optimize() ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()

{

	optimize();

	int t;

	cin>>t;

	while(t--){

		int n,l,r;

		cin>>n>>l>>r;

		vector<int>v(n);

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

			cin>>v[i];

		}

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

		int d=r-l+1;

		int sum=accumulate(v.begin(),v.begin()+d,0);

		cout<<sum<<endl;

		

	}

}