ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

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

void solve() {
    std::string a, b, c;
    std::cin >> a >> b >> c;
    
    const int n = a.size(), m = b.size(), l = c.size();
    std::queue<std::array<int, 3>> q;
    q.push({0, 0, 0});
    int ans = 1e9;

    while (!q.empty()) {
        const auto [x, i, j] = q.front();
        q.pop();

        const int idx = i + j;
        if (idx == l) {
            ans = std::min(ans, x);
            continue;
        }

        if (i < n && c[idx] == a[i]) {
            q.push({x, i + 1, j});
        }
        if (j < m && c[idx] == b[j]) {
            q.push({x, i, j + 1});
        }
        q.push({x + 1, i + 1, j});
        q.push({x + 1, i, j + 1});
    }
    
    std::cout << ans << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

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

    return 0;
}

Submission (verdict: Memory limit exceeded on test 6):
#include <bits/stdc++.h>

void solve() {
    std::string a, b, c;
    std::cin >> a >> b >> c;
    
    const int n = a.size(), m = b.size(), l = c.size();
    std::queue<std::array<int, 3>> q;
    q.push({0, 0, 0});
    int ans = 1e9;

    while (!q.empty()) {
        const auto [x, i, j] = q.front();
        q.pop();

        const int idx = i + j;
        if (idx == l) {
            ans = std::min(ans, x);
            continue;
        }

        if (i < n) {
            q.push({x + (c[idx] != a[i]), i + 1, j});
        }
        if (j < m) {
            q.push({x + (c[idx] != b[j]), i, j + 1});
        }
    }
    
    std::cout << ans << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

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

    return 0;
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Memory limit exceeded on test 6):
#include <bits/stdc++.h>

