ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)




void solve(){
    ll n;
    cin >> n;
    vector<ll>arr(n);
    for(auto &i : arr)cin >> i;

    ll max_sum = 0;

    for(ll i = 0 ; i < n ; i++)max_sum += arr[i];

    vector<ll>diff;
    for(ll i = 0 ; i < n - 1 ; i++)diff.push_back(arr[i + 1] - arr[i]);
    ll sum = accumulate(diff.begin() , diff.end() , (ll)0);
    max_sum = max(max_sum , max(sum  , -1 * sum));
    if(diff.size() == 1){
        max_sum = max(max_sum , max(diff[0] , -diff[0]));
        cout<<max_sum<<"\n";
        return;
    }

    for(ll i = 1 ;  i < n ; i++){
         if(diff.size() == 1){
            max_sum = max(max_sum , max(diff[0] , -1 * diff[0]));
            break;
         }
         vector<ll>diff2;
         for(ll j = 0 ; j < diff.size() - 1 ; j++){
             diff2.push_back(diff[j + 1] - diff[j]);
         }
    
         ll p1 = diff[diff.size() - 1] - diff[0];
         ll p2 = -p1;
         max_sum = max(max_sum , max(p1 , p2));
         diff = diff2;
    }
    cout<<max_sum<<"\n";
}


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

   fio;
   int testcase =  1;
   cin >> testcase;
   while(testcase--){
     solve();
   }

 return 0;   
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)




void solve(){
    ll n;
    cin >> n;
    vector<ll>arr(n);
    for(auto &i : arr)cin >> i;

    if(n == 1){
       cout<<arr[0]<<"\n";
       return;
    }

    ll max_sum = 0;

    for(ll i = 0 ; i < n ; i++)max_sum += arr[i];

    vector<ll>diff;
    for(ll i = 0 ; i < n - 1 ; i++)diff.push_back(arr[i + 1] - arr[i]);
    ll sum = accumulate(diff.begin() , diff.end() , (ll)0);
    max_sum = max(max_sum , max(sum  , -1 * sum));
    if(diff.size() == 1){
        max_sum = max(max_sum , max(diff[0] , -diff[0]));
        cout<<max_sum<<"\n";
        return;
    }

    for(ll i = 1 ;  i < n ; i++){
         if(diff.size() == 1){
            max_sum = max(max_sum , max(diff[0] , -1 * diff[0]));
            break;
         }
         vector<ll>diff2;
         for(ll j = 0 ; j < diff.size() - 1 ; j++){
             diff2.push_back(diff[j + 1] - diff[j]);
         }
    
         ll p1 = diff[diff.size() - 1] - diff[0];
         ll p2 = -p1;
         max_sum = max(max_sum , max(p1 , p2));
         diff = diff2;
    }
    cout<<max_sum<<"\n";
}


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

   fio;
   int testcase =  1;
   cin >> testcase;
   while(testcase--){
     solve();
   }

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


Submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)




void solve(){
    ll n;
    cin >> n;
    vector<ll>arr(n);
    for(auto &i : arr)cin >> i;

    ll max_sum = 0;

    for(ll i = 0 ; i < n ; i++)max_sum += arr[i];

    vector<ll>diff;
    for(ll i = 0 ; i < n - 1 ; i++)diff.push_back(arr[i + 1] - arr[i]);
    if(diff.size() == 1){
        max_sum = max(max_sum , max(diff[0] , -diff[0]));
        cout<<max_sum<<"\n";
        return;
    }

    for(ll i = 1 ;  i < n ; i++){
         vector<ll>diff2;
         for(ll j = 0 ; j < diff.size() - 1 ; j++){
             diff2.push_back(diff[j + 1] - diff[j]);
         }
         ll p1 = diff[diff.size() - 1] - diff[0];
         ll p2 = -p1;
         max_sum = max(max_sum , max(p1 , p2));
         diff = diff2;
    }
    cout<<max_sum<<"\n";
}


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

   fio;
   int testcase =  1;
   cin >> testcase;
   while(testcase--){
     solve();
   }

 return 0;   
}
Problem: 2050C - Uninteresting Number
Language: Java 21


