ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans;
int solve(vector<int> arr, int count, int size){
    int temp = 0;
    for (int i = 0; i < size; i++){
        temp += arr[i];
    }
    ans = max(temp, ans);
    if (size == 1){
        return temp;
    }
    vector <int> arr1(size - 1);
    vector <int> arr2(size - 1);
    for (int i = 0; i < size - 1; i++){
        arr1[i] = arr[i + 1] - arr[i];
    }
    for (int i = size - 1; i > 0; i--){
        arr2[size - 1 - i] = arr[i - 1] - arr[i];
    }
    return max(solve(arr1, temp, arr1.size()), solve(arr2, temp, arr2.size()));
}
int32_t main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        ans = max(ans, solve(a, 0, a.size()));
        cout << ans << endl;
    }
}

Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans = -50001;
int solve(vector<int> arr, int count, int size){
    int temp = 0;
    for (int i = 0; i < size; i++){
        temp += arr[i];
    }
    ans = max(temp, ans);
    if (size == 1){
        return temp;
    }
    vector <int> arr1(size - 1);
    vector <int> arr2(size - 1);
    for (int i = 0; i < size - 1; i++){
        arr1[i] = arr[i + 1] - arr[i];
    }
    for (int i = size - 1; i > 0; i--){
        arr2[size - 1 - i] = arr[i - 1] - arr[i];
    }
    return max(solve(arr1, temp, arr1.size()), solve(arr2, temp, arr2.size()));
}
int32_t main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        ans = max(ans, solve(a, 0, a.size()));
        cout << ans << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans;
int solve(vector<int> arr, int count, int size){
    int temp = 0;
    for (int i = 0; i < size; i++){
        temp += arr[i];
    }
    ans = max(temp, ans);
    if (size == 1){
        return temp;
    }
    vector <int> arr1(size - 1);
    vector <int> arr2(size - 1);
    for (int i = 0; i < size - 1; i++){
        arr1[i] = arr[i + 1] - arr[i];
    }
    for (int i = size - 1; i > 0; i--){
        arr2[size - 1 - i] = arr[i - 1] - arr[i];
    }
    return max(solve(arr1, temp, arr1.size()), solve(arr2, temp, arr2.size()));
}
int32_t main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        ans = max(ans, solve(a, 0, a.size()));
        cout << ans << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;



int main(){

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif





	int n; cin >> n;



	while(n > 0) {



		string s; cin >> s;



		long long tamanho = s.size();

		bool aumenta = true;

		long long j = 0;

		while(aumenta == true) {



			long long i = 1 + j;

				while(i > 0) {

					if(s[i] > s[i - 1] + 1) {

						swap(s[i-1],s[i]);

						s[i-1]--;

						i--;

					}

					else break;

				}



			j++;

			if(j == tamanho - 1) {

				aumenta = false;

			}

		}



		cout << s << '\n';



		n--;

	}



	return 0;



}





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

using namespace std;



int main(){

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif





	int n; cin >> n;



	while(n > 0) {



		string s; cin >> s;



		long long tamanho = s.size();

		bool aumenta = true;

		long long j = 0;

		while(aumenta == true) {



			long long i = 1 + j;

				while(i > 0) {

					if(s[i] > s[i - 1] + 1) {

						swap(s[i-1],s[i]);

						s[i-1]--;

						i--;

					}

					else break;

				}



			j++;

			if(j == tamanho) {

				aumenta = false;

			}

		}



		cout << s << '\n';



		n--;

	}



	return 0;



}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;



int main(){

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif





	int n; cin >> n;



	while(n > 0) {



		string s; cin >> s;



		long long tamanho = s.size();

		bool aumenta = true;

		long long j = 0;

		while(aumenta == true) {



			long long i = 1 + j;

				while(i > 0) {

					if(s[i] > s[i - 1] + 1) {

						swap(s[i-1],s[i]);

						s[i-1] = s[i-1] - 1;

						i--;

					}

					else break;

				}



			j++;

			if(j == tamanho - 1) {

				aumenta = false;

			}

		}



		cout << s << '\n';



		n--;

	}



	return 0;



}





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