void solve() {
    std::string a, b, c;
    std::cin >> a >> b >> c;
    
    const int n = a.size(), m = b.size(), l = c.size();
    std::queue<std::array<int, 3>> q;
    q.push({0, 0, 0});
    int ans = 1e9;

    while (!q.empty()) {
        const auto [x, i, j] = q.front();
        q.pop();

        const int idx = i + j;
        if (idx == l) {
            ans = std::min(ans, x);
            continue;
        }

        if (i < n) {
            q.push({x + (c[idx] != a[i]), i + 1, j});
        }
        if (j < m) {
            q.push({x + (c[idx] != b[j]), i, j + 1});
        }
    }
    
    std::cout << ans << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

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

    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

void solve() {
    std::string a, b, c;
    std::cin >> a >> b >> c;
    
    const int n = a.size(), m = b.size(), l = c.size();
    std::priority_queue<std::array<int, 3>, std::vector<std::array<int, 3>>, std::greater<>> q;
    q.push({0, 0, 0});
    int ans = 1e9;

    std::vector<bool> vis(n);
    while (!q.empty()) {
        const auto [x, i, j] = q.top();
        q.pop();

        const int idx = i + j;
        if (vis[idx]) {
            continue;
        }

        if (idx == l) {
            ans = std::min(ans, x);
            continue;
        }

        if (i < n) {
            q.push({x + (c[idx] != a[i]), i + 1, j});
        }
        if (j < m) {
            q.push({x + (c[idx] != b[j]), i, j + 1});
        }
    }
    
    std::cout << ans << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

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

    return 0;
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

      bool b=1;

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

      {

        cout<<"yes"<<endl;

        continue;

      }

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

      {

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

        say1++;

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

        say2++;

        if(i!=0 and s[i]=='s' and s[i-1]=='p')

        b=0;

      }

      if(say2==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

      if(s[0]=='.' and say1==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

      if(b)

      {

        cout<<"yes"<<endl;

        continue;

      }

     else

      cout<<"no"<<endl;

    }

}

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

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

      bool b=0,b1=0;

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

      {

        s[0]='.';

      }

      if(s[m-1]=='p')

      s[m-1]='.';

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

      {

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

        b=1;

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

        b1=1;

      }

      if(b1 and b)

      cout<<"no"<<endl;

      else cout<<"yes"<<endl;

    }

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

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

      {

        cout<<"yes"<<endl;

        continue;

      }

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

      {

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

        say1++;

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

        say2++;

      }

      if(say2==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

      if(s[0]=='.' and say1==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

     else

      cout<<"no"<<endl;

    }

}

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

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

      bool b=1;

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

      {

        cout<<"yes"<<endl;

        continue;

      }

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

      {

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

        say1++;

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

        say2++;

        if(i!=0 and s[i]=='s' and s[i-1]=='p')

        b=0;

      }

      if(say2==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

      if(s[0]=='.' and say1==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

      if(b)

      {

        cout<<"yes"<<endl;

        continue;

      }

     else

      cout<<"no"<<endl;

    }

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


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

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

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

      {

        cout<<"yes"<<endl;

        continue;

      }

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

      {

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

        say1++;

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

        say2++;

      }

      if(say2==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

     else

      cout<<"no"<<endl;

    }

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

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

      {

        cout<<"yes"<<endl;

        continue;

      }

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

      {

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

        say1++;

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

        say2++;

      }

      if(say2==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

     else

      cout<<"no"<<endl;

    }

}

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

using namespace std;

#define ll long long

#define pair pair<ll,ll>

ll n,m,say1,say2,cem=0;

int main()

{

    cin>>n;

    string s;

    while(n--)

    {

      cin>>m;

      cin>>s;

      say1=0;

      say2=0;

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

      {

        cout<<"yes"<<endl;

        continue;

      }

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

      {

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

        say1++;

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

        say2++;

      }

      if(say2==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

      if(s[0]=='.' and say1==0)

      {

        cout<<"yes"<<endl;

        continue;

      }

     else

      cout<<"no"<<endl;

    }

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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    ll t,a;
    cin>>t;
    while(t--)
    {
       cin>>a;
       ll cem=0,k=0,l=0;
       while(a!=0)
       {
         cem+=a%10;
         if(a%10==2)
         k++;
         if(a%10==3)
         l++;
         a/=10;
       }
       ll q=cem%9;
       if(cem%9==0)
       cout<<"yes"<<endl;
       else
       {   
           bool b=0;
           for(int i=0;i<=k%9;i++)
           {
               for(int j=0;j<=l%9;j++)
               {
                   if((2*i+6*j+cem)%9==0)
                   {
                       b=1;
                       break;
                   }
               }
           }
        if(b)
        cout<<"yes"<<endl;
        else cout<<"no"<<endl;
       }
    }
}

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

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

    vector<int> s;
    int sm = 0, twos = 0, threes = 0;
    for (char c : input) {
        int digit = c - '0';
        s.push_back(digit);
        sm += digit;
        if (digit == 2) twos++;
        if (digit == 3) threes++;
    }

    for (int i = 0; i < min(10, twos + 1); i++) {
        for (int j = 0; j < min(10, threes + 1); j++) {
            if ((sm + i * 2 + j * 6) % 9 == 0) {
                cout << "YES" << endl;
                return;
            }
        }
    }
    cout << "NO" << endl;
}

int main() {
    int t;
    cin >> t;

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

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

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    ll t,a;
    cin>>t;
    while(t--)
    {
       cin>>a;
       ll cem=0,k=0,l=0;
       while(a!=0)
       {
         cem+=a%10;
         if(a%10==2)
         k++;
         if(a%10==3)
         l++;
         a/=10;
       }
       
       if(cem%9==0)
       cout<<"yes"<<endl;
       else
       {   
           bool b=0;
           for(int i=0;i<=k%9;i++)
           {
               for(int j=0;j<=l%9;j++)
               {
                   if((2*i+6*j+cem%9)%9==0)
                   {
                       b=1;
                       break;
                   }
               }
           }
        if(b)
        cout<<"yes"<<endl;
        else cout<<"no"<<endl;
       }
    }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    ll t,a;
    cin>>t;
    while(t--)
    {
       cin>>a;
       ll cem=0,k=0,l=0;
       while(a!=0)
       {
         cem+=a%10;
         if(a%10==2)
         k++;
         if(a%10==3)
         l++;
         a/=10;
       }
       ll q=cem%9;
       if(cem%9==0)
       cout<<"yes"<<endl;
       else
       {   
           bool b=0;
           for(int i=0;i<=k%9;i++)
           {
               for(int j=0;j<=l%9;j++)
               {
                   if((2*i+6*j+cem)%9==0)
                   {
                       b=1;
                       break;
                   }
               }
           }
        if(b)
        cout<<"yes"<<endl;
        else cout<<"no"<<endl;
       }
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    ll t,a;
    cin>>t;
    while(t--)
    {
       cin>>a;
       ll cem=0,k=0,l=0;
       vector<int>v;
       while(a!=0)
       {
         v.push_back(a%10);
         cem+=a%10;
         if(a%10==2)
         k++;
         if(a%10==3)
         l++;
         a/=10;
       }
       bool b=0;
       sort(v.begin(),v.end());
       if(cem%9==0)
       cout<<"yes"<<endl;
       else
       {   
           for(int i=0;i<=k%9;i++)
           {
               for(int j=0;j<=l%9;j++)
               {
                   if((2*i+6*j+cem%9)%9==0)
                   {
                       b=1;
                       break;
                   }
               }
           }
        if(b)
        cout<<"yes"<<endl;
        else cout<<"no"<<endl;
       }
    }
}

Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    ll t,a;
    cin>>t;
    while(t--)
    {
       cin>>a;
       ll cem=0,k=0,l=0;
       while(a!=0)
       {
         cem+=a%10;
         if(a%10==2)
         k++;
         if(a%10==3)
         l++;
         a/=10;
       }
       
       if(cem%9==0)
       cout<<"yes"<<endl;
       else
       {   
           bool b=0;
           for(int i=0;i<=k%9;i++)
           {
               for(int j=0;j<=l%9;j++)
               {
                   if((2*i+6*j+cem%9)%9==0)
                   {
                       b=1;
                       break;
                   }
               }
           }
        if(b)
        cout<<"yes"<<endl;
        else cout<<"no"<<endl;
       }
    }
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
    ll t,a;
    cin>>t;
    while(t--)
    {
       cin>>a;
       ll cem=0,k=0,l=0;
       vector<int>v;
       while(a!=0)
       {
         v.push_back(a%10);
         cem+=a%10;
         if(a%10==2)
         k++;
         if(a%10==3)
         l++;
         a/=10;
       }
       bool b=0;
       sort(v.begin(),v.end());
       if(cem%9==0)
       cout<<"yes"<<endl;
       else
       {   
           for(int i=0;i<=k%9;i++)
           {
               for(int j=0;j<=l%9;j++)
               {
                   if((2*i+6*j+cem%9)%9==0)
                   {
                       b=1;
                       break;
                   }
               }
           }
        if(b)
        cout<<"yes"<<endl;
        else cout<<"no"<<endl;
       }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,m;
    bool b;
    cin>>t;
    while(t--)
    {
      b=1;
      cin>>m;
      vector<ll>v(m);
      for(int i=0;i<m;i++)
      cin>>v[i];
      vector<ll>vc=v;
      sort(vc.begin(),vc.end());
      if(v==vc)
      {
        cout<<"YES"<<endl;
      }
      else
      {
      for(int i=0;i<v.size()-1;i+=2)
      {
        if(v[i]>v[i+1])
        b=0;
      }
      if(b)
      cout<<"YES"<<endl;
      else 
      cout<<"NO"<<endl;
      }
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,m;
    bool b;
    cin>>t;
    while(t--)
    {
      b=1;
      ll maxi=-1e9;
      cin>>m;
      vector<ll>v(m);
      for(int i=0;i<m;i++)
      cin>>v[i];
      vector<ll>vc=v;
      sort(vc.begin(),vc.end());
      if(v==vc)
      {
        cout<<"YES"<<endl;
      }
      else
      {
        
      for(int i=0;i<v.size()-1;i+=2)
      {
        if(v[i]>v[i+1])
        b=0;
        maxi=max(maxi,abs(v[i]-v[i+1]));
      }
      if(b)
      cout<<"YES"<<endl;
      else if(maxi==1 and v[0]<v[v.size()-1])
      cout<<"YES"<<endl;
      else 
      cout<<"NO"<<endl;
      }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,m;
    bool b;
    cin>>t;
    while(t--)
    {
      b=1;
      ll maxi=-1e9;
      cin>>m;
      vector<ll>v(m);
      for(int i=0;i<m;i++)
      cin>>v[i];
      vector<ll>vc=v;
      sort(vc.begin(),vc.end());
      if(v==vc)
      {
        cout<<"YES"<<endl;
      }
      else
      {
        
      for(int i=0;i<v.size()-1;i+=2)
      {
        if(v[i]>v[i+1])
        b=0;
        maxi=max(maxi,abs(v[i]-v[i+1]));
      }
      if(b)
      cout<<"YES"<<endl;
      else if(maxi==1 and v[0]<v[v.size()-1])
      cout<<"YES"<<endl;
      else 
      cout<<"NO"<<endl;
      }
    }
}

Submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,m;
    bool b;
    cin>>t;
    while(t--)
    {
      b=1;
      ll maxi=-1e9;
      cin>>m;
      vector<ll>v(m);
      for(int i=0;i<m;i++)
      cin>>v[i];
      ll j=0;
      for(int i=1;i<m;i++)
      {
        if(v[i-1]>v[i])
        j=i;
      }
      if(j==0)
      cout<<"YES"<<endl;
      else
      {
        for(int i=0;i<m;i++)
        {
         ll mini=min(v[i],v[i+1]);
         v[i]-=mini;
         v[i+1]-=mini;
        }
        if(is_sorted(v.begin(),v.end()))
        cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
      }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,m;
    bool b;
    cin>>t;
    while(t--)
    {
      b=1;
      cin>>m;
      vector<ll>v(m);
      for(int i=0;i<m;i++)
      cin>>v[i];
      vector<ll>vc=v;
      sort(vc.begin(),vc.end());
      if(v==vc)
      {
        cout<<"YES"<<endl;
      }
      else
      {
      for(int i=0;i<v.size()-1;i+=2)
      {
        if(v[i]>v[i+1])
        b=0;
      }
      if(b)
      cout<<"YES"<<endl;
      else 
      cout<<"NO"<<endl;
      }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,m;
    bool b;
    cin>>t;
    while(t--)
    {
      b=1;
      ll maxi=-1e9;
      cin>>m;
      vector<ll>v(m);
      for(int i=0;i<m;i++)
      cin>>v[i];
      ll j=0;
      for(int i=1;i<m;i++)
      {
        if(v[i-1]>v[i])
        j=i;
      }
      if(j==0)
      cout<<"YES"<<endl;
      else
      {
        for(int i=0;i<m;i++)
        {
         ll mini=min(v[i],v[i+1]);
         v[i]-=mini;
         v[i+1]-=mini;
        }
        if(is_sorted(v.begin(),v.end()))
        cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
      }
    }
} 

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,n,m;
    bool b;
    cin>>t;
    while(t--)
    {
      b=1;
      ll maxi=-1e9;
      cin>>m;
      vector<ll>v(m);
      for(int i=0;i<m;i++)
      cin>>v[i];
      if(is_sorted(v.begin(),v.end()))
      cout<<"YES"<<endl;
      else
      {
        for(int i=0;i<m-1;i++)
        {
         ll mini=min(v[i],v[i+1]);
         v[i]-=mini;
         v[i+1]-=mini;
        }
        if(is_sorted(v.begin(),v.end()))
        cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
      }
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int long long
#define F first
#define S second
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
 
const int MOD = 1e9 + 7;
int powMOD(int x, int n) {
    int res = 1;
    while(n > 0) {
        if(n % 2) {
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}
 
int n;
void solve() {
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<pair<int, int>> v;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            if(a[i] < a[j]) {
                v.push_back({a[j], a[i]});
                v.push_back({a[i], a[j]});
            } else {
                v.push_back({a[i], a[j]});
            }
        }
    }
    
    cout << v.size() << "\n";
    for(auto x: v) {
        cout << x.first << " " << x.second << "\n";
    }
    
}
 
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}