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

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

#define ll long long

using namespace std;



int main(){

    int t;

    cin>>t;



    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int> arr(n);

        for(int i=0; i<n; i++) cin>>arr[i];

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



        ll total=0;

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

            total += arr[i];

        }



        cout<<total<<endl;

    }

}



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

#define ll long long

using namespace std;



int main(){

    int t;

    cin>>t;



    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int> arrleft(n);

        vector<int> arrright(n);

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

            int x;

            cin>>x;

            arrleft[i] =x; arrright[i]=x;

        }



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

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



        ll total1=0, total2=0;

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

            total1 += arrleft[i];

            total2 += arrright[i];

        }



        cout<<min(total1, total2)<<endl;

    }

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


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

#define ll long long

using namespace std;



int main(){

    int t;

    cin>>t;



    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        vector<int> arr(n);

        for(int i=0; i<n; i++) cin>>arr[i];

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



        ll total=0;

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

            total += arr[i];

        }



        cout<<total<<endl;

    }

}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

    string t;

    if(s.size()<2){

        cout<<"YES\n";

        return;

    }

    if(s.substr(0,2)=="ps" || s.substr(n-2,2)=="ps"){

        cout<<"NO\n";

        return;

    }

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

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

            continue;

        }

        t.push_back(s[i]);

        if(t.size()>1 && (t.substr(t.size()-2,2)=="ps"||t.substr(t.size()-2,2)=="sp")){

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

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



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

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

        s[0]='.';

    }

    if(s[n-1]=='p'){

        s[n-1]='.';

    }

    int cd1=0,cd2=0;

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

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

            cd1=1;

        }

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

            cd2=1;

        }

    }

    if(cd1 && cd2){

        cout<<"NO\n";

        return;

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

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

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

            continue;

        }

        if(s.substr(i,2)=="ps"){

            cout<<"NO\n";

            return;

        }

        if(s.substr(i,2)=="sp" && i+2>=3 &&n-i>=3 ){

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

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



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

    string t;

    if(s.size()<2){

        cout<<"YES\n";

        return;

    }

    if(s.substr(0,2)=="ps" || s.substr(n-2,2)=="ps"){

        cout<<"NO\n";

        return;

    }

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

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

            continue;

        }

        t.push_back(s[i]);

        if(t.size()>1 && (t.substr(t.size()-2,2)=="ps"||t.substr(t.size()-2,2)=="sp")){

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)

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



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

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

        if(s.substr(i,2)=="ps"){

            cout<<"NO\n";

            return;

        }

        if(i>0 && i<n-2 && s.substr(i,2)=="sp"){

             cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

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



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

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

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

            continue;

        }

        if(s.substr(i,2)=="ps"){

            cout<<"NO\n";

            return;

        }

        if(s.substr(i,2)=="sp" && i+2>=3 &&n-i>=3 ){

            cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}
Problem: 2049B - pspspsps
Language: C++20 (GCC 13-64)


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



using namespace std;



void solve(){

    int n;

    cin>>n;

    string s;

    cin>>s;

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

        if(s.substr(i,2)=="ps"){

            cout<<"NO\n";

            return;

        }

        if(i>0 && i<n-2 && s.substr(i,2)=="sp"){

             cout<<"NO\n";

            return;

        }

    }

    cout<<"YES\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

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

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



using namespace std;



void solve(){

    string s;

    cin>>s;

    int cnt2=0,cnt3=0;

    int sum=0;

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

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

        if (s[i]-'0'==2) {

            cnt2++;

        }

        if (s[i]-'0'==3) {

            cnt3++;

        }

    }

    sum%=9;

    if (sum==0) {

        cout<<"YES\n";

        return;

    }

    vector<int> res;

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

        for (int j=0; j<=cnt3; j++) {

            res.push_back(i*2+j*6);

        }

    }

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

        if ((sum+res[i])%9==0) {

            cout<<"YES\n";

            return;

        }

    }

    cout<<"NO\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

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



using namespace std;