Submission (verdict: Wrong answer on test 2):
// Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t>0){
            long n=sc.nextLong();
            long temp=n;
            long ans=0;
            long cnt1=0;
            long cnt2=0;
            boolean two=false;
            boolean three=false;
            while(n>0){
                long l=n%10;
                if(l==2){
                    cnt1=cnt1+2;
                }
                else if(l==3){
                    cnt2=cnt2+6;
                }
                ans=ans+l;
                n=n/10;
                if((temp+cnt1)%9==0 || (temp+cnt2)%9==0 || (temp+cnt1+cnt2)%9==0){
                    three=true;
                    break;
                }
            }
            if(ans%9==0 || three==true){
                System.out.println("YES");
            }
            else{
                long sum=temp+cnt1+cnt2;
                long temp1=sum%9;
                if(temp1>=2 && temp1%2==0){
                    if(temp<=cnt1){
                        sum=sum-temp1;
                    }
                    else{
                        sum=sum-cnt1;
                    }
                    temp1=sum%9;
                }
                if(sum%9!=0 && temp1%6==0 && temp1<=cnt2){
                    sum=sum-temp1;
                    temp1=sum%9;
                }
                if(sum%9==0){
                    System.out.println("YES");
                }
                else{
                    System.out.println("NO");
                }
            }
            t--;
        }
    }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 3):
#include<bits/stdc++.h>
using namespace std;

#define int long long int

int m = 1;

int find9(string x, int i, int n, int d){
	
	

	if(d == 0){
		return 1;
	}
	if(i >= n){
		return 0;
	}
	if( (x[i]-'0') < 4 && (x[i]-'0') > 1 ){



		if((x[i]-'0') == 2){

			int a1 = find9(x, i+1, n, d);

			
			d+=2;
			d%=9;

			int a2 = find9(x, i+1, n, d);

			return (a1||a2);
		}
		else{
			int a1 = find9(x, i+1, n, d);

			
			d+= 6;
			d%=9;

			int a2 = find9(x, i+1, n, d);

			return (a1||a2);
		}

	}
	else
	return find9(x, i+1, n, d);
}


void solve(){
	string x;
	cin >> x;

	int ans = 0;

	
	int n = x.size();
	
	int d = 0;
	for (int i = 0; i < n; ++i){

		int s = (x[i]-'0') + d*10;

		d = s%9;
	}

	if(d == 0){
		ans = 1;
	}
	else
	ans = find9(x, 0, n, d);


	if(ans){
		cout<< "YES"<< endl;
	}
	else{
		cout<< "NO" << endl;
	}
}

int32_t main(){
	string s;
	int x = 0;

	// for(int i = 0; i<43*2+1; i++)
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}

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

#define int long long int

int m = 1;

int find9(string x, int i, int n, int d){
	
	

	if(d == 0){
		return 1;
	}
	if(i >= n){
		return 0;
	}
	
	if((x[i]-'0') == 2){

			int a1 = find9(x, i+1, n, d);

			
			d+=2;
			d%=9;

			int a2 = find9(x, i+1, n, d);

			return (a1||a2);
		}
		else if(x[i]-'0' == 3){
			int a1 = find9(x, i+1, n, d);

			
			d+= 6;
			d%=9;

			int a2 = find9(x, i+1, n, d);

			return (a1||a2);
		}
	else
	return find9(x, i+1, n, d);
}


void solve(){
	string x;
	cin >> x;

	int ans = 0;

	
	int n = x.size();

	int a = 0, b = 0;
	
	int d = 0;
	for (int i = 0; i < n; ++i){

		if(x[i]-'0' == 2)
			a++;
		if(x[i]-'0' == 3)
			b++;

		int s = (x[i]-'0') + d*10;

		d = s%9;
	}

	if(d == 0 || a >= 8){
		ans = 1;
	}

	if(d == 1){
		if(a >= 4 || (b>= 1 && a >= 1)){
			ans = 1;
		}

	}else if(d == 2){
		if(a>=8 || (b>=1 && a>= 5) || (b >=2 && a >=2))
			ans = 1;

	}else if(d == 3){
		if(b>=1 || a >= 3){
			ans = 1;
		}
		
	}else if(d == 4){
		if(a >= 7 || (b>=2 && a>= 1) || (b>=1 && a>= 4))
			ans = 1;
		
	}else if(d == 5){
		if(a>=2)
			ans = 1;
		
	}else if(d == 6){
		if(b>= 2 || a>= 6 || (b>=1 && a>= 3))
			ans = 1;
		
	}else if(d == 7){
		if(a>= 1)
			ans = 1;
		
	}else if(d == 8){
		if(a>= 5 || (b>= 1 && a>= 2))
			ans = 1;
	}

	// else
	// ans = find9(x, 0, n, d);





	if(ans){
		cout<< "YES"<< endl;
	}
	else{
		cout<< "NO" << endl;
	}
}

