ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

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

    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;

        // Gather at most the last 8 numbers in [l, r].
        long long start = max(l, r - 7);
        vector<long long> cand;
        for (long long x = start; x <= r; x++) {
            cand.push_back(x);
        }

        // Brute force all distinct triples among these candidates.
        long long bestVal = -1;
        array<long long,3> bestTriple = {l, l+1, l+2}; // just a valid placeholder
        int sz = (int)cand.size();
        for (int i = 0; i < sz; i++) {
            for (int j = i + 1; j < sz; j++) {
                for (int k = j + 1; k < sz; k++) {
                    long long a = cand[i], b = cand[j], c = cand[k];
                    long long val = (a ^ b) + (b ^ c) + (a ^ c);
                    if (val > bestVal) {
                        bestVal = val;
                        bestTriple = {a, b, c};
                    }
                }
            }
        }

        // Output any triple that maximizes the expression.
        cout << bestTriple[0] << " "
             << bestTriple[1] << " "
             << bestTriple[2] << "\n";
    }
    return 0;
}


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

void solve() {
    int l, r;
    cin >> l >> r;

    // Find the highest bit where l and r differ.
    // __builtin_clz(x) gives the number of leading zeros in x,
    // so 31 - __builtin_clz(l ^ r) is the position of that highest differing bit (0-based).
    int k = 31 - __builtin_clz(l ^ r);

    // Construct a by setting all bits below k to 1 in l.
    int a = l | ((1 << k) - 1);

    // Then b is just a+1, and c is the opposite endpoint if a == l, else c = l.
    int b = a + 1;
    int c = (a == l ? r : l);

    // If b > r (edge case), simply pick the top three distinct values near r.
    // This handles the case where a+1 might exceed r.
    if (b > r) {
        a = r - 2;
        b = r - 1;
        c = r;
    }

    cout << a << " " << b << " " << c << "\n";
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

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

    int t;
    cin >> t;
    while(t--){
        long long l, r;
        cin >> l >> r;

        // We'll gather up to the last 8 numbers in [l, r]
        long long start = max(l, r - 7);
        vector<long long> cand;
        for(long long x = start; x <= r; x++){
            cand.push_back(x);
        }

        // Now brute force all distinct triples in cand
        long long bestVal = -1;
        array<long long,3> bestTriple = {l, l+1, l+2}; // any valid default

        int sz = (int)cand.size();
        for(int i = 0; i < sz; i++){
            for(int j = i+1; j < sz; j++){
                for(int k = j+1; k < sz; k++){
                    long long a = cand[i];
                    long long b = cand[j];
                    long long c = cand[k];
                    long long val = (a ^ b) + (b ^ c) + (a ^ c);
                    if(val > bestVal){
                        bestVal = val;
                        bestTriple = {a, b, c};
                    }
                }
            }
        }

        // Output any triple that attains the maximum
        cout << bestTriple[0] << " "
             << bestTriple[1] << " "
             << bestTriple[2] << "\n";
    }
    return 0;
}


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