using namespace std;



int main(){

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif





	int n; cin >> n;



	while(n > 0) {



		string s; cin >> s;



		long long tamanho = s.size();

		bool aumenta = true;

		long long j = 0;

		while(aumenta == true) {



			long long i = 1 + j;

				while(i > 0) {

					if(s[i] > s[i - 1] + 1) {

						swap(s[i-1],s[i]);

						s[i-1]--;

						i--;

					}

					else break;

				}



			j++;

			if(j == tamanho - 1) {

				aumenta = false;

			}

		}



		cout << s << '\n';



		n--;

	}



	return 0;



}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;



int main(){

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif





	int n; cin >> n;



	while(n > 0) {



		string s; cin >> s;



		int tamanho = s.size();

		bool aumenta = true;

		int j = 0;

		while(aumenta == true) {



			int i = 1 + j;

				while(i > 0) {

					if(s[i] > s[i - 1] + 1) {

						swap(s[i-1],s[i]);

						s[i-1] = s[i-1] - 1;

						i--;

					}

					else break;

				}



			j++;

			if(j == tamanho - 1) {

				aumenta = false;

			}

		}



		cout << s << '\n';



		n--;

	}



	return 0;



}





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

using namespace std;



int main(){

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif





	int n; cin >> n;



	while(n > 0) {



		string s; cin >> s;



		long long tamanho = s.size();

		bool aumenta = true;

		long long j = 0;

		while(aumenta == true) {



			long long i = 1 + j;

				while(i > 0) {

					if(s[i] > s[i - 1] + 1) {

						swap(s[i-1],s[i]);

						s[i-1] = s[i-1] - 1;

						i--;

					}

					else break;

				}



			j++;

			if(j == tamanho - 1) {

				aumenta = false;

			}

		}



		cout << s << '\n';



		n--;

	}



	return 0;



}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

using namespace std;



int main(){

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif





	int n; cin >> n;



	while(n > 0) {



		string s; cin >> s;



		int tamanho = s.size();

		bool aumenta = true;

		int j = 0;

		while(aumenta == true) {



			int i = 1 + j;

				while(i > 0) {

					if(s[i] > s[i - 1] + 1) {

						swap(s[i-1],s[i]);

						s[i-1] = s[i-1] - 1;

						i--;

					}

					else break;

				}



			j++;

			if(j == tamanho - 1) {

				aumenta = false;

			}

		}



		cout << s << '\n';



		n--;

	}



	return 0;



}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

#define putchar_unlocked putchar
#define getchar_unlocked getchar

