ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 2):
//Problem Link :

#include<bits/stdc++.h>

#define ll long long int

#define endl '\n'

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main()

{

    fast;

    ll t;

    cin>>t;

    while(t--)

    {

        ll n,l,r,x;

        cin>>n>>l>>r;

        vector<ll>b,c;

        for(ll i=1;i<=n;i++)

        {

            cin>>x;

            if(x>=l && x<=n)b.push_back(x);

            if(x<=r && x>=1)c.push_back(x);

        }

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

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



        ll sum1=0,sum2=0;

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

        {

            sum1+=b[i];

            sum2+=c[i];

        }

        cout<<min(sum1,sum2)<<endl;

    }

    return 0;

}





Submission (verdict: Accepted):
//Problem Link :

#include<bits/stdc++.h>

#define ll long long int

#define endl '\n'

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;

int main()

{

    fast;

    ll t;

    cin>>t;

    while(t--)

    {

        ll n,l,r,x;

        cin>>n>>l>>r;

        vector<ll>b,c;

        for(ll i=1;i<=n;i++)

        {

            cin>>x;

            if(i>=l && i<=n)b.push_back(x);

            if(i<=r && i>=1)c.push_back(x);

        }

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

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



        ll sum1=0,sum2=0;

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

        {

            sum1+=b[i];

            sum2+=c[i];

        }

        cout<<min(sum1,sum2)<<endl;

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {
        

        bool b = true;
        int n,k=0;
        cin >> n;
        vector<string> a(n);

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

        while (k<n-1)
        {
            if (a[k]<a[k+1])
            {
                k++;
            }
            else{
                b=false;
                break;
            }

            k++;
            
        }
        if (b)
        {
            cout<<"YES"<<endl;
        }
        else
        cout<<"NO"<<endl;
        
    }
}


Submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {
        

        bool b = true;
        int n,k=0;
        cin >> n;
        vector<int> a(n);

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

        while (k<n-1)
        {
            if (a[k]<a[k+1])
            {
                k++;
            }
            else{
                if(k>1 && (a[k]-a[k+1] != a[k-1]-a[k-2])){
                b=false;
                break;
                }
            }

            k++;
            
        }
        if (b)
        {
            cout<<"YES"<<endl;
        }
        else
        cout<<"NO"<<endl;
        
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {
        

        bool b = true;
        int n,k=0;
        cin >> n;
        vector<string> a(n);

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

        while (k<n-1)
        {
            if (a[k]<a[k+1])
            {
                k++;
            }
            else{
                b=false;
                break;
            }

            k++;
            
        }
        if (b)
        {
            cout<<"YES"<<endl;
        }
        else
        cout<<"NO"<<endl;
        
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {
        

        bool b = true;
        int n,k=0;
        cin >> n;
        vector<int> a(n);

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

        while (k<n-1)
        {
            if (a[k]<a[k+1])
            {
                k++;
            }
            else{
                if((n==2) || (k>1 && (a[k]-a[k+1] != a[k-1]-a[k-2]))){
                b=false;
                break;
                }
            }

            k++;
            
        }
        if (b)
        {
            cout<<"YES"<<endl;
        }
        else
        cout<<"NO"<<endl;
        
    }
}


Submission (verdict: Accepted):

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {

        bool b = true;
        int n, k = 0;
        cin >> n;
        vector<int> a(n);

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

        while (k < n - 1 && k >= 0)
        {
            if (a[k] <= a[k + 1])
            {
                k++;
            }
            else
            {
                b = false;
                break;
            }
        }
        if (b)
        {
            cout << "YES" << endl;
            continue;
        }
        else
        {

            for (int i = 0; i < n - 1; i++)
            {
                int mi = min(a[i], a[i + 1]);
                a[i] = a[i] - mi;
                a[i + 1] = a[i + 1] - mi;
            }

            b = true;
            while (k < n - 1 && k >= 0)
            {
                if (a[k] <= a[k + 1])
                {
                    k++;
                }
                else
                {
                    b = false;
                    break;
                }
            }

            if (b)
            {
                cout << "YES" << endl;
            }
            else
                cout << "NO" << endl;
        }
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {
        

        bool b = true;
        int n,k=0;
        cin >> n;
        vector<int> a(n);

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

        while (k<n-1)
        {
            if (a[k]<a[k+1])
            {
                k++;
            }
            else{
                if(k>1 && (a[k]-a[k+1] != a[k-1]-a[k-2])){
                b=false;
                break;
                }
            }

            k++;
            
        }
        if (b)
        {
            cout<<"YES"<<endl;
        }
        else
        cout<<"NO"<<endl;
        
    }
}


Submission (verdict: Wrong answer on test 2):

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main()

{
    int t;
    cin >> t;
    while (t--)
    {
        

        bool b = true;
        int n,k=0;
        cin >> n;
        vector<int> a(n);

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

        while (k<n-1)
        {
            if (a[k]<a[k+1])
            {
                k++;
            }
            else{
                if((n==2) || (k>1 && (a[k]-a[k+1] != a[k-1]-a[k-2]))){
                b=false;
                break;
                }
            }

            k++;
            
        }
        if (b)
        {
            cout<<"YES"<<endl;
        }
        else
        cout<<"NO"<<endl;
        
    }
}
Problem: 2049B - pspspsps
Language: C++23 (GCC 14-64, msys2)

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



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int r = INF;

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

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

            r = i;

            break;

        }

    }

    bool ok = true;

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

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

            if (n > r) {

                ok = false;

                break;

            }

        }

    }

    if (ok) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

}





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



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int r = INF;

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

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

            r = i;

            break;

        }

    }

    bool ok = true;

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

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

            if (n > r) {

                ok = false;

                break;

            }

        }

    }

    if (ok) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

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

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



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int r = INF;

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

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

            r = i;

        }

    }

    bool ok = true;

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

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

            if (n > r) {

                ok = false;

                break;

            }

        }

    }

    if (ok) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

}





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



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int r = INF;

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

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

            r = i;

            break;

        }

    }

    bool ok = true;

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

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

            if (n > r) {

                ok = false;

                break;

            }

        }

    }

    if (ok) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

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

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



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int mnp = INF, mxs = 0;

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

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

            mnp = min(mnp, i);

        } else {

            mxs = max(mxs, i);

        }

    }

    if (mnp < mxs) {

        cout << "NO\n";

    } else {

        cout << "YES\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

}





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



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int r = INF;

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

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

            r = i;

        }

    }

    bool ok = true;

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

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

            if (n > r) {

                ok = false;

                break;

            }

        }

    }

    if (ok) {

        cout << "YES\n";

    } else {

        cout << "NO\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

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


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



#define endl "\n"



// #define int long long



using namespace std;



using i64 = long long;

using u64 = unsigned long long;



constexpr int N = 2e5 + 1;

constexpr int P = 131;

constexpr int INF = 1e9;



void solve() {

    int n;

    cin >> n;

    string s;

    cin >> s;

    s = " " + s;

    int mnp = INF, mxs = 0;

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

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

            mnp = min(mnp, i);

        } else {

            mxs = max(mxs, i);

        }

    }

    if (mnp < mxs) {

        cout << "NO\n";

    } else {

        cout << "YES\n";

    }

}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    cout.tie(nullptr);

    int T;

    cin >> T;

    while (T--) {

        solve();

    }

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

