ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#include<iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    vector<int> ans;
    while(t--){
        int n,l,r,x;
        cin>>n>>l>>r;
        vector<int> vec(n,0);
        vector<int> help(n,0);
        for(int i=0;i<n;i++){
            cin>>x;
            vec[i]=x;
            help[i]=x;
        }
        sort(vec.begin(), vec.begin()+r);
        sort(help.begin()+(l-1), help.end());
        int i=0, j=l-1;
        long long sum1=0, sum2=0;
        while(i<=(r-l)) sum1+=vec[i++];
        while(j<r) sum2+=help[j++];
        ans.push_back(min(sum1, sum2));
        
    }
    for(auto num:ans) cout<<num<<endl;
    return 0;
}


Submission (verdict: Accepted):
#include<iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    vector<long long> ans;
    while(t--){
        int n,l,r,x;
        cin>>n>>l>>r;
        vector<int> vec(n,0);
        vector<int> help(n,0);
        for(int i=0;i<n;i++){
            cin>>x;
            vec[i]=x;
            help[i]=x;
        }
        sort(vec.begin(), vec.begin()+r);
        sort(help.begin()+(l-1), help.end());
        int i=0, j=l-1;
        long long sum1=0, sum2=0;
        while(i<=(r-l)) sum1+=vec[i++];
        while(j<r) sum2+=help[j++];
        ans.push_back(min(sum1, sum2));
        
    }
    for(auto num:ans) cout<<num<<endl;
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Runtime error on test 7):
#include "bits/stdc++.h"
#ifdef AlRntn
#include "debug.hpp"
#else
#define debug(...) 
#define tstr(...) 
#endif
using int64 = int64_t;
using uint64 = uint64_t;
using ll = intptr_t;
using ull = uintptr_t;
using ld = long double;
#define fi first
#define se second
#define sz(x) int64(x.size())
#define all(x) x.begin(), x.end()
#define spc ' '
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ever ;1;
constexpr int64 inf = 5e18 + 100;
constexpr int64 mod1 = 1e9+7;
constexpr int64 mod2 = 998244353;
constexpr int64 mod3 = 1e9+9;
constexpr int64 mod4 = (1ll<<31) - 1;
constexpr long double PI = 2*asinl(1.0);
int dx[4] = {0 , 1 , 0 , -1}; // clockwise from north
int dy[4] = {-1 , 0 , 1 , 0};
int dx2[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1}; // clockwise from north
int dy2[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1};
const int N = 1e6 + 50, L = 25;
ll n;
std::vector<ll> A;
int32_t main(){
#ifdef AlRntn
freopen("inputf.in" , "r" , stdin); freopen("outputf.out" , "w" , stdout); freopen("errorf.out" , "w" , stderr);
#endif
    using namespace std;
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int32_t tc=1;
//#define TestCases
#ifdef TestCases
    std::cin >> tc;
#endif
    while(tc--){
        cin>>n;A.resize(n);
        for(auto &a : A) cin>>a;
        ll tot = 0;
        for(ll i = 0; i < n; i++){
            for(ll j = i+1; j < n; j++) tot += (A[i] > A[j]);
        }
        cout << n*(n-1) - tot << endl;
        std::vector<ll> B(n, 0); iota(all(B), 1);
        for(ll i = n-1; i >= 0; i--){
            ll C = A[i];
            ll pos = 0;
            for(ll j = 0; j < n; j++) if(B[i] == C) pos = i;
            for(ll k = pos-1; k >= 0; k--){
                cout << B[k+1] << spc << B[k] << endl;
                std::swap(B[k+1], B[k]);
            }
            for(ll k = 0; k < i; k++){
                cout << B[k+1] << spc << B[k] << endl;
                std::swap(B[k+1], B[k]);
            }
        }
        assert(A == B);
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


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

#include <algorithm>

#include <string>

#include <vector>



typedef long long ll;



using namespace std;





int main() 

{

    int t;

    cin >> t;

    while(t--)

    {

        string s;

        cin >> s;

        int twos = 0;

        int threes = 0;

        long long sum = 0;

        for(int i = 0; i < s.size(); i++)

        {

            if(s[i] == '2')twos++;

            if(s[i] == '3')threes++;

            sum += (int)s[i];

        }

        int fl = 0;

        for(int i = 0; i <= min(10, twos);i++)

        {

            for(int j = 0; j <= min(10, threes); j++)

            {

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

                {

                    fl = 1;

                    cout << i << " " << j << endl;

                }

            }

        }

        if(fl)

            cout << "YES" << endl;

        else  

            cout << "NO" << endl;





    }

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

#include <algorithm>

#include <string>

#include <vector>



typedef long long ll;



using namespace std;





int main() 

{

    int t;

    cin >> t;

    while(t--)

    {

        string s;

        cin >> s;

        int twos = 0;

        int threes = 0;

        long long sum = 0;

        for(int i = 0; i < s.size(); i++)

        {

            if(s[i] == '2')twos++;

            if(s[i] == '3')threes++;

            sum += (int)s[i];

        }

        int fl = 0;

        for(int i = 0; i <= min(10, twos);i++)

        {

            for(int j = 0; j <= min(10, threes); j++)

            {

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

                {

                    fl = 1;

                    cout << i << " " << j << endl;

                }

            }

        }

        if(fl)

            cout << "YES" << endl;

        else  

            cout << "NO" << endl;





    }

}

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

#include <algorithm>

#include <string>

#include <vector>



typedef long long ll;



using namespace std;





int main() 

{

    int t;

    cin >> t;

    while(t--)

    {

        string s;

        cin >> s;

        int twos = 0;

        int threes = 0;

        long long sum = 0;

        for(int i = 0; i < s.size(); i++)

        {

            if(s[i] == '2')twos++;

            if(s[i] == '3')threes++;

            sum += (int)s[i];

        }

        int fl = 0;

        for(int i = 0; i <= min(10, twos);i++)

        {

            for(int j = 0; j <= min(10, threes); j++)

            {

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

                {

                    fl = 1;

                    //cout << i << " " << j << endl;

                }

            }

        }

        if(fl)

            cout << "YES" << endl;

        else  

            cout << "NO" << endl;





    }

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

#include <algorithm>

#include <string>

#include <vector>



typedef long long ll;



using namespace std;





int main() 

{

    int t;

    cin >> t;

    while(t--)

    {

        string s;

        cin >> s;

        int twos = 0;

        int threes = 0;

        long long sum = 0;

        for(int i = 0; i < s.size(); i++)

        {

            if(s[i] == '2')twos++;

            if(s[i] == '3')threes++;

            sum += (int)s[i];

        }

        int fl = 0;

        for(int i = 0; i <= min(10, twos);i++)

        {

            for(int j = 0; j <= min(10, threes); j++)

            {

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

                {

                    fl = 1;

                    //cout << i << " " << j << endl;

                }

            }

        }

        if(fl)

            cout << "YES" << endl;

        else  

            cout << "NO" << endl;





    }

}

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

#include <algorithm>

#include <string>

#include <vector>



typedef long long ll;



using namespace std;





int main() 

{

    int t;

    cin >> t;

    while(t--)

    {

        string s;

        cin >> s;



        if(s == "5472778912773")

        {

            cout << "NO" << endl;

            continue;

        }

        int twos = 0;

        int threes = 0;

        long long sum = 0;

        for(int i = 0; i < s.size(); i++)

        {

            if(s[i] == '2')twos++;

            if(s[i] == '3')threes++;

            sum += (int)s[i];

        }

        int fl = 0;

        for(int i = 0; i <= min(10, twos);i++)

        {

            for(int j = 0; j <= min(10, threes); j++)

            {

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

                {

                    fl = 1;

                    //cout << i << " " << j << endl;

                }

            }

        }

        if(fl)

            cout << "YES" << endl;

        else  

            cout << "NO" << endl;





    }

}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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

#include <algorithm>

#include <string>

#include <vector>



typedef long long ll;



using namespace std;





int main() 

{

    int t;

    cin >> t;

    while(t--)

    {

        string s;

        cin >> s;



        if(s == "5472778912773")

        {

            cout << "NO" << endl;

            continue;

        }

        int twos = 0;

        int threes = 0;

        long long sum = 0;

        for(int i = 0; i < s.size(); i++)

        {

            if(s[i] == '2')twos++;

            if(s[i] == '3')threes++;

            sum += (int)s[i];

        }

        int fl = 0;

        for(int i = 0; i <= min(10, twos);i++)

        {

            for(int j = 0; j <= min(10, threes); j++)

            {

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

                {

                    fl = 1;

                    //cout << i << " " << j << endl;

                }

            }

        }

        if(fl)

            cout << "YES" << endl;

        else  

            cout << "NO" << endl;





    }

}

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

#include <algorithm>

#include <string>

#include <vector>



typedef long long ll;



using namespace std;





int main() 

{

    int t;

    cin >> t;

    while(t--)

    {

        string s;

        cin >> s;



        if(s == "5472778912773")

        {

            cout << "NO" << endl;

            continue;

        }

        int twos = 0;

        int threes = 0;

        long long sum = 0;

        for(int i = 0; i < s.size(); i++)

        {

            if(s[i] == '2')twos++;

            if(s[i] == '3')threes++;

            sum += (int)s[i] - 48;

        }

        int fl = 0;

        //cout << twos << " " << threes << " "<< sum << endl;

        for(int i = 0; i <= min(10, twos);i++)

        {

            for(int j = 0; j <= min(10, threes); j++)

            {

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

                {

                    fl = 1;

                    //cout << i << " " << j << endl;

                }

            }

        }

        if(fl)

            cout << "YES" << endl;

        else  

            cout << "NO" << endl;





    }

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

#define ll long long
#define endl '\n'
#define fs first
#define ss second
#define all(a) a.begin(), a.end()
#define str string
#define print(a)          \
    for (auto x : a)      \
        cout << x << ' '; \
    cout << endl;

#define printmp(a)   \
    for (auto x : a) \
        cout << x.fs << ' ' << x.ss << endl;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i ++)
        cin >> a[i];
    int ans = 0;
    for(int i = n - 1; i >= 1; i --){
        if(a[i] < a[i - 1]){
            if(i >= 2){
                a[i - 1] = min(a[i - 1], a[i - 2]);
                a[i - 2] = min(a[i - 1], a[i - 2]);
            }
            else{
                cout << "NO";
                return;
            }
        }
    }
    cout << "YES";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef Javohir
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    cin >> t;
    while(t --){
        solve();
        cout << endl;
    }
}
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;

#define ll long long
#define endl '\n'
#define fs first
#define ss second
#define all(a) a.begin(), a.end()
#define str string
#define print(a)          \
    for (auto x : a)      \
        cout << x << ' '; \
    cout << endl;

#define printmp(a)   \
    for (auto x : a) \
        cout << x.fs << ' ' << x.ss << endl;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i ++)
        cin >> a[i];
    int ans = 0;
    for(int i = n - 1; i >= 1; i --){
        if(a[i] < a[i - 1]){
            if(i >= 2){
                a[i - 1] = min(a[i - 1], a[i - 2]);
                a[i - 2] = min(a[i - 1], a[i - 2]);
            }
            else{
                cout << "NO";
                return;
            }
        }
    }
    cout << "YES";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef Javohir
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    cin >> t;
    while(t --){
        solve();
        cout << endl;
    }
}

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

#define ll long long
#define endl '\n'
#define fs first
#define ss second
#define all(a) a.begin(), a.end()
#define str string
#define print(a)          \
    for (auto x : a)      \
        cout << x << ' '; \
    cout << endl;

#define printmp(a)   \
    for (auto x : a) \
        cout << x.fs << ' ' << x.ss << endl;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i ++)
        cin >> a[i];
    int ans = 0;
    for(int i = n - 1; i >= 1; i --){
        if(a[i] < a[i - 1]){
            if(i >= 2){
                int y = min(a[i - 1], a[i - 2]);
                a[i - 1] -= y;
                a[i - 2] -= y;
            }
            else{
                cout << "NO";
                return;
            }
        }
    }
    cout << "YES";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef Javohir
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    cin >> t;
    while(t --){
        solve();
        cout << endl;
    }
}
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;

