ShaysXIA/CodeInsightBench huggingface dataset:
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 namespace std;
typedef long long ll;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ppair pair<int, pair<int, int>>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pii>
#define tc int t; cin>>t; while(t--)
const ll mod = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1e10;
const ll mxn = 2e5+2;
// int pangkat(int a, int b){if(b == 0) return 1;ll res = pangkat(a, b/2);if(b&1) return ((res*res)%MOD*a)%MOD;else return (res*res)%MOD;}
// void chmn(int &a, int b){a = min(a,b);}

signed main(){
    fastio;
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        int a[n+5], pref[n+5];
        bool ok = 1;
        for(int i = 1; i <= n; i++){
            cin >> a[i];
            if(i%2==0 && a[i]<a[i-1])ok=0;
        }
        if(!ok){
            cout << "NO" << endl;
            continue;
        }
        pref[0] = 0;
        for(int i = 2; i <= n; i+=2){
            pref[i] = pref[i-2]+(a[i]-a[i-1]);
        }
        for(int i = 2; i <= n; i+=2){
            if(pref[i]>a[i+1] && (i+2)<=n){
                ok = 0; break;
            }
        }
        if(!ok){
            cout << "NO"<<endl; continue;
        } cout << "YES"<<endl;
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ppair pair<int, pair<int, int>>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pii>
#define tc int t; cin>>t; while(t--)
const ll mod = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1e10;
const ll mxn = 2e5+2;
// int pangkat(int a, int b){if(b == 0) return 1;ll res = pangkat(a, b/2);if(b&1) return ((res*res)%MOD*a)%MOD;else return (res*res)%MOD;}
// void chmn(int &a, int b){a = min(a,b);}

signed main(){
    fastio;
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        deque<int> dq(n);
        for(auto &v:dq)cin>>v;
        bool ok = 1;
        while(dq.size()>1){
            if(dq[0]>dq[1]){
                ok = 0; break;
            } else if(dq[0]<dq[1]){
                dq[1] -= dq[0];
                dq.pop_front();
            } else {
                dq.pop_front();
                dq.pop_front();
            }
        }
        cout << (ok?"YES":"NO")<<endl;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ppair pair<int, pair<int, int>>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pii>
#define tc int t; cin>>t; while(t--)
const ll mod = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1e10;
const ll mxn = 2e5+2;
// int pangkat(int a, int b){if(b == 0) return 1;ll res = pangkat(a, b/2);if(b&1) return ((res*res)%MOD*a)%MOD;else return (res*res)%MOD;}
// void chmn(int &a, int b){a = min(a,b);}

signed main(){
    fastio;
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        int a[n+1]; bool ok = 1;
        int pref[n+1];
        for(int i = 1; i <= n; i++){
            cin >> a[i];
            if(i%2==0 && a[i]<a[i-1])ok=0;
        }
        if(!ok){
            cout << "NO" << endl;
            continue;
        }
        pref[0] = 0;
        for(int i = 2; i <= n; i+=2){
            pref[i] = pref[i-2]+(a[i]-a[i-1]);
        }
        for(int i = 2; i <= n; i+=2){
            if(pref[i]>a[i+1]){
                ok = 0; break;
            }
        }
        if(!ok){
            cout << "NO"<<endl; continue;
        } cout << "YES"<<endl;
    }
}
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 namespace std;
typedef long long ll;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ppair pair<int, pair<int, int>>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pii>
#define tc int t; cin>>t; while(t--)
const ll mod = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1e10;
const ll mxn = 2e5+2;
// int pangkat(int a, int b){if(b == 0) return 1;ll res = pangkat(a, b/2);if(b&1) return ((res*res)%MOD*a)%MOD;else return (res*res)%MOD;}
// void chmn(int &a, int b){a = min(a,b);}

signed main(){
    fastio;
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        int a[n+1]; bool ok = 1;
        int pref[n+1];
        for(int i = 1; i <= n; i++){
            cin >> a[i];
            if(i%2==0 && a[i]<a[i-1])ok=0;
        }
        if(!ok){
            cout << "NO" << endl;
            continue;
        }
        pref[0] = 0;
        for(int i = 2; i <= n; i+=2){
            pref[i] = pref[i-2]+(a[i]-a[i-1]);
        }
        for(int i = 2; i <= n; i+=2){
            if(pref[i]>a[i+1]){
                ok = 0; break;
            }
        }
        if(!ok){
            cout << "NO"<<endl; continue;
        } cout << "YES"<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ppair pair<int, pair<int, int>>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pii>
#define tc int t; cin>>t; while(t--)
const ll mod = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1e10;
const ll mxn = 2e5+2;
// int pangkat(int a, int b){if(b == 0) return 1;ll res = pangkat(a, b/2);if(b&1) return ((res*res)%MOD*a)%MOD;else return (res*res)%MOD;}
// void chmn(int &a, int b){a = min(a,b);}

signed main(){
    fastio;
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        int a[n+5], pref[n+5];
        bool ok = 1;
        for(int i = 1; i <= n; i++){
            cin >> a[i];
            if(i%2==0 && a[i]<a[i-1])ok=0;
        }
        if(!ok){
            cout << "NO" << endl;
            continue;
        }
        pref[0] = 0;
        for(int i = 2; i <= n; i+=2){
            pref[i] = pref[i-2]+(a[i]-a[i-1]);
        }
        for(int i = 2; i <= n; i+=2){
            if(pref[i]>a[i+1]){
                ok = 0; break;
            }
        }
        if(!ok){
            cout << "NO"<<endl; continue;
        } cout << "YES"<<endl;
    }
}
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 namespace std;
typedef long long ll;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ppair pair<int, pair<int, int>>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pii>
#define tc int t; cin>>t; while(t--)
const ll mod = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1e10;
const ll mxn = 2e5+2;
// int pangkat(int a, int b){if(b == 0) return 1;ll res = pangkat(a, b/2);if(b&1) return ((res*res)%MOD*a)%MOD;else return (res*res)%MOD;}
// void chmn(int &a, int b){a = min(a,b);}

signed main(){
    fastio;
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        int a[n+5], pref[n+5];
        bool ok = 1;
        for(int i = 1; i <= n; i++){
            cin >> a[i];
            if(i%2==0 && a[i]<a[i-1])ok=0;
        }
        if(!ok){
            cout << "NO" << endl;
            continue;
        }
        pref[0] = 0;
        for(int i = 2; i <= n; i+=2){
            pref[i] = pref[i-2]+(a[i]-a[i-1]);
        }
        for(int i = 2; i <= n; i+=2){
            if(pref[i]>a[i+1]){
                ok = 0; break;
            }
        }
        if(!ok){
            cout << "NO"<<endl; continue;
        } cout << "YES"<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ppair pair<int, pair<int, int>>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pii>
#define tc int t; cin>>t; while(t--)
const ll mod = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1e10;
const ll mxn = 2e5+2;
// int pangkat(int a, int b){if(b == 0) return 1;ll res = pangkat(a, b/2);if(b&1) return ((res*res)%MOD*a)%MOD;else return (res*res)%MOD;}
// void chmn(int &a, int b){a = min(a,b);}

signed main(){
    fastio;
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        int a[n+5], pref[n+5];
        bool ok = 1;
        for(int i = 1; i <= n; i++){
            cin >> a[i];
            if(i%2==0 && a[i]<a[i-1])ok=0;
        }
        if(!ok){
            cout << "NO" << endl;
            continue;
        }
        pref[0] = 0;
        for(int i = 2; i <= n; i+=2){
            pref[i] = pref[i-2]+(a[i]-a[i-1]);
        }
        for(int i = 2; i <= n; i+=2){
            if(pref[i]>a[i+1] && (i+2)<=n){
                ok = 0; break;
            }
        }
        if(!ok){
            cout << "NO"<<endl; continue;
        } cout << "YES"<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl '\n'
#define xx first
#define yy second

const i64 MAXN = 1e6;

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> arr(n + 1);
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> arr[i];
            sum += arr[i];
        }
        if (n == 1)
        {
            cout << arr[1] << endl;
            continue;
        }
        int temp = n;
        while (temp)
        {
            int sum1 = arr[temp] - arr[1];
            sum = max(abs(sum1), sum);
            temp--;
            for (int i = 1; i <= temp; i++)
                arr[i] = arr[i + 1] - arr[i];
        }
        cout << sum << endl;
    }

    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl '\n'
#define xx first
#define yy second

const i64 MAXN = 1e6;

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> arr(n + 2);
        i64 sum = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> arr[i];
            sum += arr[i];
        }
        if (n == 1)
        {
            cout << arr[1] << endl;
            continue;
        }
        int temp = n;
        while (temp)
        {
            i64 sum1 = arr[temp] - arr[1];
            sum = max(abs(sum1), sum);
            temp--;
            for (int i = 1; i <= temp; i++)
                arr[i] = arr[i + 1] - arr[i];
        }
        cout << sum << endl;
    }

    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;
