ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using orderStaticTree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long

#define saleh                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);

const int md = 1e9 + 7;

int main()
{
    saleh;
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = n - 1; i >= 1; i--)
        {
            int curr = s[i] - '0';
            --curr;
            int pre = s[i - 1] - '0';
            if (curr > pre)
            {

                s[i - 1] = char(curr + '0');
                s[i] = char(pre + '0');
            }
            int j = i;
            int ii = i + 1;
            while (ii <= n - 1)
            {
                int curr = s[j] - '0';
                int nxt = s[ii] - '0';
                nxt--;
                if (nxt > curr)
                {
                    s[j] = char(nxt + '0');
                    s[ii] = char(curr + '0');
                }
                j++;
                ii++;
            }
        }
        cout << s << endl;
    }

    return 0;
}

Submission (verdict: Time limit exceeded on test 8):


#include <iostream>

#include <vector>

#include <algorithm>

#include <queue>

#include <map>

#include <set>

#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template <class T>

using orderStaticTree =

    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define ll long long



#define saleh                         \

    ios_base::sync_with_stdio(false); \

    cin.tie(nullptr);



const int md = 1e9 + 7;



int main()

{

    saleh;

    int t;

    cin >> t;

    while (t--)

    {

        string s;

        cin >> s;

        int n = s.size();

        for (int i = n - 1; i >= 1; i--)

        {

            int curr = s[i] - '0';

            --curr;

            int pre = s[i - 1] - '0';

            if (curr > pre)

            {



                s[i - 1] = char(curr + '0');

                s[i] = char(pre + '0');

            }

            int j = i;

            int ii = i + 1;

            while (ii <= n - 1 && s[ii]!='0')

            {

                int curr = s[j] - '0';

                int nxt = s[ii] - '0';

                nxt--;

                if (nxt > curr)

                {

                    s[j] = char(nxt + '0');

                    s[ii] = char(curr + '0');

                }

                j++;

                ii++;

            }

        }

        cout << s << endl;

    }



    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 8):


#include <iostream>

#include <vector>

#include <algorithm>

#include <queue>

#include <map>

#include <set>

#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template <class T>

using orderStaticTree =

    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define ll long long



#define saleh                         \

    ios_base::sync_with_stdio(false); \

    cin.tie(nullptr);



const int md = 1e9 + 7;



int main()

{

    saleh;

    int t;

    cin >> t;

    while (t--)

    {

        string s;

        cin >> s;

        int n = s.size();

        for (int i = n - 1; i >= 1; i--)

        {

            int curr = s[i] - '0';

            --curr;

            int pre = s[i - 1] - '0';

            if (curr > pre)

            {



                s[i - 1] = char(curr + '0');

                s[i] = char(pre + '0');

            }

            int j = i;

            int ii = i + 1;

            while (ii <= n - 1 && s[ii]!='0')

            {

                int curr = s[j] - '0';

                int nxt = s[ii] - '0';

                nxt--;

                if (nxt > curr)

                {

                    s[j] = char(nxt + '0');

                    s[ii] = char(curr + '0');

                }

                j++;

                ii++;

            }

        }

        cout << s << endl;

    }



    return 0;

}

Submission (verdict: Accepted):


#include <iostream>

#include <vector>

#include <algorithm>

#include <queue>

#include <map>

#include <set>

#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template <class T>

using orderStaticTree =

    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define ll long long



#define saleh                         \

    ios_base::sync_with_stdio(false); \

    cin.tie(nullptr);



const int md = 1e9 + 7;



int main()

{

    saleh;

    int t;

    cin >> t;

    while (t--)

    {

        string s;

        cin >> s;

        int n = s.size();

        for (int i = n - 1; i >= 1; i--)

        {

            int curr = s[i] - '0';

            --curr;

            int pre = s[i - 1] - '0';

            if (curr > pre)

            {



                s[i - 1] = char(curr + '0');

                s[i] = char(pre + '0');

            }

            int j = i;

            int ii = i + 1;

            while (ii <= n - 1 && s[ii] != '0' && s[j] < s[ii])

            {

                int curr = s[j] - '0';

                int nxt = s[ii] - '0';

                nxt--;

                if (nxt > curr)

                {

                    s[j] = char(nxt + '0');

                    s[ii] = char(curr + '0');

                }

                j++;

                ii++;

            }

        }

        cout << s << endl;

    }



    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using orderStaticTree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long

#define saleh                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);

const int md = 1e9 + 7;

int main()
{
    saleh;
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int n = s.size();
        for (int i = n - 1; i >= 1; i--)
        {
            int curr = s[i] - '0';
            --curr;
            int pre = s[i - 1] - '0';
            if (curr > pre)
            {

                s[i - 1] = char(curr + '0');
                s[i] = char(pre + '0');
            }
            int j = i;
            int ii = i + 1;
            while (ii <= n - 1)
            {
                int curr = s[j] - '0';
                int nxt = s[ii] - '0';
                nxt--;
                if (nxt > curr)
                {
                    s[j] = char(nxt + '0');
                    s[ii] = char(curr + '0');
                }
                j++;
                ii++;
            }
        }
        cout << s << endl;
    }

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

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        string b;
        cin >> b;
        int jmlh = 0, dua = 0, tiga = 0;
        for (char digit : b) {
            jmlh += (digit - '0');
            if (digit == '2')
                dua++;
            else if (digit == '3')
                tiga++;
        }
        bool found = false;
        while (dua > 0 || tiga > 0) {
            if (jmlh % 9 == 0) {
                found = true;
                cout << "YES" << '\n';
                break;
            }
            if (tiga > 0 && (dua <= 0 || jmlh % 9 == 6)) {
                tiga--;
                jmlh += 6;
            } else if (dua > 0) {
                dua--;
                jmlh += 2;
            }
        }
        if (!found && jmlh % 9 != 0) {
            cout << "NO" << '\n';
        }
    }
    return 0;
}


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