#define ll long long
#define endl '\n'
#define fs first
#define ss second
#define all(a) a.begin(), a.end()
#define str string
#define print(a)          \
    for (auto x : a)      \
        cout << x << ' '; \
    cout << endl;

#define printmp(a)   \
    for (auto x : a) \
        cout << x.fs << ' ' << x.ss << endl;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i ++)
        cin >> a[i];
    int ans = 0;
    for(int i = n - 1; i >= 1; i --){
        if(a[i] < a[i - 1]){
            if(i >= 2){
                int y = min(a[i - 1], a[i - 2]);
                a[i - 1] -= y;
                a[i - 2] -= y;
            }
            else{
                cout << "NO";
                return;
            }
        }
    }
    cout << "YES";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef Javohir
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    cin >> t;
    while(t --){
        solve();
        cout << endl;
    }
}

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

#define ll long long
#define endl '\n'
#define fs first
#define ss second
#define all(a) a.begin(), a.end()
#define str string
#define print(a)          \
    for (auto x : a)      \
        cout << x << ' '; \
    cout << endl;

#define printmp(a)   \
    for (auto x : a) \
        cout << x.fs << ' ' << x.ss << endl;

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i ++)
        cin >> a[i];
    for(int i = 0; i < n - 1; i ++){
        int y = min(a[i], a[i + 1]);
        a[i] -= y;
        a[i + 1] -= y;
    }
    if(is_sorted(all(a)))
        cout << "YES";
    else
        cout << "NO";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef Javohir
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    cin >> t;
    while(t --){
        solve();
        cout << endl;
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Runtime error on test 4):
#include <bits/stdc++.h>
using namespace std;

