ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
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
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        string res = s;

        // cout << n << endl;
        for (int i = 0; i < n; i++)
        {
            int k = -1;
            for (int j = i + 1; j < n; j++)
            {
                if (res[j] - j > res[i] - i and res[j] - j >= '0' and res[j] - j <= '9')
                {
                    if (k == -1)
                    {
                        k = j;
                        // cout << "Here " << s[k] << endl;
                    }
                    else if (k != -1 and res[j] - j > res[k] - k)
                    {
                        k = j;
                        // cout << "There " << s[k] << endl;
                    }
                }
            }
            if (k != -1)
            {
                res[k] = res[k] - k + i;
                string temp = res.substr(0, i);
                temp.push_back(res[k]);
                for (int p = i; p < n; p++)
                {
                    if (p == k)
                        continue;
                    temp.push_back(res[p]);
                }
                res = temp;
            }

            // cout << i << " " << k << " " << res << endl;
        }
        cout << res << endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        string res = s;

        // cout << n << endl;
        for (int i = 0; i < n; i++)
        {
            int k = -1;
            for (int j = i + 1; j < n; j++)
            {
                if (res[j] - j > res[i] - i and res[j] - j >= '0' and res[j] - j <= '9')
                {
                    if (k == -1)
                    {
                        k = j;
                        // cout << "Here " << s[k] << endl;
                    }
                    else if (k != -1 and res[j] - j > res[k] - k)
                    {
                        k = j;
                        // cout << "There " << s[k] << endl;
                    }
                }
            }
            if (k != -1)
            {
                res[k] = res[k] - k + i;
                string temp = res.substr(0, i);
                temp.push_back(res[k]);
                for (int p = i; p < n; p++)
                {
                    if (p == k)
                        continue;
                    temp.push_back(res[p]);
                }
                res = temp;
            }

            // cout << i << " " << k << " " << res << endl;
        }
        cout << res << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        string res = s;

        // cout << n << endl;
        for (int i = 0; i < n; i++)
        {
            int k = -1;
            for (int j = i + 1; j < n; j++)
            {
                if (res[j] - j > res[i] - i and res[j] - j >= '0' and res[j] - j <= '9')
                {
                    if (k == -1)
                    {
                        k = j;
                        // cout << "Here " << s[k] << endl;
                    }
                    else if (k != -1 and res[j] - j > res[k] - k)
                    {
                        k = j;
                        // cout << "There " << s[k] << endl;
                    }
                }
            }
            if (k != -1)
            {
                res[k] = res[k] - k + i;
                while (k > i)
                {
                    swap(res[k], res[k - 1]);
                    k--;
                }
            }

            // cout << i << " " << k << " " << res << endl;
        }
        cout << res << endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        string res = s;

        // cout << n << endl;
        for (int i = 0; i < n; i++)
        {
            int k = -1;
            // cout << res[i] << endl;
            for (int j = i + 1; j < n; j++)
            {
                // cout << "ta " << res[i] << " " << res[j] << endl;
                if (res[j] + i - j > res[i] and res[j] - j + i >= '0' and res[j] - j + i <= '9')
                {
                    if (k == -1)
                    {
                        k = j;
                        // cout << "Here " << res[k] << endl;
                    }
                    else if (k != -1 and res[j] - j > res[k] - k)
                    {
                        k = j;
                        // cout << "There " << res[k] << endl;
                    }
                }
            }
            // cout << i << " " << k << " ";
            if (k != -1)
            {
                res[k] = res[k] - k + i;
                while (k > i)
                {
                    swap(res[k], res[k - 1]);
                    k--;
                }
            }
            // cout << res << endl;
        }
        cout << res << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        string res = s;

        // cout << n << endl;
        for (int i = 0; i < n; i++)
        {
            int k = -1;
            // cout << res[i] << endl;
            for (int j = i + 1; j < min(i + 10, n); j++)
            {
                // cout << "ta " << res[i] << " " << res[j] << endl;
                if (res[j] + i - j > res[i] and res[j] - j + i >= '0' and res[j] - j + i <= '9')
                {
                    if (k == -1)
                    {
                        k = j;
                        // cout << "Here " << res[k] << endl;
                    }
                    else if (k != -1 and res[j] - j > res[k] - k)
                    {
                        k = j;
                        // cout << "There " << res[k] << endl;
                    }
                }
            }
            // cout << i << " " << k << " ";
            if (k != -1)
            {
                res[k] = res[k] - k + i;
                while (k > i)
                {
                    swap(res[k], res[k - 1]);
                    k--;
                }
            }
            // cout << res << endl;
        }
        cout << res << endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    for(int i = 1 ; i < n ; i++){
        if(a[i] < a[i-1]){
            if(i == 1){
                cout << "NO" << endl;
                return;
            }
            else{
                if(a[i-2] == 0){
                    cout << "NO" << endl;
                    return;
                }
                a[i-1] -= a[i-2];
                a[i-2] = 0;
            }
        }
    }
    cout << "YES" << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    for(int i = 1 ; i < n ; i++){
        if(a[i] < a[i-1]){
            if(i == 1){
                cout << "NO" << endl;
                return;
            }
            else{
                if(a[i-2] == 0){
                    cout << "NO" << endl;
                    return;
                }
                a[i-1] -= a[i-2];
                a[i-2] = 0;
                if(a[i] < a[i-1]){
                    cout << "NO" << endl;
                    return;
                }
            }
        }
    }
    cout <<(is_sorted(all(a))? "YES" :"NO")<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}