int main() {
	int t;
	cin >> t;
	while (t--) {
		string b;
		cin >> b;
		int jmlh = 0, dua = 0, tiga = 0;
		for ( int i = 0; i < b.length(); i++) {
			jmlh += (b[i] - '0');
			if ( b[i] == '2')
				dua++;
			else if ( b[i] == '3')
				tiga++;
		}

		while (true) {
			if ( jmlh % 9 == 0) {
				cout << "YES" << '\n';
				//	cout << jmlh << "JML" << '\n' ;
				break;
			} else if ( dua > 0 || tiga > 0) {
				if ((dua <= 0 || jmlh % 9 == 6 || jmlh % 9 < 4 ) && tiga > 0 ) {
					tiga--;
					jmlh += 6;
					//	cout << "tambah 3"  << jmlh << '\n';
				} else if ( dua > 0) {
					jmlh += 2;
					dua --;
				}//cout << "tambah dua"  << jmlh << '\n';

			} else {
				cout << "NO" << '\n';
				break;
			}




		}




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

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

int main() {
	int t;
	cin >> t;
	while (t--) {
		string b;
		cin >> b;
		int jmlh = 0, dua = 0, tiga = 0;
		for ( int i = 0; i < b.length(); i++) {
			jmlh += (b[i] - '0');
			if ( b[i] == '2')
				dua++;
			else if ( b[i] == '3')
				tiga++;
		}

		while (true) {
			if ( jmlh % 9 == 0) {
				cout << "YES" << '\n';
				//	cout << jmlh << "JML" << '\n' ;
				break;
			} else if ( dua > 0 || tiga > 0) {
				if (dua <= 0 || jmlh % 9 == 6) {
					tiga--;
					jmlh += 6;
					//	cout << "tambah 3"  << jmlh << '\n';
				} else if ( dua > 0) {
					jmlh += 2;
					dua --;
				}//cout << "tambah dua"  << jmlh << '\n';

			} else {
				cout << "NO" << '\n';
				break;
			}




		}




	}
}

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

int main() {
	int t;
	cin >> t;
	while (t--) {
		string b;
		cin >> b;
		int jmlh = 0, dua = 0, tiga = 0;
		for ( int i = 0; i < b.length(); i++) {
			jmlh += (b[i] - '0');
			if ( b[i] == '2')
				dua++;
			else if ( b[i] == '3')
				tiga++;
		}

		while (true) {
			if ( jmlh % 9 == 0) {
				cout << "YES" << '\n';
				//	cout << jmlh << "JML" << '\n' ;
				break;
			} else if ( dua > 0 || tiga > 0) {
				if (dua <= 0 || jmlh % 9 == 6 && tiga > 0 ) {
					tiga--;
					jmlh += 6;
					//	cout << "tambah 3"  << jmlh << '\n';
				} else if ( dua > 0) {
					jmlh += 2;
					dua --;
				}//cout << "tambah dua"  << jmlh << '\n';

			} else {
				cout << "NO" << '\n';
				break;
			}




		}




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

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

int main() {
	int t;
	cin >> t;
	while (t--) {
		string b;
		cin >> b;
		int jmlh = 0, dua = 0, tiga = 0;
		for ( int i = 0; i < b.length(); i++) {
			jmlh += (b[i] - '0');
			if ( b[i] == '2')
				dua++;
			else if ( b[i] == '3')
				tiga++;
		}

		while (true) {
			if ( jmlh % 9 == 0) {
				cout << "YES" << '\n';
				//	cout << jmlh << "JML" << '\n' ;
				break;
			} else if ( dua > 0 || tiga > 0) {
				if ((dua <= 0 || jmlh % 9 == 6 ) && tiga > 0 ) {
					tiga--;
					jmlh += 6;
					//	cout << "tambah 3"  << jmlh << '\n';
				} else if ( dua > 0) {
					jmlh += 2;
					dua --;
				}//cout << "tambah dua"  << jmlh << '\n';

			} else {
				cout << "NO" << '\n';
				break;
			}




		}




	}
}

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        string b;
        cin >> b;
        int jmlh = 0, dua = 0, tiga = 0;
        for (char digit : b) {
            jmlh += (digit - '0');
            if (digit == '2')
                dua++;
            else if (digit == '3')
                tiga++;
        }
        bool found = false;
        while (dua > 0 || tiga > 0) {
            if (jmlh % 9 == 0) {
                found = true;
                cout << "YES" << '\n';
                break;
            }
            if (tiga > 0 && (dua <= 0 || jmlh % 9 == 6)) {
                tiga--;
                jmlh += 6;
            } else if (dua > 0) {
                dua--;
                jmlh += 2;
            }
        }
        if (!found && jmlh % 9 != 0) {
            cout << "NO" << '\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;

int main() {
	int t;
	cin >> t;
	while (t--) {
		string b;
		cin >> b;
		int jmlh = 0, dua = 0, tiga = 0;
		for ( int i = 0; i < b.length(); i++) {
			jmlh += (b[i] - '0');
			if ( b[i] == '2')
				dua++;
			else if ( b[i] == '3')
				tiga++;
		}

		while (true) {
			if ( jmlh % 9 == 0) {
				cout << "YES" << '\n';
				//	cout << jmlh << "JML" << '\n' ;
				break;
			} else if ( dua > 0 || tiga > 0) {
				if (dua <= 0 || jmlh % 9 == 6) {
					tiga--;
					jmlh += 6;
					//	cout << "tambah 3"  << jmlh << '\n';
				} else if ( dua > 0) {
					jmlh += 2;
					dua --;
				}//cout << "tambah dua"  << jmlh << '\n';

			} else {
				cout << "NO" << '\n';
				break;
			}




		}




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

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

int main() {
	int t;
	cin >> t;
	while (t--) {
		string b;
		cin >> b;
		int jmlh = 0, dua = 0, tiga = 0;
		for ( int i = 0; i < b.length(); i++) {
			jmlh += (b[i] - '0');
			if ( b[i] == '2')
				dua++;
			else if ( b[i] == '3')
				tiga++;
		}

		while (true) {
			if ( jmlh % 9 == 0) {
				cout << "YES" << '\n';
				//	cout << jmlh << "JML" << '\n' ;
				break;
			} else if ( dua > 0 || tiga > 0) {
				if (dua <= 0 || jmlh % 9 == 6 && tiga > 0 ) {
					tiga--;
					jmlh += 6;
					//	cout << "tambah 3"  << jmlh << '\n';
				} else if ( dua > 0) {
					jmlh += 2;
					dua --;
				}//cout << "tambah dua"  << jmlh << '\n';

			} else {
				cout << "NO" << '\n';
				break;
			}




		}




	}
}

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

int main() {
	int t;
	cin >> t;
	while (t--) {
		string b;
		cin >> b;
		int jmlh = 0, dua = 0, tiga = 0;
		for ( int i = 0; i < b.length(); i++) {
			jmlh += (b[i] - '0');
			if ( b[i] == '2')
				dua++;
			else if ( b[i] == '3')
				tiga++;
		}

		while (true) {
			if ( jmlh % 9 == 0) {
				cout << "YES" << '\n';
				//	cout << jmlh << "JML" << '\n' ;
				break;
			} else if ( dua > 0 || tiga > 0) {
				if ((dua <= 0 || jmlh % 9 == 6 ) && tiga > 0 ) {
					tiga--;
					jmlh += 6;
					//	cout << "tambah 3"  << jmlh << '\n';
				} else if ( dua > 0) {
					jmlh += 2;
					dua --;
				}//cout << "tambah dua"  << jmlh << '\n';

			} else {
				cout << "NO" << '\n';
				break;
			}




		}




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

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

//void solve(){
//    string s;
//    cin >> s;
//    int len = s.size();
//
//}

void solve(){
    string s;
    cin >> s;
    int len = s.size();
    while(true){
        bool didOne = false;
        for(int i = len-1; i >= 1; i--){
            int dig = s[i] - '0';
            int prevDig = s[i-1] - '0';
            if(dig-1 > prevDig){
                s[i-1] = dig-1 + '0';
                s[i] = prevDig + '0';
                didOne = true;
            }
        }
        if(!didOne){ break; }
    }
    cout << s << '\n';
    return;
}

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

    int T;
    cin >> T;
    for(int t = 1; t <= T; t++){
        solve();
    }
    return 0;
}


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

//void solve(){
//    string s;
//    cin >> s;
//    int n = s.size();
//    vimo<int> backMax(n), backMaxIdx(n);
//    backMax[n-1] = s[n-1]-'0';
//    backMaxIdx[n-1] = n-1;
//    for(int i = n; i >= 0; i--){
//        if(backMax[i+1]-1 > s[i]-'0'){
//            backMax[i] = backMax[i+1]-1;
//            backMaxIdx[i] = backMaxIdx[i+1];
//        }else{
//            backMax[i] = s[i]-'0';
//            backMaxIdx[i] = i;
//        }
//    }
//
//
//
//    return;
//}

void solve(){
    string s;
    cin >> s;
    int len = s.size();
    while(true){
        bool didOne = false;
        for(int i = 1; i < len; i++){
            int dig = s[i] - '0';
            int prevDig = s[i-1] - '0';
            if(dig-1 > prevDig){
                s[i-1] = dig-1 + '0';
                s[i] = prevDig + '0';
                didOne = true;
            }
        }
        if(!didOne){ break; }
    }
    cout << s << '\n';
    return;
}

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

    int T;
    cin >> T;
    for(int t = 1; t <= T; t++){
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

void solve(){
    string s;
    cin >> s;
    int len = s.size();
    while(true){
        bool didOne = false;
        for(int i = len-1; i >= 1; i--){
            int dig = s[i] - '0';
            int prevDig = s[i-1] - '0';
            if(dig-1 > prevDig){
                s[i-1] = dig-1 + '0';
                s[i] = prevDig + '0';
                didOne = true;
            }
        }
        if(!didOne){ break; }
    }
    cout << s << '\n';
    return;
}

int main(){
    int T;
    cin >> T;
    for(int t = 1; t <= T; t++){
        solve();
    }
    return 0;
}


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

//void solve(){
//    string s;
//    cin >> s;
//    int len = s.size();
//
//}

void solve(){
    string s;
    cin >> s;
    int len = s.size();
    while(true){
        bool didOne = false;
        for(int i = len-1; i >= 1; i--){
            int dig = s[i] - '0';
            int prevDig = s[i-1] - '0';
            if(dig-1 > prevDig){
                s[i-1] = dig-1 + '0';
                s[i] = prevDig + '0';
                didOne = true;
            }
        }
        if(!didOne){ break; }
    }
    cout << s << '\n';
    return;
}

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

    int T;
    cin >> T;
    for(int t = 1; t <= T; t++){
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

void solve(){
    string s;
    cin >> s;
    int len = s.size();
    while(true){
        bool didOne = false;
        for(int i = len-1; i >= 1; i--){
            int dig = s[i] - '0';
            int prevDig = s[i-1] - '0';
            if(dig-1 > prevDig){
                s[i-1] = dig-1 + '0';
                s[i] = prevDig + '0';
                didOne = true;
            }
        }
        if(!didOne){ break; }
    }
    cout << s << '\n';
    return;
}

int main(){
    int T;
    cin >> T;
    for(int t = 1; t <= T; t++){
        solve();
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int sum=0,count=0;
        int a[n];
        int b[50000];
        bool found=true;
         for (int i = 0; i < 50000; i++){
            b[i]=0;
            }
        for (int i = 0; i < n; i++)
        {
            cin>>a[i];
            b[a[i]]++;
        }
            sort(b, b + 50000);
        for (int i = 0; i < 50000; i++)
        {
            if(found==true){
                sum+=b[i];
            if(sum>k){
                found = false;
            }
            }
            else{
                count++;
            }
        }
         if(sum>=k){
        cout<<count+1<<endl;
        }
        else{
            cout<<"1"<<endl;
        }
}
    return 0;
}

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

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        int sum=0,count=0;
        int a[n];
        vector<int>b;
        bool found=true;
        for (int i = 0; i < n; i++)
        {
            cin>>a[i];
        }
            sort(a,a+n);
                int index=1;
            for (int i = 0; i < n; i++)
            {
                
                if(a[i]==a[i+1]){
                    index++;
                }
                else if(i==n-1){
                    if(a[n-2]==a[n-1]){
                    b.push_back(index);
                    }
                    else{
                    b.push_back(1);
                    }
                }
                else{
                    b.push_back(index);
                    index=1;
                }
            }
            int size = b.size();
            sort(b.begin(), b.end());
        for (int i = 0; i < size; i++)
        {
            if(found==true){
                sum+=b[i];
            if(sum>k){
                found = false;
            }
            }
            else{
                count++;
            }
        }
         if(sum>k){
        cout<<count+1<<endl;
        }
        else{
            cout<<"1"<<endl;
        }
}
    return 0;
}