void solve() {
    long long l, r;
    cin >> l >> r;

    // Gather up to the last 8 numbers in [l, r].
    // (You could use 4 or 5 instead of 8; any small constant > 3 works fine.)
    long long start = max(l, r - 7);
    vector<long long> cand;
    for (long long x = start; x <= r; x++) {
        cand.push_back(x);
    }

    // Brute force all distinct triples among these candidates
    long long bestVal = -1; 
    array<long long, 3> bestTriple = {l, l+1, l+2}; // placeholder

    int sz = (int)cand.size();
    for (int i = 0; i < sz; i++) {
        for (int j = i + 1; j < sz; j++) {
            for (int k = j + 1; k < sz; k++) {
                long long a = cand[i], b = cand[j], c = cand[k];
                long long val = (a ^ b) + (b ^ c) + (a ^ c);
                if (val > bestVal) {
                    bestVal = val;
                    bestTriple = {a, b, c};
                }
            }
        }
    }

    // Output the triple that gave the maximum value
    cout << bestTriple[0] << " "
         << bestTriple[1] << " "
         << bestTriple[2] << "\n";
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

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

    int t;
    cin >> t;
    while(t--){
        long long l, r;
        cin >> l >> r;

        // We'll gather up to the last 8 numbers in [l, r]
        long long start = max(l, r - 7);
        vector<long long> cand;
        for(long long x = start; x <= r; x++){
            cand.push_back(x);
        }

        // Now brute force all distinct triples in cand
        long long bestVal = -1;
        array<long long,3> bestTriple = {l, l+1, l+2}; // any valid default

        int sz = (int)cand.size();
        for(int i = 0; i < sz; i++){
            for(int j = i+1; j < sz; j++){
                for(int k = j+1; k < sz; k++){
                    long long a = cand[i];
                    long long b = cand[j];
                    long long c = cand[k];
                    long long val = (a ^ b) + (b ^ c) + (a ^ c);
                    if(val > bestVal){
                        bestVal = val;
                        bestTriple = {a, b, c};
                    }
                }
            }
        }

        // Output any triple that attains the maximum
        cout << bestTriple[0] << " "
             << bestTriple[1] << " "
             << bestTriple[2] << "\n";
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

#define vi vector<int>
#define vll vector<long long>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<long long,long long>>
#define mod1 1000000007
#define mod2 998244353
#define INF 1e18
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define ff first
#define ss second
#define pi 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mn(nums) *min_element(nums.begin(),nums.end()) 
#define mx(nums) *max_element(nums.begin(),nums.end())
#define rep(i,a,b) for(ll i=(a) ; i<(b) ; i++)
#define read(a) for(auto &it : a) cin>>it
#define ll long long
#define yes cout << "YES" << endl 
#define no cout << "NO" << endl 
#define nl endl 
// Memoization map

bool isprime(ll x)
{
	if(x == 2) return true ;
	for(int i=2;i<x;i++)
	{
		if(x%i == 0) return false ;
	}
	return true ;
}
ll cell(ll a,ll b)
{
	ll res = a/b ;
	if(a%b) res++ ;
	return res ;
}

bool solver(vector<ll> &v, vector<vector<ll>> &dp, ll sum, ll ind)
{
	if(ind >= v.size())
	{
		if(sum%9 == 0) return true ;
		return false ;
	}
	
	
	if(dp[ind][sum] != -1) return dp[ind][sum] ;
	
	bool take = false , nottake = false ;
	if(v[ind] == 2 or v[ind] == 3) 
	{
		ll a = v[ind] ;
		take = solver(v, dp, sum+a*a-a, ind+1) ;
	}
	nottake = solver(v, dp, sum, ind+1) ;
	
	return dp[ind][sum] = take or nottake ;
	
}
void solve() {   
    
        string s ;
        cin>>s ;
        vll v ;
        for(auto &it : s) v.pb(it-'0') ;
        
        ll sum = accumulate(all(v),0LL) ;
        
        vector<vector<ll>> dp(v.size(),vector<ll>(9*v.size(),-1)) ;
        
        bool check = solver(v, dp, sum, 0) ;
        if(check) yes ;
        else no ;
    
        	
        
    }
 
 

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("Error.txt", "w", stderr);
    #endif

    ll t=1 ;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }
    vector<pair<int,int>>m;
    long long s = 0;
    for(int i = 0;i<n;i++)
    {
        
        for(int j = i+1;j<n;j++)
        {
            if(v[j]<v[i])
            {
                s++;
                m.push_back({v[i],v[j]});
            }
        }
        // for(int j = v[i]-1;j>=1;j--)
        // {
        //     for(int k = i+1;k<n;k++)
        //     {
        //         if(v[k]==j)
        //         {
        //             m.push_back({v[i],j});
        //             s++;
        //             break;
        //         }f
        //     }
            
        // }
        int pos = -1;
        for(int j = i-1;j>=0;j--)
        {
            if(v[j]<v[i])
            {
                s++;
                m.push_back({v[i],v[j]});
            }
            else
            {
                pos = j;
                break;
            }
        }
        for(int j = pos+1;j<i;j++)
        {
            if(v[j]<v[i])
            {
                s++;
                m.push_back({v[j],v[i]});
            }
            
            
        }
        
        
    }
    cout<<s<<endl;
    for(int i = 0;i<m.size();i++)
    {
        auto it = m[i];
        cout<<it.first<<" "<<it.second;
        cout<<endl;
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
========================================
Author:         Aditya Chandak
Institution:    IIITL
========================================
*/

int main()
{
    
    
        int n;
        cin>>n;
        vector<int> v(n+1);
        vector<int>a(n+1);
        for(int i  = 1;i<=n;i++)
        {
            int ele;
            cin>>ele;
            v[ele] = i;
            a[i]= ele;
        }
        vector<pair<int,int>> m;
        long long s = 0;
        for(int i = 1;i<=n;i++)
        {
            int index = v[i];
            for(int j = n;j>index;j--)
            {
                if(a[j]<i)
                {
                    s++;
                    m.push_back({i,a[j]});
                }
            }
            for(int j=index-1;j>0;j--)
            {
                if(a[j]<i)
                {
                    s+=1;
                    m.push_back({i,a[j]});
                    
                }
            }
            for(int j=1;j<index;j++)
            {
                if(a[j]<i)
                {
                    s+=1;
                    m.push_back({a[j],i});
                    
                }
            }
        }
        cout<<s<<endl;
        for(int i = 0;i<m.size();i++)
        {
            cout<<m[i].first<<" "<<m[i].second<<endl;
        }
        
    }
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }
    vector<pair<int,int>>m;
    long long s = 0;
    for(int i = 0;i<n;i++)
    {
        int curp = v[i];
        s+=v[i]-1;
        for(int j = 1;j<v[i];j++)
        {
            m.push_back({v[i],j});
        }
        for(int j = 0;j<i;j++)
        {
            if(v[j]<v[i])
            {
                s++;
                m.push_back({v[j],v[i]});
            }
        }
    }
    cout<<s<<endl;
    for(int i = 0;i<m.size();i++)
    {
        auto it = m[i];
        cout<<it.first<<" "<<it.second;
        cout<<endl;
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }
    vector<pair<int,int>>m;
    long long s = 0;
    for(int i = 0;i<n;i++)
    {
        int curp = v[i];
        s+=v[i]-1;
        for(int j = 1;j<v[i];j++)
        {
            m.push_back({v[i],j});
        }
        for(int j = 0;j<i;j++)
        {
            if(v[j]<v[i])
            {
                s++;
                m.push_back({v[j],v[i]});
            }
        }
    }
    cout<<s<<endl;
    for(int i = 0;i<m.size();i++)
    {
        auto it = m[i];
        cout<<it.first<<" "<<it.second;
        cout<<endl;
    }
}

Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }
    vector<pair<int,int>>m;
    long long s = 0;
    for(int i = 0;i<n;i++)
    {
        
        for(int j = i+1;j<n;j++)
        {
            if(v[j]<v[i])
            {
                s++;
                m.push_back({v[i],v[j]});
            }
        }
        // for(int j = v[i]-1;j>=1;j--)
        // {
        //     for(int k = i+1;k<n;k++)
        //     {
        //         if(v[k]==j)
        //         {
        //             m.push_back({v[i],j});
        //             s++;
        //             break;
        //         }f
        //     }
            
        // }
        int pos = -1;
        for(int j = i-1;j>=0;j--)
        {
            if(v[j]<v[i])
            {
                s++;
                m.push_back({v[i],v[j]});
            }
            else
            {
                pos = j;
                break;
            }
        }
        for(int j = pos+1;j<i;j++)
        {
            if(v[j]<v[i])
            {
                s++;
                m.push_back({v[j],v[i]});
            }
            
            
        }
        
        
    }
    cout<<s<<endl;
    for(int i = 0;i<m.size();i++)
    {
        auto it = m[i];
        cout<<it.first<<" "<<it.second;
        cout<<endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
void solve (int n){
	string s=to_string(n);
	int m=s.size();
	for(int j=0; j<m; j++){
	for(int i=1; i<m; i++){
		if(s[i]-1>0 && s[i-1]<s[i]-1){
		    int k=s[i];
		    s[i]=s[i-1];
		    s[i-1]=k-1;
		}
			
		
	}
	}
	
	
	cout<<s;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		solve(n);
		cout<<endl;
	}
}
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;
void solve (string s){
	
	int m=s.size();
	for(int j=0; j<m; j++){
	for(int i=1; i<m; i++){
		if(s[i]-1>0 && s[i-1]<s[i]-1){
		    int k=s[i];
		    s[i]=s[i-1];
		    s[i-1]=k-1;
		}
			
		
	}
	}
	
	
	cout<<s;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		string s;
		cin>>s;
		solve(s);
		cout<<endl;
	}
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
void solve (string s){
	
	int m=s.size();
	bool flag =  true;
	while(flag){
		flag =false;
		for(int i=1; i<m; i++){
			
		if(s[i]-1>0 && s[i-1]<s[i]-1){
		    int k=s[i];
		    s[i]=s[i-1];
		    s[i-1]=k-1;
		    flag=true;
		}
			
		
	}
	}
	
	
	
	
	cout<<s;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		string s;
		cin>>s;
		solve(s);
		cout<<endl;
	}
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
void solve (int n){
	string s=to_string(n);
	int m=s.size();
	for(int j=0; j<m; j++){
	for(int i=1; i<m; i++){
		if(s[i]-1>0 && s[i-1]<s[i]-1){
		    int k=s[i];
		    s[i]=s[i-1];
		    s[i-1]=k-1;
		}
			
		
	}
	}
	
	
	cout<<s;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		solve(n);
		cout<<endl;
	}
}

Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;
void solve (string s){
	
	int m=s.size();
	for(int j=0; j<m; j++){
	for(int i=1; i<m; i++){
		if(s[i]-1>0 && s[i-1]<s[i]-1){
		    int k=s[i];
		    s[i]=s[i-1];
		    s[i-1]=k-1;
		}
			
		
	}
	}
	
	
	cout<<s;
}
int main(){
	int t;
	cin>>t;
	while(t--){
		string s;
		cin>>s;
		solve(s);
		cout<<endl;
	}
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long
// const long long MOD = 998244353;
 
// #define MAXN 200001
// int d[MAXN];
// std::vector<int> g[MAXN];
// inline int deg(int u) { return g[u].size(); }
void solve() {
ll n; cin >> n;
int num2=0,num3=0;
ll sum=0;
while(n!=0){
	int p=n%10;
	
	if( p == 2){
		num2++;
	}
	else if(p==3){
		num3++;
	}
	sum+=(p);
	n=n/10;
}

// if(sum % 9 == 0){
// 	cout << "yes" << endl;
// 	return ;
// }

	for(int i=0;i<min(num2+1,10);i++){
	for(int j=0;j<min(num3+1,10);j++){
		if((sum+(i*2+j*6))% 9 == 0){
			cout << "yes" << endl;
			return ;
		}
	}
}

cout << "No " << endl;

}


 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr), std::cout.tie(nullptr);
	int t; std::cin >> t; while (t--) solve(); return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long
