ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define f(i,a) for(ll i = 0; i < a; i++)

int dx[4] = { 0, 0, 1, -1 };
int dy[4] = { 1, -1, 0, 0 };

using namespace std;

ll pow(ll n, ll exp)
{
    if(exp == 0)
    return 1;
    if(exp == 1)
    return n;

    ll half = pow(n, exp / 2);
    
    if(exp%2 == 0)
    return half * half;    
    else
    return n * half * half;
    
}

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

    ll t  = 1;
    cin >> t;   
    while (t--) {
        //unordered_map<ll, ll> mpp;
        bool choice = false;
        ll n = -1, m, k;
        
        cin >> n >> k;
        vector<ll> a(n);
        map<ll, ll> mpp;

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

        priority_queue<ll, vector<ll>, greater<ll>> pq;
        for(auto x : mpp)
        pq.push(x.second);
        
        ll removed = 0;
        while(k>0)
        {
            ll temp = pq.top(); pq.pop();
            if(k - temp >= 0)
            removed++;
            k-=temp;
        }
        if(pq.size() != 0)
        cout << pq.size() << endl;
        else
        cout << 1 << endl;

        
    }
        return 0;
    }
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 16):
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;



int solve(string s,string t,string c,int i,int j,int y,vector<vector<int>>&dp,vector<int>&m_a,vector<int>&m_b){
  
    if(i>=s.size()||j>=t.size()){
        int count=0;
        if(i<s.size())
        count+=m_a[i];
        else if(j<t.size())
        count+=m_b[j];
        return count;
    }
    
    if(dp[i][j]!=-1)return dp[i][j];

   return dp[i][j]=max(int(s[i]==c[y])+solve(s,t,c,i+1,j,y+1,dp,m_a,m_b),int(t[j]==c[y])+solve(s,t,c,i,j+1,y+1,dp,m_a,m_b));
    
}

int main() {
int t,u;
cin>>t;
u=t;
vector<int> ans;
while(t--){

string a,b,c;

cin>>a>>b>>c;
if(u==2&&a.size()>b.size())cout<<a.size()<<","<<b.size()<<","<<c.size();
vector<vector<int>> dp(a.size(),vector<int>(b.size(),-1));
vector<int> m_a(a.size(),0), m_b(b.size(),0);
int count=0,c_id=c.size()-1;

for(int i=a.size()-1;i>=0;i--){
    if(a[i]==c[c_id])count++;
    m_a[i]=count;
    c_id--;
}
count=0;
c_id=c.size()-1;
for(int i=b.size()-1;i>=0;i--){
    if(b[i]==c[c_id])count++;
    m_b[i]=count;
    c_id--;
}

int m=solve(a,b,c,0,0,0,dp,m_a,m_b);

// for(int i=0;i<a.size();i++){
//     for(int j=0;j<b.size();j++){
//         if(m<dp[i][j])m=dp[i][j];
//     }
// }
ans.push_back(c.size()-m);
}
for(int i=0;i<ans.size();
i++)cout<<ans[i]<<endl;
    return 0;
}

Submission (verdict: Accepted):
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;


int main() {
int t,u;
cin>>t;
u=t;
vector<int> ans;
while(t--){

string a,b,c;

cin>>a>>b>>c;

vector<vector<int>> dp(a.size()+1,vector<int>(b.size()+1,0));
vector<int> m_a(a.size(),0), m_b(b.size(),0);
int count=0,c_id=c.size()-1;

for(int i=a.size()-1;i>=0;i--){
    if(a[i]==c[c_id])count++;
    m_a[i]=count;
    c_id--;
}
count=0;
c_id=c.size()-1;
for(int i=b.size()-1;i>=0;i--){
    if(b[i]==c[c_id])count++;
    m_b[i]=count;
    c_id--;
}

int m=INT_MIN;

for(int i=a.size();i>=0;i--){
  for(int j=b.size();j>=0;j--){
    if(i>=a.size()||j>=b.size()){
      if(i<a.size()){
        dp[i][j]=m_a[i];
      }
      else if(j<b.size())dp[i][j]=m_b[j];
    }
    else 
    dp[i][j]=max(int(a[i]==c[i+j])+dp[i+1][j],int(b[j]==c[i+j])+dp[i][j+1]);
    m=max(m,dp[i][j]);
  }
}

ans.push_back(c.size()-m);
}
for(int i=0;i<ans.size();
i++)cout<<ans[i]<<endl;
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 16):
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;



