ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
signed main()
{
    int tt;cin>>tt;
    while(tt--){
        int n;cin>>n;
        int sum=0;
        int ct2=0,ct3=0;
        while(n>0){
            sum+=n%10;
            if(n%10==2) ct2+=1;
            else if(n%10==3) ct3+=1;
            n/=10;
        }
        int temp=sum;
        bool f=false;
        for(int i=0;i<=min(10LL,ct2);i++){
            
            for (int j=0;j<=min(10LL,ct3);j++){
                temp=sum;
                temp+=(i*2)+(j*6);
                if(temp%9==0) {
                    
                    f=true;
                    break;
                }
            }
            if(f) break;

        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;        
    }
return 0;
}

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

signed main() {
    int tt;
    cin >> tt;
    while (tt--) {
        string s;
        cin >> s;

        int sum = 0, ct2 = 0, ct3 = 0;

        for (char c : s) {
            int digit = c - '0';
            sum += digit;
            if (digit == 2) ct2++;
            if (digit == 3) ct3++;
        }

        bool f = false;
        for (int i = 0; i <= min(10LL, ct2); i++) {
            for (int j = 0; j <= min(10LL, ct3); j++) {
                if ((sum + i * 2 + j * 6) % 9 == 0) {
                    f = true;
                    break;
                }
            }
            if (f) break;
        }

        if (f) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

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

    while (t--) {
        
        string s;
        cin >> s;
        ll n = s.size();
        for (int i = 0; i < n; i++) {
            ll maxc = s[i] - '0';
            ll maxi = i;
            for (int j = i + 1; j < n; j++) {
                if (s[j] - '0' + (i - j) > maxc) {
                    maxc = s[j] - '0' + (i - j);
                    maxi = j;
                }
            }

            swap(s[i], s[maxi]);
            s[i]+= (i - maxi);
        }

        cout << s << endl;
    }

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

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

    while (t--) {
        
        string s;
        cin >> s;
        ll n = s.size();
        for (int i = 0; i < n; i++) {
            ll maxc = s[i] - '0';
            ll maxi = i;
            for (int j = i ; j < n; j++) {
                if (s[j] - '0' + (i - j) > maxc) {
                    maxc = s[j] - '0' + (i - j);
                    maxi = j;
                }
            }
            ll k= maxi;

            while(maxi > i) {
                swap(s[maxi], s[maxi - 1]);
                maxi--;
            }
            s[i] += (i - k);
        }

        cout <<s << endl;
    }

    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

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

    while (t--) {
        
        string s;
        cin >> s;
        ll n = s.size();
        for (ll i = 0; i < n; i++) {
            ll maxc = s[i] - '0';
            ll maxi = i;
            for (ll j = i ; j < min(i+10,n); j++) {
                if (s[j] - '0' + (i - j) > maxc) {
                    maxc = s[j] - '0' + (i - j);
                    maxi = j;
                }
            }ll k = maxi;

            while(maxi > i) {
                swap(s[maxi], s[maxi - 1]);
                maxi--;
            }
            s[i] += (i - k);
        }

        cout <<s << endl;
    }

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

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

    while (t--) {
        
        string s;
        cin >> s;
        ll n = s.size();
        for (int i = 0; i < n; i++) {
            ll maxc = s[i] - '0';
            ll maxi = i;
            for (int j = i + 1; j < n; j++) {
                if (s[j] - '0' + (i - j) > maxc) {
                    maxc = s[j] - '0' + (i - j);
                    maxi = j;
                }
            }

            swap(s[i], s[maxi]);
            s[i]+= (i - maxi);
        }

        cout << s << endl;
    }

    return 0;
}


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

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

    while (t--) {
        
        string s;
        cin >> s;
        ll n = s.size();
        for (int i = 0; i < n; i++) {
            ll maxc = s[i] - '0';
            ll maxi = i;
            for (int j = i ; j < n; j++) {
                if (s[j] - '0' + (i - j) > maxc) {
                    maxc = s[j] - '0' + (i - j);
                    maxi = j;
                }
            }
            ll k= maxi;

            while(maxi > i) {
                swap(s[maxi], s[maxi - 1]);
                maxi--;
            }
            s[i] += (i - k);
        }

        cout <<s << endl;
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAXN=2e6+5;
const ll mod=998244353;
ll n,k;
ll tot=0,cnt=0;

void solve(){
	int n;cin>>n;
	vector<int> a(n+5),b(n+5);
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	b[i]=i;
	queue<pair<int,int>> q;
	int j;
	for(int i=1;i<=n;i++){
		j=i;
		while(b[j]!=a[i])	j++;
		while(j>i){
			q.push({b[j],b[j-1]});
			swap(b[j],b[j-1]);
			j--;
		}	
	} 
	for(int i=1;i<n;i++){
		if(b[i]<b[i+1]){
			q.push({b[i+1],b[i]});
			q.push({b[i],b[i+1]});
		}
	}
	cout<<q.size()<<endl;
	while(!q.empty()){
		auto [x,y]=q.front();
		q.pop();
		cout<<x<<' '<<y<<endl;
	}
}	

                 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;//cin>>t;
    while(t--){
    	solve();
    }
}

Submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAXN=2e6+5;
const ll mod=998244353;
ll n,k;
ll tot=0,cnt=0;

void solve(){
	int n;cin>>n;
	vector<int> a(n+5),b(n+5);
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	b[i]=i;
	queue<pair<int,int>> q;
	int j;
	for(int i=1;i<=n;i++){
		j=i;
		while(b[j]!=a[i])	j++;
		while(j>i){
			q.push({b[j],b[j-1]});
			swap(b[j],b[j-1]);
			j--;
		}	
	} 
	for(int i=n;i>=1;){
		j=i-1;
		while(j>=1&&a[j]<a[i])	j--;
		int end=j;
		for(int k=1;k<=i-end;k++){
			int j2=i;
			while(j2>end+1){
				q.push({a[j2],a[j2-1]});
				swap(a[j2],a[j2-1]);
				j2--;
			}
		}
		i=end;
	}
	cout<<q.size()<<endl;
	while(!q.empty()){
		auto [x,y]=q.front();
		q.pop();
		cout<<x<<' '<<y<<endl;
	}
}	

                 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;cin>>t;
    while(t--){
    	solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAXN=2e6+5;
const ll mod=998244353;
ll n,k;
ll tot=0,cnt=0;

void solve(){
	int n;cin>>n;
	vector<int> a(n+5),b(n+5);
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	b[i]=i;
	queue<pair<int,int>> q;
	int j;
	for(int i=1;i<=n;i++){
		j=i;
		while(b[j]!=a[i])	j++;
		while(j>i){
			q.push({b[j],b[j-1]});
			swap(b[j],b[j-1]);
			j--;
		}	
	} 
	for(int i=1;i<n;i++){
		if(b[i]<b[i+1]){
			q.push({b[i+1],b[i]});
			q.push({b[i],b[i+1]});
		}
	}
	cout<<q.size()<<endl;
	while(!q.empty()){
		auto [x,y]=q.front();
		q.pop();
		cout<<x<<' '<<y<<endl;
	}
}	

                 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;//cin>>t;
    while(t--){
    	solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAXN=2e6+5;
const ll mod=998244353;
ll n,k;
ll tot=0,cnt=0;

void solve(){
	int n;cin>>n;
	vector<int> a(n+5),b(n+5);
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	b[i]=i;
	queue<pair<int,int>> q;
	int j;
	for(int i=1;i<=n;i++){
		j=i;
		while(b[j]!=a[i])	j++;
		while(j>i){
			q.push({b[j],b[j-1]});
			swap(b[j],b[j-1]);
			j--;
		}	
	} 
	for(int i=n;i>=1;){
		j=i-1;
		while(j>=1&&a[j]<a[i])	j--;
		int end=j;
		for(int k=1;k<=i-end;k++){
			int j2=i;
			while(j2>end+1){
				q.push({a[j2],a[j2-1]});
				swap(a[j2],a[j2-1]);
				j2--;
			}
		}
		i=end;
	}
	cout<<q.size()<<endl;
	while(!q.empty()){
		auto [x,y]=q.front();
		q.pop();
		cout<<x<<' '<<y<<endl;
	}
}	

                 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;//cin>>t;
    while(t--){
    	solve();
    }
}

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

using namespace std;

using ll=long long;

const int MAXN=2e6+5;

const ll mod=998244353;

ll n,k;

ll tot=0,cnt=0;



void solve(){

	int n;cin>>n;

	vector<int> a(n+5),b(n+5);

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

	for(int i=1;i<=n;i++)	b[i]=i;

	queue<pair<int,int>> q;

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

		int j=n;

		while(b[j]>b[j-1]&&j>1){q.push({b[j],b[j-1]});swap(b[j],b[j-1]);j--;tot++;}

	}

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

		int j=i;

		while(b[j]!=a[i]&&j<=n){j++;}

		while(j>i){q.push({b[j],b[j-1]});swap(b[j],b[j-1]);j--;tot++;}

	}

	cout<<tot<<endl;

	while(!q.empty()){

		auto [x,y]=q.front();

		cout<<x<<' '<<y<<endl;

		q.pop();

	}

}	



                 

int main(){

    ios::sync_with_stdio(false);

    cin.tie(0),cout.tie(0);

    int t=1;//cin>>t;

    while(t--){

    	solve();

    }

}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 1):
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAXN=2e6+5;
const ll mod=998244353;
ll n,k;
ll tot=0,cnt=0;