Previous submission (verdict: Time limit exceeded on test 6):
#include<iostream>

using namespace std;

 int  main()

 {

     int  test;

     cin>>test;

     

     while(test--)

     {

         string arr;

         cin>>arr;

         

      for(int i=0;i<arr.size()-1;i++)

     {

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

         {

             if((arr[j]-j+i)>arr[i])

             {

                 int a=arr[j]-j+i;

                 

                 for(int k=j;k>=i+1;k--)

                 {

                     arr[k]=arr[k-1];

                 }

                 arr[i]=a;

             }

         }

     }

     

     

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

     {

         cout<<arr[i];

     }

     cout<<endl;

        

        

        

     }

 }

Submission (verdict: Wrong answer on test 2):
#include<iostream>

using namespace std;

 int  main()

 {

     int  test;

     cin>>test;

     

     while(test--)

     {

         string arr;

         cin>>arr;

         

      for(int i=0;i<arr.size()-1;i++)

     {

         int max=arr[i];

         int index=i;

         for(int j=i+1;j<i+10;j++)

         {

             

             

             if((arr[j]-j+i)>max)

             {

                 max=arr[j]-j+i;

                 index=j;

                 

                 

                 

                 

             }

         }

         if(index>i)

         {

             int a=index;

             while(a>i)

             {

                 arr[a]=arr[a-1];

                 a--;

             }

             arr[i]=max;

         }

     }

     

     

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

     {

         cout<<arr[i];

     }

     cout<<endl;

        

        

        

     }

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


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

using namespace std;

 int  main()

 {

     int  test;

     cin>>test;

     

     while(test--)

     {

         string arr;

         cin>>arr;

         

      for(int i=0;i<arr.size()-1;i++)

     {

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

         {

             if((arr[j]-j+i)>arr[i])

             {

                 int a=arr[j]-j+i;

                 

                 for(int k=j;k>=i+1;k--)

                 {

                     arr[k]=arr[k-1];

                 }

                 arr[i]=a;

             }

         }

     }

     

     

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

     {

         cout<<arr[i];

     }

     cout<<endl;

        

        

        

     }

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

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>

using namespace std;

 int  main()

 {

     int  test;

     cin>>test;

     

     while(test--)

     {

         string arr;

         cin>>arr;

         

      for(int i=0;i<arr.size()-1;i++)

     {

         int max=arr[i];

         int index=i;

         for(int j=i+1;j<i+10;j++)

         {

             

             

             if((arr[j]-j+i)>max)

             {

                 max=arr[j]-j+i;

                 index=j;

                 

                 

                 

                 

             }

         }

         if(index>i)

         {

             int a=index;

             while(a>i)

             {

                 arr[a]=arr[a-1];

                 a--;

             }

             arr[i]=max;

         }

     }

     

     

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

     {

         cout<<arr[i];

     }

     cout<<endl;

        

        

        

     }

 }

Submission (verdict: Accepted):
#include<iostream>

using namespace std;

 int  main()

 {

     int  test;

     cin>>test;

     

     while(test--)

     {

         string arr;

         cin>>arr;

         int n=arr.size();

         

      for(int i=0;i<arr.size()-1;i++)

     {

         int max=arr[i];

         int index=i;

         for(int j=i+1;j< min(i+10,n);j++)

         {

             

             

             if((arr[j]-j+i)>max)

             {

                 max=arr[j]-j+i;

                 index=j;

                 

                 

                 

                 

             }

         }

         if(index>i)

         {

             int a=index;

             while(a>i)

             {

                 arr[a]=arr[a-1];

                 a--;

             }

             arr[i]=max;

         }

     }

     

     

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

     {

         cout<<arr[i];

     }

     cout<<endl;

        

        

        

     }

 }
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

using namespace std;

int v[NMAX];

int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        int n, maxx = INT_MIN;
        cin >> n;
        int s = 0;
        for (int i = 1; i <= n; i++) {
            cin >> v[i];
            s += v[i];
        }
        maxx = max(maxx, s);
        int p = n;
        while(p > 1) {
            int s1 = 0, s2 = 0;
            for (int i = 1; i < p; i++) {
                v[i] = v[i + 1] - v[i];
                s1 += v[i];
                s2 += -(v[i]);
            }
            p--;
            maxx = max(maxx, max(s1, s2));
        }
        if (n > 1)
            cout << maxx << '\n';
        else cout << v[1] << '\n';
    }
    return 0;
}


Submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
#define NMAX 55
#define pb push_back
#define int long long
using namespace std;

int v[NMAX];

signed main() {
    ifstream cin("in");
    ofstream cout("out");
    int tt;
    cin >> tt;
    while (tt--) {
        int n, maxx = INT_MIN;
        cin >> n;
        int s = 0;
        for (int i = 1; i <= n; i++) {
            cin >> v[i];
            s += v[i];
        }
        maxx = max(maxx, s);
        int p = n;
        while(p > 1) {
            int s1 = 0, s2 = 0;
            for (int i = 1; i < p; i++) {
                v[i] = v[i + 1] - v[i];
                s1 += v[i];
                s2 += -(v[i]);
            }
            p--;
            maxx = max(maxx, max(s1, s2));
        }
        if (n > 1)
            cout << maxx << '\n';
        else cout << v[1] << '\n';
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
#define NMAX 55
#define pb push_back
#define int long long
using namespace std;

int v[NMAX];

signed main() {
    ifstream cin("in");
    ofstream cout("out");
    int tt;
    cin >> tt;
    while (tt--) {
        int n, maxx = INT_MIN;
        cin >> n;
        int s = 0;
        for (int i = 1; i <= n; i++) {
            cin >> v[i];
            s += v[i];
        }
        maxx = max(maxx, s);
        int p = n;
        while(p > 1) {
            int s1 = 0, s2 = 0;
            for (int i = 1; i < p; i++) {
                v[i] = v[i + 1] - v[i];
                s1 += v[i];
                s2 += -(v[i]);
            }
            p--;
            maxx = max(maxx, max(s1, s2));
        }
        if (n > 1)
            cout << maxx << '\n';
        else cout << v[1] << '\n';
    }
    return 0;
}


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

using namespace std;

int v[NMAX];

int main() {
    int tt;
    cin >> tt;
    while (tt--) {
        int n;
        long long maxx = LONG_LONG_MIN;
        cin >> n;
        long long s = 0;
        for (int i = 1; i <= n; i++) {
            cin >> v[i];
            s += v[i];
        }
        maxx = max(maxx, s);
        int p = n;
        while(p > 1) {
            long long s1 = 0, s2 = 0;
            for (int i = 1; i < p; i++) {
                v[i] = v[i + 1] - v[i];
                s1 += v[i];
                s2 += -(v[i]);
            }
            p--;
            maxx = max(maxx, max(s1, s2));
        }
        if (n > 1)
            cout << maxx << '\n';
        else cout << v[1] << '\n';
    }
    return 0;
}