// const long long MOD = 998244353;
 
// #define MAXN 200001
// int d[MAXN];
// std::vector<int> g[MAXN];
// inline int deg(int u) { return g[u].size(); }
void solve() {
ll n; cin >> n;
int num2=0,num3=0;
ll sum=0;
while(n!=0){
	int p=n%10;
	
	if( p == 2){
		num2++;
	}
	else if(p==3){
		num3++;
	}
	sum+=(p);
	n=n/10;
}

// if(sum % 9 == 0){
// 	cout << "yes" << endl;
// 	return ;
// }

	for(int i=0;i<min(num2+1,10);i++){
	for(int j=0;j<min(num3+1,10);j++){
		if((sum+(i*2+j*6))% 9 == 0){
			cout << "yes" << endl;
			return ;
		}
	}
}

cout << "No " << endl;

}


 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr), std::cout.tie(nullptr);
	int t; std::cin >> t; while (t--) solve(); return 0;
}

Submission (verdict: Compilation error):
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long
// const long long MOD = 998244353;
 
// #define MAXN 200001
// int d[MAXN];
// std::vector<int> g[MAXN];
// inline int deg(int u) { return g[u].size(); }
void solve() {
string n; cin >> n;
int num2=0,num3=0;

ll sum=0;
for(auto c :n){
    if(c== '2'){
        num2++;
    }
    if(c=='3'){
        num3++;
    }
    sum+=(c-'0');
    
}
while(n!=0){
	int p=n%10;
	
	if( p == 2){
		num2++;
	}
	else if(p==3){
		num3++;
	}
	sum+=(p);
	n=n/10;
}

// if(sum % 9 == 0){
// 	cout << "yes" << endl;
// 	return ;
// }

	for(int i=0;i<min(num2+1,10);i++){
	for(int j=0;j<min(num3+1,10);j++){
		if((sum+(i*2+j*6))% 9 == 0){
			cout << "yes" << endl;
			return ;
		}
	}
}

cout << "No " << endl;

}


 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr), std::cout.tie(nullptr);
	int t; std::cin >> t; while (t--) solve(); return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long