int solve(string s,string t,string c,int i,int j,int y,vector<vector<int>>&dp,vector<int>&m_a,vector<int>&m_b){
  
    if(i>=s.size()||j>=t.size()){
        int count=0;
        if(i<s.size())
        count+=m_a[i];
        else if(j<t.size())
        count+=m_b[j];
        return count;
    }
    
    if(dp[i][j]!=-1)return dp[i][j];

   return dp[i][j]=max(int(s[i]==c[y])+solve(s,t,c,i+1,j,y+1,dp,m_a,m_b),int(t[j]==c[y])+solve(s,t,c,i,j+1,y+1,dp,m_a,m_b));
    
}

int main() {
int t;
cin>>t;
vector<int> ans;
while(t--){

string a,b,c;

cin>>a>>b>>c;

vector<vector<int>> dp(a.size(),vector<int>(b.size(),-1));
vector<int> m_a(a.size(),0), m_b(b.size(),0);
int count=0,c_id=c.size()-1;
for(int i=a.size()-1;i>=0;i--){
    if(a[i]==c[c_id])count++;
    m_a[i]=count;
    c_id--;
}
count=0;
c_id=c.size()-1;
for(int i=b.size()-1;i>=0;i--){
    if(b[i]==c[c_id])count++;
    m_b[i]=count;
    c_id--;
}

int m=solve(a,b,c,0,0,0,dp,m_a,m_b);

// for(int i=0;i<a.size();i++){
//     for(int j=0;j<b.size();j++){
//         if(m<dp[i][j])m=dp[i][j];
//     }
// }
ans.push_back(c.size()-m);
}
for(int i=0;i<ans.size();
i++)cout<<ans[i]<<endl;
    return 0;
}

Submission (verdict: Time limit exceeded on test 16):
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;



int solve(string s,string t,string c,int i,int j,int y,vector<vector<int>>&dp,vector<int>&m_a,vector<int>&m_b){
  
    if(i>=s.size()||j>=t.size()){
        int count=0;
        if(i<s.size())
        count+=m_a[i];
        else if(j<t.size())
        count+=m_b[j];
        return count;
    }
    
    if(dp[i][j]!=-1)return dp[i][j];

   return dp[i][j]=max(int(s[i]==c[y])+solve(s,t,c,i+1,j,y+1,dp,m_a,m_b),int(t[j]==c[y])+solve(s,t,c,i,j+1,y+1,dp,m_a,m_b));
    
}

int main() {
int t,u;
cin>>t;
u=t;
vector<int> ans;
while(t--){

string a,b,c;

cin>>a>>b>>c;
if(u==2&&a.size()>b.size())cout<<a.size()<<","<<b.size()<<","<<c.size();
vector<vector<int>> dp(a.size(),vector<int>(b.size(),-1));
vector<int> m_a(a.size(),0), m_b(b.size(),0);
int count=0,c_id=c.size()-1;

for(int i=a.size()-1;i>=0;i--){
    if(a[i]==c[c_id])count++;
    m_a[i]=count;
    c_id--;
}
count=0;
c_id=c.size()-1;
for(int i=b.size()-1;i>=0;i--){
    if(b[i]==c[c_id])count++;
    m_b[i]=count;
    c_id--;
}

int m=solve(a,b,c,0,0,0,dp,m_a,m_b);

// for(int i=0;i<a.size();i++){
//     for(int j=0;j<b.size();j++){
//         if(m<dp[i][j])m=dp[i][j];
//     }
// }
ans.push_back(c.size()-m);
}
for(int i=0;i<ans.size();
i++)cout<<ans[i]<<endl;
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 16):
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;



int solve(string s,string t,string c,int i,int j,int y,vector<vector<int>>&dp,vector<int>&m_a,vector<int>&m_b){
  
    if(i>=s.size()||j>=t.size()){
        int count=0;
        if(i<s.size())
        count+=m_a[i];
        else if(j<t.size())
        count+=m_b[j];
        return count;
    }
    
    if(dp[i][j]!=-1)return dp[i][j];

   return dp[i][j]=max(int(s[i]==c[y])+solve(s,t,c,i+1,j,y+1,dp,m_a,m_b),int(t[j]==c[y])+solve(s,t,c,i,j+1,y+1,dp,m_a,m_b));
    
}