int32_t main(){
	string s;
	int x = 0;

	// for(int i = 0; i<43*2+1; i++)
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 3):
#include<bits/stdc++.h>
using namespace std;

#define int long long int

int m = 1;

int find9(string x, int i, int n, int m){
	
	// cerr << i << "-"<<x <<", ";

	
	// check divisible

	int d = 0;
	for (int i = 0; i < n; ++i)
	{
		int s = (x[i]-'0') + d*10;

		d = s%9;
	}

	if(d == 0){
		return 1;
	}


	if(i >= n){
		return 0;
	}

	// cerr << m;

	// cerr << (x/(m*1)) << " ..";


	if( (x[i]-'0') < 4 && (x[i]-'0') > 1 ){



		if((x[i]-'0') == 2){

			int a1 = find9(x, i+1, n, m);

			x[i] = (4+'0');

			int a2 = find9(x, i+1, n, m);

			return (a1||a2);
		}
		else{
			int a1 = find9(x, i+1, n, m);

			x[i] = (9+'0');

			int a2 = find9(x, i+1, n, m);

			return (a1||a2);
		}

	}
	else
	return find9(x, i+1, n, m);
}


void solve(){
	string x;
	cin >> x;

	int ans = 0;

	
	int n = x.size();
	

	ans = find9(x, 0, n, 1);


	if(ans){
		cout<< "YES"<< endl;
	}
	else{
		cout<< "NO" << endl;
	}
}

int32_t main(){
	string s;
	int x = 0;

	// for(int i = 0; i<43*2+1; i++)
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}

Submission (verdict: Time limit exceeded on test 3):
#include<bits/stdc++.h>
using namespace std;

#define int long long int

int m = 1;

int find9(string x, int i, int n, int d){
	
	

	if(d == 0){
		return 1;
	}
	if(i >= n){
		return 0;
	}
	if( (x[i]-'0') < 4 && (x[i]-'0') > 1 ){



		if((x[i]-'0') == 2){

			int a1 = find9(x, i+1, n, d);

			
			d+=2;
			d%=9;

			int a2 = find9(x, i+1, n, d);

			return (a1||a2);
		}
		else{
			int a1 = find9(x, i+1, n, d);

			
			d+= 6;
			d%=9;

			int a2 = find9(x, i+1, n, d);

			return (a1||a2);
		}

	}
	else
	return find9(x, i+1, n, d);
}


void solve(){
	string x;
	cin >> x;

	int ans = 0;

	
	int n = x.size();
	
	int d = 0;
	for (int i = 0; i < n; ++i){

		int s = (x[i]-'0') + d*10;

		d = s%9;
	}

	if(d == 0){
		ans = 1;
	}
	else
	ans = find9(x, 0, n, d);


	if(ans){
		cout<< "YES"<< endl;
	}
	else{
		cout<< "NO" << endl;
	}
}