Submission (verdict: Wrong answer on test 2):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    int pos = 0;
    for(int i = 1 ; i < n ; i++){
        if(a[i] < a[i-1]){
            if(i == 1){
                cout << "NO" << endl;
                return;
            }
            else{
                if(a[pos] == 0){
                    cout << "NO" << endl;
                    return;
                }
                while(pos != i - 1){
                    a[pos + 1] -= a[pos];
                    a[pos] = 0;
                    pos ++;
                }
                if(a[i] < a[i-1]){
                    cout << "NO" << endl;
                    return;
                }
            }
        }
    }
    cout << "YES" << endl;
    // for(int x : a) cout << x <<" ";
    // cout <<(is_sorted(all(a))? "YES" :"NO")<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    for(int i = 1 ; i < n ; i++){
        if(a[i] < a[i-1]){
            if(i == 1){
                cout << "NO" << endl;
                return;
            }
            else{
                if(a[i-2] == 0){
                    cout << "NO" << endl;
                    return;
                }
                a[i-1] -= a[i-2];
                a[i-2] = 0;
                if(a[i] < a[i-1]){
                    cout << "NO" << endl;
                    return;
                }
            }
        }
    }
    cout << "YES" << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}

Submission (verdict: Wrong answer on test 1):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    for(int i = 1 ; i < n ; i++){
        if(a[i] < a[i-1]){
            if(i == 1){
                cout << "NO" << endl;
                return;
            }
            else{
                if(a[i-2] == 0){
                    cout << "NO" << endl;
                    return;
                }
                a[i-1] -= a[i-2];
                a[i-2] = 0;
                if(a[i] < a[i-1]){
                    cout << "NO" << endl;
                    return;
                }
            }
        }
    }
    cout <<(is_sorted(all(a))? "YES" :"NO")<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    for(int i = 1 ; i < n ; i++){
        if(a[i] < a[i-1]){
            if(i == 1){
                cout << "NO" << endl;
                return;
            }
            else{
                if(a[i-2] == 0){
                    cout << "NO" << endl;
                    return;
                }
                a[i-1] -= a[i-2];
                a[i-2] = 0;
            }
        }
    }
    cout << "YES" << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}

Submission (verdict: Wrong answer on test 2):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    for(int i = 1 ; i < n ; i++){
        if(a[i] < a[i-1]){
            if(i == 1){
                cout << "NO" << endl;
                return;
            }
            else{
                if(a[i-2] == 0){
                    cout << "NO" << endl;
                    return;
                }
                a[i-1] -= a[i-2];
                a[i-2] = 0;
                if(a[i] < a[i-1]){
                    cout << "NO" << endl;
                    return;
                }
            }
        }
    }
    cout << "YES" << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    int pos = 0;
    for(int i = 1 ; i < n ; i++){
        if(a[i] < a[i-1]){
            if(i == 1){
                cout << "NO" << endl;
                return;
            }
            else{
                if(a[pos] == 0){
                    cout << "NO" << endl;
                    return;
                }
                while(pos != i - 1){
                    a[pos + 1] -= a[pos];
                    a[pos] = 0;
                    pos ++;
                }
                if(a[i] < a[i-1]){
                    cout << "NO" << endl;
                    return;
                }
            }
        }
    }
    cout << "YES" << endl;
    // for(int x : a) cout << x <<" ";
    // cout <<(is_sorted(all(a))? "YES" :"NO")<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}

Submission (verdict: Accepted):
/* Truong Nhat Nguyen */

#include <bits/stdc++.h>

