ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int main() {

    int t;

    cin >> t;



    while (t--) {

        int n, l, r;

        cin >> n >> l >> r;



        vector<int> a(n);

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

            cin >> a[i];

        }

        l--;

        r--;



        vector<int> v(a.begin() + l, a.begin() + r + 1);



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



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

            a[l + i] = v[i];

        }



        int result = 0;

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

            result += a[i];

        }



        cout << result << endl;

    }



    return 0;

}



Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;





int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);



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

        }



        int start = l - 1;

        int end = r;



        vector<int> a(v.begin() + start, v.begin() + end);

        vector<int> b;

        b.insert(b.end(), v.begin(), v.begin() + start);

        b.insert(b.end(), v.begin() + end, v.end());



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

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



        long long sum = 0;

        for (int x : a) {

            sum += x;

        }



        long long mx = 0;

       

        int i = 0;

        while (i < a.size() && i < b.size()) {

            if (a[i] > b[i]) {

                mx += a[i] - b[i];

                i++;

            }

            else {

                break;

            }

        }



        cout << sum - mx << "\n";

    }



    return 0;

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

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;





int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);



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

        }



        int start = l - 1;

        int end = r;



        vector<int> a(v.begin() + start, v.begin() + end);

        vector<int> b;

        b.insert(b.end(), v.begin(), v.begin() + start);

        b.insert(b.end(), v.begin() + end, v.end());



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

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



        long long sum = 0;

        for (int x : a) {

            sum += x;

        }



        long long mx = 0;

       

        int i = 0;

        while (i < a.size() && i < b.size()) {

            if (a[i] > b[i]) {

                mx += a[i] - b[i];

                i++;

            }

            else {

                break;

            }

        }



        cout << sum - mx << "\n";

    }



    return 0;

}



Submission (verdict: Accepted):
#include <iostream>

#include <vector>

#include <algorithm>



using namespace std;



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);



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

        }



        l--; r--;



        vector<int> a(v.begin(), v.begin() + r + 1);

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

        long long sum1 = 0;

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

            sum1 += a[i];

        }



        vector<int> b(v.begin() + l, v.end());

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

        long long sum2 = 0;

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

            sum2 += b[i];

        }



        cout << min(sum1, sum2) << "\n";

    }



    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;   
using ld = long double;
using db = double;
#define fi first
#define se second
#define uw upper_bound
#define lw lower_bound
#define see setprecision
#define memaybeo main       
#define sigma return 0;
#define en "\n";
#define hackspeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ld pi = atan(1.0L)*4;
const ll inf = 9e18 + 9e16;
const ll mmb = 1e18;
const int  mod  = 1e9 +7; // 998244535  123456789  

void skibidi()
{
	string s;int tong =0 , d2 =0 , d3 =0 ;
	cin >> s;
	
	for(int i=0 ; i<s.length() ; ++i)
	{
		tong+= s[i] - '0';
		if(s[i] - '0' == 2)++d2;
		if(s[i] - '0' == 3)++d3;
	} 
	int k = tong % 9 ;
	if(k == 0)
	{
		cout << "YES" << en;
		return;
	}
	k = 9-k;
	vector<int> ud3(d3+2);
	for(int i =0 ; i<=d3; ++i)
	{
		ud3[i] = (6*i) % 9;
	}
	sort(ud3.begin() ,  ud3.begin() + d3 + 1);
	for(int i =0 ; i<=d2; ++i)
	{
		int hi = (2*i) % 9;
		hi = k- hi;
		int kk = *lower_bound(ud3.begin() , ud3.begin() + d3 + 1 , hi );
		if(kk == hi)
		{
			cout << "YES" << en;
			return;
		}
	}
	cout <<"NO" << en;
}