int32_t main(){
	string s;
	int x = 0;

	// for(int i = 0; i<43*2+1; i++)
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

#define int long long int

int m = 1;

int find9(int x, int i, int n, int m){
	if(i != 0){
		m*=10;
	}

	// cerr << i << "-"<<x <<", ";

	if(x%9 == 0){
		return 1;
	}

	if(i >= n){
		return 0;
	}

	// cerr << m;

	// cerr << (x/(m*1)) << " ..";


	if((x/(m))%10 < 4 && (x/(m))%10 > 1 ){



		if((x/(m))%10 == 2){

			return ( find9(x, i+1, n, m) || find9(x+(2*(m)), i+1, n, m));

		}
		else{


			return (find9(x, i+1, n, m) || find9(x+(6*m), i+1, n, m));
		}

	}
	else
	return find9(x, i+1, n, m);
}


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

	int ans = 0;

	if(x%9 == 0)
		ans = 1;
	
	int n = 0, p=x;
	while(p>0){
		n++;
		p/=10;
	}
	cerr << endl;

	ans = find9(x, 0, n, 1);

	if(ans){
		cout<< "YES"<< endl;
	}
	else{
		cout<< "NO" << endl;
	}
}

int32_t main(){
	string s;
	int x = 0;

	// for(int i = 0; i<43*2+1; i++)
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}

Submission (verdict: Time limit exceeded on test 3):
#include<bits/stdc++.h>
using namespace std;

#define int long long int

int m = 1;

int find9(string x, int i, int n, int m){
	
	// cerr << i << "-"<<x <<", ";

	
	// check divisible

	int d = 0;
	for (int i = 0; i < n; ++i)
	{
		int s = (x[i]-'0') + d*10;

		d = s%9;
	}

	if(d == 0){
		return 1;
	}


	if(i >= n){
		return 0;
	}

	// cerr << m;

	// cerr << (x/(m*1)) << " ..";


	if( (x[i]-'0') < 4 && (x[i]-'0') > 1 ){



		if((x[i]-'0') == 2){

			int a1 = find9(x, i+1, n, m);

			x[i] = (4+'0');

			int a2 = find9(x, i+1, n, m);

			return (a1||a2);
		}
		else{
			int a1 = find9(x, i+1, n, m);

			x[i] = (9+'0');

			int a2 = find9(x, i+1, n, m);

			return (a1||a2);
		}

	}
	else
	return find9(x, i+1, n, m);
}


void solve(){
	string x;
	cin >> x;

	int ans = 0;

	
	int n = x.size();
	

	ans = find9(x, 0, n, 1);


	if(ans){
		cout<< "YES"<< endl;
	}
	else{
		cout<< "NO" << endl;
	}
}

int32_t main(){
	string s;
	int x = 0;

	// for(int i = 0; i<43*2+1; i++)
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


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

#define int long long int

int m = 1;

int find9(int x, int i, int n, int m){
	if(i != 0){
		m*=10;
	}

	// cerr << i << "-"<<x <<", ";

	if(x%9 == 0){
		return 1;
	}

	if(i >= n){
		return 0;
	}

	// cerr << m;

	// cerr << (x/(m*1)) << " ..";


	if((x/(m))%10 < 4 && (x/(m))%10 > 1 ){



		if((x/(m))%10 == 2){

			return ( find9(x, i+1, n, m) || find9(x+(2*(m)), i+1, n, m));

		}
		else{


			return (find9(x, i+1, n, m) || find9(x+(6*m), i+1, n, m));
		}

	}
	else
	return find9(x, i+1, n, m);
}


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

	int ans = 0;

	if(x%9 == 0)
		ans = 1;
	
	int n = 0, p=x;
	while(p>0){
		n++;
		p/=10;
	}
	cerr << endl;

	ans = find9(x, 0, n, 1);

	if(ans){
		cout<< "YES"<< endl;
	}
	else{
		cout<< "NO" << endl;
	}
}

int32_t main(){
	string s;
	int x = 0;

	// for(int i = 0; i<43*2+1; i++)
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve(){
	int n;

	string a;
	cin>> a;
	n = a.size();

	for (int i = 0; i < n; ++i)
	{
		
		int mx = a[i]-'0', mxi=i;

		for (int j = i+1; j < i+9; ++j)
		{
			if(mx < (a[j]-'0'-(j-i))){
				mx = (a[j]-'0'-(j-i));

				mxi = j;
			}
		}

		// swap

		
		int c = a[i], cn = 0;
		for (int k = i+1; k <= mxi; ++k)
		{
			cn = a[k];
			a[k] = c;
			c = cn;
		}
		a[i] = mx+'0';

		// cerr<< a <<",";
	}

	// cerr<<endl;

	cout<< a << endl;
}

int32_t main(){

	std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr); std::cout.tie(nullptr);
	// string s;
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}

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

