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

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

using namespace std;

#define ll long long

const int mod = 998244353;

typedef pair<ll, ll> Interval;



void solve() {

    int n,l,r;

    cin >> n >> l >> r;

    vector<int> a(n);

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

    vector<int> b,c;

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

        b.push_back(a[i]);

    }

    for(int i = r-1; i <n;i++){

        c.push_back(b[i]);

    }

    sort(b.begin(),a.end());

    sort(c.begin(),b.end());

    ll sum1 = accumulate(b.begin(),b.begin() +(r-l+1) ,0ll);

    ll sum2 = accumulate(c.begin(),c.begin() +(r-l+1) ,0ll);

    cout << max(sum1,sum2) <<"\n";

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t = 1;

    cin >> t;

    

    while (t--) {

        solve();

    }

    

    return 0;

}







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

using namespace std;

#define ll long long

const int mod = 998244353;

typedef pair<ll, ll> Interval;



void solve() {

    int n,l,r;

    cin >> n >> l >> r;

    vector<int> a(n);

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

    vector<int> b,c;

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

        b.push_back(a[i]);

    }

    for(int i = l-1; i <n;i++){

        c.push_back(a[i]);

    }

    sort(b.begin(),b.end());

    sort(c.begin(),c.end());

    ll sum1 = accumulate(b.begin(),b.begin() +(int)(r-l+1) ,0ll);

    ll sum2 = accumulate(c.begin(),c.begin() +(int)(r-l+1) ,0ll);

    cout << min(sum1,sum2) <<"\n";

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t = 1;

    cin >> t;

    

    while (t--) {

        solve();

    }

    

    return 0;

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

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<math.h>
using namespace std;
int a[60],c[60];
int main(){
	int t;
	scanf("%d",&t);
	for(int i=1;i<=t;i++){
		int n;
		scanf("%d",&n);
		long long ans=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			ans=ans+a[i];
		}
		if(n==1){
			printf("%d\n",abs(a[n]));
			continue;
		}else if(n==2){
			int z=a[1]+a[2];
			printf("%d\n",max(z,abs(a[1]-a[2])));
			continue;
		}
		long long ans1=0;
		while(n>0){
			ans1=0;
			for(int i=1;i<n;i++){
				c[i]=a[i+1]-a[i];
				ans1=ans1+c[i];
			}
			n--;
			ans=max(ans,abs(ans1));
			for(int i=1;i<=n;i++){
				a[i]=c[i];
			}
	}
	printf("%lld\n",ans);
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<math.h>
using namespace std;
int a[60],c[60];
int main(){
	int t;
	scanf("%d",&t);
	for(int i=1;i<=t;i++){
		int n;
		scanf("%d",&n);
		long long ans=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			ans=ans+a[i];
		}
		if(n==1){
			printf("%d\n",a[n]);
			continue;
		}else if(n==2){
			int z=a[1]+a[2];
			printf("%d\n",max(z,abs(a[1]-a[2])));
			continue;
		}
		long long ans1=0;
		while(n>0){
			ans1=0;
			for(int i=1;i<n;i++){
				c[i]=a[i+1]-a[i];
				ans1=ans1+c[i];
			}
			n--;
			ans=max(ans,abs(ans1));
			for(int i=1;i<=n;i++){
				a[i]=c[i];
			}
	}
	printf("%lld\n",ans);
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<math.h>
using namespace std;
int a[60],c[60];
int main(){
	int t;
	scanf("%d",&t);
	for(int i=1;i<=t;i++){
		int n;
		scanf("%d",&n);
		long long ans=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			ans=ans+a[i];
		}
		if(n==1){
			printf("%d\n",abs(a[n]));
			continue;
		}else if(n==2){
			int z=a[1]+a[2];
			printf("%d\n",max(z,abs(a[1]-a[2])));
			continue;
		}
		long long ans1=0;
		while(n>0){
			ans1=0;
			for(int i=1;i<n;i++){
				c[i]=a[i+1]-a[i];
				ans1=ans1+c[i];
			}
			n--;
			ans=max(ans,abs(ans1));
			for(int i=1;i<=n;i++){
				a[i]=c[i];
			}
	}
	printf("%lld\n",ans);
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<math.h>
using namespace std;
int a[60],c[60];
int main(){
	int t;
	scanf("%d",&t);
	for(int i=1;i<=t;i++){
		int n;
		scanf("%d",&n);
		long long ans=0;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			ans=ans+a[i];
		}
		if(n==1){
			printf("%d\n",a[n]);
			continue;
		}else if(n==2){
			int z=a[1]+a[2];
			printf("%d\n",max(z,abs(a[1]-a[2])));
			continue;
		}
		long long ans1=0;
		while(n>0){
			ans1=0;
			for(int i=1;i<n;i++){
				c[i]=a[i+1]-a[i];
				ans1=ans1+c[i];
			}
			n--;
			ans=max(ans,abs(ans1));
			for(int i=1;i<=n;i++){
				a[i]=c[i];
			}
	}
	printf("%lld\n",ans);
	}
	return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<math.h>
using namespace std;
long long a[60],c[60];
int main(){
	int t;
	scanf("%d",&t);
	for(int i=1;i<=t;i++){
		int n;
		scanf("%d",&n);
		long long ans=0;
		for(int i=1;i<=n;i++){
			scanf("%lld",&a[i]);
			ans=ans+a[i];
		}
		if(n==1){
			printf("%lld\n",a[n]);
			continue;
		}else if(n==2){
			long long z=a[1]+a[2];
			printf("%lld\n",max(z,abs(a[1]-a[2])));
			continue;
		}
		long long ans1=0;
		while(n>1){
			ans1=0;
			for(int i=1;i<n;i++){
				c[i]=a[i+1]-a[i];
				ans1=ans1+c[i];
			}
			n--;
			ans=max(ans,abs(ans1));
			for(int i=1;i<=n;i++){
				a[i]=c[i];
			}
	}
	printf("%lld\n",ans);
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
/*********************************************
 * Author  : Gansukh Lkhagva
 * Created : 2025-02-17 20:19
 * Problem : 2060B - Farmer John's Card Game
 * Source  : Codeforces Round #1000 (Div. 3)
 * Time    : 
 * Status  : 
 *********************************************/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> card(m);
    vector<pair<int, int>> card_index;
    bool flag = true;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> card[j];
        }
        sort(card.begin(), card.end());
        for(int j = 0; j < m - 1; j++) {
            if(card[j] + n != card[j+1]) {
                flag = false;
                break;
            }
        }
        card_index.push_back(make_pair(card[0], i));
    }
    sort(card_index.begin(), card_index.end(), [](pair<int,int> a, pair<int,int> b) {
        return a.first < b.first;
    });
    if(flag) {
        for(int i = 0; i < n; i++) {
            cout << card_index[i].second + 1 << " ";
        }
        cout << endl;
    } else {
        cout << "-1" << endl;
    }
}

int main() {
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}



Submission (verdict: Accepted):
/*********************************************
 * Author  : Gansukh Lkhagva
 * Created : 2025-02-17 20:19
 * Problem : 2057B - Gorilla and the Example
 * Source  : Codeforces Round #1000 (Div. 3)
 * Time    : 
 * Status  : 
 *********************************************/

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long

void solve() {
    int n, k, inp;
    cin >> n >> k;
    map<int, int> mp;
    vector<int> keyCount;
    for(int i = 0; i < n; i++) {
        cin >> inp;
        mp[inp]++;
    }
    for(auto it : mp) {
        keyCount.push_back(it.second);
    }
    sort(keyCount.begin(), keyCount.end());
    int prefixSum = 0, indexCnt=0;
    while(indexCnt < keyCount.size() && prefixSum + keyCount[indexCnt] <= k) {
        prefixSum += keyCount[indexCnt];
        indexCnt++;
    }
    cout << max((int)keyCount.size() - indexCnt, 1) << endl;
}

int main() {
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long

void solve() {
    int n, k, inp;
    cin >> n >> k;
    map<int, int> mp;
    vector<int> keyCount;
    for(int i = 0; i < n; i++) {
        cin >> inp;
        mp[inp]++;
    }
    for(auto it : mp) {
        keyCount.push_back(it.second);
    }
    sort(keyCount.begin(), keyCount.end());
    int prefixSum = 0, indexCnt=0;
    while(indexCnt < keyCount.size() && prefixSum < k) {
        prefixSum += keyCount[indexCnt];
        indexCnt++;
    }
    cout << max((int)keyCount.size() - indexCnt, 1) << endl;
}

int main() {
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long

void solve() {
    int n, k, inp;
    cin >> n >> k;
    map<int, int> mp;
    vector<int> keyCount;
    for(int i = 0; i < n; i++) {
        cin >> inp;
        mp[inp]++;
    }
    for(auto it : mp) {
        keyCount.push_back(it.second);
    }
    sort(keyCount.begin(), keyCount.end());
    int prefixSum = 0, indexCnt=0;
    while(indexCnt < keyCount.size() && prefixSum < k) {
        prefixSum += keyCount[indexCnt];
        indexCnt++;
    }
    cout << max((int)keyCount.size() - indexCnt, 1) << endl;
}

int main() {
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Submission (verdict: Runtime error on test 1):
/*********************************************
 * Author  : Gansukh Lkhagva
 * Created : 2025-02-17 20:19
 * Problem : 2060B - Farmer John's Card Game
 * Source  : Codeforces Round #1000 (Div. 3)
 * Time    : 
 * Status  : 
 *********************************************/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> card(m);
    vector<pair<int, int>> card_index;
    bool flag = true;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> card[j];
        }
        sort(card.begin(), card.end());
        for(int j = 0; j < m - 1; j++) {
            if(card[j] + n != card[j+1]) {
                flag = false;
                break;
            }
        }
        card_index.push_back(make_pair(card[0], i));
    }
    sort(card_index.begin(), card_index.end(), [](pair<int,int> a, pair<int,int> b) {
        return a.first < b.first;
    });
    if(flag) {
        for(int i = 0; i < n; i++) {
            cout << card_index[i].second + 1 << " ";
        }
        cout << endl;
    } else {
        cout << "-1" << endl;
    }
}

int main() {
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
// #pragma GCC optimize(2)

#include <bits/stdc++.h>

using namespace std;

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

#define pb push_back

#define st first

#define nd second

#define PII pair<ll, ll>

#define D(x, y) cout << x << "=" << y << endl;

#define fcout(x, n) cout << fixed << setprecision(x) << n << endl;

#define rep(i, a, b) for (int i = a; i < b; i++)

#define rep2(i, a, b) for (int i = a; i >= b; i--)

// #define int long long

// #define endl '\n'

typedef long long ll;

typedef unsigned long long ull;

const ll inf = 0x3f3f3f3f;

const int N = 2e6 + 10;

const int M = 1e9+7;

inline ll read()

{

    ll x = 0;

    bool f = 1;

    char c = getchar();

    for (; !isdigit(c); c = getchar())

        if (c == '-')

            f = 0;

    for (; isdigit(c); c = getchar())

        x = (x << 3) + (x << 1) + c - '0';

    return f ? x : 0 - x;

}

inline void out(ll x)

{

    if (x < 0)

        putchar('-'), x = -x;

    if (x > 9)

        out(x / 10);

    putchar(x % 10 + '0');

}

// __int128 rd()

// {

// 	char arr[30];

// 	__int128 res = 0;

// 	scanf("%s", arr);

// 	for (int i = 1; i <= strlen(arr); i++)

// 	{

// 		res *= 10;

// 		res += arr[i]-'0';

// 	}

// 	return res;

// }

// void pt(__int128 num)

// {

// 	if (num > 9) pt(num / 10);

// 	putchar(num % 10 + '0');

// }

ll n, m;

ll a[N],d[N];

void solve()

{

    cin>>n;

    rep(i,0,n) 

    {

        cin>>a[i];

        if(i==0) continue;

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

    }

    //rep(i,0,n) cout<<d[i]<<" ";cout<<endl;

    if(d[1]<0) return cout<<"NO\n",void();

    rep(i,1,n)

    {

        if(d[i]<0&&a[i]<d[i-1]) return cout<<"NO\n",void();

        if(d[i]<0) d[i]=a[i]-d[i-1];

    }

    cout<<"YES\n";

}   

signed main()

{

    IOS

        //freopen("../.vscode/io/in.txt","r",stdin),freopen("../.vscode/io/out.txt","w",stdout);

        ll T = 1;

    cin >> T;

    while (T--)

        solve();

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <ostream>

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,number=1,total,num2,num3;

char num[1005][100005];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        total = 0;

        num2 = 0;

        num3 = 0;

        scanf("%s",num[number]);

        for (int i = 0; i < strlen(num[number]); i++)

        {

            total += (num[number][i] - '0');

            if (num[number][i] == '2')

            {

                num2 ++;

            }

            if (num[number][i] == '3')

            {

                num3 ++;

            }

            

        }

        if (total%9 == 0)

        {

            printf("YES\n");

            continue;

        }

        

        if ((total%9)%2 == 0)

        {

            total = 18-(total%9);

        }else{

            total = 9-(total%9);

        }



        int temp = num2+num3;

       for (int i = 1; i <= temp; i++)

       {

        if (total == 0)

        {

            printf("YES\n");

            break;

        }

        

         if (total>=6 && num3>0)

         {

            total -= 6;

            num3--;

         }

         else if (total>=2 && num2>0)

         {

            total -= 2;

            num2--;

         }else{

            printf("NO\n");

            break;

         }

         

         

         

       }

       

        

       

        

        

        number++;

    }

    

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 7):
#include <ostream>

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,max1=numeric_limits<int>::min(),a;

char s[1000000];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        a=0;

        scanf("%s",s);

        for (int i = 0; i < strlen(s); i++)

        {

            for (int j = i; j < i+9; j++)

            {

                if ((s[j]-'0')-j+i > max1)

                {

                    max1 = (s[j]-'0')-j+i;

                    a = j;

                }

                

            }

            for (int b = a; b > i; b--)

            {

                s[b] = s[b-1];

            }

                s[i] = '0';

            

            

            

            printf("%d",max1);

            max1=numeric_limits<int>::min();

        }

        printf("\n");

        

    }

    

    return 0;

}

