ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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


void solve()
{
   int n;
   cin >> n;

   vector<long> a(n);
   for(auto &x:a) cin >> x;

   if(n==1)
   {
    cout << a[0] << endl;
    return;
   }
    int ans = accumulate(a.begin(),a.end(),0LL);
    vector<long> b = a;
   while(b.size()>1)
   {
    vector<long> temp;
    for(int i=1;i<b.size();i++)
    {
        temp.push_back(b[i] - b[i-1]);
    }
    b = temp;
   }

   cout << max(1LL*ans,1LL*abs(b[0])) << endl;

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

    while(t--)
    {
        solve();
    }
}

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


void solve()
{
   int n;
   cin >> n;

   vector<int> a(n);
   for(auto &x:a) cin >> x;

   if(n==1)
   {
    cout << a[0] << endl;
    return;
   }
    int ans = accumulate(a.begin(),a.end(),0LL);
    vector<int> b = a;
   while(b.size()>1)
   {
    vector<int> temp;
    for(int i=1;i<b.size();i++)
    {
        temp.push_back(b[i] - b[i-1]);
    }
    b = temp;
   }

   cout << max(ans,abs(b[0])) << endl;

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

    while(t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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


void solve()
{
   int n;
   cin >> n;

   vector<int> a(n);
   for(auto &x:a) cin >> x;

   if(n==1)
   {
    cout << a[0] << endl;
    return;
   }
    int ans = accumulate(a.begin(),a.end(),0LL);
    vector<int> b = a;
   while(b.size()>1)
   {
    vector<int> temp;
    for(int i=1;i<b.size();i++)
    {
        temp.push_back(b[i] - b[i-1]);
    }
    b = temp;
   }

   cout << max(ans,abs(b[0])) << endl;

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

    while(t--)
    {
        solve();
    }
}

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


void solve()
{
   int n;
   cin >> n;

   vector<long long> a(n);
   for(auto &x:a) cin >> x;

   if(n==1)
   {
    cout << a[0] << endl;
    return;
   }
    long long ans = accumulate(a.begin(),a.end(),0LL);
    vector<long long> b = a;
   while(b.size()>1)
   {
    vector<long long> temp;
    for(int i=1;i<b.size();i++)
    {
        temp.push_back(b[i] - b[i-1]);
    }
    b = temp;
   }

   cout << max(ans,abs(b[0])) << endl;

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

    while(t--)
    {
        solve();
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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


void solve()
{
   int n;
   cin >> n;

   vector<long long> a(n);
   for(auto &x:a) cin >> x;

   if(n==1)
   {
    cout << a[0] << endl;
    return;
   }
    long long ans = accumulate(a.begin(),a.end(),0LL);
    vector<long long> b = a;
   while(b.size()>1)
   {
    vector<long long> temp;
    for(int i=1;i<b.size();i++)
    {
        temp.push_back(b[i] - b[i-1]);
    }
    b = temp;
   }

   cout << max(ans,abs(b[0])) << endl;

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

    while(t--)
    {
        solve();
    }
}

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


void solve()
{
   int n;
   cin >> n;

   vector<long long> a(n);
   for(auto &x:a) cin >> x;

   if(n==1)
   {
    cout << a[0] << endl;
    return;
   }
    long long ans = accumulate(a.begin(),a.end(),0LL);
    vector<long long> b = a;
   while(b.size()>1)
   {
    vector<long long> temp;
    for(int i=1;i<b.size();i++)
    {
        temp.push_back(b[i] - b[i-1]);
    }
    long long t = accumulate(temp.begin(),temp.end(),0LL);
    ans = max(ans,abs(t));
    b = temp;
   }

//    cout << max(ans,abs(b[0])) << endl;
cout << ans << endl;

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

    while(t--)
    {
        solve();
    }
}
Problem: 2050D - Digital string maximization
Language: Java 8

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

public class D_2050 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        while(n-->0){
            String s=sc.nextLine();
            String res=modified(s);
            System.out.println(res);
        }
    }
    public static String modified(String s){
        int n=s.length();
        char[] arr=s.toCharArray();
        for(int i=n-1;i>0;i--){
            if(arr[i]>'0' && arr[i]-1>arr[i-1]){
                arr[i]--;
                char temp=arr[i];
                arr[i]=arr[i-1];
                arr[i-1]=temp;
            }
        }
        return new String(arr);
    }
}


Submission (verdict: Time limit exceeded on test 6):
import java.util.Scanner;

public class D_2050 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        sc.nextLine(); // Consume newline
        while (t-- > 0) {
            String s = sc.nextLine();
            String res = maximizeString(s);
            System.out.println(res);
        }
    }

    public static String maximizeString(String s) {
        int n = s.length();
        char[] arr = s.toCharArray();
        for (int i = n - 1; i > 0; i--) {
            // If the current digit is greater than 0 and greater than the previous digit
            if (arr[i] > '0' && arr[i] - 1 > arr[i - 1]) {
                // Decrease the current digit
                arr[i]--;
                // Swap with the previous digit to maximize lexicographical order
                char temp = arr[i];
                arr[i] = arr[i - 1];
                arr[i - 1] = temp;
                i=n;
            }
        }
        
        return new String(arr);
    }
}
Problem: 2050D - Digital string maximization
Language: Java 8


