ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    
    if l[0]>=l[1]:
        print("NO")
    else:
        f=1
        for i in range(1,n-1):
            
            if l[i]<l[i+1]:
                pass
            else:
            
                k=l[i]-l[i-1]
                
                if l[i+1]<=k:
                    f=0
                    break
                
                l[i]=k
            
        if f:
            print("YES")
        else:
            print("NO")
Problem: 2060D - Subtract Min Sort
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    
    if l[0]>=l[1]:
        print("NO")
    else:
        f=1
        for i in range(1,n-1):
            
            if l[i]<l[i+1]:
                pass
            else:
            
                k=l[i]-l[i-1]
                
                if l[i+1]<=k:
                    f=0
                    break
                
                l[i]=k
            
        if f:
            print("YES")
        else:
            print("NO")

Submission (verdict: Wrong answer on test 2):
for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    
    if l[0]>=l[1]:
        print("NO")
    else:
        f=1
        for i in range(1,n-1):
            
            if l[i]<=l[i-1]:
                f=0
                break
        
            if l[i+1]<=l[i]:
                l[i]=l[i]-l[i-1]
                
                
                
            
        if f:
            print("YES")
        else:
            print("NO")
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define all(v)  (v).begin(), (v).end()
#define allR(v) (v).rbegin(), (v).rend()
#define pb  push_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define el "\n"
#define popc(x) __builtin_popcount(x)
#define sz(x) int((x).size())
#define Mahmoud ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>// set
typedef tree<int, null_type,less_equal<>, rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
//----------------------------------
template <typename T> istream& operator>>(istream& input, vector<T>& data) { for (T& x : data)input >> x; return input; }
template <typename T> ostream& operator<<(ostream& output, const vector<T>& data) { for (const T& x : data) output << x << " "; return output; }
//----------------------------------
void Memo() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const double eps = 1e-9;
const ll MOD = 1e9 + 7, INF = 1e18, N = 1e5 + 5 ;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
char di[]{ 'R', 'D', 'L', 'U'};

void Solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (auto &it: a)cin >> it;
    if (a[0] > a[1])
        return cout << "NO\n", void();
    for (int i = 1; i + 1 < n; ++i) {
        if (a[i] > a[i + 1]) {
            ll x = min(a[i], a[i - 1]);
            a[i] -= x;
            a[i - 1] -= x;
        }
        if (a[i] > a[i + 1]) return cout << "NO\n", void();
    }
    cout << "YES\n";
}
int main() {
    Memo();
    Mahmoud
    int tt = 1;
    cin >> tt;
    while (tt--)
        Solve();
    return 0;
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;

int main() 
{
    int t,n;
    cin >> t;
    while(t--){
      cin >> n;
      int sumEven = 0,m,sumOdd = 0,odd = 0,even = 0;
      for(int i = 0; i < n;i++){
        cin >> m;
        if(i % 2 == 0){
          sumEven += m;
          even++;
        }
        else{
          sumOdd += m;
          odd++;
        }
      }
      if(sumOdd / odd == sumEven / even){
        cout << "YES" << endl;
      }
      else{
        cout << "NO" << endl;
      }
    }
    return 0;
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>
using namespace std;

int main() 
{
    int t,n;
    cin >> t;
    while(t--){
      cin >> n;
      int sumEven = 0,m,sumOdd = 0,odd = 0,even = 0;
      for(int i = 0; i < n;i++){
        cin >> m;
        if(i % 2 == 0){
          sumEven += m;
          even++;
        }
        else{
          sumOdd += m;
          odd++;
        }
      }
      if(sumOdd / odd == sumEven / even && sumOdd % odd == 0 && sumEven % even == 0){
        cout << "YES" << endl;
      }
      else{
        cout << "NO" << endl;
      }
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
using namespace std;

int main() 
{
    long long t,n;
    cin >> t;
    while(t--){
      cin >> n;
      long long sumEven = 0,m,sumOdd = 0,odd = 0,even = 0;
      for(int i = 0; i < n;i++){
        cin >> m;
        if(i % 2 == 0){
          sumEven += m;
          even++;
        }
        else{
          sumOdd += m;
          odd++;
        }
      }
      if(sumOdd / odd == sumEven / even && sumOdd % odd == 0 && sumEven % even == 0){
        cout << "YES" << endl;
      }
      else{
        cout << "NO" << endl;
      }
    }
    return 0;
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;

int main() 
{
    int t,n;
    cin >> t;
    while(t--){
      cin >> n;
      int sumEven = 0,m,sumOdd = 0,odd = 0,even = 0;
      for(int i = 0; i < n;i++){
        cin >> m;
        if(i % 2 == 0){
          sumEven += m;
          even++;
        }
        else{
          sumOdd += m;
          odd++;
        }
      }
      if(sumOdd / odd == sumEven / even){
        cout << "YES" << endl;
      }
      else{
        cout << "NO" << endl;
      }
    }
    return 0;
}

Submission (verdict: Wrong answer on test 3):
#include <iostream>
using namespace std;

int main() 
{
    int t,n;
    cin >> t;
    while(t--){
      cin >> n;
      int sumEven = 0,m,sumOdd = 0,odd = 0,even = 0;
      for(int i = 0; i < n;i++){
        cin >> m;
        if(i % 2 == 0){
          sumEven += m;
          even++;
        }
        else{
          sumOdd += m;
          odd++;
        }
      }
      if(sumOdd / odd == sumEven / even && sumOdd % odd == 0 && sumEven % even == 0){
        cout << "YES" << endl;
      }
      else{
        cout << "NO" << endl;
      }
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
   ll t,n,z,i,j;
   cin>>t;
   while(t--)
   {
     cin>>n;
     vector<ll>v(n),x(n);
     for(i=0;i<n;i++) 
     {
       cin>>v[i];
     }
     if(n==1) cout<<v[0]<<"\n";
     else{
     for(i=1;i<=n-2;i++)
     {
        for(j=0;j<n;j++)
        {
            v[j]=v[j+1]-v[j];
        }
        v.pop_back();
     }
     cout<<abs(v[0])+abs(v[1])<<"\n";
     }
   }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
   ll t,n,z,i,j;
   cin>>t;
   while(t--)
   {
     cin>>n;
     vector<ll>v(n),x(n);
     for(i=0;i<n;i++) 
     {
       cin>>v[i];
     }
     if(n==1) cout<<v[0]<<"\n";
     else{
     for(i=1;i<=n-2;i++)
     {
        for(j=0;j<n;j++)
        {
            v[j]=v[j+1]-v[j];
        }
        v.pop_back();
     }
     cout<<abs(v[0])+abs(v[1])<<"\n";
     }
   }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
   ll t,n,z,i,j;
   cin>>t;
   while(t--)
   {
     cin>>n;
     vector<ll>v(n),x(n);
     for(i=0;i<n;i++) 
     {
       cin>>v[i];
     }
     if(n==1) cout<<v[0]<<"\n";
     else{
     for(i=1;i<=n-2;i++)
     {
        for(j=0;j<n;j++)
        {
            v[j]=v[j+1]-v[j];
        }
        v.pop_back();
     }
     if((v[0]<0 && v[1]>=0)||(v[0]>=0 && v[1]<0)||(v[0]>=0 && v[1]>=0))
       cout<<abs(v[0])+abs(v[1])<<"\n";
     else
     {
        if(abs(v[0])>=abs(v[1])) cout<<abs(v[0])-abs(v[1])<<"\n";
        else cout<<abs(v[1])-abs(v[0])<<"\n";
     }
     }
   }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
   ll t,n,z,i,j;
   cin>>t;
   while(t--)
   {
     cin>>n;
     vector<ll>v(n),x(n);
     for(i=0;i<n;i++) 
     {
       cin>>v[i];
     }
     if(n==1) cout<<v[0]<<"\n";
     else{
     for(i=1;i<=n-2;i++)
     {
        for(j=0;j<n-1;j++)
        {
            v[j]=v[j+1]-v[j];
        }
        v.pop_back();
     }
     if((v[0]<0 && v[1]>=0)||(v[0]>=0 && v[1]<0)||(v[0]>=0 && v[1]>=0))
       cout<<abs(v[0])+abs(v[1])<<"\n";
     else
     {
        if(abs(v[0])>=abs(v[1])) cout<<abs(v[0])-abs(v[1])<<"\n";
        else cout<<abs(v[1])-abs(v[0])<<"\n";
     }
     }
   }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
   ll t,n,z,i,j,m;
   cin>>t;
   while(t--)
   {
     cin>>n;
     vector<ll>v(n),x(n);
     for(i=0;i<n;i++) 
     {
       cin>>v[i];
     }
     m=accumulate(v.begin(),v.end(),0LL);
     if(n==1) cout<<v[0]<<"\n";
     else{
     for(i=1;i<=n-2;i++)
     {
        for(j=0;j<n-1;j++)
        {
            v[j]=v[j+1]-v[j];
        }
        v.pop_back();
        z=accumulate(v.begin(),v.end(),0LL);
        m=max(m,abs(z));
     }
     if((v[0]<0 && v[1]>=0)||(v[0]>=0 && v[1]<0)||(v[0]>=0 && v[1]>=0)){
       m=max(m,(abs(v[0])+abs(v[1])));
       cout<<m<<"\n";}
     else
     {
        if(abs(v[0])>=abs(v[1])){
           m=max(m,(abs(v[0])-abs(v[1])));
           cout<<m<<"\n";}
        else{
         m=max(m,(abs(v[1])-abs(v[0])));
         cout<<m<<"\n";}
     }
     }
   }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
   ll t,n,z,i,j;
   cin>>t;
   while(t--)
   {
     cin>>n;
     vector<ll>v(n),x(n);
     for(i=0;i<n;i++) 
     {
       cin>>v[i];
     }
     if(n==1) cout<<v[0]<<"\n";
     else{
     for(i=1;i<=n-2;i++)
     {
        for(j=0;j<n;j++)
        {
            v[j]=v[j+1]-v[j];
        }
        v.pop_back();
     }
     if((v[0]<0 && v[1]>=0)||(v[0]>=0 && v[1]<0)||(v[0]>=0 && v[1]>=0))
       cout<<abs(v[0])+abs(v[1])<<"\n";
     else
     {
        if(abs(v[0])>=abs(v[1])) cout<<abs(v[0])-abs(v[1])<<"\n";
        else cout<<abs(v[1])-abs(v[0])<<"\n";
     }
     }
   }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
   ll t,n,z,i,j;
   cin>>t;
   while(t--)
   {
     cin>>n;
     vector<ll>v(n),x(n);
     for(i=0;i<n;i++) 
     {
       cin>>v[i];
     }
     if(n==1) cout<<v[0]<<"\n";
     else{
     for(i=1;i<=n-2;i++)
     {
        for(j=0;j<n-1;j++)
        {
            v[j]=v[j+1]-v[j];
        }
        v.pop_back();
     }
     if((v[0]<0 && v[1]>=0)||(v[0]>=0 && v[1]<0)||(v[0]>=0 && v[1]>=0))
       cout<<abs(v[0])+abs(v[1])<<"\n";
     else
     {
        if(abs(v[0])>=abs(v[1])) cout<<abs(v[0])-abs(v[1])<<"\n";
        else cout<<abs(v[1])-abs(v[0])<<"\n";
     }
     }
   }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

using namespace std;

bool canMakeN(long long threecount, long long twocount, long long rem)

{

  long long res = rem / 6;

  // min

  if (res <= threecount)

  {

    if ((rem - res * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

  else

  {

    if ((rem - threecount * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

}

int main()

{

  int t;

  cin >> t;

  while (t--)

  {

    string s;

    cin >> s;

    long long sum = 0;

    long long twocount = 0;

    long long threecount = 0;

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

    {

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

      {

        twocount++;

      }

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

      {

        threecount++;

      }

      sum += (s[i] - '0');

    }

    long long near = 9 * ((sum / 9) + 2);

    long long rem = near - sum;

    if (sum % 9 == 0)

    {

      cout << "YES" << endl;

    }

    else if ((rem % 2 == 0 && rem / 2 <= twocount) || (rem % 6 == 0 && rem / 6 <= threecount) || canMakeN(threecount, twocount, rem))

    {

      cout << "YES" << endl;

    }

    else

    {

      cout << "NO" << endl;

    }

  }

}

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

using namespace std;

bool canMakeN(long long threecount, long long twocount, long long rem)

{

  long long res = rem / 6;

  // min

  if (res <= threecount)

  {

    if ((rem - res * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

  else

  {

    if ((rem - threecount * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

}

int main()

{

  int t;

  cin >> t;

  while (t--)

  {

    string s;

    cin >> s;

    long long sum = 0;

    long long twocount = 0;

    long long threecount = 0;

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

    {

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

      {

        twocount++;

      }

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

      {

        threecount++;

      }

      sum += (s[i] - '0');

    }

    long long near;

    if (sum % 9 == 0)

    {

      near = sum;

    }

    else

    {

      if ((sum % 9) <= 3)

      {

        near = (sum / 9 + 1) * 9;

      }

      else

      {

        near = (sum / 9 + 2) * 9;

      }

    }



    long long rem = near - sum;

    if (sum % 9 == 0)

    {

      cout << "YES" << endl;

    }

    else if ((rem % 2 == 0 && rem / 2 <= twocount) || (rem % 6 == 0 && rem / 6 <= threecount) || canMakeN(threecount, twocount, rem))

    {

      cout << "YES" << endl;

    }

    else

    {

      cout << "NO" << endl;

    }

  }

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

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

using namespace std;

bool canMakeN(long long threecount, long long twocount, long long rem)

{

  long long res = rem / 6;

  // min

  if (res <= threecount)

  {

    if ((rem - res * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

  else

  {

    if ((rem - threecount * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

}

int main()

{

  int t;

  cin >> t;

  while (t--)

  {

    string s;

    cin >> s;

    long long sum = 0;

    long long twocount = 0;

    long long threecount = 0;

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

    {

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

      {

        twocount++;

      }

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

      {

        threecount++;

      }

      sum += (s[i] - '0');

    }

    long long near;

    if (sum % 9 == 0)

    {

      near = sum;

    }

    else

    {

      if ((sum % 9) <= 3)

      {

        near = (sum / 9 + 1) * 9;

      }

      else

      {

        near = (sum / 9 + 2) * 9;

      }

    }



    long long rem = near - sum;

    if (sum % 9 == 0)

    {

      cout << "YES" << endl;

    }

    else if ((rem % 2 == 0 && rem / 2 <= twocount) || (rem % 6 == 0 && rem / 6 <= threecount) || canMakeN(threecount, twocount, rem))

    {

      cout << "YES" << endl;

    }

    else

    {

      cout << "NO" << endl;

    }

  }

}

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

using namespace std;

bool canMakeN(long long threecount, long long twocount, long long rem)

{

  long long res = rem / 6;

  // min

  if (res <= threecount)

  {

    if ((rem - res * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

  else

  {

    if ((rem - threecount * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

}

int fnear(long long n2, long long n3)

{

  if (n3 == 0)

  {

    return 1;

  }

  else if (n2 == 0 && n3 > 1)

  {

    return 2;

  }

  else if (n2 == 0 && n3 == 1)

  {

    return 1;

  }

  else

  {

    return 2;

  }

}

int main()

{

  int t;

  cin >> t;

  while (t--)

  {

    string s;

    cin >> s;

    long long sum = 0;

    long long twocount = 0;

    long long threecount = 0;

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

    {

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

      {

        twocount++;

      }

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

      {

        threecount++;

      }

      sum += (s[i] - '0');

    }

    long long near = (sum / 9 + fnear(twocount, threecount)) * 9;



    long long rem = near - sum;

    if (sum % 9 == 0)

    {

      cout << "YES" << endl;

    }

    else if ((rem % 2 == 0 && rem / 2 <= twocount) || (rem % 6 == 0 && rem / 6 <= threecount) || canMakeN(threecount, twocount, rem))

    {

      cout << "YES" << endl;

    }

    else

    {

      cout << "NO" << endl;

    }

  }

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


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

using namespace std;

bool canMakeN(long long threecount, long long twocount, long long rem)

{

  long long res = rem / 6;

  // min

  if (res <= threecount)

  {

    if ((rem - res * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

  else

  {

    if ((rem - threecount * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

}

int main()

{

  int t;

  cin >> t;

  while (t--)

  {

    string s;

    cin >> s;

    long long sum = 0;

    long long twocount = 0;

    long long threecount = 0;

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

    {

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

      {

        twocount++;

      }

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

      {

        threecount++;

      }

      sum += (s[i] - '0');

    }

    long long near = 9 * ((sum / 9) + 2);

    long long rem = near - sum;

    if (sum % 9 == 0)

    {

      cout << "YES" << endl;

    }

    else if ((rem % 2 == 0 && rem / 2 <= twocount) || (rem % 6 == 0 && rem / 6 <= threecount) || canMakeN(threecount, twocount, rem))

    {

      cout << "YES" << endl;

    }

    else

    {

      cout << "NO" << endl;

    }

  }

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

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

using namespace std;

bool canMakeN(long long threecount, long long twocount, long long rem)

{

  long long res = rem / 6;

  // min

  if (res <= threecount)

  {

    if ((rem - res * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

  else

  {

    if ((rem - threecount * 6) / 2 <= twocount)

    {

      return true;

    }

    else

    {

      return false;

    }

  }

}

int fnear(long long n2, long long n3)

{

  if (n3 == 0)

  {

    return 1;

  }

  else if (n2 == 0 && n3 > 1)

  {

    return 2;

  }

  else if (n2 == 0 && n3 == 1)

  {

    return 1;

  }

  else

  {

    return 2;

  }

}

int main()

{

  int t;

  cin >> t;

  while (t--)

  {

    string s;

    cin >> s;

    long long sum = 0;

    long long twocount = 0;

    long long threecount = 0;

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

    {

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

      {

        twocount++;

      }

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

      {

        threecount++;

      }

      sum += (s[i] - '0');

    }

    long long near = (sum / 9 + fnear(twocount, threecount)) * 9;



    long long rem = near - sum;

    if (sum % 9 == 0)

    {

      cout << "YES" << endl;

    }

    else if ((rem % 2 == 0 && rem / 2 <= twocount) || (rem % 6 == 0 && rem / 6 <= threecount) || canMakeN(threecount, twocount, rem))

    {

      cout << "YES" << endl;

    }

    else

    {

      cout << "NO" << endl;

    }

  }

}

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

using namespace std;



bool canMakeN(long long threecount, long long twocount, long long rem)

{

  for (long long i = 0; i <= threecount; i++)

  {

    long long remaining = rem - (i * 6);

    if (remaining >= 0 && remaining % 2 == 0 && remaining / 2 <= twocount)

    {

      return true;

    }

  }

  return false;

}



int main()

{

  int t;

  cin >> t;

  while (t--)

  {

    string s;

    cin >> s;

    long long sum = 0;

    long long twocount = 0;

    long long threecount = 0;

    

    for (char c : s)

    {

      if (c == '2') twocount++;

      if (c == '3') threecount++;

      sum += (c - '0');

    }



    long long near = (sum / 9 + 1) * 9;

    long long rem = near - sum;



    if ((rem % 2 != 0 && rem % 6 != 0))

    {

      near += 9;

      rem = near - sum;

    }



    if (sum % 9 == 0)

    {

      cout << "YES" << endl;

    }

    else if ((rem % 2 == 0 && rem / 2 <= twocount) || (rem % 6 == 0 && rem / 6 <= threecount) || canMakeN(threecount, twocount, rem))

    {

      cout << "YES" << endl;

    }

    else

    {

      cout << "NO" << endl;

    }

  }

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

int main()
{
    ios::sync_with_stdio(false); // I/O ফাস্ট করার জন্য
    cin.tie(0); // cin & cout এর মধ্যে ফ্লাশিং বন্ধ করে আরও দ্রুত করে

    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        bool check = true;
        while (check)
        {
            int flag = 0;
            for (int i = 0; i < s.size() - 1; i++)
            {
                if (s[i] - '0' < s[i + 1] - '0' - 1)
                {
                    swap(s[i], s[i + 1]);
                    int temp = (s[i] - '0' - 1);
                    s[i] = temp + '0';
                    flag = 1;
                    break;
                }
            }
            if (flag == 1)
            {
                check = true;
            }
            else
            {
                check = false;
            }
        }
        cout << s << '\n'; // endl এর বদলে '\n' ব্যবহার করা আরও দ্রুত
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  cin >> t;
  while (t--)
  {
    string s;
    cin >> s;
    bool check = true;
    while (check)
    {
      int flag = 0;
      for (int i = 0; i < s.size() - 1; i++)
      {
        if (s[i] - '0' < s[i + 1] - '0' - 1)
        {
          swap(s[i], s[i + 1]);
          int temp = (s[i] - '0' - 1);
          s[i] = temp + '0';
          flag = 1;
        }
      }
      if (flag == 1)
      {
        check = true;
      }
      else
      {
        check = false;
      }
    }
    cout << s << endl;
  }
}