signed memaybeo(){
	hackspeed
	//freopen(".INP" , "r" , stdin);
	//freopen(".OUT"  , "w" , stdout);
	int t ; cin >>t;
	while(t--)
		skibidi(); 
	sigma
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;   
using ld = long double;
using db = double;
#define fi first
#define se second
#define uw upper_bound
#define lw lower_bound
#define see setprecision
#define memaybeo main       
#define sigma return 0;
#define en "\n";
#define hackspeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ld pi = atan(1.0L)*4;
const ll inf = 9e18 + 9e16;
const ll mmb = 1e18;
const int  mod  = 1e9 +7; // 998244535  123456789  

void skibidi()
{
	string s;int tong =0 , d2 =0 , d3 =0 ;
	cin >> s;
	
	for(int i=0 ; i<s.length() ; ++i)
	{
		tong+= s[i] - '0';
		if(s[i] - '0' == 2)++d2;
		if(s[i] - '0' == 3)++d3;
	} 
	int k = tong % 9 ;
	if(k == 0)
	{
		cout << "YES" << en;
		return;
	}
	int newk = 9-k;
	vector<int> ud3(d3+1);
	for(int i =0 ; i<=d3; ++i)
	{
		ud3[i] = (6*i) % 9;
	}
	sort(ud3.begin() ,  ud3.end());
	for(int i =0 ; i<=d2; ++i)
	{
		int hi = (2*i) % 9;
		int newhi = newk - hi;
		int kk = *lower_bound(ud3.begin() , ud3.end(), newhi );
		if(kk == newhi)
		{
			cout << "YES" << en;
			return;
		}
	}
	cout <<"NO" << en;
}



signed memaybeo(){
	hackspeed
	//freopen(".INP" , "r" , stdin);
	//freopen(".OUT"  , "w" , stdout);
	int t ; cin >>t;
	while(t--)
		skibidi(); 
	sigma
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;   
using ld = long double;
using db = double;
#define fi first
#define se second
#define uw upper_bound
#define lw lower_bound
#define see setprecision
#define memaybeo main       
#define sigma return 0;
#define en "\n";
#define hackspeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ld pi = atan(1.0L)*4;
const ll inf = 9e18 + 9e16;
const ll mmb = 1e18;
const int  mod  = 1e9 +7; // 998244535  123456789  

void skibidi()
{
	string s;int tong =0 , d2 =0 , d3 =0 ;
	cin >> s;
	
	for(int i=0 ; i<s.length() ; ++i)
	{
		tong+= s[i] - '0';
		if(s[i] - '0' == 2)++d2;
		if(s[i] - '0' == 3)++d3;
	} 
	//cout << d2 << " " << d3 << en;
 	int k = tong % 9 ;
	if(k == 0)
	{
		cout << "YES" << en;
		return;
	}
	k = 9-k;
	vector<int> ud3(d3+2);
	for(int i =0 ; i<=d3; ++i)
	{
		ud3[i] = (6*i) % 9;
	//	cout << ud3[i] << en;
	}
	sort(ud3.begin() ,  ud3.begin() + d3 + 1);
	for(int i =0 ; i<=d2; ++i)
	{
		int hi = (2*i) % 9;
		hi = k - hi;
		if(hi < 0) hi+=9;
		int kk = *lower_bound(ud3.begin() , ud3.begin() + d3 + 1 , hi );
		if(kk == hi)
		{
			cout << "YES" << en;
			return;
		}
	}
	cout <<"NO" << en;
}



signed memaybeo(){
	hackspeed
	//freopen(".INP" , "r" , stdin);
	//freopen(".OUT"  , "w" , stdout);
	int t ; cin >>t;
	while(t--)
		skibidi(); 
	sigma
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;   
using ld = long double;
using db = double;
#define fi first
#define se second
#define uw upper_bound
#define lw lower_bound
#define see setprecision
#define memaybeo main       
#define sigma return 0;
#define en "\n";
#define hackspeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ld pi = atan(1.0L)*4;
const ll inf = 9e18 + 9e16;
const ll mmb = 1e18;
const int  mod  = 1e9 +7; // 998244535  123456789  

void skibidi()
{
	string s;int tong =0 , d2 =0 , d3 =0 ;
	cin >> s;
	
	for(int i=0 ; i<s.length() ; ++i)
	{
		tong+= s[i] - '0';
		if(s[i] - '0' == 2)++d2;
		if(s[i] - '0' == 3)++d3;
	} 
	int k = tong % 9 ;
	if(k == 0)
	{
		cout << "YES" << en;
		return;
	}
	k = 9-k;
	vector<int> ud3(d3+2);
	for(int i =0 ; i<=d3; ++i)
	{
		ud3[i] = (6*i) % 9;
	}
	sort(ud3.begin() ,  ud3.begin() + d3 + 1);
	for(int i =0 ; i<=d2; ++i)
	{
		int hi = (2*i) % 9;
		hi = k- hi;
		int kk = *lower_bound(ud3.begin() , ud3.begin() + d3 + 1 , hi );
		if(kk == hi)
		{
			cout << "YES" << en;
			return;
		}
	}
	cout <<"NO" << en;
}



signed memaybeo(){
	hackspeed
	//freopen(".INP" , "r" , stdin);
	//freopen(".OUT"  , "w" , stdout);
	int t ; cin >>t;
	while(t--)
		skibidi(); 
	sigma
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;   
using ld = long double;
using db = double;
#define fi first
#define se second
#define uw upper_bound
#define lw lower_bound
#define see setprecision
#define memaybeo main       
#define sigma return 0;
#define en "\n";
#define hackspeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ld pi = atan(1.0L)*4;
const ll inf = 9e18 + 9e16;
const ll mmb = 1e18;
const int  mod  = 1e9 +7; // 998244535  123456789  

void skibidi()
{
	string s;int tong =0 , d2 =0 , d3 =0 ;
	cin >> s;
	
	for(int i=0 ; i<s.length() ; ++i)
	{
		tong+= s[i] - '0';
		if(s[i] - '0' == 2)++d2;
		if(s[i] - '0' == 3)++d3;
	} 
	int k = tong % 9 ;
	if(k == 0)
	{
		cout << "YES" << en;
		return;
	}
	int newk = 9-k;
	vector<int> ud3(d3+1);
	for(int i =0 ; i<=d3; ++i)
	{
		ud3[i] = (6*i) % 9;
	}
	sort(ud3.begin() ,  ud3.end());
	for(int i =0 ; i<=d2; ++i)
	{
		int hi = (2*i) % 9;
		int newhi = newk - hi;
		int kk = *lower_bound(ud3.begin() , ud3.end(), newhi );
		if(kk == newhi)
		{
			cout << "YES" << en;
			return;
		}
	}
	cout <<"NO" << en;
}



signed memaybeo(){
	hackspeed
	//freopen(".INP" , "r" , stdin);
	//freopen(".OUT"  , "w" , stdout);
	int t ; cin >>t;
	while(t--)
		skibidi(); 
	sigma
}
Problem: 2057C - Trip to the Olympiad
Language: Java 8

Previous submission (verdict: Wrong answer on test 1):
import java.util.*;
public class triptotheolympiad {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for(int testCase = 0; testCase < t; testCase++){
            long l = sc.nextLong();
            long r = sc.nextLong();

            String lBinary = Long.toBinaryString(l);
            String rBinary = Long.toBinaryString(r);

            int bit = -1;
            if(lBinary.length() < rBinary.length()){
                bit = rBinary.length() - 1;
            }else{
                for(int i = 0; i < rBinary.length(); i++){
                    if(lBinary.charAt(i) == rBinary.charAt(i)){
                        continue;
                    }else{
                        bit = i;
                        break;
                    }
                }
            }
            //System.out.println("BIT: " + bit);

            long val = (long) Math.pow(2, bit);
            long firstNumber = (r / val) * val;

            long secondNumber = firstNumber - 1;
            long thirdNumber = 0;
            if(firstNumber == r){
                thirdNumber = r - 2;
            }else{
                thirdNumber = r;
            }

            System.out.println(firstNumber + " " + secondNumber + " " + thirdNumber);
        }

    }
}


Submission (verdict: Accepted):
import java.util.*;
public class triptotheolympiad {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for(int testCase = 0; testCase < t; testCase++){
            long l = sc.nextLong();
            long r = sc.nextLong();

            String lBinary = Long.toBinaryString(l);
            String rBinary = Long.toBinaryString(r);

            int bit = -1;
            if(lBinary.length() < rBinary.length()){
                bit = rBinary.length() - 1;
            }else{
                //System.out.println(lBinary + " " + rBinary);
                for(int i = 0; i < rBinary.length(); i++){
                    if(lBinary.charAt(i) == rBinary.charAt(i)){
                        continue;
                    }else{
                        bit = rBinary.length() - i - 1;
                        break;
                    }
                }
            }

            long val = (long) Math.pow(2, bit);
            long firstNumber = (r / val) * val;

            long secondNumber = firstNumber - 1;
            long thirdNumber = 0;
            if(firstNumber == r){
                thirdNumber = r - 2;
            }else{
                thirdNumber = r;
            }

            System.out.println(firstNumber + " " + secondNumber + " " + thirdNumber);
        }

    }
}
Problem: 2057C - Trip to the Olympiad
Language: Java 8

Previous submission (verdict: Wrong answer on test 1):
import java.util.*;
public class triptotheolympiad {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for(int testCase = 0; testCase < t; testCase++){
            long l = sc.nextLong();
            long r = sc.nextLong();

            String lBinary = Long.toBinaryString(l);
            String rBinary = Long.toBinaryString(r);

            int bit = -1;
            if(lBinary.length() < rBinary.length()){
                bit = rBinary.length() - 1;
            }else{
                for(int i = 0; i < rBinary.length(); i++){
                    if(lBinary.charAt(i) == rBinary.charAt(i)){
                        continue;
                    }else{
                        bit = i;
                        break;
                    }
                }
            }
            //System.out.println("BIT: " + bit);

            long val = (long) Math.pow(2, bit);
            long firstNumber = (l / val + 1) * val;

            long secondNumber = firstNumber - 1;
            long thirdNumber = 0;
            if(firstNumber == r){
                thirdNumber = r - 2;
            }else{
                thirdNumber = r;
            }

            System.out.println(firstNumber + " " + secondNumber + " " + thirdNumber);
        }

    }
}


Submission (verdict: Wrong answer on test 1):
import java.util.*;
public class triptotheolympiad {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for(int testCase = 0; testCase < t; testCase++){
            long l = sc.nextLong();
            long r = sc.nextLong();

            String lBinary = Long.toBinaryString(l);
            String rBinary = Long.toBinaryString(r);

            int bit = -1;
            if(lBinary.length() < rBinary.length()){
                bit = rBinary.length() - 1;
            }else{
                for(int i = 0; i < rBinary.length(); i++){
                    if(lBinary.charAt(i) == rBinary.charAt(i)){
                        continue;
                    }else{
                        bit = i;
                        break;
                    }
                }
            }
            //System.out.println("BIT: " + bit);

            long val = (long) Math.pow(2, bit);
            long firstNumber = (r / val) * val;

            long secondNumber = firstNumber - 1;
            long thirdNumber = 0;
            if(firstNumber == r){
                thirdNumber = r - 2;
            }else{
                thirdNumber = r;
            }

            System.out.println(firstNumber + " " + secondNumber + " " + thirdNumber);
        }

    }
}
Problem: 2057C - Trip to the Olympiad
Language: Java 8


