ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <vector>

//#include <bits/stdc++.h>

using namespace std;

#define int long long

#define INF __builtin_inf()

#define endl '\n'

#define couthi cout <<'h'<<'i'<<endl;

#define hi(i) cout <<'h'<<'i'<<i<<endl;

#define vin(a) for(auto&XX:a)cin>>XX;

#define vout(v) for (auto XX: v)cout<<XX<<' ';cout<<endl;

#define ignore_kroo_ise ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);



//-------------------------------------------------------------------------------------------------



void solve() 

{

    string s;

    cin >> s;

    int n=s.length();

    vector<char> word;

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

        word.push_back(s[i]);

    }

    vector<char> answer;

    while (n){

        int max=0;

        int maxi=0;

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

            if(word[i]-i>max){max=word[i]-i; maxi=i;}

        }

        answer.push_back(word[maxi]-maxi);

        word.erase(word.begin()+maxi);

        n--;

    }

    vout(answer);

    cout << endl;

}



int32_t main()

{

    ignore_kroo_ise

    int t = 1;

    cin >> t;

    int answers[t];

    while (t--)

    {

        solve();

    }

    return 0;

}

Submission (verdict: Time limit exceeded on test 6):
#include <iostream>

#include <vector>

//#include <bits/stdc++.h>

using namespace std;

#define int long long

#define INF __builtin_inf()

#define endl '\n'

#define couthi cout <<'h'<<'i'<<endl;

#define hi(i) cout <<'h'<<'i'<<i<<endl;

#define vin(a) for(auto&XX:a)cin>>XX;

#define vout(v) for (auto XX: v)cout<<XX;cout<<endl;

#define ignore_kroo_ise ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);



//-------------------------------------------------------------------------------------------------



void solve() 

{

    string s;

    cin >> s;

    int n=s.length();

    vector<char> word;

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

        word.push_back(s[i]);

    }

    vector<char> answer;

    while (n){

        int max=0;

        int maxi=0;

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

            if(word[i]-i>max){max=word[i]-i; maxi=i;}

        }

        answer.push_back(word[maxi]-maxi);

        word.erase(word.begin()+maxi);

        n--;

    }

    vout(answer);

}



int32_t main()