struct Reader { int ch; operator bool() { return ch != EOF; } template<typename T> Reader &operator>>(T &x) { x = 0; int f = 1; ch = getchar_unlocked(); while (ch != EOF && (ch < '0' || ch > '9')) { if (ch == '-') f = -1; ch = getchar_unlocked(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar_unlocked(); } x *= f; return *this; } Reader &operator>>(char &s) { ch = getchar_unlocked(); while (ch == ' ' || ch == '\n' || ch == '\r') ch = getchar_unlocked(); s = ch; return *this; } Reader &operator>>(char *s) { char ch = getchar_unlocked(); while (ch == ' ' || ch == '\n' || ch == '\r') ch = getchar_unlocked(); while (ch != ' ' && ch != '\n' && ch != '\r' && ch != EOF) *(s++) = ch, ch = getchar_unlocked(); *s = '\0'; return *this; } } reader; struct Writer { template<typename T> Writer &operator<<(T x) { if (x < 0) { putchar_unlocked('-'); x = -x; } if (x > 9) *this << x / 10; putchar_unlocked(x % 10 + '0'); return *this; } Writer &operator<<(char ch) { putchar_unlocked(ch); return *this; } Writer &operator<<(const char *s) { for (int i = 0; s[i]; i++) putchar_unlocked(s[i]); return *this; } } writer;

#define cin reader
#define cout writer
#define endl '\n'

#define f(i, a, b) for (int i = (a), _##i = (b); i <= _##i; i++)
#define fr(i, a, b) for (int i = (a), _##i = (b); i >= _##i; i--)
typedef long long LL;

const int N = 55;
int n, a[N];
int solve() {
    cin >> n; f(i, 1, n) cin >> a[i];
    LL ans = accumulate(a + 1, a + n + 1, 0ll);
    while (n > 1) {
        f(i, 1, n - 1) a[i] = a[i + 1] - a[i];
        n--;
        LL sum = accumulate(a + 1, a + n + 1, 0ll);
        ans = max(ans, abs(sum));
    }
    return ans;
}
int main() {
    int T; cin >> T;
    while (T--) cout << solve() << endl;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int best = s[i] - '0', pos = i;
        for (int j = i; j < min(i + 10, (int) s.size()); j++) {
            if (s[j] - '0' - (j - i) > best) {
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s;
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int best = s[i] - '0', pos = i;
        for (int j = i; j < min(i + 10, (int) s.size()); j++) {
            if (s[j] - '0' - (j - i) > best) {
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s;
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int best = s[i] - '0', pos = i;
        for (int j = i; j < min(i + 10, (int) s.size()); j++) {
            if (s[j] - '0' - (j - i) > best) {
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s<<"/n";
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int best = s[i] - '0', pos = i;
        for (int j = i; j < min(i + 10, (int) s.size()); j++) {
            if (s[j] - '0' - (j - i) > best) {
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s<<"/n";
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

void solve() {
    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        int best = s[i] - '0', pos = i;
        for (int j = i; j < min(i + 10, (int) s.size()); j++) {
            if (s[j] - '0' - (j - i) > best) {
                best = s[j] - '0' - (j - i);
                pos = j;
            }
        }
        while (pos > i) {
            swap(s[pos], s[pos - 1]);
            pos--;
        }
        s[i] = char(best + '0');
    }
    cout << s<<endl;
}

int main() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.*;



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

if(i>0){

if(A[i-1]>=A[i]){

flag=1;

}

}else{

flag=1;

}

}

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}













Submission (verdict: Wrong answer on test 2):
import java.util.*;



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

if(i>0){

// System.out.println(A[i]-A[i-1]);

if((A[i]-A[i-1])>A[i+1]){

flag=1;

}else{

int min = Math.min(A[i],A[i-1]);

A[i] = A[i]-min;

A[i-1] = A[i-1]-min;

}

}else{

flag=1;

}

}

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}
Problem: 2060D - Subtract Min Sort
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.*;



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

if(i>0){

// System.out.println(A[i]-A[i-1]);

if((A[i]-A[i-1])>A[i+1]){

flag=1;

}else{

int min = Math.min(A[i],A[i-1]);

A[i] = A[i]-min;

A[i-1] = A[i-1]-min;

}

}else{

flag=1;

}

}

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}













Submission (verdict: Wrong answer on test 2):
import java.util.*;



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

if(i>0){

// System.out.println(A[i]-A[i-1]);

if((A[i]-A[i+1]-A[i-1])<0){

int min = Math.min(A[i],A[i-1]);

A[i] = A[i]-min;

A[i-1] = A[i-1]-min;



}else{

flag=1;

break;



}

}else{

flag=1;

break;

}

}

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}
Problem: 2060D - Subtract Min Sort
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.*;



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

if(i>0){

// System.out.println(A[i]-A[i-1]);

if((A[i]-A[i+1]-A[i-1])<=0){

int min = Math.min(A[i],A[i-1]);

A[i] = A[i]-min;

A[i-1] = A[i-1]-min;



}else{

flag=1;

break;



}

}else{

flag=1;

break;

}

}

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}













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



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

flag=1;

break;

}

int min = Math.min(A[i+1],A[i]);

A[i+1]= A[i+1]-min;

A[i]= A[i]-min;

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}
Problem: 2060D - Subtract Min Sort
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.util.*;



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