Submission (verdict: Wrong answer on test 1):
import java.util.*;
public class triptotheolympiad {
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for(int testCase = 0; testCase < t; testCase++){
            long l = sc.nextLong();
            long r = sc.nextLong();

            String lBinary = Long.toBinaryString(l);
            String rBinary = Long.toBinaryString(r);

            int bit = -1;
            if(lBinary.length() < rBinary.length()){
                bit = rBinary.length() - 1;
            }else{
                for(int i = 0; i < rBinary.length(); i++){
                    if(lBinary.charAt(i) == rBinary.charAt(i)){
                        continue;
                    }else{
                        bit = i;
                        break;
                    }
                }
            }
            //System.out.println("BIT: " + bit);

            long val = (long) Math.pow(2, bit);
            long firstNumber = (l / val + 1) * val;

            long secondNumber = firstNumber - 1;
            long thirdNumber = 0;
            if(firstNumber == r){
                thirdNumber = r - 2;
            }else{
                thirdNumber = r;
            }

            System.out.println(firstNumber + " " + secondNumber + " " + thirdNumber);
        }

    }
}
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
from itertools import accumulate, pairwise
import math
import bisect
import heapq
from collections import Counter, defaultdict
from functools import cache
def solve():
    n, l, r = map(int, input().split())
    arr = [int(x) for x in input().split()]
    # 1 1 2 1 
    if l == 1 or r == n or r - l == 0:
        arr.sort()
        print(sum(arr[: r - l + 1]))
    else:
        # keep one element from arr[l: r] and r - l elements of smallest
        mn = math.inf
        idx = -1
        for i in range(l - 1, r):
            if arr[i] < mn:
                mn = arr[i]
                idx = i
        other = arr[:i] + arr[i + 1:]
        other.sort()
        print(mn + sum(other[: r - l]))