Submission (verdict: Wrong answer on test 1):
import java.util.Scanner;

public class D_2050 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        while(n-->0){
            String s=sc.nextLine();
            String res=modified(s);
            System.out.println(res);
        }
    }
    public static String modified(String s){
        int n=s.length();
        char[] arr=s.toCharArray();
        for(int i=n-1;i>0;i--){
            if(arr[i]>'0' && arr[i]-1>arr[i-1]){
                arr[i]--;
                char temp=arr[i];
                arr[i]=arr[i-1];
                arr[i-1]=temp;
            }
        }
        return new String(arr);
    }
}
Problem: 2050D - Digital string maximization
Language: Java 8

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

public class D_2050 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            String s = sc.nextLine();
            char[] arr = s.toCharArray();
            int swapcount = 1;
            int ans = 0;
            while (swapcount != 0) {
                int sw = 0;
                for (int i = 1; i < arr.length; i++) {
                    char a = (char) (arr[i] - 1);
                    char b = arr[i - 1];
                    if ((arr[i] != '1' || arr[i] != '0') && a - b > 0) {
                        if (arr[i] > arr[i - 1]) {
                            swap(i - 1, i, arr);
                            sw++;
                        }
                    }
                }

                if (sw == 0) {
                    break;
                }
            }
            System.out.println(new String(arr));
        }
    }

    public static void swap(int i, int j, char[] arr) {
        arr[j] = (char) (arr[j] - 1);
        char t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
    }
}

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

public class D_2050 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        sc.nextLine();
        while (t-- > 0) {
            String s = sc.nextLine();
            char[] arr = s.toCharArray();
            int swapcount = 1;
            int ans = 0;
            while (swapcount != 0) {
                int sw = 0;
                for (int i = 1; i < arr.length; i++) {
                    char a = (char) (arr[i] - 1);
                    char b = arr[i - 1];
                    if ((arr[i] != '1' || arr[i] != '0') && a - b > 0) {
                        if (arr[i] > arr[i - 1]) {
                            swap(i - 1, i, arr);
                            sw++;
                        }
                    }
                }

                if (sw == 0) {
                    break;
                }
            }
            System.out.println(new String(arr));
        }
    }

    public static void swap(int i, int j, char[] arr) {
        arr[j] = (char) (arr[j] - 1);
        char t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
    }
}
Problem: 2050D - Digital string maximization
Language: Java 8

Previous submission (verdict: Time limit exceeded on test 6):
import java.util.Scanner;

public class D_2050 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        sc.nextLine(); // Consume newline
        while (t-- > 0) {
            String s = sc.nextLine();
            String res = maximizeString(s);
            System.out.println(res);
        }
    }

    public static String maximizeString(String s) {
        int n = s.length();
        char[] arr = s.toCharArray();
        for (int i = n - 1; i > 0; i--) {
            // If the current digit is greater than 0 and greater than the previous digit
            if (arr[i] > '0' && arr[i] - 1 > arr[i - 1]) {
                // Decrease the current digit
                arr[i]--;
                // Swap with the previous digit to maximize lexicographical order
                char temp = arr[i];
                arr[i] = arr[i - 1];
                arr[i - 1] = temp;
                i=n;
            }
        }
        
        return new String(arr);
    }
}



