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

Previous submission (verdict: Wrong answer on test 8):
#include <bits/stdc++.h>
using namespace std;
#define ll             long long int 
#define ff(i,a,b)      for(int i=a;i<b;i++)
#define l(s)           s.length()
#define sa(a,n)        sort(a,a+n)
#define sv(v)          sort(v.begin(),v.end())
#define vi             vector<int>
#define input(a,n)     for(int i=0;i<n;i++) cin>>a[i];
#define rv(v)          reverse(v.begin(),v.end())
#define pb             push_back
#define mp             make_pair
#define all(v)         v.begin(),v.end()
#define ff(i,a,b)      for(int i=a;i<b;i++)
#define fr(i,a,b)      for(int i=a;i>=b;i--)
const int mod=1e9+7;
vector<bool> isprime(1000001,true);
int binexp(int a,int b,int m){
 int res=1;
while(b>0){
if(b&1){
res=(res*1LL*a)%mod;
}
a=(a*1LL*a)%mod;
b>>=1;
}
return res;
}
void peak_pd(){
  int t;
  cin>>t;
  while(t--){
    int n, l, r;
        cin >> n >> l >> r;
        l--;
        
        vi arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        
        vi brr(arr.begin(), arr.begin() + l);
        vi crr(arr.begin(), arr.begin() + r);
        
        vi sorted_part(arr.begin() + l, arr.end());
        sort(sorted_part.begin(), sorted_part.end());
        brr.insert(brr.end(), sorted_part.begin(), sorted_part.end());
        
        sort(crr.begin(), crr.end(), greater<int>());
        crr.insert(crr.end(), arr.begin() + r, arr.end());
        
        int sumb = 0, sumc = 0;
        for (int i = l; i < r; i++) {
            sumb += brr[i];
            sumc += crr[i];
        }
        
        cout << min(sumb, sumc) << '\n';
  }
  

}
int main(){
isprime[0]=isprime[1]=1;
for(int i=2;i<=1000000;i++)
{
if(isprime[i]==true)
{
for(int j=2*i;j<=1000000;j+=i)
{
isprime[j]=false;
}
}
}
peak_pd();
return 0;
}

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

using namespace std;

#define ll             long long int 

#define ff(i,a,b)      for(int i=a;i<b;i++)

#define l(s)           s.length()

#define sa(a,n)        sort(a,a+n)

#define sv(v)          sort(v.begin(),v.end())

#define vi             vector<ll>

#define input(a,n)     for(int i=0;i<n;i++) cin>>a[i];

#define rv(v)          reverse(v.begin(),v.end())

#define pb             push_back

#define mp             make_pair

#define all(v)         v.begin(),v.end()

#define ff(i,a,b)      for(int i=a;i<b;i++)

#define fr(i,a,b)      for(int i=a;i>=b;i--)

const int mod=1e9+7;

vector<bool> isprime(1000001,true);

int binexp(int a,int b,int m){

 int res=1;

while(b>0){

if(b&1){

res=(res*1LL*a)%mod;

}

a=(a*1LL*a)%mod;

b>>=1;

}

return res;

}

void peak_pd(){

  int t;

  cin>>t;

  while(t--){

    ll n, l, r;

        cin >> n >> l >> r;

        l--;

        

        vi arr(n);

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

            cin >> arr[i];

        }

        

        vi brr(arr.begin(), arr.begin() + l);

        vi crr(arr.begin(), arr.begin() + r);

        

        vi sorted_part(arr.begin() + l, arr.end());

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

        brr.insert(brr.end(), sorted_part.begin(), sorted_part.end());

        

        sort(crr.begin(), crr.end(), greater<int>());

        crr.insert(crr.end(), arr.begin() + r, arr.end());

        

        ll sumb = 0, sumc = 0;

        for (int i = l; i < r; i++) {

            sumb += brr[i];

            sumc += crr[i];

        }

        

        cout << min(sumb, sumc) << '\n';

  }

  



}

int main(){

isprime[0]=isprime[1]=1;

for(int i=2;i<=1000000;i++)

{

if(isprime[i]==true)

{

for(int j=2*i;j<=1000000;j+=i)

{

isprime[j]=false;

}

}

}

peak_pd();

return 0;

}