{

    ignore_kroo_ise

    int t = 1;

    cin >> t;

    int answers[t];

    while (t--)

    {

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

#define endl '\n'

typedef long long ll;

using namespace std;



void sol() {

    ll n;

    cin >> n;

    ll a[n];

    for (ll i = 0; i < n; i++) cin >> a[i];

    for (ll i = 0; i < n; i += 2) if (a[i] > a[i + 1]) {

        cout << "NO" << endl;

        return;

    }

    cout << "YES" << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    #ifdef NGUYEN_PHUC_LOC

    freopen(".INP", "r", stdin);

    freopen(".OUT", "w", stdout);

    #endif



    ll t = 1;

    cin >> t;

    while (t--) {

        sol();

    }



    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

#define endl '\n'

typedef long long ll;

using namespace std;



void sol() {

    ll n;

    cin >> n;

    ll a[n];

    for (ll i = 0; i < n; i++) cin >> a[i];

    for (ll i = 0; i + 1 < n; i += 2) if (a[i] > a[i + 1]) {

        cout << "NO" << endl;

        return;

    }

    cout << "YES" << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    #ifdef NGUYEN_PHUC_LOC

    freopen(".INP", "r", stdin);

    freopen(".OUT", "w", stdout);

    #endif



    ll t = 1;

    cin >> t;

    while (t--) {

        sol();

    }



    return 0;

}

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

#define endl '\n'

typedef long long ll;

using namespace std;



void sol() {

    ll n;

    cin >> n;

    ll a[n];

    for (ll i = 0; i < n; i++) cin >> a[i];

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

        if (a[i] > a[i + 1]) {

            cout << "NO" << endl;

            return;

        }

        a[i + 1] -= a[i];

    }

    cout << "YES" << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    #ifdef NGUYEN_PHUC_LOC

    freopen(".INP", "r", stdin);

    freopen(".OUT", "w", stdout);

    #endif



    ll t = 1;

    cin >> t;

    while (t--) {

        sol();

    }



    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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

#define endl '\n'

typedef long long ll;

using namespace std;



void sol() {

    ll n;

    cin >> n;

    ll a[n];

    for (ll i = 0; i < n; i++) cin >> a[i];

    for (ll i = 0; i < n; i += 2) if (a[i] > a[i + 1]) {

        cout << "NO" << endl;

        return;

    }

    cout << "YES" << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    #ifdef NGUYEN_PHUC_LOC

    freopen(".INP", "r", stdin);

    freopen(".OUT", "w", stdout);

    #endif



    ll t = 1;

    cin >> t;

    while (t--) {

        sol();

    }



    return 0;

}

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

#define endl '\n'

typedef long long ll;

using namespace std;



void sol() {

    ll n;

    cin >> n;

    ll a[n];

    for (ll i = 0; i < n; i++) cin >> a[i];

    for (ll i = 0; i + 1 < n; i += 2) if (a[i] > a[i + 1]) {

        cout << "NO" << endl;

        return;

    }

    cout << "YES" << endl;

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    #ifdef NGUYEN_PHUC_LOC

    freopen(".INP", "r", stdin);

    freopen(".OUT", "w", stdout);

    #endif



    ll t = 1;

    cin >> t;

    while (t--) {

        sol();

    }



    return 0;

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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fix(x) fixed<<setprecision(x)
#define int long long
#define endl '\n' 
using namespace std;
using vei = vector<int>;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;

void solve() 
{
    int n;cin>>n;
    auto a=vei(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    vector<pii>f;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(a[j]<a[j+1])
            {
                swap(a[j],a[j+1]);
                f.push_back({a[j],a[j+1]});
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(a[j]>a[j+1])
            {
                swap(a[j],a[j+1]);
                f.push_back({a[j],a[j+1]});
            }
        }
    }
    reverse(f.begin(),f.end());
    cout<<f.size()<<'\n';
    for(auto [x,y]:f) cout<<x<<" "<<y<<"\n";

}
signed main() 
{
    IOS;

    int _ = 1; //cin >> _;
    while (_--) solve();
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fix(x) fixed<<setprecision(x)
#define int long long
#define endl '\n' 
using namespace std;
using vei = vector<int>;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;

void solve() 
{
    int n;cin>>n;
    auto a=vei(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    vector<pii>f;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(a[j]<a[j+1])
            {
                swap(a[j],a[j+1]);
                f.push_back({a[j],a[j+1]});
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(a[j]>a[j+1])
            {
                swap(a[j],a[j+1]);
                f.push_back({a[j],a[j+1]});
            }
        }
    }
    reverse(f.begin(),f.end());
    cout<<f.size()<<'\n';
    for(auto [x,y]:f) cout<<y<<" "<<x<<"\n";

}
signed main() 
{
    IOS;

    int _ = 1; //cin >> _;
    while (_--) 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 IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fix(x) fixed<<setprecision(x)
#define int long long
#define endl '\n' 
using namespace std;
using vei = vector<int>;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;

void solve() 
{
    int n;cin>>n;
    vei a(n+1) ;
    for(int i=1;i<=n;i++) cin>>a[i];
    vector<pii>f;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(a[i]<a[j])
            {
                f.push_back({a[j],a[i]});
                f.push_back({a[i],a[j]});
            }
            else 
            {
                f.push_back({a[i],a[j]});
            }
        }
    }
    cout<<f.size()<<'\n';
    for(auto [x,y]:f) cout<<x<<" "<<y<<'\n';



}
signed main() 
{
    IOS;

    int _ = 1; //cin >> _;
    while (_--) 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 IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fix(x) fixed<<setprecision(x)
#define int long long
#define endl '\n' 
using namespace std;
using vei = vector<int>;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;

void solve() 
{
    int n;cin>>n;
    vei a(n+1) ;
    for(int i=1;i<=n;i++) cin>>a[i];
    vector<pii>f;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            if(a[i]<a[j])
            {
                f.push_back({a[j],a[i]});
                f.push_back({a[i],a[j]});
            }
            else 
            {
                f.push_back({a[i],a[j]});
            }
        }
    }
    cout<<f.size()<<'\n';
    for(auto [x,y]:f) cout<<x<<" "<<y<<'\n';



}
signed main() 
{
    IOS;

    int _ = 1; //cin >> _;
    while (_--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fix(x) fixed<<setprecision(x)
#define int long long
#define endl '\n' 
using namespace std;
using vei = vector<int>;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;

void solve() 
{
    int n;cin>>n;
    auto a=vei(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];
    vector<pii>f;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(a[j]<a[j+1])
            {
                swap(a[j],a[j+1]);
                f.push_back({a[j],a[j+1]});
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(a[j]>a[j+1])
            {
                swap(a[j],a[j+1]);
                f.push_back({a[j],a[j+1]});
            }
        }
    }
    reverse(f.begin(),f.end());
    cout<<f.size()<<'\n';
    for(auto [x,y]:f) cout<<x<<" "<<y<<"\n";

}
signed main() 
{
    IOS;

    int _ = 1; //cin >> _;
    while (_--) solve();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
// 7075009e-9a07-4be3-84c5-db1170f928e7
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    while(t--){
        int n, m;
        cin >> n >> m;
        
        vector<long long> a(n);
        for(auto &x : a) cin >> x;
        
        vector<long long> b(m);
        for(auto &x : b) cin >> x;
        
        // Sort both arrays
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        
        bool possible = true;
        long long running_sum = 0;
        int idx_a = 0;
        int idx_b = 0;
        
        while(idx_b < m){
            // Start a new sum to match b[idx_b]
            running_sum = 0;
            bool matched = false;
            
            while(idx_a < n){
                running_sum += a[idx_a];
                idx_a++;
                
                if(running_sum == b[idx_b]){
                    // Successfully matched one b
                    matched = true;
                    break;
                }
                else if(running_sum > b[idx_b]){
                    // If running sum exceeds b[idx_b], it's impossible
                    possible = false;
                    break;
                }
            }
            
            if(!matched){
                possible = false;
                break;
            }
            idx_b++;
        }
        
        if(idx_a < n){
            possible = false;
        }
        
        if(possible){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
}

Submission (verdict: Wrong answer on test 1):
// 8df9be4d-120c-4dba-9209-7e129489d3f5
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        
        // Read array a
        vector<long long> a(n);
        for(int i = 0; i < n; ++i) cin >> a[i];
        
        // Read array b
        vector<long long> b(m);
        for(int i = 0; i < m; ++i) cin >> b[i];
        
        // Calculate frequency of each number in a and b
        map<long long, int> freq_a, freq_b;
        long long sum_a = 0, sum_b = 0;
        
        for(auto x : a){
            freq_a[x]++;
            sum_a += x;
        }
        for(auto x : b){
            freq_b[x]++;
            sum_b += x;
        }
        
        // First check: parity of sum_a and sum_b
        bool ok = (sum_a % 2 == sum_b % 2);
        
        // Second check: frequency of each element in b should be <= frequency in a
        if(ok){
            for(auto &[x, cnt_b] : freq_b){
                if(freq_a[x] < cnt_b){
                    ok = false;
                    break;
                }
            }
        }
        
        if(ok){
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
// 8df9be4d-120c-4dba-9209-7e129489d3f5
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t;
    cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        
        // Read array a
        vector<long long> a(n);
        for(int i = 0; i < n; ++i) cin >> a[i];
        
        // Read array b
        vector<long long> b(m);
        for(int i = 0; i < m; ++i) cin >> b[i];
        
        // Calculate frequency of each number in a and b
        map<long long, int> freq_a, freq_b;
        long long sum_a = 0, sum_b = 0;
        
        for(auto x : a){
            freq_a[x]++;
            sum_a += x;
        }
        for(auto x : b){
            freq_b[x]++;
            sum_b += x;
        }
        
        // First check: parity of sum_a and sum_b
        bool ok = (sum_a % 2 == sum_b % 2);
        
        // Second check: frequency of each element in b should be <= frequency in a
        if(ok){
            for(auto &[x, cnt_b] : freq_b){
                if(freq_a[x] < cnt_b){
                    ok = false;
                    break;
                }
            }
        }
        
        if(ok){
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        int n, m; cin >> n >> m;
        priority_queue<int> a, b;
        for (int i = 0; i < n; ++i) {
            int x; cin >> x;
            a.push(x);
        }
        for (int i = 0; i < m; ++i) {
            int x; cin >> x;
            b.push(x);
        }
        int times = n - m;
        bool can = true;
        while (times && !a.empty()) {
            if (a.top() == b.top()) {
                a.pop();
                b.pop();
                continue;
            }
            else if (a.top() < b.top()) {
                int aux = b.top();
                b.pop();
                b.push((aux + 1) / 2);
                b.push(aux / 2);
                times--;
            }
            else {
                can = false;
                break;
            }
        }
        if (!can) {
            cout << "NO\n";
            continue;
        }
        if (a.size() == b.size()) {
            while (!a.empty()) {
                if (a.top() == b.top()) a.pop(), b.pop();
                else {
                    can = false;
                    break;
                }
            }
            cout << (can ? "YES" : "NO") << "\n";
        }
        else {
            cout << "NO\n";
        }
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        int n, m; cin >> n >> m;
        priority_queue<int> a, b;
        for (int i = 0; i < n; ++i) {
            int x; cin >> x;
            a.push(x);
        }
        for (int i = 0; i < m; ++i) {
            int x; cin >> x;
            b.push(x);
        }
        int times = n - m;
        bool can = true;
        while (times && !a.empty()) {
            if (a.top() == b.top()) {
                a.pop();
                b.pop();
                continue;
            }
            else if (a.top() < b.top()) {
                int aux = b.top();
                b.pop();
                b.push((aux + 1) / 2);
                b.push(aux / 2);
                times--;
            }
            else {
                can = false;
                break;
            }
        }
        if (!can) {
            cout << "NO\n";
            continue;
        }
        if (a.size() == b.size()) {
            while (!a.empty()) {
                if (a.top() == b.top()) a.pop(), b.pop();
                else {
                    can = false;
                    break;
                }
            }
            cout << (can ? "YES" : "NO") << "\n";
        }
        else {
            cout << "NO\n";
        }
    }
    return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        int n, m; cin >> n >> m;
        priority_queue<int> a, b;
        for (int i = 0; i < n; ++i) {
            int x; cin >> x;
            a.push(x);
        }
        for (int i = 0; i < m; ++i) {
            int x; cin >> x;
            b.push(x);
        }
        int times = n - m;
        bool can = true;
        while (times && !a.empty() && !b.empty()) {
            if (a.top() == b.top()) {
                a.pop();
                b.pop();
                continue;
            }
            else if (a.top() < b.top()) {
                int aux = b.top();
                b.pop();
                b.push((aux + 1) / 2);
                b.push(aux / 2);
                times--;
            }
            else {
                can = false;
                break;
            }
        }
        if (!can) {
            cout << "NO\n";
            continue;
        }
        if (a.size() == b.size()) {
            while (!a.empty()) {
                if (a.top() == b.top()) a.pop(), b.pop();
                else {
                    can = false;
                    break;
                }
            }
            cout << (can ? "YES" : "NO") << "\n";
        }
        else {
            cout << "NO\n";
        }
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
// 7075009e-9a07-4be3-84c5-db1170f928e7
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    
    while(t--){
        int n, m;
        cin >> n >> m;
        
        vector<long long> a(n);
        for(auto &x : a) cin >> x;
        
        vector<long long> b(m);
        for(auto &x : b) cin >> x;
        
        // Sort both arrays
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        
        bool possible = true;
        long long running_sum = 0;
        int idx_a = 0;
        int idx_b = 0;
        
        while(idx_b < m){
            // Start a new sum to match b[idx_b]
            running_sum = 0;
            bool matched = false;
            
            while(idx_a < n){
                running_sum += a[idx_a];
                idx_a++;
                
                if(running_sum == b[idx_b]){
                    // Successfully matched one b
                    matched = true;
                    break;
                }
                else if(running_sum > b[idx_b]){
                    // If running sum exceeds b[idx_b], it's impossible
                    possible = false;
                    break;
                }
            }
            
            if(!matched){
                possible = false;
                break;
            }
            idx_b++;
        }
        
        if(idx_a < n){
            possible = false;
        }
        
        if(possible){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
    }
}