void solve(){
	int n;

	string a;
	cin>> a;
	n = a.size();

	for (int i = 0; i < n; ++i)
	{
		
		int mx = a[i]-'0', mxi=i;

		for (int j = i+1; j < i+9 && j < n; ++j)
		{
			if(mx < (a[j]-'0'-(j-i))){
				mx = (a[j]-'0'-(j-i));

				mxi = j;
			}
		}

		// swap

		
		int c = a[i], cn = 0;
		for (int k = i+1; k <= mxi; ++k)
		{
			cn = a[k];
			a[k] = c;
			c = cn;
		}
		a[i] = mx+'0';

		// cerr<< a <<",";
	}

	// cerr<<endl;

	cout<< a << endl;
}

int32_t main(){

	std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr); std::cout.tie(nullptr);
	// string s;
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 6):
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;

void solve(){
	int n;

	string a;
	cin>> a;
	n = a.size();

	for (int i = 0; i < n; ++i)
	{
		
		int mx = a[i]-'0', mxi=i;

		for (int j = i+1; j < n; ++j)
		{
			if(mx < (a[j]-'0'-(j-i))){
				mx = (a[j]-'0'-(j-i));

				mxi = j;
			}
		}

		// swap

		
		int c = a[i], cn = 0;
		for (int k = i+1; k <= mxi; ++k)
		{
			cn = a[k];
			a[k] = c;
			c = cn;
		}
		a[i] = mx+'0';

		// cerr<< a <<",";
	}

	// cerr<<endl;

	cout<< a << endl;
}