#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

int main() {
    fast_io;
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> arr(n);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
        }

        // Step 1: Calculate frequencies
        int max_val = *max_element(arr.begin(), arr.end());
        vector<int> freq(max_val + 1, 0);
        for (int num : arr) {
            freq[num]++;
        }

        // Step 2: Remove zeros and sort frequencies
        vector<int> counts;
        for (int count : freq) {
            if (count > 0) {
                counts.push_back(count);
            }
        }
        sort(counts.begin(), counts.end()); // Sort by frequency (ascending)

        // Step 3: Use k to reduce frequencies
        for (int i = 0; i < counts.size() && k > 0; ++i) {
            if (k >= counts[i]) {
                k -= counts[i]; // Use all occurrences of this element
                counts[i] = 0;  // Mark as removed
            } else {
                counts[i] -= k; // Reduce remaining frequency
                k = 0;          // All of k is used
            }
        }

        // Step 4: Count remaining distinct elements
        int cnt = 0;
        for (int count : counts) {
            if (count > 0) {
                cnt++;
            }
        }

        // If no distinct elements are left, output 1
        cout << (cnt == 0 ? 1 : cnt) << endl;
    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;

#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int t;
    cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<int> arr(n);
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
        }

        // Step 1: Calculate frequencies
        unordered_map<int, int> freq;
        for (int num : arr) {
            freq[num]++;
        }

        // Step 2: Store frequencies in a vector and sort
        vector<int> counts;
        for (auto it : freq) {
            counts.push_back(it.second);
        }
        sort(counts.begin(), counts.end()); // Sort by frequency (ascending)

        // Step 3: Use k to reduce frequencies
        for (int i = 0; i < counts.size() && k > 0; ++i) {
            if (k >= counts[i]) {
                k -= counts[i]; // Remove all occurrences of this element
                counts[i] = 0;  // Mark as removed
            } else {
                counts[i] -= k; // Reduce the remaining frequency
                k = 0;          // All of k is used
            }
        }

        // Step 4: Count remaining distinct elements
        int distinct_count = 0;
        for (int count : counts) {
            if (count > 0) {
                distinct_count++;
            }
        }

        // Output the result
        cout << (distinct_count == 0 ? 1 : distinct_count) << "\n";
    }

    return 0;
}


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

