ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) {
        cin>>v[i];
    }
    vector<pi>ans;
    for(ll i=n-1;i>=0;i--) {
        for(ll j=i+1;j<n;j++) {
            if(v[i]<v[j]) {
                ans.push_back(pi(v[i],v[j]));
                ans.push_back(pi(v[j],v[i]));
            }
            else {
                ans.push_back(pi(v[i],v[j]));
            }
        }
    }
reverse(ans.begin(),ans.end());

cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n+1);
    map<ll,ll> mp;
    for(ll i=1;i<=n;i++) {
        cin>>v[i];
        mp[v[i]]=i;
    }
    vector<pi>ans;
   for(int i=n;i>=1;i--) {
       for(int j=i-1;j>=1;j--) {
           ans.emplace_back(i,j);
       }
       for(int j=i+1;j<=n;j++) {
           if(mp[i]<mp[j]) {
               ans.emplace_back(i,j);
           }
       }
   }

cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int x[]={0,0,-1,1};
int y[]={-1,1,0,0};
char dir[]={'L','R','U','D'};
using pi = pair<ll,ll>;

void fast() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
   ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) {
        cin>>v[i];
    }
    vector<pi>ans;
    for(ll i=0;i<n;i++) {
        for(ll j=i+1;j<n;j++) {
            if(v[i]>v[j]) {
                ans.push_back(pi(v[i],v[j]));
            }
            else {
                ans.push_back(pi(v[j],v[i]));
                ans.push_back(pi(v[i],v[j]));
            }
        }
    }


cout<<ans.size()<<endl;
    for(ll i=0;i<ans.size();i++) {
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }

}


int main() {
    fast();

    int T = 1;
 // cin >> T;
    while (T--) {
        solve();

    }
    return 0;
}
Problem: 2063B - Subsequence Update
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
#define int ll
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ed '\n'

void files()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> a(n);

    for (auto &i:a) cin >>i;
    int ans = 0;
    sort(all(a));
    int range = r-l+1;
    for(int i = 0 ; i<range ; i++)ans+=a[i];
    // int ans = accumulate(a.begin() + (l - 1), a.begin() + r, 0LL);

    // vector<int> in_lr(a.begin() + (l - 1), a.begin() + r);
    // vector<int> out_lr;

    // for (int i = 0; i < n; i++)
    //     if (i < l - 1 || i >= r)
    //         out_lr.push_back(a[i]);

    // sort(rall(in_lr));
    // sort(all(out_lr));

    // int mn = ans;
    // for (int i = 0; i < min(in_lr.size(), out_lr.size()); i++)
    // {
    //     mn -= in_lr[i];
    //     mn += out_lr[i];

    //     ans = min(ans, mn);
    // }

    cout << ans << ed;
}
signed main()
{
    // ( إِنَّ اللَّهَ وَمَلَائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ ۚ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا )
    // files();
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ed '\n'

void files()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    l--;
    vector<int> a(n);
    
    for (int &i : a) cin >> i;

    vector<int> b1 = a, b2 = a;

    sort(b1.begin() + l, b1.end());
    sort(b2.begin(), b2.begin() + r);
    reverse(b2.begin(), b2.begin() + r);
    int ans = min(accumulate(b1.begin() + l, b1.begin() + r, 0LL),accumulate(b2.begin() + l, b2.begin() + r, 0LL));

    cout << ans<<ed;
}
signed main()
{
    // ( إِنَّ اللَّهَ وَمَلَائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ ۚ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا )
    // files();
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
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 int ll

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

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

#define ed '\n'



void files()

{

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

}

void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> a(n);



    for (auto &i:a) cin >>i;



    int ans = accumulate(a.begin() + (l - 1), a.begin() + r, 0LL);



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

    vector<int> out_lr;



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

        if (i < l - 1 || i >= r)

            out_lr.push_back(a[i]);



    sort(rall(in_lr));

    sort(all(out_lr));



    int mn = ans;

    for (int i = 0; i < min(in_lr.size(), out_lr.size()); i++)

    {

        mn -= in_lr[i];

        mn += out_lr[i];



        ans = min(ans, mn);

    }



    cout << ans << ed;

}

signed main()

{

    // ( إِنَّ اللَّهَ وَمَلَائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ ۚ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا )

    // files();

    int t = 1;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}
Problem: 2063B - Subsequence Update
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

#define int ll

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

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

#define ed '\n'



void files()

{

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

}

