ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous 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;

        if (n==k)
        {
            cout << 1 << endl;
            continue;
        }

        vector<int> v(n);
        map<int, int> mpp;

        for (int i = 0; i<n; i++)
        {
            cin >> v[i];
            mpp[v[i]]++;
        }

        int numDistinct = 0;
        for (pair<int, int> it : mpp)
        {
            numDistinct++;
        }

        vector<int> freq;
        
        for (pair<int, int> it : mpp)
        {
            freq.push_back(it.second);
        }

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

        int i, sum = 0;
        for (i = 0; i<n; i++)
        {
            sum += freq[i];
            if (sum>k) break;
        }

        cout << numDistinct - i << 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;

        if (n==k)
        {
            cout << 1 << endl;
            continue;
        }

        vector<int> v(n);
        map<int, int> mpp;

        for (int i = 0; i<n; i++)
        {
            cin >> v[i];
            mpp[v[i]]++;
        }

        int numDistinct = 0;
        for (pair<int, int> it : mpp)
        {
            numDistinct++;
        }

        vector<int> freq;
        
        for (pair<int, int> it : mpp)
        {
            freq.push_back(it.second);
        }

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

        int i, sum = 0;
        for (i = 0; i<freq.size(); i++)
        {
            sum += freq[i];
            if (sum>k) break;
        }

        cout << numDistinct - i << endl;
    }

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    vector<pair<int, int>> erg;
    for (int i = 0; i < N; i++)
    {
        int ind = -1;
        for (int j = 0; j < N; j++)
        {
            if (a[j] == i) ind = j;
        }
        
        for (int j = ind; j < N - 1; j++)
        {
            erg.push_back({a[j], a[j + 1]});
            swap(a[j], a[j + 1]);
        }
        for (int j = N - 1; j > i; j--)
        {
            erg.push_back({a[j], a[j - 1]});
            swap(a[j], a[j - 1]);
        } 
    }
    
    cout << erg.size() << "\n";
    for (auto [a, b]: erg) cout << ++a << " " << ++b << "\n";
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    vector<pair<int, int>> erg;
    for (int i = 0; i < N; i++)
    {
        int ind = -1;
        for (int j = 0; j < N; j++)
        {
            if (a[j] == i) ind = j;
        }
        
        for (int j = ind; j < N - 1; j++)
        {
            erg.push_back({a[j + 1], a[j]});
            swap(a[j + 1], a[j]);
        }
        for (int j = N - 1; j > i; j--)
        {
            erg.push_back({a[j], a[j - 1]});
            swap(a[j], a[j - 1]);
        } 
    }
    
    cout << erg.size() << "\n";
    reverse(erg.begin(), erg.end());
    for (auto [a, b]: erg) cout << ++b << " " << ++a << "\n";
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


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

using namespace std;

string cut(string n) {
    for (int i = 0; i < n.size(); i++)
    {
        if (n[i] >= 'A' && n[i] <= 'Z') return n.substr(i);
    }
}

int main() {
    int N;
    scanf("%i", &N);

    string n;
    getline(cin, n);
    vector<pair<string, string>> names;
    for (int i = 0; i < N; i++)
    {
        getline(cin, n);
        names.push_back({cut(n), n});
    }
    
    sort(names.begin(), names.end());

    for (auto n: names) cout << n.second << "\n";
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

using namespace std;

string cut(string n) {
    for (int i = 0; i < n.size(); i++)
    {
        if (n[i] >= 'A' && n[i] <= 'Z') return n.substr(i);
    }
}

int main() {
    int N;
    scanf("%i", &N);

    string n;
    getline(cin, n);
    vector<pair<string, string>> names;
    for (int i = 0; i < N; i++)
    {
        getline(cin, n);
        names.push_back({cut(n), n});
    }
    
    sort(names.begin(), names.end());

    for (auto n: names) cout << n.second << "\n";
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    vector<pair<int, int>> erg;
    for (int i = 0; i < N; i++)
    {
        int ind = -1;
        for (int j = 0; j < N; j++)
        {
            if (a[j] == i) ind = j;
        }
        
        for (int j = ind; j < N - 1; j++)
        {
            erg.push_back({a[j], a[j + 1]});
            swap(a[j], a[j + 1]);
        }
        for (int j = N - 1; j > i; j--)
        {
            erg.push_back({a[j], a[j - 1]});
            swap(a[j], a[j - 1]);
        } 
    }
    
    cout << erg.size() << "\n";
    for (auto [a, b]: erg) cout << ++a << " " << ++b << "\n";
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

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

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

    int max_val = l;

    for(int i=0;i<30;i++){
        int num = pow(2,i);
        if(num>=l&&num<=r) max_val=max(max_val,num);
    }

    // If-else case
    int a,b,c;

    if(max_val==l){

        a=l;
        c=r;
        int num1 = -1;

        for(int i=l+1;i<r;i++){
            if(num1<=((a^i)+(c^i))){
                num1 = max(num1,(a^i+c^i));
                b=i;
            }
        }

    }else if(max_val==r){

        a=r;
        b=r-1;
        c=l;

    }else{

        a=max_val;
        b=a-1;
        int check1 = (a^r)+(b^r);
        int check2 = (a^l)+(b^l);
        if(check1>check2) c=r;
        else c=l; 
        if(b==l) c=r;

    }
        cout<<a<<" "<<b<<" "<<c<<endl;
}

signed main() {
    fastio();

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

    int t; t = 1;
    cin >> t;

    for (int i = 0; i < t; i++) {
         solve(i);
    }
    return 0;
}

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

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

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

    // int max_val = l;

    // for(int i=0;i<30;i++){
    //     int num = pow(2,i);
    //     if(num>=l&&num<=r) max_val=max(max_val,num);
    // }

    // // If-else case
    // int a,b,c;

    // if(max_val==l){

    //     a=l;
    //     c=r;
    //     int num1 = -1;

    //     for(int i=l+1;i<r;i++){
    //         if(num1<=((a^i)+(c^i))){
    //             num1 = max(num1,(a^i+c^i));
    //             b=i;
    //         }
    //     }

    // }else if(max_val==r){

    //     a=r;
    //     b=r-1;
    //     c=l;

    // }else{

    //     a=max_val;
    //     b=a-1;
    //     int check1 = (a^r)+(b^r);
    //     int check2 = (a^l)+(b^l);
    //     if(check1>check2) c=r;
    //     else c=l; 
    //     if(b==l) c=r;

    // }
    //     cout<<a<<" "<<b<<" "<<c<<endl;

    int l, r;
    cin >> l >> r;
    int k = 31 - __builtin_clz(l ^ r); // Trailing zeroes of l^r
    int a =(pow(2,k) - 1);
    a=a|l;
    int b = a + 1; 
    int c = (a == l ? r : l);
    cout << a << " " << b << " " << c << "\n";
}