#define endl '\n'
#define f0(i, n) for (int i = 0; i < n; ++i)
#define f1(i, n) for (int i = 1; i <= n; ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define setpr(x) cout << setprecision(x) << fixed
#define MOD 1000000007
#define ll long long
// #define int long long
const long long INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int>a(n);
    f0(i,n) cin >> a[i];
    f0(i,n-1){
        int min_val = min(a[i],a[i+1]);
        a[i] -= min_val;
        a[i+1] -= min_val;
    }
    f0(i,n-1){
        if(a[i] > a[i+1]){
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int TC;
    cin >> TC;
    while (TC--)
    {
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>

using i64 = int64_t;

using namespace std;











void solve(){

    int n;

    cin>>n;

    int zxc=0

    cin>>zxc;

    int ok=1;

    for(int x,i=2;i<=n;++i){

        cin>>x;

        if(zxc>x)ok=0;

        zxc=x-zxc;

    }

    if(ok)cout<<"Yes"<<"\n";

    else cout<<"No"<<"\n";

}





int main() {

	int t;

	cin>>t;

	while(t--){

	    solve();

	}

}



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

using i64 = int64_t;

using namespace std;











void solve(){

    int n;

    cin>>n;

    int zxc=0;

    cin>>zxc;

    int ok=1;

    for(int x,i=2;i<=n;++i){

        cin>>x;

        if(zxc>x)ok=0;

        zxc=x-zxc;

    }

    if(ok)cout<<"Yes"<<"\n";

    else cout<<"No"<<"\n";

}





int main() {

	int t;

	cin>>t;

	while(t--){

	    solve();

	}

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


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

using i64 = int64_t;

using namespace std;













void solve(){

    int n;

    cin>>n;

    vector<i64>a(n+1);

    i64 zxc=0;

    for(int i=1;i<=n;++i){cin>>a[i];zxc=max(zxc,a[i]);};

    if(a[1]==zxc){

        cout<<"No"<<"\n";

        return;

    }else

        cout<<"Yes"<<"\n";

    

}





int main() {

	int t;

	cin>>t;

	while(t--){

	    solve();

	}

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using i64 = int64_t;

using namespace std;













void solve(){

    int n;

    cin>>n;

    vector<i64>a(n+1);

    i64 zxc=0;

    for(int i=1;i<=n;++i){cin>>a[i];zxc=max(zxc,a[i]);};

    if(a[1]==zxc){

        cout<<"No"<<"\n";

        return;

    }else

        cout<<"Yes"<<"\n";

    

}





int main() {

	int t;

	cin>>t;

	while(t--){

	    solve();

	}

}



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

using i64 = int64_t;

using namespace std;











void solve(){

    int n;

    cin>>n;

    int zxc=0

    cin>>zxc;

    int ok=1;

    for(int x,i=2;i<=n;++i){

        cin>>x;

        if(zxc>x)ok=0;

        zxc=x-zxc;

    }

    if(ok)cout<<"Yes"<<"\n";

    else cout<<"No"<<"\n";

}





int main() {

	int t;

	cin>>t;

	while(t--){

	    solve();

	}

}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 5):
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define ll long long
#define fr(i,a,b) for (ll i = a; i < b; i++)
#define fr1(i,a,b) for (ll i = a-1; i>=b; i--)
#define fi first
#define se second
#define mp(j, k) make_pair(j, k)
#define pb(x) push_back(x)
#define in(x) insert(x)
#define vec vector<ll>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define ac 1000000007;
#define fauto(a) for(auto i:a) cout<<i<<" ";
#define fautop(a) for(auto i:a) cout<<i.fi<<" "<<i.se<<endl;
using namespace std;
bool comp(vec a,vec b){
  return a[1]>b[1];
}

ll dp[1010][1010];

void solve(){
ll n; cin>>n;
vec v(n+1);
for(ll i=1;i<=n;i++){cin>>v[i];}
vec a(n+1);
fr(i,1,n+1){a[i]=i;}
vector<pair<ll,ll>> p;
set<pair<ll,ll>> m;
for(ll i=n;i>=1;i--){
    ll l=v[i];
     for(ll j=l-1;j>=1;j--){
    if(m.find({l,j})==m.end() && l!=j){
        m.insert({l,j});
        p.push_back({l,j});

    }}
    for(ll j=1;j<=i;j++){
        if(m.find({v[j],l})==m.end() && v[j]!=l){
    
        m.insert({v[j],l});
         p.push_back({v[j],l});
         }
    }


}
cout<<m.size()<<endl;
// reverse(all(p));
for(auto x:p){
    cout<<x.fi<<" "<<x.se<<endl;
}



}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // ll tc;
    // cin >> tc;
    // while (tc--) {
        solve();
    // }
    
}