int main() {
int t;
cin>>t;
vector<int> ans;
while(t--){

string a,b,c;

cin>>a>>b>>c;

vector<vector<int>> dp(a.size(),vector<int>(b.size(),-1));
vector<int> m_a(a.size(),0), m_b(b.size(),0);
int count=0,c_id=c.size()-1;
for(int i=a.size()-1;i>=0;i--){
    if(a[i]==c[c_id])count++;
    m_a[i]=count;
    c_id--;
}
count=0;
c_id=c.size()-1;
for(int i=b.size()-1;i>=0;i--){
    if(b[i]==c[c_id])count++;
    m_b[i]=count;
    c_id--;
}

int m=solve(a,b,c,0,0,0,dp,m_a,m_b);

// for(int i=0;i<a.size();i++){
//     for(int j=0;j<b.size();j++){
//         if(m<dp[i][j])m=dp[i][j];
//     }
// }
ans.push_back(c.size()-m);
}
for(int i=0;i<ans.size();
i++)cout<<ans[i]<<endl;
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

typedef long long ll;
typedef long double doo;

typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef set<ll> sl;
typedef map<ll, ll> ml;
typedef map<string, ll> ms;

#define gett(s) string s; cin>>s;
#define ll_max INT64_MAX
#define ll_min INT64_MIN

#define mp make_pair
#define pb push_back
#define f first
#define se second

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define cn continue;
#define nl cout << "\n";

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll t;
    cin >> t;
    
    while(t--){
        ll n, l, r;
        cin >> n >> l >> r;

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

        sort(a.begin(), a.end());
        ll sum = 0;
        for(ll i = 0; i < r-l+1; i++){
            sum += a[i];
        }

        cout << sum << endl;
    }
    return 0;
}   

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

using namespace std;



typedef long long ll;

typedef long double doo;



typedef vector<pair<ll,ll>> vp;

typedef pair<ll,ll> pl;

typedef vector<ll> vl;

typedef set<ll> sl;

typedef map<ll, ll> ml;

typedef map<string, ll> ms;



#define gett(s) string s; cin>>s;

#define ll_max INT64_MAX

#define ll_min INT64_MIN



#define mp make_pair

#define pb push_back

#define f first

#define se second



#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define cn continue;

#define nl cout << "\n";



signed main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    ll t;

    cin >> t;

    

    while(t--){

        ll n, l, r;

        cin >> n >> l >> r;



        ll a[n] = {0};

        for(ll i = 0; i < n; i++){

            cin >> a[i];

        }



        sort(a, a+n);

        ll sum = 0;

        for(ll i = 0; i < abs(r-l)+1; i++){

            sum += a[i];

        }



        cout << sum << endl;

    }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

typedef long long ll;
typedef long double doo;

typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef set<ll> sl;
typedef map<ll, ll> ml;
typedef map<string, ll> ms;

#define gett(s) string s; cin>>s;
#define ll_max INT64_MAX
#define ll_min INT64_MIN

#define mp make_pair
#define pb push_back
#define f first
#define se second

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define cn continue;
#define nl cout << "\n";

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll t;
    cin >> t;
    
    while(t--){
        ll n, l, r;
        cin >> n >> l >> r;

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

        sort(a.begin(), a.end());
        ll sum = 0;
        for(ll i = 0; i < r-l+1; i++){
            sum += a[i];
        }

        cout << sum << endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;



typedef long long ll;

typedef long double doo;



typedef vector<pair<ll,ll>> vp;

typedef pair<ll,ll> pl;

typedef vector<ll> vl;

typedef set<ll> sl;

typedef map<ll, ll> ml;

typedef map<string, ll> ms;



#define gett(s) string s; cin>>s;

#define ll_max INT64_MAX

#define ll_min INT64_MIN



#define mp make_pair

#define pb push_back

#define f first

#define se second



#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define cn continue;

#define nl cout << "\n";



signed main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    ll t;

    cin >> t;

    

    while(t--){

        ll n, l, r;

        cin >> n >> l >> r;



        ll a[n] = {0};

        for(ll i = 0; i < n; i++){

            cin >> a[i];

        }



        sort(a, a+n);

        ll sum = 0;

        for(ll i = 0; i < abs(r-l)+1; i++){

            sum += a[i];

        }



        cout << sum << endl;

    }

    return 0;

}   

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