signed main() {
    fastio();

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

    int t; t = 1;
    cin >> t;

    for (int i = 0; i < t; i++) {
         solve(i);
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

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

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

    int max_val = l;

    for(int i=0;i<30;i++){
        int num = pow(2,i);
        if(num>=l&&num<=r) max_val=max(max_val,num);
    }

    // If-else case
    int a,b,c;

    if(max_val==l){

        a=l;
        b=l+1;
        c=r;

    }else if(max_val==r){

        a=r;
        b=r-1;
        c=l;

    }else{

        a=max_val;
        b=a-1;
        int check1 = (a^r)+(b^r);
        int check2 = (a^l)+(b^l);
        if(check1>check2) c=r;
        else c=l; 
        if(b==l) c=r;

    }
        cout<<a<<" "<<b<<" "<<c<<endl;
}

signed main() {
    fastio();

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

    int t; t = 1;
    cin >> t;

    for (int i = 0; i < t; i++) {
         solve(i);
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

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

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

    int max_val = l;

    for(int i=0;i<30;i++){
        int num = pow(2,i);
        if(num>=l&&num<=r) max_val=max(max_val,num);
    }

    // If-else case
    int a,b,c;

    if(max_val==l){

        a=l;
        b=l+1;
        c=r;

    }else if(max_val==r){

        a=r;
        b=r-1;
        c=l;

    }else{

        a=max_val;
        b=a-1;
        int check1 = (a^r)+(b^r);
        int check2 = (a^l)+(b^l);
        if(check1>check2) c=r;
        else c=l; 
        if(b==l) c=r;

    }
        cout<<a<<" "<<b<<" "<<c<<endl;
}

signed main() {
    fastio();

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

    int t; t = 1;
    cin >> t;

    for (int i = 0; i < t; i++) {
         solve(i);
    }
    return 0;
}

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

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

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

    int max_val = l;

    for(int i=0;i<30;i++){
        int num = pow(2,i);
        if(num>=l&&num<=r) max_val=max(max_val,num);
    }

    // If-else case
    int a,b,c;

    if(max_val==l){

        a=l;
        c=r;
        int num1 = -1;

        for(int i=l+1;i<r;i++){
            if(num1<=((a^i)+(c^i))){
                num1 = max(num1,(a^i+c^i));
                b=i;
            }
        }

    }else if(max_val==r){

        a=r;
        b=r-1;
        c=l;

    }else{

        a=max_val;
        b=a-1;
        int check1 = (a^r)+(b^r);
        int check2 = (a^l)+(b^l);
        if(check1>check2) c=r;
        else c=l; 
        if(b==l) c=r;

    }
        cout<<a<<" "<<b<<" "<<c<<endl;
}

signed main() {
    fastio();

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

    int t; t = 1;
    cin >> t;

    for (int i = 0; i < t; i++) {
         solve(i);
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

#define dbg(x) cout << (#x) << ": " << x << "\n";
#define be(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repm(i, m, n) for(int i = (m); i < (n); i++)
#define rev(i, n) for(int i = (n)-1; i >= 0; i--)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

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

    int n = 0;
    for(int i = 31; i >= 0; i--) {
        if((l & (1 << i)) != (r & (1 << i))) {
            n = i;
            break;
        }
    }

    int a, b, c;
    a = 1 << n, b = a - 1, c = l > a-2 ? a+1 : a-2;

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

int32_t main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    rep(i, t) {
        test_case();
    }

    return 0;
}

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

#define dbg(x) cout << (#x) << ": " << x << "\n";
#define be(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repm(i, m, n) for(int i = (m); i < (n); i++)
#define rev(i, n) for(int i = (n)-1; i >= 0; i--)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

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

    int n = 0, off = 0;
    for(int i = 31; i >= 0; i--) {
        int lx = l & (1 << i), rx = r & (1 << i);
        if(lx != rx) {
            n = i;
            break;
        } else if(lx && rx) off += 1 << i;
    }

    int a, b, c;
    a = 1 << n, b = a - 1, c = l > a-2 ? a+1 : a-2;
    a += off, b += off, c += off;

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

int32_t main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    rep(i, t) {
        test_case();
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

#define dbg(x) cout << (#x) << ": " << x << "\n";
#define be(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repm(i, m, n) for(int i = (m); i < (n); i++)
#define rev(i, n) for(int i = (n)-1; i >= 0; i--)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

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

    int n = 0, off = 0;
    for(int i = 31; i >= 0; i--) {
        int lx = l & (1 << i), rx = r & (1 << i);
        if(lx != rx) {
            n = i;
            break;
        } else if(lx && rx) off += 1 << i;
    }

    int a, b, c;
    a = 1 << n, b = a - 1, c = l > a-2 ? a+1 : a-2;
    a += off, b += off, c += off;

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

int32_t main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    rep(i, t) {
        test_case();
    }

    return 0;
}

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

#define dbg(x) cout << (#x) << ": " << x << "\n";
#define be(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repm(i, m, n) for(int i = (m); i < (n); i++)
#define rev(i, n) for(int i = (n)-1; i >= 0; i--)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

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

    int n = 0, off = 0;
    for(int i = 31; i >= 0; i--) {
        int lx = l & (1 << i), rx = r & (1 << i);
        if(lx != rx) {
            n = i;
            break;
        } else if(lx && rx) off += 1 << i;
    }

    int a, b, c;
    a = 1 << n, b = a - 1;
    a += off, b += off;
    c = l > a-2 ? a+1 : a-2;

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

int32_t main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    rep(i, t) {
        test_case();
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

#define dbg(x) cout << (#x) << ": " << x << "\n";
#define be(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repm(i, m, n) for(int i = (m); i < (n); i++)
#define rev(i, n) for(int i = (n)-1; i >= 0; i--)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

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

    int n = 0;
    for(int i = 31; i >= 0; i--) {
        if((l & (1 << i)) != (r & (1 << i))) {
            n = i;
            break;
        }
    }

    int a, b, c;
    a = 1 << n, b = a - 1, c = max(l, a-2);

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

int32_t main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    rep(i, t) {
        test_case();
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

#define dbg(x) cout << (#x) << ": " << x << "\n";
#define be(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repm(i, m, n) for(int i = (m); i < (n); i++)
#define rev(i, n) for(int i = (n)-1; i >= 0; i--)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

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

    int n = 0;
    for(int i = 31; i >= 0; i--) {
        if((l & (1 << i)) != (r & (1 << i))) {
            n = i;
            break;
        }
    }

    int a, b, c;
    a = 1 << n, b = a - 1, c = max(l, a-2);

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

int32_t main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    rep(i, t) {
        test_case();
    }

    return 0;
}

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

#define dbg(x) cout << (#x) << ": " << x << "\n";
#define be(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repm(i, m, n) for(int i = (m); i < (n); i++)
#define rev(i, n) for(int i = (n)-1; i >= 0; i--)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> 
ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }

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

    int n = 0;
    for(int i = 31; i >= 0; i--) {
        if((l & (1 << i)) != (r & (1 << i))) {
            n = i;
            break;
        }
    }

    int a, b, c;
    a = 1 << n, b = a - 1, c = l > a-2 ? a+1 : a-2;

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

int32_t main() {    
    ios::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    rep(i, t) {
        test_case();
    }

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


Submission (verdict: Time limit exceeded on test 4):
#include <iostream>

#include <string>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <queue>

#include <utility>

#include <algorithm>

#define ll long long

#define st string

#define ld long double

#define pb push_back

#define mk make_pair

#define ff first

#define ss second

using namespace std;









void solve() {

	st s; cin >> s;

	while (!(is_sorted(s.begin(), s.end(), greater<ll>()))) {

		st s1 = s;

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

			if (s[i] == '0') continue;

			st s2 = s;

			s2[i] = char(int(s2[i]) - 1);

			swap(s2[i-1], s2[i]);

			s1 = max(s1, s2);

		}

		if (s == s1) break;

		else s = max(s, s1);

		

		//cout << s << "\n";

		

	}

	cout << s << "\n";

}



int main() {

	ios::sync_with_stdio(false);

	cin.tie(nullptr); cout.tie(nullptr);

	int tt = 1;

	cin >> tt;

	while (tt--) {

		solve();

	}

	cout << "\n";

	return 0;

}