Submission (verdict: Wrong answer on test 1):
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        sc.nextLine(); // Consume the newline after integer input
        
        StringBuilder result = new StringBuilder();
        
        while (t-- > 0) {
            String s = sc.nextLine();
            char[] arr = s.toCharArray();
            boolean swapped = true;

            while (swapped) {
                swapped = false; // Reset swapped flag
                for (int i = arr.length - 1; i > 0; i--) {
                    // If the current digit is not 0, it's not the first digit, and swapping improves the order
                    if (arr[i] > '0' && arr[i] > arr[i - 1]) {
                        arr[i]--; // Decrease the current digit
                        char temp = arr[i];
                        arr[i] = arr[i - 1];
                        arr[i - 1] = temp; // Perform the swap
                        swapped = true; // Indicate a swap occurred
                    }
                }
            }
            result.append(new String(arr)).append("\n");
        }
        
        System.out.print(result); // Output all results at once for efficiency
    }
}
Problem: 2050D - Digital string maximization
Language: Java 8

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        sc.nextLine(); // Consume the newline after integer input
        
        StringBuilder result = new StringBuilder();
        
        while (t-- > 0) {
            String s = sc.nextLine();
            char[] arr = s.toCharArray();
            boolean swapped = true;

            while (swapped) {
                swapped = false; // Reset swapped flag
                for (int i = arr.length - 1; i > 0; i--) {
                    // If the current digit is not 0, it's not the first digit, and swapping improves the order
                    if (arr[i] > '0' && arr[i] > arr[i - 1]) {
                        arr[i]--; // Decrease the current digit
                        char temp = arr[i];
                        arr[i] = arr[i - 1];
                        arr[i - 1] = temp; // Perform the swap
                        swapped = true; // Indicate a swap occurred
                    }
                }
            }
            result.append(new String(arr)).append("\n");
        }
        
        System.out.print(result); // Output all results at once for efficiency
    }
}


Submission (verdict: Wrong answer on test 1):
import java.util.Scanner;

public class D_2050 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            String s = sc.nextLine();
            char[] arr = s.toCharArray();
            int swapcount = 1;
            int ans = 0;
            while (swapcount != 0) {
                int sw = 0;
                for (int i = 1; i < arr.length; i++) {
                    char a = (char) (arr[i] - 1);
                    char b = arr[i - 1];
                    if ((arr[i] != '1' || arr[i] != '0') && a - b > 0) {
                        if (arr[i] > arr[i - 1]) {
                            swap(i - 1, i, arr);
                            sw++;
                        }
                    }
                }

                if (sw == 0) {
                    break;
                }
            }
            System.out.println(new String(arr));
        }
    }

    public static void swap(int i, int j, char[] arr) {
        arr[j] = (char) (arr[j] - 1);
        char t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
    }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;



// Yash Raj 2112047

#define ll long long

#define ld long double

#define pb push_back

#define mp make_pair

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

#define rall(v) (v).rbegin(), (v).rend()

#define sz(x) (int)(x).size()

#define F first

#define S second

#define endl '\n'



// Fast Input/Output

void fast_io() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

}



// Debugging (for personal use during development)

#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;

template <typename T> void _print(T x) { cerr << x; }

template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }

template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }



int main() {

    fast_io(); // Ensures fast input/output

    

    ll t;

    cin >> t; // Multiple test cases

    while (t--) {

        

        ll n;

        cin >> n;

        ll two = 0, three = 0, sum = 0;

        

        ll temp = n;

        while (temp > 0) {

            ll digit = temp % 10;

            sum += digit;

            if (digit == 2) two++;

            if (digit == 3) three++;

            temp /= 10;

        }

        

        if (sum % 9 == 0) {

            cout << "YES" << endl;

            continue;

        }



        bool flag = false;

        for (ll i = 0; i <= min(two, 10LL); i++) {

            for (ll j = 0; j <= min(three, 10LL); j++) {

                if ((sum + i * 2 + j * 6) % 9 == 0) {

                    cout << "YES" << endl;

                    flag = true;

                    break;

                }

            }

            if (flag) break;

        }



        if (!flag) cout << "NO" << endl;



    }



    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

// Yash Raj 2112047
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

// Fast Input/Output
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

// Debugging (for personal use during development)
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
template <typename T> void _print(T x) { cerr << x; }
template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }
template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