typedef long long ll;
typedef long double doo;

typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef set<ll> sl;
typedef map<ll, ll> ml;
typedef map<string, ll> ms;

#define gett(s) string s; cin>>s;
#define ll_max INT64_MAX
#define ll_min INT64_MIN

#define mp make_pair
#define pb push_back
#define f first
#define se second

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define cn continue;
#define nl cout << "\n";

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll t;
    cin >> t;
    
    while(t--){
        ll n, l, r;
        cin >> n >> l >> r;
        vector<ll> a(n), b(n);
        
        for(ll i = 0; i < n; i++){
            cin >> a[i];
            b[i] = a[i];
        }

        sort(a.begin(), a.begin() + r);
        sort(b.begin() + (l - 1), b.end());
        
        ll sum1 = 0, sum2 = 0;
        ll length = r - l + 1;
        for(ll j = 0; j < length; j++){
            sum1 += a[j];
            sum2 += b[j];
        }
        
        cout << min(sum1, sum2);
        nl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

typedef long long ll;
typedef long double doo;

typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
typedef set<ll> sl;
typedef map<ll, ll> ml;
typedef map<string, ll> ms;

#define gett(s) string s; cin>>s;
#define ll_max INT64_MAX
#define ll_min INT64_MIN

#define mp make_pair
#define pb push_back
#define f first
#define se second

#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define cn continue;
#define nl cout << "\n";

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll t;
    cin >> t;
    
    while(t--){
        ll n, l, r;
        cin >> n >> l >> r;
        vector<ll> a(n), b(n);
        
        for(ll i = 0; i < n; i++){
            cin >> a[i];
            b[i] = a[i];
        }

        sort(a.begin(), a.begin() + r);
        sort(b.begin() + (l - 1), b.end());
        
        ll sum1 = 0, sum2 = 0;
        ll length = r - l + 1;
        for(ll j = 0; j < length; j++){
            sum1 += a[j];
            sum2 += b[j];
        }
        
        cout << min(sum1, sum2);
        nl;
    }
    return 0;
}   

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

using namespace std;



typedef long long ll;

typedef long double doo;



typedef vector<pair<ll,ll>> vp;

typedef pair<ll,ll> pl;

typedef vector<ll> vl;

typedef set<ll> sl;

typedef map<ll, ll> ml;

typedef map<string, ll> ms;



#define gett(s) string s; cin>>s;

#define ll_max INT64_MAX

#define ll_min INT64_MIN



#define mp make_pair

#define pb push_back

#define f first

#define se second



#define yes cout<<"YES"<<endl;

#define no cout<<"NO"<<endl;

#define cn continue;

#define nl cout << "\n";



signed main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    ll t;

    cin >> t;

    

    while(t--){

        ll n, l, r;

        cin >> n >> l >> r;

        vector<ll> a(n), b(n);

        

        for(ll i = 0; i < n; i++){

            cin >> a[i];

            b[i] = a[i];

        }



        sort(a.begin(), a.begin() + r);

        sort(b.begin() + (l - 1), b.end());

        

        ll sum1 = 0, sum2 = 0;

        ll length = r - l + 1;

        for(ll j = 0; j < length; j++){

            sum1 += a[j];

        }

        for(ll k = l-1; k < r; k++){

            sum2 += b[k];

        }

        

        cout << min(sum1, sum2);

        nl;

    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0) , cout.tie(0);

    int t;

    cin >> t;

    while(t --){

        int n;

        cin >> n;

        string s;

        cin >> s;

        int s_cnt = 0 , p_cnt = 0 , wzs = -1 , wzp = -1 , cs = -1;

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

            if(s[i] == 's')

                s_cnt ++;

            else if(s[i] == 'p')

                p_cnt ++;

            if(s[i] == 's')

                wzs = i;

            else if(s[i] == 'p' && wzp == -1)

                wzp = i;

            if(s[i] == 's' && cs == -1)

                cs = i;

        }

        if(s_cnt && p_cnt){

            if(wzs > wzp || (cs != 0 && wzp != n - 1))

                cout << "NO" << '\n';

            else

                cout << "YES" << '\n';

        }else

            cout << "YES" << '\n';

    }

    return 0;

}

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