void solve(){

    string s;

    cin>>s;

    int cnt2=0,cnt3=0;

    int sum=0;

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

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

        if (s[i]-'0'==2) {

            cnt2++;

        }

        if (s[i]-'0'==3) {

            cnt3++;

        }

    }

    sum%=9;

    if (sum==0) {

        cout<<"YES\n";

        return;

    }

    set<int> res;

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

        for (int j=0; j<=cnt3; j++) {

            res.insert(i*2+j*6);

        }

    }

    for (auto it=res.begin(); it!=res.end(); it++) {

        if ((sum+*it)%9==0) {

            cout<<"YES\n";

            return;

        }

    }

    cout<<"NO\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

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


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



using namespace std;



void solve(){

    string s;

    cin>>s;

    int cnt2=0,cnt3=0;

    int sum=0;

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

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

        if (s[i]-'0'==2) {

            cnt2++;

        }

        if (s[i]-'0'==3) {

            cnt3++;

        }

    }

    sum%=9;

    if (sum==0) {

        cout<<"YES\n";

        return;

    }

    vector<int> res;

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

        for (int j=0; j<=cnt3; j++) {

            res.push_back(i*2+j*6);

        }

    }

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

        if ((sum+res[i])%9==0) {

            cout<<"YES\n";

            return;

        }

    }

    cout<<"NO\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

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

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



using namespace std;



void solve(){

    string s;

    cin>>s;

    int cnt2=0,cnt3=0;

    int sum=0;

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

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

        if (s[i]-'0'==2) {

            cnt2++;

        }

        if (s[i]-'0'==3) {

            cnt3++;

        }

    }

    sum%=9;

    if (sum==0) {

        cout<<"YES\n";

        return;

    }

    set<int> res;

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

        for (int j=0; j<=cnt3; j++) {

            res.insert(i*2+j*6);

        }

    }

    for (auto it=res.begin(); it!=res.end(); it++) {

        if ((sum+*it)%9==0) {

            cout<<"YES\n";

            return;

        }

    }

    cout<<"NO\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}

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



using namespace std;



void solve(){

    string s;

    cin>>s;

    int cnt2=0,cnt3=0;

    int sum=0;

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

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

        if (s[i]-'0'==2) {

            cnt2++;

        }

        if (s[i]-'0'==3) {

            cnt3++;

        }

    }

    sum%=9;

    if (sum==0) {

        cout<<"YES\n";

        return;

    }

    set<int> res;

    for (int i=0; i<=min(cnt2,9); i++) {

        for (int j=0; j<=min(cnt3,9); j++) {

            res.insert(i*2+j*6);

        }

    }

    for (auto it=res.begin(); it!=res.end(); it++) {

        if ((sum+*it)%9==0) {

            cout<<"YES\n";

            return;

        }

    }

    cout<<"NO\n";

}

 

int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    };

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define aint(a) a.begin(), a.end()
#define int long long
const int MOD = 1000000007;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}


void myprog(){
        string s;
        cin >> s;

        int n = s.size();
        for(int i = 1; i < n; i++){
                for(int j = i; j >= 1; j--){
                        if(s[j] > s[j - 1] + 1){
                                swap(s[j], s[j - 1]);
                                s[j - 1]--;
                                //cout << s << " ";
                        }
                }
        }

        cout << s << endl;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define aint(a) a.begin(), a.end()
#define int long long
const int MOD = 1000000007;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}


void myprog(){
        string s;
        cin >> s;

        int n = s.size();
        for(int i = 1; i < n; i++){
                for(int j = i; j >= 1 and s[j] > '0'; j--){
                        if(s[j] > s[j - 1] + 1){
                                swap(s[j], s[j - 1]);
                                s[j - 1]--;
                                //cout << s << " ";
                        }
                }
        }

        cout << s << endl;
}

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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define aint(a) a.begin(), a.end()
#define int long long
const int MOD = 1000000007;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}


void myprog(){
        string s;
        cin >> s;

        int n = s.size();
        for(int i = 1; i < n; i++){
                for(int j = i; j >= 1; j--){
                        if(s[j] > s[j - 1] + 1){
                                swap(s[j], s[j - 1]);
                                s[j - 1]--;
                                //cout << s << " ";
                        }
                        else{
                                break;
                        }
                }
        }

        cout << s << endl;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define aint(a) a.begin(), a.end()
#define int long long
const int MOD = 1000000007;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}