using i64 = long long;
#define endl '\n'
#define xx first
#define yy second

const i64 MAXN = 1e6;

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> arr(n + 1);
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> arr[i];
            sum += arr[i];
        }
        if (n == 1)
        {
            cout << arr[1] << endl;
            continue;
        }
        int temp = n;
        while (temp)
        {
            int sum1 = arr[temp] - arr[1];
            sum = max(abs(sum1), sum);
            temp--;
            for (int i = 1; i <= temp; i++)
                arr[i] = arr[i + 1] - arr[i];
        }
        cout << sum << endl;
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl '\n'
#define xx first
#define yy second

const i64 MAXN = 1e6;

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<int> arr(n + 2);
        i64 sum = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> arr[i];
            sum += arr[i];
        }
        if (n == 1)
        {
            cout << arr[1] << endl;
            continue;
        }
        int temp = n;
        while (temp)
        {
            i64 sum1 = arr[temp] - arr[1];
            sum = max(abs(sum1), sum);
            temp--;
            for (int i = 1; i <= temp; i++)
                arr[i] = arr[i + 1] - arr[i];
        }
        cout << sum << endl;
    }

    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl '\n'
#define xx first
#define yy second

const i64 MAXN = 1e6;

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vector<i64> arr(n + 2);
        i64 sum = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> arr[i];
            sum += arr[i];
        }
        if (n == 1)
        {
            cout << arr[1] << endl;
            continue;
        }
        int temp = n;
        while (temp)
        {
            i64 sum1 = arr[temp] - arr[1];
            sum = max(abs(sum1), sum);
            temp--;
            for (int i = 1; i <= temp; i++)
                arr[i] = arr[i + 1] - arr[i];
        }
        cout << sum << endl;
    }

    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