using namespace std;



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0) , cout.tie(0);

    int t;

    cin >> t;

    while(t --){

        int n;

        cin >> n;

        string s;

        cin >> s;

        int wzs = -1 , wzp = -1;

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

            if(s[i] == 's')

                wzs = i;

            else if(s[i] == 'p' && wzp == -1)

                wzp = i;

        }

        if((wzs >= -1 && (wzp == n - 1 || wzp == -1)) || (wzs == -1 || wzs == 0) && wzp >= -1)

            cout << "YES" << '\n';

        else

            cout << "NO" << '\n';

    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0) , cout.tie(0);

    int t;

    cin >> t;

    while(t --){

        int n;

        cin >> n;

        string s;

        cin >> s;

        int s_cnt = 0 , p_cnt = 0 , wzs = -1 , wzp = -1 , cs = -1;

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

            if(s[i] == 's')

                s_cnt ++;

            else if(s[i] == 'p')

                p_cnt ++;

            if(s[i] == 's')

                wzs = i;

            else if(s[i] == 'p' && wzp == -1)

                wzp = i;

            if(s[i] == 's' && cs == -1)

                cs = i;

        }

        if(s_cnt && p_cnt){

            if(wzs > wzp || cs != 0)

                cout << "NO" << '\n';

            else

                cout << "YES" << '\n';

        }else

            cout << "YES" << '\n';

    }

    return 0;

}

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

using namespace std;



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0) , cout.tie(0);

    int t;

    cin >> t;

    while(t --){

        int n;

        cin >> n;

        string s;

        cin >> s;

        int s_cnt = 0 , p_cnt = 0 , wzs = -1 , wzp = -1 , cs = -1;

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

            if(s[i] == 's')

                s_cnt ++;

            else if(s[i] == 'p')

                p_cnt ++;

            if(s[i] == 's')

                wzs = i;

            else if(s[i] == 'p' && wzp == -1)

                wzp = i;

            if(s[i] == 's' && cs == -1)

                cs = i;

        }

        if(s_cnt && p_cnt){

            if(wzs > wzp || (cs != 0 && wzp != n - 1))

                cout << "NO" << '\n';

            else

                cout << "YES" << '\n';

        }else

            cout << "YES" << '\n';

    }

    return 0;

}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;



int main(){

    ios::sync_with_stdio(false);

    cin.tie(0) , cout.tie(0);

    int t;

    cin >> t;

    while(t --){

        int n;

        cin >> n;

        string s;

        cin >> s;

        int s_cnt = 0 , p_cnt = 0 , wzs = -1 , wzp = -1 , cs = -1;

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

            if(s[i] == 's')

                s_cnt ++;

            else if(s[i] == 'p')

                p_cnt ++;

            if(s[i] == 's')

                wzs = i;

            else if(s[i] == 'p' && wzp == -1)

                wzp = i;

            if(s[i] == 's' && cs == -1)

                cs = i;

        }

        if(s_cnt && p_cnt){

            if(wzs > wzp || cs != 0)

                cout << "NO" << '\n';

            else

                cout << "YES" << '\n';

        }else

            cout << "YES" << '\n';

    }

    return 0;

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


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

#define int long long

using namespace std;

const int N = 2e5 + 10,INF=0x3f3f3f3f,mod= 1e9 + 7;

/*int prime[N];bool st[N];int cnt=0;

void getprime(long long  n)

{

    for(int i=2;i<=n;i++)

    {

        if(!st[i])prime[cnt++]=i;

        for(int j=0;prime[j]<=n/i;j++)

        {

            st[prime[j]*i]=true;

            if(prime[j]%i==0)break;

        }

        

    }

}*/

int qsm(int n,int m)/*n^m*/

{

    int res=1;

    while(m)

    {

        if(m&1) 

        res=res*n%mod;

        n=n*n%mod;

        m>>=1;

    }

    return res;

}

map<string,int>mp,mpp; 

void solve()

{

    string s;

    cin>>s;

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

    {

        int mx=-1;

        int pos=-1;

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

        {

            

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

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

            if(b-j+i>a)

            {

                if(b-j+i>mx)

                {

                    mx=b-j+i;

                    pos=j;

                }

            }

        }

        if(mx!=-1)

        {

            s[pos]=mx+'0';

            swap(s[i],s[pos]);

        }

        

    }

    cout<<s<<endl;

}

signed main() 

{

	cin.tie(0),cout.tie(0);

  	int T=1;

  	cin>>T;

  	while(T--)

  	{

  		solve();

	}

    return 0;

}