int main() {
    fast_io(); // Ensures fast input/output
    
    int t;
    cin >> t; // Multiple test cases
    while (t--) {
        
        int n;
        cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }

        int j=0;
        for(int i=0; i<n-1; i++){
            if(arr[i]>arr[i+1]){
                j = i;
            }
        }

        if(j==0){
            cout<<"YES\n";
        }else{
            for(int i=0; i<j; i++){
                int minN = min(arr[i], arr[i+1]);
                arr[i]-=minN;
                arr[i+1]-=minN;
            }
            cout<<(is_sorted(arr.begin(), arr.end())?"YES":"NO")<<'\n';
        }
    }

    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

// Yash Raj 2112047
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

// Fast Input/Output
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

// Debugging (for personal use during development)
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
template <typename T> void _print(T x) { cerr << x; }
template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }
template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

int main() {
    fast_io(); // Ensures fast input/output
    
    int t;
    cin >> t; // Multiple test cases
    while (t--) {
        
        int n;
        cin >> n;
        vector<int> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }

        int j=0;
        for(int i=0; i<n-1; i++){
            if(arr[i]>arr[i+1]){
                j = i;
            }
        }

        if(j==0){
            cout<<"YES\n";
            continue;
        }
        for(int i=0; i<j; i++){
            int minN = min(arr[i], arr[i+1]);
            arr[i]-=minN;
            arr[i+1]-=minN;
        }
        cout<<(is_sorted(arr.begin(), arr.end())?"YES":"NO")<<'\n';
        
    }

    return 0;
}

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

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    for (ll &x : a) cin >> x;
    
    for (ll i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            cout << "NO\n";
            return;
        }
        a[i + 1] -= a[i];
        a[i] = 0;
    }
    
    cout << "YES\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll T;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}
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;

// Yash Raj 2112047
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second

// Fast Input/Output
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

// Debugging (for personal use during development)
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
template <typename T> void _print(T x) { cerr << x; }
template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }
template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }

int main() {
    fast_io(); // Ensures fast input/output
    
    int t;
    cin >> t; // Multiple test cases
    while (t--) {
        
        ll n, l, r;
        cin >> n>>l>>r;
        vector<ll> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        sort(arr.begin(), arr.end());
        int sum = 0, sum2=0, sum3=0;
        
        // for(int i=0; i<r; i++)
        //     sum += arr[i];
        for(int i=0; i<r-l+1; i++)
            sum3 += arr[i];
        // for(int i=l; i<n; i++)
        //     sum2+= arr[i];
        
        cout<<sum3 << "\n";
    }

    return 0;
}

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

using namespace std;



// Yash Raj 2112047

#define ll long long

#define ld long double

#define pb push_back

#define mp make_pair

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

#define rall(v) (v).rbegin(), (v).rend()

#define sz(x) (int)(x).size()

#define F first

#define S second



// Fast Input/Output

void fast_io() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

}



// Debugging (for personal use during development)

#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;

template <typename T> void _print(T x) { cerr << x; }

template <typename T, typename V> void _print(pair<T, V> p) { cerr << "{" << p.F << "," << p.S << "}"; }

template <typename T> void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }



int main() {

    fast_io(); // Ensures fast input/output

    

    int t;

    cin >> t; // Multiple test cases

    while (t--) {

        

        ll n, l, r;

        cin >> n>>l>>r;

        --l;

        vector<ll> arr(n);

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

            cin >> arr[i];

        }

        vector<ll>b = arr;

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

        vector<ll>c = arr;

        sort(c.begin(), c.begin()+r, greater<int>());

        ll sum1 = accumulate(b.begin()+l, b.begin()+r, 0LL);

        ll sum2 = accumulate(c.begin()+l, c.begin()+r, 0LL);

        

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

    }



    return 0;

}