namespace Le0{
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define db double
#define _int __int128
#define vi vector<int>
#define tii tuple<int,int,int>
const int N=55,inf=0x3f3f3f3f;
const ll lnf=1e18;
int n;  
void sv(){
    ll tot=0;
    cin>>n;vi a(n);
    for(int i=0;i<n;i++) cin>>a[i],tot+=a[i];
    for(int i=1;i<n;i++){
        vi b;
        for(int j=0;j<a.size();j++){
            if(j) b.pb(a[j]-a[j-1]);
        }
        swap(a,b);
        ll sm=0;
        for(int x:a) sm+=x;
        tot=max({tot,sm,-sm});
    }
    cout<<tot<<'\n';
}
int main(){
    int _T;cin>>_T;
    while(_T--){
        sv();
    }
    return 0;
}
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    return Le0::main();
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
namespace Le0{
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define db double
#define _int __int128
#define vi vector<int>
#define tii tuple<int,int,int>
const int N=55,inf=0x3f3f3f3f;
const ll lnf=1e18;
int n;  
void sv(){
    ll tot=0;
    cin>>n;vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i],tot+=a[i];
    for(int i=1;i<n;i++){
        vector<ll> b;
        for(int j=0;j<a.size();j++){
            if(j) b.pb(a[j]-a[j-1]);
        }
        swap(a,b);
        ll sm=0;
        for(int x:a) sm+=x;
        tot=max({tot,sm,-sm});
    }
    cout<<tot<<'\n';
}
int main(){
    int _T;cin>>_T;
    while(_T--){
        sv();
    }
    return 0;
}
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    return Le0::main();
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
namespace Le0{
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define db double
#define _int __int128
#define vi vector<int>
#define tii tuple<int,int,int>
const int N=55,inf=0x3f3f3f3f;
const ll lnf=1e18;
int n;  
void sv(){
    ll tot=0;
    cin>>n;vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i],tot+=a[i];
    for(int i=1;i<n;i++){
        vector<ll> b;
        for(int j=0;j<a.size();j++){
            if(j) b.pb(a[j]-a[j-1]);
        }
        swap(a,b);
        ll sm=0;
        for(int x:a) sm+=x;
        tot=max({tot,sm,-sm});
    }
    cout<<tot<<'\n';
}
int main(){
    int _T;cin>>_T;
    while(_T--){
        sv();
    }
    return 0;
}
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    return Le0::main();
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
namespace Le0{
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define db double
#define _int __int128
#define vi vector<int>
#define tii tuple<int,int,int>
const int N=55,inf=0x3f3f3f3f;
const ll lnf=1e18;
int n;  
void sv(){
    ll tot=0;
    cin>>n;vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i],tot+=a[i];
    for(int i=1;i<n;i++){
        vector<ll> b;
        for(int j=0;j<a.size();j++){
            if(j) b.pb(a[j]-a[j-1]);
        }
        swap(a,b);
        ll sm=0;
        for(ll x:a) sm+=x;
        tot=max({tot,sm,-sm});
    }
    cout<<tot<<'\n';
}
int main(){
    int _T;cin>>_T;
    while(_T--){
        sv();
    }
    return 0;
}
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    return Le0::main();
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
namespace Le0{
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define db double
#define _int __int128
#define vi vector<int>
#define tii tuple<int,int,int>
const int N=55,inf=0x3f3f3f3f;
const ll lnf=1e18;
int n;  
void sv(){
    ll tot=0;
    cin>>n;vi a(n);
    for(int i=0;i<n;i++) cin>>a[i],tot+=a[i];
    for(int i=1;i<n;i++){
        vi b;
        for(int j=0;j<a.size();j++){
            if(j) b.pb(a[j]-a[j-1]);
        }
        swap(a,b);
        ll sm=0;
        for(int x:a) sm+=x;
        tot=max({tot,sm,-sm});
    }
    cout<<tot<<'\n';
}
int main(){
    int _T;cin>>_T;
    while(_T--){
        sv();
    }
    return 0;
}
}
int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    return Le0::main();
}
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Compilation error):
# Positiondef solve():
    s = input()
    s = list(s)  # Convert string to list for mutable operations

    for i in range(len(s)):
        best = int(s[i])  # Current best value
        pos = i  # Position of the best value
        
        for j in range(i, min(i + 10, len(s))):
            if int(s[j]) - (j - i) > best:
                best = int(s[j]) - (j - i)
                pos = j

        while pos > i:
            s[pos], s[pos - 1] = s[pos - 1], s[pos]
            pos -= 1

        s[i] = str(best)

    print(''.join(s))


