Problem: 2063B - Subsequence Update
Language: Java 21

Previous submission (verdict: Wrong answer on test 8):
import java.util.Scanner;

public class Subsequence_Update{

    public static void merge(int[] arr, int l, int m, int r){

        int n1 = m - l + 1;

        int n2 = r - m;



        int[] L = new int[n1];

        int[] R = new int[n2];



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

            L[i] = arr[l + i];

        }



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

            R[i] = arr[m + 1 + i];

        }



        int i = 0;

        int j = 0;

        int k = l;



        while(i<n1 && j<n2){

            if(L[i] <= R[j]){

                arr[k] = L[i];

                i++;

            }else{

                arr[k] = R[j];

                j++;

            }

            k++;

        }



        while(i<n1){

            arr[k] = L[i];

            i++;

            k++;

        }



        while(j<n2){

            arr[k] = R[j];

            j++;

            k++;

        }

    }

    public static void mergeSort(int[] arr, int l, int r){

        if(l<r){

            int m = (l+r)/2;

            mergeSort(arr, l, m);

            mergeSort(arr, m+1, r);

            merge(arr, l, m, r);

        }

    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();

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

            int n = sc.nextInt();

            long l = sc.nextLong();

            long r = sc.nextLong();

            int[] arr = new int[n];

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

                arr[j] = sc.nextInt();

            }



            int[] arr1 = new int[(int) r];

            for(long j = 0; j<r; j++){

                arr1[(int)j] = arr[(int)j];

            }



            int[] arr2 = new int[(int)(n-l + 1)];

            for(int j = 0; j<n-l+1; j++){

                arr2[(int)j] = arr[(int)(j+l-1)];

            }



            mergeSort(arr1, 0, (int)(r-1));

            mergeSort(arr2, 0, (int)(n-l));



            int sum1 = 0;

            int sum2 = 0;



            for(int j = 0; j<(r - l + 1); j++){

                sum1 += arr1[j];

                sum2 += arr2[j];

            }



            if(sum1<=sum2){

                System.out.println(sum1);

            }else{

                System.out.println(sum2);

            }

        }

    }

}

Submission (verdict: Wrong answer on test 8):
import java.util.Scanner;
public class Subsequence_Update{
    public static void merge(int[] arr, int l, int m, int r){
        int n1 = m - l + 1;
        int n2 = r - m;

        int[] L = new int[n1];
        int[] R = new int[n2];

        for(int i = 0; i<n1; i++){
            L[i] = arr[l + i];
        }

        for(int i = 0; i<n2; i++){
            R[i] = arr[m + 1 + i];
        }

        int i = 0;
        int j = 0;
        int k = l;

        while(i<n1 && j<n2){
            if(L[i] <= R[j]){
                arr[k] = L[i];
                i++;
            }else{
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while(i<n1){
            arr[k] = L[i];
            i++;
            k++;
        }

        while(j<n2){
            arr[k] = R[j];
            j++;
            k++;
        }
    }
    public static void mergeSort(int[] arr, int l, int r){
        if(l<r){
            int m = (l+r)/2;
            mergeSort(arr, l, m);
            mergeSort(arr, m+1, r);
            merge(arr, l, m, r);
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long t = sc.nextLong();
        for(int i = 0; i<t; i++){
            int n = sc.nextInt();
            long l = sc.nextLong();
            long r = sc.nextLong();
            int[] arr = new int[n];
            for(int j = 0; j<n; j++){
                arr[j] = sc.nextInt();
            }

            int[] arr1 = new int[(int) r];
            for(long j = 0; j<r; j++){
                arr1[(int)j] = arr[(int)j];
            }

            int[] arr2 = new int[(int)(n-l + 1)];
            for(int j = 0; j<n-l+1; j++){
                arr2[(int)j] = arr[(int)(j+l-1)];
            }

            mergeSort(arr1, 0, (int)(r-1));
            mergeSort(arr2, 0, (int)(n-l));

            int sum1 = 0;
            int sum2 = 0;

            for(int j = 0; j<(r - l + 1); j++){
                sum1 += arr1[j];
                sum2 += arr2[j];
            }

            if(sum1<=sum2){
                System.out.println(sum1);
            }else{
                System.out.println(sum2);
            }
        }
    }
}