if(i>0){

if(A[i-1]>=A[i]){

flag=1;

}

}else{

flag=1;

}

}

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}
Problem: 2060D - Subtract Min Sort
Language: Java 21

Previous submission (verdict: Wrong answer on test 2):
import java.util.*;



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

if(i>0){

// System.out.println(A[i]-A[i-1]);

if((A[i]-A[i+1]-A[i-1])<0){

int min = Math.min(A[i],A[i-1]);

A[i] = A[i]-min;

A[i-1] = A[i-1]-min;



}else{

flag=1;

break;



}

}else{

flag=1;

break;

}

}

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}













Submission (verdict: Wrong answer on test 2):
import java.util.*;



public class mywork {

public static boolean isPrime(int n) {

if (n <= 1) {

return false;

}

for (int i = 2; i * i <= n; i++) {

if (n % i == 0) {

return false;

}

}

return true;

}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

long T = sc.nextLong();

while (T-- > 0) {

int N = sc.nextInt();

int A[] = new int[N];

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

A[i] = sc.nextInt();

}

int flag = 0;

for(int i = 0;i<N-1;i++){

if(A[i+1]<A[i]){

if(i>0){

// System.out.println(A[i]-A[i-1]);

if((A[i]-A[i+1]-A[i-1])<=0){

int min = Math.min(A[i],A[i-1]);

A[i] = A[i]-min;

A[i-1] = A[i-1]-min;



}else{

flag=1;

break;



}

}else{

flag=1;

break;

}

}

}

if(flag==1){

System.out.println("NO");

}else{

System.out.println("YES");

}



}

}

}
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;

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " " << x << endl;
#else
#define debug(x)
#endif

int main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; ++i)
    {
        int n, l, r;
        cin >> n >> l >> r;
        l--;
        r--;
        vector<int> v1;
        v1.reserve(n);
        int t1;
        string check = "checking\n";
        int x = max(0, l - (r - l + 1));
        int y = min(n - 1, r + (r - l + 1));
        debug(x) debug(y);
        for (int j = 0; j < n; ++j)
        {
            cin >> t1;
            v1.push_back(t1);
        }
        // debug(check);
        vector<int> v2(v1.begin() + l, v1.begin() + y + 1);
        sort(v2.begin(), v2.end());
        int a1 = 0;
        for (int i = 0; i < r - l + 1; i++)
        {
            a1 += v2[i];
        }
        int a2 = 0;
        // debug(check);
        vector<int> v3(v1.begin() + x, v1.begin() + r + 1);
        sort(v3.begin(), v3.end());
        for (int i = 0; i < r - l + 1; ++i)
        {
            a2 += v3[i];
        }
        // debug(check)
        cout << min(a1, a2) << endl;
    }
}

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

#define pyes cout << "YES\n"
#define pno cout << "NO\n"
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " " << x << endl;
#else
#define debug(x)
#endif

int main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; ++i)
    {
        int n, l, r;
        cin >> n >> l >> r;
        l--;
        r--;
        vector<int> v1;
        v1.reserve(n);
        int t1;
        string check = "checking\n";
        int x = max(0, l - (r - l + 1));
        int y = min(n - 1, r + (r - l + 1));
        debug(x) debug(y);
        for (int j = 0; j < n; ++j)
        {
            cin >> t1;
            v1.push_back(t1);
        }
        if(n==1)
        {
            cout<<t1<<endl;
        }
        // debug(check);
        vector<int> v2(v1.begin() + l, v1.begin() + y + 1);
        sort(v2.begin(), v2.end());
        int a1 = 0;
        for (int i = 0; i < r - l + 1; i++)
        {
            a1 += v2[i];
        }
        int a2 = 0;
        // debug(check);
        vector<int> v3(v1.begin() + x, v1.begin() + r + 1);
        sort(v3.begin(), v3.end());
        for (int i = 0; i < r - l + 1; ++i)
        {
            a2 += v3[i];
        }
        // debug(check)
        cout << min(a1, a2) << endl;
    }
}