int main(){
	// string s;
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

void solve(){
	int n;

	string a;
	cin>> a;
	n = a.size();

	for (int i = 0; i < n; ++i)
	{
		
		int mx = a[i]-'0', mxi=i;

		for (int j = i+1; j < n; ++j)
		{
			if(mx < (a[j]-'0'-(j-i))){
				mx = (a[j]-'0'-(j-i));

				mxi = j;
			}
		}

		// swap

		
		int c = a[i], cn = 0;
		for (int k = i+1; k <= mxi; ++k)
		{
			cn = a[k];
			a[k] = c;
			c = cn;
		}
		a[i] = mx+'0';

		// cerr<< a <<",";
	}

	// cerr<<endl;

	cout<< a << endl;
}

int main(){
	// string s;
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    cin>> t;
    while(t--){
    	solve();
    }

    return 0;
}

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

void solve(){
	int n;

	string a;
	cin>> a;
	n = a.size();

	for (int i = 0; i < n; ++i)
	{
		
		int mx = a[i]-'0', mxi=i;

		for (int j = i+1; j < i+9; ++j)
		{
			if(mx < (a[j]-'0'-(j-i))){
				mx = (a[j]-'0'-(j-i));

				mxi = j;
			}
		}

		// swap

		
		int c = a[i], cn = 0;
		for (int k = i+1; k <= mxi; ++k)
		{
			cn = a[k];
			a[k] = c;
			c = cn;
		}
		a[i] = mx+'0';

		// cerr<< a <<",";
	}

	// cerr<<endl;

	cout<< a << endl;
}

int32_t main(){

	std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr); std::cout.tie(nullptr);
	// string s;
	// getline(cin, s);

	// int i = 0;
	// while(s[i] != '\0'){
	// 	cout<< s[i];
	// 	i++;
	// }

	// cout<< s << endl;

	int t = 0;

    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 <bits/stdc++.h>
using namespace std;

#define RANGE(i, a, b)                                                         \
    for (auto i = a - (a > b); (i < b) ^ (a > b); i += 1 - 2 * (a > b))
#define ll long long
/*
 1 -> 1 No change
 2 -> 4: +2 // only this can be applied twice, in that case: +5
 3 -> 9: +6
 So we can change x 2s to 4, and y 3s to 6s. The new remainder of the number
 becomes 2*x + 6*y == 0 [9]. We must find a solution for (x, y), with the upper
 bound being the actual number of occurence of 2s and 3s.
 Les restes possible d'un multiplication par 2 mod 9:
 1*2 = 2 [9]
 2*2 = 4 [9]
 3*2 = 6 [9]
 4*2 = 8 [9]
 5*2 = 0 [9]
 Les restes possible d'une multiplication par 6 mod 9:
 1*6 = 6 [9]
 2*6 = 3 [9]
 3*6 = 0 [9]
 Tableau des additions possibles:
 ---- 0 2 4 6 8
    0 0 2 4 6 7
    3 3 5 7 0 2
    6 6 8 1 3 5

*/

void solve() {
    ll n;
    cin >> n;
    ll count2 = 0, count3 = 0;
    ll rem = 0;
    for (; n > 0; n /= 10) {
        rem += n % 10;
        if (n % 10 == 2)
            count2++;
        else if (n % 10 == 3)
            count3++;
    }
    rem %= 9;
    // cout << count2 << " " << count3 << " " << rem << endl;
    if (count2 >= 5 && count3 >= 3) {
        cout << "Yes" << endl;
        return;
    }
    for (int n2 = 0; n2 <= min(count2, 10ll); n2++)
        for (int n3 = 0; n3 <= min(count3, 10ll); n3++)
            if ((n2 * 2 + n3 * 6 + rem) % 9 == 0) {
                cout << "Yes" << endl;
                return;
            }
    cout << "No" << endl;
}

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

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


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

// #pragma GCC optimize("O3,unroll-loops,Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")

#include <algorithm>
#include <chrono>
#include <cmath>
#include <iostream>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <unordered_set>
#include <string>
#include <iomanip>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
#define endl "\n"
#define pii pair<ll,ll>
#define rep(i,x,a) for(ll i=x;i<a;i++)
#define per(i,x,a) for(ll i=a-1;i>=x;i--)
#define yesno(x) cout << ((x) ? "YES" : "NO") << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll MOD = 1e9 + 7;

struct Point{
    ll x, y;
};

void print(vector<ll> &a){
    for(ll i = 0; i<a.size(); i++){
        cout << a[i] << ' ';
    }
    cout << endl;
}

void print_pii(vector<pii> &a){
    for(ll i = 0; i<a.size(); i++){
        cout << a[i].first << ' ' << a[i].second << '\n';
    }
    cout << "\n";
}

ll fact(ll n){
    if(n == 0) return 1;
    return n * fact(n-1);
}

ll sum_d(ll n){
    ll s = 0;
    while(n > 0){
        s += n % 10;
        n /= 10;
    }

    return s;
}

bool cmp(pii a, pii b){
    if(a.first == b.first){
        return a.second < b.second;
    } else {
        return a.first > b.first;
    }
}

ll gcd(ll a, ll b){
    return (a == 0) ? b : gcd(b % a, a);
}

ll sum_a_progress(ll a, ll d, ll n){
    if(n <= 0) return 0;
    return (2 * a + d * (n - 1)) * n / 2;
}

ll c(ll n, ll k){
    return fact(n) / (fact(k) * fact(n - k));
}

ll c2(ll n){
    return n * (n - 1) / 2;
}

ll c3(ll n){
    return n * (n - 1) * (n - 2) / 6;
}

bool is_prime(ll n){
    if(n == 1) return 0;
    if(n == 2) return 1;

    ll d = 2;
    while(d * d <= n){
        if(n % d == 0) return 0;
        d++;
    }
    return 1;
}

ll mex(vector<ll> a, ll l, ll r){
    set<ll> s;
    for(ll i = l; i<=r; i++){
        s.insert(a[i]);
    }

    ll i = 1;
    while(1){
        if(s.find(i) == s.end()){
            return i;
        } else {
            i++;
        }
    }
}

void solve(){
    ll n;

    cin >> n;

    vector<ll> a(n);
    for(ll i = 0; i<n; i++){
        cin >> a[i];
    }

    ll f = 1;
    for(ll i = 0; i<n - 1; i++){
        if(a[i] < a[i+1]){
            a[i + 1] -= a[i];
            a[i] = 0;
        } else if(a[i] > a[i+1]){
            f = 0;
        }
    }

    yesno(f);
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("input.txt", "r", stdin);

    ll t = 1;
    cin >> t;

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