// const long long MOD = 998244353;
 
// #define MAXN 200001
// int d[MAXN];
// std::vector<int> g[MAXN];
// inline int deg(int u) { return g[u].size(); }
void solve() {
string n; cin >> n;
int num2=0,num3=0;

ll sum=0;
for(auto c :n){
    if(c== '2'){
        num2++;
    }
    if(c=='3'){
        num3++;
    }
    sum+=(c-'0');
    
}
while(n!=0){
	int p=n%10;
	
	if( p == 2){
		num2++;
	}
	else if(p==3){
		num3++;
	}
	sum+=(p);
	n=n/10;
}

// if(sum % 9 == 0){
// 	cout << "yes" << endl;
// 	return ;
// }

	for(int i=0;i<min(num2+1,10);i++){
	for(int j=0;j<min(num3+1,10);j++){
		if((sum+(i*2+j*6))% 9 == 0){
			cout << "yes" << endl;
			return ;
		}
	}
}

cout << "No " << endl;

}


 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr), std::cout.tie(nullptr);
	int t; std::cin >> t; while (t--) solve(); return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long
// const long long MOD = 998244353;
 
// #define MAXN 200001
// int d[MAXN];
// std::vector<int> g[MAXN];
// inline int deg(int u) { return g[u].size(); }
void solve() {
string n; cin >> n;
int num2=0,num3=0;

ll sum=0;
for(auto c :n){
    if(c== '2'){
        num2++;
    }
    if(c=='3'){
        num3++;
    }
    sum+=(c-'0');
    
}

	for(int i=0;i<min(num2+1,10);i++){
	for(int j=0;j<min(num3+1,10);j++){
		if((sum+(i*2+j*6))% 9 == 0){
			cout << "yes" << endl;
			return ;
		}
	}
}

cout << "No " << endl;

}


 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr), std::cout.tie(nullptr);
	int t; std::cin >> t; while (t--) solve(); return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long