void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    vector<int> a(n);



    for (auto &i:a) cin >>i;



    int ans = accumulate(a.begin() + (l - 1), a.begin() + r, 0LL);



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

    vector<int> out_lr;



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

        if (i < l - 1 || i >= r)

            out_lr.push_back(a[i]);



    sort(rall(in_lr));

    sort(all(out_lr));



    int mn = ans;

    for (int i = 0; i < min(in_lr.size(), out_lr.size()); i++)

    {

        mn -= in_lr[i];

        mn += out_lr[i];



        ans = min(ans, mn);

    }



    cout << ans << ed;

}

signed main()

{

    // ( إِنَّ اللَّهَ وَمَلَائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ ۚ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا )

    // files();

    int t = 1;

    cin >> t;

    while (t--)

    {

        solve();

    }

    return 0;

}



Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ed '\n'

void files()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
}
void solve()
{
    int n, l, r;
    cin >> n >> l >> r;
    vector<int> a(n);

    for (auto &i:a) cin >>i;
    int ans = 0;
    sort(all(a));
    int range = r-l+1;
    for(int i = 0 ; i<range ; i++)ans+=a[i];
    // int ans = accumulate(a.begin() + (l - 1), a.begin() + r, 0LL);

    // vector<int> in_lr(a.begin() + (l - 1), a.begin() + r);
    // vector<int> out_lr;

    // for (int i = 0; i < n; i++)
    //     if (i < l - 1 || i >= r)
    //         out_lr.push_back(a[i]);

    // sort(rall(in_lr));
    // sort(all(out_lr));

    // int mn = ans;
    // for (int i = 0; i < min(in_lr.size(), out_lr.size()); i++)
    // {
    //     mn -= in_lr[i];
    //     mn += out_lr[i];

    //     ans = min(ans, mn);
    // }

    cout << ans << ed;
}
signed main()
{
    // ( إِنَّ اللَّهَ وَمَلَائِكَتَهُ يُصَلُّونَ عَلَى النَّبِيِّ ۚ يَا أَيُّهَا الَّذِينَ آمَنُوا صَلُّوا عَلَيْهِ وَسَلِّمُوا تَسْلِيمًا )
    // files();
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

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

 while(t--)
 {
 string s;
 cin>>s;

 int rem=0;
int cnt2=0;
int cnt3=0;
 for(int i=0;i<s.length();i++)
 {

         rem=(rem+(s[i]-'0'))%9;

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

        if(s[i]=='3')
         cnt3++;
 }
 int flag=0;
// cout<<rem;
 for(int i=0;i<=min(cnt2,8);i++)
 {
     for(int j=0;j<=min(3,cnt3);j++)
     {
      //   cout<<i<<j<<"\n";
         if((rem+(i*2)%9+(j*6)%9)%9==0)
         {
             cout<<"YES\n";
             flag=1;
             break;
         }
         if(flag)
         break;
     }
 }
 if(!flag)
 cout<<"NO\n";
 }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

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

 while(t--)
 {
 string s;
 cin>>s;

 int rem=0;
int cnt2=0;
int cnt3=0;
 for(int i=0;i<s.length();i++)
 {

         rem=(rem+(s[i]-'0'))%9;

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

        if(s[i]=='3')
         cnt3++;
 }
 int flag=0;
// cout<<rem;
 for(int i=0;i<=min(cnt2,10);i++)
 {
     for(int j=0;j<=min(10,cnt3);j++)
     {
      //   cout<<i<<j<<"\n";
         if((rem+(i*2)%9+(j*6)%9)%9==0)
         {
             cout<<"YES\n";
             flag=1;
             break;
         }
         if(flag)
         break;
     }
 }
 if(!flag)
 cout<<"NO\n";
 }
}


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

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

 while(t--)
 {
 string s;
 cin>>s;

 int rem=0;
int cnt2=0;
int cnt3=0;
 for(int i=0;i<s.length();i++)
 {

         rem=(rem+(s[i]-'0'))%9;

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

        if(s[i]=='3')
         cnt3++;
 }
 int flag=0;
// cout<<rem;
 for(int i=0;i<=min(cnt2,8);i++)
 {
     for(int j=0;j<=min(3,cnt3);j++)
     {
      //   cout<<i<<j<<"\n";
         if((rem+(i*2)%9+(j*6)%9)%9==0)
         {
             cout<<"YES\n";
             flag=1;
             break;
         }

     }
      if(flag)
         break;
 }
 if(!flag)
 cout<<"NO\n";
 }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

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

 while(t--)
 {
 string s;
 cin>>s;

 int rem=0;
int cnt2=0;
int cnt3=0;
 for(int i=0;i<s.length();i++)
 {

         rem=(rem+(s[i]-'0'))%9;

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

        if(s[i]=='3')
         cnt3++;
 }
 int flag=0;
// cout<<rem;
 for(int i=0;i<=min(cnt2,8);i++)
 {
     for(int j=0;j<=min(3,cnt3);j++)
     {
      //   cout<<i<<j<<"\n";
         if((rem+(i*2)%9+(j*6)%9)%9==0)
         {
             cout<<"YES\n";
             flag=1;
             break;
         }
         if(flag)
         break;
     }
 }
 if(!flag)
 cout<<"NO\n";
 }
}


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

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

 while(t--)
 {
 string s;
 cin>>s;

 int rem=0;
int cnt2=0;
int cnt3=0;
 for(int i=0;i<s.length();i++)
 {

         rem=(rem+(s[i]-'0'))%9;

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

        if(s[i]=='3')
         cnt3++;
 }
 int flag=0;
// cout<<rem;
 for(int i=0;i<=min(cnt2,8);i++)
 {
     for(int j=0;j<=min(10,cnt3);j++)
     {
      //   cout<<i<<j<<"\n";
         if((rem+(i*2)%9+(j*6)%9)%9==0)
         {
             cout<<"YES\n";
             flag=1;
             break;
         }
         if(flag)
         break;
     }
 }
 if(!flag)
 cout<<"NO\n";
 }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

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

 while(t--)
 {
 string s;
 cin>>s;

 int rem=0;
int cnt2=0;
int cnt3=0;
 for(int i=0;i<s.length();i++)
 {

         rem=(rem+(s[i]-'0'))%9;

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

        if(s[i]=='3')
         cnt3++;
 }
 int flag=0;
// cout<<rem;
 for(int i=0;i<=min(cnt2,8);i++)
 {
     for(int j=0;j<=min(10,cnt3);j++)
     {
      //   cout<<i<<j<<"\n";
         if((rem+(i*2)%9+(j*6)%9)%9==0)
         {
             cout<<"YES\n";
             flag=1;
             break;
         }
         if(flag)
         break;
     }
 }
 if(!flag)
 cout<<"NO\n";
 }
}


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

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

 while(t--)
 {
 string s;
 cin>>s;

 int rem=0;
int cnt2=0;
int cnt3=0;
 for(int i=0;i<s.length();i++)
 {

         rem=(rem+(s[i]-'0'))%9;

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

        if(s[i]=='3')
         cnt3++;
 }
 int flag=0;
// cout<<rem;
 for(int i=0;i<=min(cnt2,10);i++)
 {
     for(int j=0;j<=min(10,cnt3);j++)
     {
      //   cout<<i<<j<<"\n";
         if((rem+(i*2)%9+(j*6)%9)%9==0)
         {
             cout<<"YES\n";
             flag=1;
             break;
         }
         if(flag)
         break;
     }
 }
 if(!flag)
 cout<<"NO\n";
 }
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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