Submission (verdict: Accepted):
#include <ostream>

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

using i64 = long long;

int T, n;

void solve() {

    string s; cin >> s;

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

        int res = s[i], pos = i;

        for (int j = i + 1; j < min((int)s.size(), i + 11); j ++) 

            if ((int)s[j] - (j - i) > res) res = (int)s[j] - (j - i), pos = j;

        for (int j = pos; j > i; j --) swap(s[j], s[j - 1]), s[j - 1] --;

    }

    cout << s << '\n';

}

int main() {

    cin.tie(NULL) -> sync_with_stdio(false);

    cin >> T;

    while (T --) solve();

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <ostream>

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,max1=numeric_limits<int>::min(),a;

char s[1000000];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        a=0;

        scanf("%s",s);

        for (int i = 0; i < strlen(s); i++)

        {

            for (int j = i; j < i+9; j++)

            {

                if ((s[j]-'0')-j+i > max1)

                {

                    max1 = (s[j]-'0')-j+i;

                    a = j;

                }

                

            }

            for (int b = a; b > i; b--)

            {

                s[b] = s[b-1];

            }

                s[0] = '0';

            

            

            

            printf("%d",max1);

            max1=numeric_limits<int>::min();

        }

        printf("\n");

        

    }

    

    return 0;

}