for _ in range(int(input())):
    solve()

Submission (verdict: Accepted):
from itertools import accumulate, pairwise
import math
import bisect
import heapq
from collections import Counter, defaultdict
from functools import cache
def solve():
    n, l, r = map(int, input().split())
    arr = [int(x) for x in input().split()]
    # 
    if l == 1 or r == n or r - l == 0:
        arr.sort()
        print(sum(arr[: r - l + 1]))
    else:
        first = arr[:r]
        second = arr[l - 1:]
        first.sort()
        second.sort()
        print(min(sum(first[: r - l + 1]), sum(second[: r - l + 1])))
for _ in range(int(input())):
    solve()
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
from itertools import accumulate, pairwise

import math

import bisect

import heapq

from collections import Counter, defaultdict

from functools import cache

def solve():

    n, l, r = map(int, input().split())

    arr = [int(x) for x in input().split()]

    # 2 2 1 1 

    if l == 1 or r == n:

        arr.sort()

        print(sum(arr[: r - l + 1]))

    else:

        # keep one element from arr[l: r] and r - l elements of smallest

        mn = math.inf

        idx = -1

        for i in range(l - 1, r):

            if arr[i] < mn:

                mn = arr[i]

                idx = i

        other = arr[:i] + arr[i + 1:]

        other.sort()

        print(mn + sum(other[: r- l]))