void solv() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &i:v) cin>>i;
    int odd=0, even=0, sum = 0;
    for(int i=0;i<n; i++) {
        if(i%2) odd+=v[i];
        else even+=v[i];
        sum+=v[i];
    }
    if(sum % n != 0) {
        cout << "NO\n";
        return;
    } // 6 2 1 4 2
    if(n%2) {
        if(even%((n+1)/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }else {
        if(even%(n/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}


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


void solv() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &i:v) cin>>i;
    int odd=0, even=0, sum = 0;
    for(int i=0;i<n; i++) {
        if(i%2) odd+=v[i];
        else even+=v[i];
        sum+=v[i];
    }
    if(sum % n != 0) {
        cout << "NO\n";
        return;
    }
    int avg = sum / n;
    if(n%2) {
        if(even / ((n+1)/2) == avg && odd / (n/2) == avg) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }else {
        if(even / (n/2) == avg && odd / (n/2) == avg) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)


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



void solv() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &i:v) cin>>i;
    int odd=0, even=0, sum = 0;
    for(int i=0;i<n; i++) {
        if(i%2) odd+=v[i];
        else even+=v[i];
        sum+=v[i];
    }
    if(sum % n != 0) {
        cout << "NO\n";
        return;
    } // 6 2 1 4 2
    if(n%2) {
        if(even%((n+1)/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }else {
        if(even%(n/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}
Problem: 2050B - Transfusion
Language: C++17 (GCC 7-32)

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



void solv() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &i:v) cin>>i;
    int odd=0, even=0, sum = 0;
    for(int i=0;i<n; i++) {
        if(i%2) odd+=v[i];
        else even+=v[i];
        sum+=v[i];
    }
    if(sum % n != 0) {
        cout << "NO\n";
        return;
    } // 6 2 1 4 2
    if(n%2) {
        if(even%((n+1)/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }else {
        if(even%(n/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}


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


void solv() {
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &i:v) cin>>i;
    int odd=0, even=0, sum = 0;
    for(int i=0;i<n; i++) {
        if(i%2) odd+=v[i];
        else even+=v[i];
        sum+=v[i];
    }
    if(sum % n != 0) {
        cout << "NO\n";
        return;
    } // 6 2 1 4 2
    if(n%2) {
        if(even%((n+1)/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }else {
        if(even%(n/2) == 0 && odd % (n/2) == 0) {
            cout<<"YES\n";
        }else cout<< "NO\n";
    }
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el '\n'

void solv() {
    string s, ans="";
    cin>>s;
    for(int i=0;i<s.size();i++) {
        int z=0;
        for(int j=1;j<s.size();j++) {
            if(s[z] < s[j] && abs(s[z] - s[j]) > 1) {
                s[j]--;
                swap(s[z],s[j]);
            }
            z++;
        }
    }
    cout<<s<<el;
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el '\n'

void solv() {
    string s, ans="";
    cin>>s;
    for(int i=0;i<s.size();i++) {
        int z=0;
        for(int j=1;j<s.size()-i;j++) {
            if(s[z] < s[j] && abs(s[z] - s[j]) > 1) {
                s[j]--;
                swap(s[z],s[j]);
            }
            z++;
        }
    }
    cout<<s<<el;
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 5):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el '\n'

void solv() {
    string s, ans="";
    cin>>s;
    for(int i=0;i<s.size();i++) {
        int z=0;
        for(int j=1;j<s.size();j++) {
            if(s[z] < s[j] && abs(s[z] - s[j]) > 1) {
                s[j]--;
                swap(s[z],s[j]);
            }
            z++;
        }
    }
    cout<<s<<el;
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el '\n'

void solv() {
    string s, ans="";
    cin>>s;
    for(int i=0;i<s.size();i++) {
        int z=0;
        for(int j=1;j<s.size()-i;j++) {
            if(s[z] < s[j] && abs(s[z] - s[j]) > 1) {
                s[j]--;
                swap(s[z],s[j]);
            }
            z++;
        }
    }
    cout<<s<<el;
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define el '\n'

void solv() {
    string s, ans="";
    cin>>s;
    for(int i=0;i<s.size();i++) {
        int z=s[i]-'0', p=i;
        for(int j=i;j<min((int)s.size(), i+10);j++) {
            if(s[j]-'0'-(j-i) > z) {
                z = s[j]-'0'-(j-i);
                p=j;
            }
        }
        
        while(p>i) {
            swap(s[p], s[p-1]);
            p--;
        }
        s[i]=z+'0';
    }
    cout<<s<<el;
}


int32_t main() {
    int t=1;
    cin >> t;
    while (t--) {
        solv();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<string>
#include<algorithm>
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define big 998244353
#define pb push_back
#define mp make_pair
#define forn for(int i=0;i<n;i++)
using namespace std;

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

    int b[n];
    forn cin>>b[i];

    int a[n];
    forn a[i]=i+1;

    int ans = 0;

    int effective_size = n;
    for(int i=n-1;i>=0;i--)
    {
        int ele = b[i];

        auto it = lower_bound(a, a+n, ele);

        int loc = it-a;

        for(int j=loc-1;j>=0;j--)
        {
            // cout<<ele<<" "<<a[j]<<endl;
            // a[j+1] = a[j];
            // a[j] = ele;
            ++ans;
        }

        for(int j=0;j<i;j++)
        {
            // cout<<a[j+1]<<" "<<a[j]<<endl;
            // swap(a[j],a[j+1]);
            ans++;
        }

    }

    cout<<ans<<endl;

    for(int i=n-1;i>=0;i--)
    {
        int ele = b[i];

        auto it = lower_bound(a, a+n, ele);

        int loc = it-a;

        for(int j=loc-1;j>=0;j--)
        {
            cout<<ele<<" "<<a[j]<<endl;
            a[j+1] = a[j];
            a[j] = ele;
            
        }

        for(int j=0;j<i;j++)
        {
            cout<<a[j+1]<<" "<<a[j]<<endl;
            swap(a[j],a[j+1]);
            
        }

    }
}

int32_t main() {
    // fast io
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin >> t;

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