Submission (verdict: Time limit exceeded on test 7):
#include <ostream>

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,max1=numeric_limits<int>::min(),a;

char s[1000000];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        a=0;

        scanf("%s",s);

        for (int i = 0; i < strlen(s); i++)

        {

            for (int j = i; j < i+9; j++)

            {

                if ((s[j]-'0')-j+i > max1)

                {

                    max1 = (s[j]-'0')-j+i;

                    a = j;

                }

                

            }

            for (int b = a; b > i; b--)

            {

                s[b] = s[b-1];

            }

                s[i] = '0';

            

            

            

            printf("%d",max1);

            max1=numeric_limits<int>::min();

        }

        printf("\n");

        

    }

    

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <ostream>

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,max1=numeric_limits<int>::min(),a;

char s[1000000];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        a=0;

        scanf("%s",s);

        for (int i = 0; i < strlen(s); i++)

        {

            for (int j = i; j < strlen(s); j++)

            {

                if ((s[j]-'0')-j+i > max1)

                {

                    max1 = (s[j]-'0')-j+i;

                    a = j;

                }

                

            }

            for (int b = a; b > 0; b--)

            {

                s[b] = s[b-1];

            }

                s[0] = '0';

            

            

            

            printf("%d",max1);

            max1=numeric_limits<int>::min();

        }

        printf("\n");

        

    }

    

    return 0;

}

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

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,max1=numeric_limits<int>::min(),a;