for _ in range(int(input())):

    solve()

Submission (verdict: Wrong answer on test 2):
from itertools import accumulate, pairwise

import math

import bisect

import heapq

from collections import Counter, defaultdict

from functools import cache

def solve():

    n, l, r = map(int, input().split())

    arr = [int(x) for x in input().split()]

    # 2 1 2 1 

    if l == 1 or r == n or r - l == 1:

        arr.sort()

        print(sum(arr[: r - l + 1]))

    else:

        # keep one element from arr[l: r] and r - l elements of smallest

        mn = math.inf

        idx = -1

        for i in range(l - 1, r):

            if arr[i] < mn:

                mn = arr[i]

                idx = i

        other = arr[:i] + arr[i + 1:]

        other.sort()

        print(mn + sum(other[: r- l]))

for _ in range(int(input())):

    solve()
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
from itertools import accumulate, pairwise

import math

import bisect

import heapq

from collections import Counter, defaultdict

from functools import cache

def solve():

    n, l, r = map(int, input().split())

    arr = [int(x) for x in input().split()]

    arr.sort()

    print(sum(arr[: r - l + 1]))

for _ in range(int(input())):

    solve()

Submission (verdict: Wrong answer on test 2):
from itertools import accumulate, pairwise

import math

import bisect

import heapq

from collections import Counter, defaultdict

from functools import cache

def solve():

    n, l, r = map(int, input().split())

    arr = [int(x) for x in input().split()]

    # 2 2 1 1 

    if l == 1 or r == n:

        arr.sort()

        print(sum(arr[: r - l + 1]))

    else:

        # keep one element from arr[l: r] and r - l elements of smallest

        mn = math.inf

        idx = -1

        for i in range(l - 1, r):

            if arr[i] < mn:

                mn = arr[i]

                idx = i

        other = arr[:i] + arr[i + 1:]

        other.sort()

        print(mn + sum(other[: r- l]))

for _ in range(int(input())):

    solve()
Problem: 2063B - Subsequence Update
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
from itertools import accumulate, pairwise

import math

import bisect

import heapq

from collections import Counter, defaultdict

from functools import cache

def solve():

    n, l, r = map(int, input().split())

    arr = [int(x) for x in input().split()]

    arr.sort()

    print(sum(arr[: r - l + 1]))

for _ in range(int(input())):

    solve()