void myprog(){
        string s;
        cin >> s;

        int n = s.size();
        for(int i = 1; i < n; i++){
                for(int j = i; j >= 1; j--){
                        if(s[j] > s[j - 1] + 1){
                                swap(s[j], s[j - 1]);
                                s[j - 1]--;
                                //cout << s << " ";
                        }
                }
        }

        cout << s << endl;
}

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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define aint(a) a.begin(), a.end()
#define int long long
const int MOD = 1000000007;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}


void myprog(){
        string s;
        cin >> s;

        int n = s.size();
        for(int i = 1; i < n; i++){
                for(int j = i; j >= 1 and s[j] > '0'; j--){
                        if(s[j] > s[j - 1] + 1){
                                swap(s[j], s[j - 1]);
                                s[j - 1]--;
                                //cout << s << " ";
                        }
                }
        }

        cout << s << endl;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define int long long
const int MOD = 998244353;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        //cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}



void myprog() {
        int n;
        cin >> n;

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

        map<int, int> mp;
        

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

        vector<pair<int, int>> ans;

        reverse(all(a));
        for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                        ans.push_back({j, i});
                }
        }

        for(int i = 0; i < n; i++){
                for(int j = 0; j < n - 1; j++){
                        if(mp[a[i]] > mp[a[i + 1]]){
                                ans.push_back({a[i + 1], a[i]});
                                swap(a[i], a[i + 1]);
                        }
                }
        }

        cout << ans.size() << endl;
        
        for(auto &[u, v] : ans){
                cout << u + 1 << " " << v + 1 << endl;
        }
}



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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define int long long
const int MOD = 998244353;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        //cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}



void myprog() {
        int n;
        cin >> n;

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

        map<int, int> mp;
        

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

        vector<pair<int, int>> ans;

        reverse(all(a));
        for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                        ans.push_back({j, i});
                }
        }

        for(int i = 0; i < n; i++){
                for(int j = 0; j < n - 1; j++){
                        if(mp[a[j]] > mp[a[j + 1]]){
                                ans.push_back({a[j + 1], a[i]});
                                swap(a[j], a[j + 1]);
                        }
                }
        }

        cout << ans.size() << endl;

        for(auto &[u, v] : ans){
                cout << u + 1 << " " << v + 1 << endl;
        }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define int long long
const int MOD = 998244353;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        //cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}



void myprog() {
        int n;
        cin >> n;

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

        map<int, int> mp;
        

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

        vector<pair<int, int>> ans;

        reverse(all(a));
        for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                        ans.push_back({j, i});
                }
        }

        for(int i = 0; i < n; i++){
                for(int j = 0; j < n - 1; j++){
                        if(mp[a[j]] > mp[a[j + 1]]){
                                ans.push_back({a[j + 1], a[i]});
                                swap(a[j], a[j + 1]);
                        }
                }
        }

        cout << ans.size() << endl;

        for(auto &[u, v] : ans){
                cout << u + 1 << " " << v + 1 << endl;
        }
}



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

using namespace std;

#define cin(v) for (auto& i : v) cin >> i;
#define cout(v) for (auto& i : v) cout << i << " "; cout << endl;
#define endl "\n"
#define all(a) a.begin(), a.end()
#define int long long
const int MOD = 998244353;

void myprog();

int32_t main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int t = 1;
        //cin >> t;
        while (t-- > 0)
                myprog();
        return 0;
}



void myprog() {
        int n;
        cin >> n;

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

        map<int, int> mp;
        

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

        vector<pair<int, int>> ans;

        reverse(all(a));
        for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                        ans.push_back({j, i});
                }
        }

        for(int i = 0; i < n; i++){
                for(int j = 0; j < n - 1; j++){
                        if(mp[a[j]] > mp[a[j + 1]]){
                                ans.push_back({a[j + 1], a[j]});
                                swap(a[j], a[j + 1]);
                        }
                }
        }

        cout << ans.size() << endl;

        for(auto &[u, v] : ans){
                cout << u + 1 << " " << v + 1 << endl;
        }
}