char s[1000000];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        a=0;

        scanf("%s",s);

        for (int i = 0; i < strlen(s); i++)

        {

            for (int j = i; j < i+9; j++)

            {

                if ((s[j]-'0')-j+i > max1)

                {

                    max1 = (s[j]-'0')-j+i;

                    a = j;

                }

                

            }

            for (int b = a; b > 0; b--)

            {

                s[b] = s[b-1];

            }

                s[0] = '0';

            

            

            

            printf("%d",max1);

            max1=numeric_limits<int>::min();

        }

        printf("\n");

        

    }

    

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,max1=numeric_limits<int>::min(),a;

char s[1000000];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        a=0;

        scanf("%s",s);

        for (int i = 0; i < strlen(s); i++)

        {

            for (int j = i; j < strlen(s); j++)

            {

                if ((s[j]-'0')-j+i > max1)

                {

                    max1 = (s[j]-'0')-j+i;

                    a = j;

                }

                

            }

            for (int b = a; b > 0; b--)

            {

                s[b] = s[b-1];

            }

                s[0] = '0';

            

            

            

            printf("%d",max1);

            max1=numeric_limits<int>::min();

        }

        printf("\n");

        

    }

    

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <ostream>

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,max1=numeric_limits<int>::min(),a;

char s[1000000];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        a=0;

        scanf("%s",s);

        for (int i = 0; i < strlen(s); i++)

        {

            for (int j = i; j < i+9; j++)

            {

                if ((s[j]-'0')-j+i > max1)

                {

                    max1 = (s[j]-'0')-j+i;

                    a = j;

                }

                

            }

            for (int b = a; b > 0; b--)

            {

                s[b] = s[b-1];

            }

                s[0] = '0';

            

            

            

            printf("%d",max1);

            max1=numeric_limits<int>::min();

        }

        printf("\n");

        

    }

    

    return 0;

}

Submission (verdict: Wrong answer on test 2):
#include <ostream>

#include <cstdio>

#include <algorithm>

#include<list>

#include<queue>

#include <iostream>

#include <cstring>

#include <math.h>

#include <cmath>

#include <string>

using namespace std;

int t,max1=numeric_limits<int>::min(),a;

char s[1000000];

int main(){

    scanf("%d",&t);

    while (t--)

    {

        a=0;

        scanf("%s",s);

        for (int i = 0; i < strlen(s); i++)

        {

            for (int j = i; j < i+9; j++)

            {

                if ((s[j]-'0')-j+i > max1)

                {

                    max1 = (s[j]-'0')-j+i;

                    a = j;

                }

                

            }

            for (int b = a; b > i; b--)

            {

                s[b] = s[b-1];

            }

                s[0] = '0';

            

            

            

            printf("%d",max1);

            max1=numeric_limits<int>::min();

        }

        printf("\n");

        

    }

    

    return 0;

}