if __name__ == "__main__":
    TESTS = int(input())
    for _ in range(TESTS):
        solve()
        print()
 of the best value

Submission (verdict: Wrong answer on test 1):
def solve():
    s = input()
    s = list(s)  # Convert string to list for mutable operations

    for i in range(len(s)):
        best = int(s[i])  # Current best value
        pos = i  # Position of the best value
        
        for j in range(i, min(i + 10, len(s))):
            if int(s[j]) - (j - i) > best:
                best = int(s[j]) - (j - i)
                pos = j

        while pos > i:
            s[pos], s[pos - 1] = s[pos - 1], s[pos]
            pos -= 1

        s[i] = str(best)

    print(''.join(s))


if __name__ == "__main__":
    TESTS = int(input())
    for _ in range(TESTS):
        solve()
        print()
Problem: 2050D - Digital string maximization
Language: PyPy 3


Submission (verdict: Wrong answer on test 1):
def solve():
    s = input()
    s = list(s)  
    for i in range(len(s)):
        best = int(s[i])  
        pos = i  
        
        for j in range(i, min(i + 10, len(s))):
            if int(s[j]) - (j - i) > best:
                best = int(s[j]) - (j - i)
                pos = j

        while pos > i:
            s[pos], s[pos - 1] = s[pos - 1], s[pos]
            pos -= 1

        s[i] = str(best)

    print(''.join(s))


if __name__ == "__main__":
    TESTS = int(input())
    for _ in range(TESTS):
        solve()
        print()
Problem: 2050D - Digital string maximization
Language: PyPy 3

Previous submission (verdict: Wrong answer on test 1):
def solve():
    s = input()
    s = list(s)  # Convert string to list for mutable operations

    for i in range(len(s)):
        best = int(s[i])  # Current best value
        pos = i  # Position of the best value
        
        for j in range(i, min(i + 10, len(s))):
            if int(s[j]) - (j - i) > best:
                best = int(s[j]) - (j - i)
                pos = j

        while pos > i:
            s[pos], s[pos - 1] = s[pos - 1], s[pos]
            pos -= 1

        s[i] = str(best)

    print(''.join(s))


if __name__ == "__main__":
    TESTS = int(input())
    for _ in range(TESTS):
        solve()
        print()


Submission (verdict: Time limit exceeded on test 7):
n = int(input())
for _ in range(n):
    n1 = str(input())
    for i in range(len(n1)):
        best = int(n1[i])
        pos = i
        for j in range(i, min(i+9, len(n1))):
            if (int(n1[j]) - (j-i)) > best:
                best = int(n1[j]) - (j-i)
                pos = j
        arr1 = n1[0:i]
        arr2 = n1[i:pos]
        arr3 = n1[pos+1:len(n1)]
        n1 = arr1+str(best)+arr2+arr3
    print(n1)