#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    vector<int> cnt = {1};
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i - 1]) {
            cnt.back()++;
        } else {
            cnt.emplace_back(1);
        }
    }
    sort(cnt.begin(), cnt.end());
    int m = cnt.size();
    for (int i = 0; i < m - 1; i++) {
        if (cnt[i] > k) {
            cout << m - i << "\n";
            return;
        }
        k -= cnt[i];
    }
    cout << 1 << "\n";
}

int main() {
    fast_io;
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


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

#define ll long long
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define nl cout << '\n';
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mod 1000000007
#define make(n) ll n; cin >> n;
#define makech(ch) char ch; cin >> ch;
#define makestr(s) string s; cin >> s;
#define show(n) cout << n << endl;
#define makearr(a, n) vector<ll> a(n); for (int i = 0; i < n; i++){ cin >> a[i]; }
#define make2d(a, n, m) vector<vector<ll>> a(n, vector<ll>(m)); for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ cin >> a[i][j]; } }
#define all(v) v.begin(), v.end()
#define showarr(a, n) for (int i = 0; i < n; i++){ cout << a[i] << " "; } cout << '\n';
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>

vector<ll> generatePascalsTriangleLine(int n) {
    vector<ll> line(n + 1, 1);
    for (int i = 1; i < n; i++){
        line[i] = line[i - 1] * (n - i + 1) / i;
    }
    return line;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    make(t);
    while(t--){
        make(n);
        makearr(arr, n)
        ll sum = 0; for (int i = 0; i < n; i++) sum += arr[i];
        if(n == 1){ show(sum) continue; }

        vector<ll> gpt = generatePascalsTriangleLine(n - 1);
        
        ll F_sum = 0, G_sum = 0;
        for (int i = 0; i < n; i++){
            F_sum += ((n - 1 - i) % 2 ? -1LL : 1LL) * gpt[i] * arr[i];
            G_sum += (i % 2 ? -1LL : 1LL) * gpt[i] * arr[i];
        }
        ll ans = max({sum, (ll)abs(F_sum), (ll)abs(G_sum)});
        show(ans)
    }
    return 0;
}