// const long long MOD = 998244353;
 
// #define MAXN 200001
// int d[MAXN];
// std::vector<int> g[MAXN];
// inline int deg(int u) { return g[u].size(); }
void solve() {
string s;
cin >> s;
for(int i=0;i<s.size();i++){
	int best=s[i]-'0',pos=i;
	for(int j=i;j<min(i+10,(int)s.size();j++)){
		if(s[j] -'0' -(j-i)>best){
			best=s[j]-'0'-(j-i);
			pos=j;
		}
	}
	while(pos > i){
		swap(s[pos],s[pos-1]);
		pos--;
	}
}
cout << s << endl;
}


 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr), std::cout.tie(nullptr);
	int t; std::cin >> t; while (t--) solve(); return 0;
}

Submission (verdict: Compilation error):
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long
// const long long MOD = 998244353;
 
// #define MAXN 200001
// int d[MAXN];
// std::vector<int> g[MAXN];
// inline int deg(int u) { return g[u].size(); }
void solve() {
string s;
cin >> s;
for(int i=0;i<s.size();i++){
	int best=s[i]-'0',pos=i;
	for(int j=i;j<min(i+10,(int)s.size());j++)){
		if(s[j] -'0' -(j-i)>best){
			best=s[j]-'0'-(j-i);
			pos=j;
		}
	}
	while(pos > i){
		swap(s[pos],s[pos-1]);
		pos--;
	}
}
cout << s << endl;
}


 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr), std::cout.tie(nullptr);
	int t; std::cin >> t; while (t--) solve(); return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Compilation error):
#include <bits/stdc++.h>
 using namespace std;
 #define ll long long
// const long long MOD = 998244353;
 
// #define MAXN 200001
// int d[MAXN];
// std::vector<int> g[MAXN];
// inline int deg(int u) { return g[u].size(); }
void solve() {
string s;
cin >> s;
for(int i=0;i<s.size();i++){
	int best=s[i]-'0',pos=i;
	for(int j=i;j<min(i+10,(int)s.size();j++)){
		if(s[j] -'0' -(j-i)>best){
			best=s[j]-'0'-(j-i);
			pos=j;
		}
	}
	while(pos > i){
		swap(s[pos],s[pos-1]);
		pos--;
	}
}
cout << s << endl;
}


 
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr), std::cout.tie(nullptr);
	int t; std::cin >> t; while (t--) solve(); return 0;
}