void solve(){
	int n;cin>>n;
	vector<int> a(n+5),b(n+5);
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	b[i]=i;
	queue<pair<int,int>> q;
	int j;
	for(int i=1;i<=n;i++){
		j=i;
		while(b[j]!=a[i])	j++;
		while(j>i){
			q.push({b[j],b[j-1]});
			swap(b[j],b[j-1]);
			j--;
		}	
	} 
	for(int i=n;i>=1;){
		j=i-1;
		while(j>=1&&a[j]<a[i])	j--;
		int end=j;
		for(int k=1;k<=i-end;k++){
			int j2=i;
			while(j2>end+1){
				q.push({a[j2],a[j2-1]});
				swap(a[j2],a[j2-1]);
				j2--;
			}
		}
		i=end;
	}
	cout<<q.size()<<endl;
	while(!q.empty()){
		auto [x,y]=q.front();
		q.pop();
		cout<<x<<' '<<y<<endl;
	}
}	

                 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;cin>>t;
    while(t--){
    	solve();
    }
}

Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MAXN=2e6+5;
const ll mod=998244353;
ll n,k;
ll tot=0,cnt=0;

void solve(){
	int n;cin>>n;
	vector<int> a(n+5),b(n+5);
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=1;i<=n;i++)	b[i]=i;
	queue<pair<int,int>> q;
	int j;
	for(int i=1;i<=n;i++){
		j=i;
		while(b[j]!=a[i])	j++;
		while(j>i){
			q.push({b[j],b[j-1]});
			swap(b[j],b[j-1]);
			j--;
		}	
	} 
	for(int i=n;i>=1;){
		j=i-1;
		while(j>=1&&a[j]<a[i])	j--;
		int end=j;
		for(int k=1;k<=i-end;k++){
			int j2=i;
			while(j2>end+1){
				q.push({a[j2],a[j2-1]});
				swap(a[j2],a[j2-1]);
				j2--;
			}
		}
		i=end;
	}
	cout<<q.size()<<endl;
	while(!q.empty()){
		auto [x,y]=q.front();
		q.pop();
		cout<<x<<' '<<y<<endl;
	}
}	

                 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;//cin>>t;
    while(t--){
    	solve();
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define forr(i,x,n) for(int i = x ; i < n ; i ++)  
constexpr int MOD = 1e9 + 7;  


int sumOfDigits(int number) {
    int sum = 0;

    // Ensure the number is positive for calculation
    number = abs(number);

    while (number > 0) {
        sum += number % 10; // Add the last digit
        number /= 10;       // Remove the last digit
    }

    return sum;
}

int c2(int number) {
    int s = 0;

    // Ensure the number is positive for calculation
    number = abs(number);

    while (number > 0) {
        if(number % 10 == 2) s++ ; // Add the last digit
        number /= 10;       // Remove the last digit
    }

    return s;
} 

int c3(int number) {
    int s = 0;

    // Ensure the number is positive for calculation
    number = abs(number);

    while (number > 0) {
        if(number % 10 == 3) s++ ; // Add the last digit
        number /= 10;       // Remove the last digit
    }

    return s;
}

int32_t main() {   
    int t  ; 
    cin >> t ; 
    while(t--) {    
        int n ; 
        cin >> n ;  
        int s = sumOfDigits(n) ;   
        int k = s ; 
        bool ya = false ; 
        if(s%9 == 0) ya = true ; 
        else { 
            int tw = c2(n) ; 
            int th = c3(n) ; 
          //  cout << (th) << endl ;
            forr(i,0,th + 1){ 
                forr(j,0,tw + 1) { 
                    s= k +  j*2 + i*6 ;  
                  //  cout << s << endl ; 
                    if(s%9 == 0){ 
                        ya = true ; 
                        break ; 
                    } 
                  // if(ya) cout << "YES" << endl ;
                  // else cout << "NO" << endl ;
                }
            }  
        } 

                   if(ya) cout << "YES" << endl ;
                   else cout << "NO" << endl ;
            
        

         
         

    }
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define Akhaja ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#include<math.h>
#define ll long long 
using namespace std;
 
void init(){
    // Now its my turn
}

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    vector<pair<ll,ll>> ans;
    for(ll i=n-1;i>=0;i--){
        for(ll j=i+1;j<n;j++){
            if(a[i]<a[j]){
                ans.push_back({a[j],a[i]});
                ans.push_back({a[i],a[j]});
            }else if(a[i]>a[j]){
                ans.push_back({a[i],a[j]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto it:ans){
        cout<<it.first<<" "<<it.second<<endl;
    }
}   
    
int main(){
    Akhaja;
    // init();
    // ll t;
    // cin>>t;
    // while(t--){
        solve();
    // }
    return 0;
}

Submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
#define Akhaja ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#include<math.h>
#define ll long long 
using namespace std;
 
void init(){
    // Now its my turn
}

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    set<pair<ll,ll>> mali;
    vector<pair<ll,ll>> ans;
    vector<ll> pos(n);
    map<ll,ll> mp;
    for(ll i=0;i<n;i++){
        pos[i]=(i+1);
        mp[i+1]=i;
    }

    for(ll i=0;i<n-1;i++){
        ll bando=a[i];
        ll idx=mp[bando];
        for(ll j=idx+1;j<n;j++){
            if(mali.find({pos[j],bando})==mali.end()){
                ans.push_back({pos[j],bando});
                mali.insert({pos[j],bando});
            }
        }
        for(ll j=n-1;j>=idx+1;j--){
            if(mali.find({bando,pos[j]})==mali.end()){
                ans.push_back({bando,pos[j]});
                mali.insert({bando,pos[j]});
            }
        }
        for(ll j=idx-1;j>=0;j--){
            if(mali.find({bando,pos[j]})==mali.end()){
                ans.push_back({bando,pos[j]});
                mali.insert({bando,pos[j]});
            }
            mp[bando]--;
            mp[pos[j]]++;
            pos[j+1]=pos[j];
        }
        pos[i]=bando;

        // for(auto it:pos){
        //     cout<<it<<" ";
        // }
        // cout<<endl;
    }
    cout<<ans.size()<<endl;
    for(auto it:ans){
        cout<<it.first<<" "<<it.second<<endl;
    }
}   
    
int main(){
    Akhaja;
    // init();
    // ll t;
    // cin>>t;
    // while(t--){
        solve();
    // }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
#define Akhaja ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#include<math.h>
#define ll long long 
using namespace std;
 
void init(){
    // Now its my turn
}

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    vector<pair<ll,ll>> ans;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            if(a[i]<a[j]){
                ans.push_back({a[j],a[i]});
                ans.push_back({a[i],a[j]});
            }else if(a[i]>a[j]){
                ans.push_back({a[i],a[j]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto it:ans){
        cout<<it.first<<" "<<it.second<<endl;
    }
}   
    
int main(){
    Akhaja;
    // init();
    // ll t;
    // cin>>t;
    // while(t--){
        solve();
    // }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define Akhaja ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#include<math.h>
#define ll long long 
using namespace std;
 
void init(){
    // Now its my turn
}

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    vector<pair<ll,ll>> ans;
    for(ll i=n-1;i>=0;i--){
        for(ll j=i+1;j<n;j++){
            if(a[i]<a[j]){
                ans.push_back({a[j],a[i]});
                ans.push_back({a[i],a[j]});
            }else if(a[i]>a[j]){
                ans.push_back({a[i],a[j]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto it:ans){
        cout<<it.first<<" "<<it.second<<endl;
    }
}   
    
int main(){
    Akhaja;
    // init();
    // ll t;
    // cin>>t;
    // while(t--){
        solve();
    // }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
#define Akhaja ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#include<math.h>
#define ll long long 
using namespace std;
 
void init(){
    // Now its my turn
}

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    vector<pair<ll,ll>> ans;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            if(a[i]<a[j]){
                ans.push_back({a[j],a[i]});
                ans.push_back({a[i],a[j]});
            }else if(a[i]>a[j]){
                ans.push_back({a[i],a[j]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto it:ans){
        cout<<it.first<<" "<<it.second<<endl;
    }
}   
    
int main(){
    Akhaja;
    // init();
    // ll t;
    // cin>>t;
    // while(t--){
        solve();
    // }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: Java 21

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

import java.util.Collections;

import java.util.Scanner;



public class SubsequenceUpdate {

  public static void main(String[] args){

    Scanner scanner = new Scanner(System.in);

    int tests = Integer.parseInt(scanner.nextLine());

    while (tests > 0){

      int n = scanner.nextInt();

      int l = scanner.nextInt();

      int r = scanner.nextInt();

      long[] arr = new long[n];

      for (int i = 0; i < arr.length; i++){

        arr[i] = scanner.nextLong();

      }



      ArrayList<Long> toL = new ArrayList<>();

      ArrayList<Long> toR = new ArrayList<>();

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

        toR.add(arr[i]);

      }

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

        toL.add(arr[i]);

      }



      Collections.sort(toL);

      Collections.sort(toR);



      int sumOne = 0;

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

        sumOne += toL.get(i);

      }



      int sumTwo = 0;

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

        sumTwo += toR.get(i);

      }



      System.out.println(Math.min(sumTwo, sumOne));

      tests--;

    }

  }

}



Submission (verdict: Accepted):
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class SubsequenceUpdate {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int tests = Integer.parseInt(scanner.nextLine());
    while (tests > 0){
      int n = scanner.nextInt();
      int l = scanner.nextInt();
      int r = scanner.nextInt();
      long[] arr = new long[n];
      for (int i = 0; i < arr.length; i++){
        arr[i] = scanner.nextLong();
      }

      ArrayList<Long> toL = new ArrayList<>();
      ArrayList<Long> toR = new ArrayList<>();
      for (int i = 0; i < r; i++){
        toR.add(arr[i]);
      }
      for (int i = l - 1; i < n; i++){
        toL.add(arr[i]);
      }

      Collections.sort(toL);
      Collections.sort(toR);

      long sumOne = 0;
      for (int i = 0; i < r - l + 1; i++){
        sumOne += toL.get(i);
      }

      long sumTwo = 0;
      for (int i = 0; i < r - l + 1; i++){
        sumTwo += toR.get(i);
      }

      System.out.println(Math.min(sumTwo, sumOne));
      tests--;
    }
  }
}
Problem: 2063B - Subsequence Update
Language: Java 21


Submission (verdict: Wrong answer on test 8):
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class SubsequenceUpdate {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int tests = Integer.parseInt(scanner.nextLine());
    while (tests > 0){
      int n = scanner.nextInt();
      int l = scanner.nextInt();
      int r = scanner.nextInt();
      int[] arr = new int[n];
      for (int i = 0; i < arr.length; i++){
        arr[i] = scanner.nextInt();
      }

      ArrayList<Integer> toL = new ArrayList<>();
      ArrayList<Integer> toR = new ArrayList<>();
      for (int i = 0; i < r; i++){
        toR.add(arr[i]);
      }
      for (int i = l - 1; i < n; i++){
        toL.add(arr[i]);
      }

      Collections.sort(toL);
      Collections.sort(toR);

      int sumOne = 0;
      for (int i = 0; i < r - l + 1; i++){
        sumOne += toL.get(i);
      }

      int sumTwo = 0;
      for (int i = 0; i < r - l + 1; i++){
        sumTwo += toR.get(i);
      }

      System.out.println(Math.min(sumTwo, sumOne));
      tests--;
    }
  }
}