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>
using namespace std;


string a,b,c;

int dp[5010][1010];

int rec(int level , int i){
    
    int j = level - i;
    
    
    if(level == c.size()){
        return 0;
    }
    
    
    
    
    
    if(i==a.size() && j==b.size()) return 1e9;
    
    if(dp[level][i] != -1)return dp[level][i];
    
    int ans = 1e9;
    
    
    if(a[i] == c[level]){
        ans = min(ans , rec(level+1 , i+1 ));
    }else if(b[j] == c[level]){
        ans = min(ans , rec(level+1 , i));
    }else{
        ans = min(ans ,1 +  min(rec(level+1 , i) , rec(level+1 , i+1 )));
    }
    
    
    
    if (i < a.size()) {
        ans = min(ans, 1 + rec(level + 1, i + 1));  
    }

    if (j < b.size()) {
        ans = min(ans, 1 + rec(level + 1, i)); 
    }
    
    return dp[level][i] =  ans;
}


void solve(){
    cin>>a>>b>>c;
    memset(dp,-1,sizeof(dp));
    cout<<rec(0,0)<<endl;
}



int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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


string a,b,c;

int dp[5010][1010];

int rec(int level , int i){
    
    int j = level - i;
    
    if (j < 0 || j > b.size()) return 1e9;
    
    
    if(level == c.size()){
        return 0;
    }

    
    if(dp[level][i] != -1)return dp[level][i];
    
    int ans = 1e9;
    
    
    if(a[i] == c[level]){
        ans = min(ans , rec(level+1 , i+1 ));
    }else if(b[j] == c[level]){
        ans = min(ans , rec(level+1 , i));
    }else{
        ans = min(ans ,1 +  min(rec(level+1 , i) , rec(level+1 , i+1 )));
    }
    
    
    
    if (i < a.size()) {
        ans = min(ans, 1 + rec(level + 1, i + 1));  
    }

    if (j < b.size()) {
        ans = min(ans, 1 + rec(level + 1, i)); 
    }
    
    return dp[level][i] =  ans;
}


void solve(){
    cin>>a>>b>>c;
    memset(dp,-1,sizeof(dp));
    cout<<rec(0,0)<<endl;
}



int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


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


string a,b,c;

int dp[5010][1010];

int rec(int level , int i){
    
    int j = level - i;
    
    
    if(level == c.size()){
        return 0;
    }
    
    
    
    
    
    if(i==a.size() && j==b.size()) return 1e9;
    
    if(dp[level][i] != -1)return dp[level][i];
    
    int ans = 1e9;
    
    
    if(a[i] == c[level]){
        ans = min(ans , rec(level+1 , i+1 ));
    }else if(b[j] == c[level]){
        ans = min(ans , rec(level+1 , i));
    }else{
        ans = min(ans ,1 +  min(rec(level+1 , i) , rec(level+1 , i+1 )));
    }
    
    
    
    if (i < a.size()) {
        ans = min(ans, 1 + rec(level + 1, i + 1));  
    }

    if (j < b.size()) {
        ans = min(ans, 1 + rec(level + 1, i)); 
    }
    
    return dp[level][i] =  ans;
}


void solve(){
    cin>>a>>b>>c;
    memset(dp,-1,sizeof(dp));
    cout<<rec(0,0)<<endl;
}



int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j+1], b[j]});
            }
        }
    }
    reverse(v.begin(), v.end());
    ll cnt = v.size();
    for(ll i = 0; i<n-1; i++){
        if(a[i]<a[i-1]) {
            cnt+=2;
            v.push_back({a[i+1], a[i]});
            v.push_back({a[i], a[i+1]});
            
        }
    }
    cout<<cnt<<"\n";
    for(auto&i:v) cout<<i.first<<" "<<i.second<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) solve();

    return 0;
}

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j+1], b[j]});
            }
        }
    }
    reverse(v.begin(), v.end());
    ll cnt = v.size();
    // for(ll i = 0; i<n-1; i++){
    //     if(a[i]<a[i-1]) {
    //         cnt+=2;
    //         v.push_back({a[i+1], a[i]});
    //         v.push_back({a[i], a[i+1]});
            
    //     }
    // }
    for(ll i = 0; i<n-1; i++) {
        ll j = i;
        while(j<n-1 && a[j]<a[j+1]) {
            j++;
        }
        for(ll k = j; k>i; k--) {
            for(ll t = k-1;t>=i; t--) {
                v.push_back({a[k], a[t]});
            }
            for(ll t = i; t<k; t++) {
                v.push_back({a[t], a[k]});
            }
        }
        i = j;
    }
    cout<<v.size()<<"\n";
    for(auto&i:v) cout<<i.first<<" "<<i.second<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--) solve();

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j+1], b[j]});
            }
        }
    }
    reverse(v.begin(), v.end());
    ll cnt = v.size();
    for(ll i = 0; i<n-1; i++){
        if(a[i]<a[i-1]) {
            cnt+=2;
            v.push_back({a[i+1], a[i]});
            v.push_back({a[i], a[i+1]});
            
        }
    }
    cout<<cnt<<"\n";
    for(auto&i:v) cout<<i.first<<" "<<i.second<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) solve();

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j+1], b[j]});
            }
        }
    }
    reverse(v.begin(), v.end());
    ll cnt = v.size();
    // for(ll i = 0; i<n-1; i++){
    //     if(a[i]<a[i-1]) {
    //         cnt+=2;
    //         v.push_back({a[i+1], a[i]});
    //         v.push_back({a[i], a[i+1]});
            
    //     }
    // }
    for(ll i = 0; i<n-1; i++) {
        ll j = i;
        while(j<n-1 && a[j]<a[j+1]) {
            j++;
        }
        for(ll k = j; k>i; k--) {
            for(ll t = k-1;t>=i; t--) {
                v.push_back({a[k], a[t]});
            }
            for(ll t = i; t<k; t++) {
                v.push_back({a[t], a[k]});
            }
        }
        i = j;
    }
    cout<<v.size()<<"\n";
    for(auto&i:v) cout<<i.first<<" "<<i.second<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--) solve();

    return 0;
}

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j+1], b[j]});
            }
        }
    }
    reverse(v.begin(), v.end());
    ll cnt = v.size();
    // for(ll i = 0; i<n-1; i++){
    //     if(a[i]<a[i-1]) {
    //         cnt+=2;
    //         v.push_back({a[i+1], a[i]});
    //         v.push_back({a[i], a[i+1]});
            
    //     }
    // }
    for(ll i = 0; i<n-1; i++) {
        ll j = i;
        while(j<n-1 && a[j]<a[j+1]) {
            j++;
        }
        for(ll k = j; k>i; k--) {
            for(ll t = k-1;t>=i; t--) {
                v.push_back({a[k], a[t]});
            }
            for(ll t = i; t<k; t++) {
                v.push_back({a[t], a[k]});
            }
        }
        i = j;
    }
    cout<<v.size()<<"\n";
    for(auto&i:v) cout<<i.first<<" "<<i.second<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) solve();

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]<b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j], b[j+1]});
            }
        }
    }
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j], b[j+1]});
            }
        }
    }
    reverse(v.begin(), v.end());

    cout<<v.size()<<"\n";
    for(auto&i:v) cout<<i.first<<" "<<i.second<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) solve();

    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]<b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j], b[j+1]});
            }
        }
    }
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j], b[j+1]});
            }
        }
    }
    reverse(v.begin(), v.end());

    cout<<v.size()<<"\n";
    for(auto&i:v) cout<<i.second<<" "<<i.first<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) solve();

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j+1], b[j]});
            }
        }
    }
    reverse(v.begin(), v.end());
    ll cnt = v.size();
    // for(ll i = 0; i<n-1; i++){
    //     if(a[i]<a[i-1]) {
    //         cnt+=2;
    //         v.push_back({a[i+1], a[i]});
    //         v.push_back({a[i], a[i+1]});
            
    //     }
    // }
    for(ll i = 0; i<n-1; i++) {
        ll j = i;
        while(j<n-1 && a[j]<a[j+1]) {
            j++;
        }
        for(ll k = j; k>i; k--) {
            for(ll t = k-1;t>=i; t--) {
                v.push_back({a[k], a[t]});
            }
            for(ll t = i; t<k; t++) {
                v.push_back({a[t], a[k]});
            }
        }
        i = j;
    }
    cout<<v.size()<<"\n";
    for(auto&i:v) cout<<i.first<<" "<<i.second<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) solve();

    return 0;
}

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n;
    cin>>n;
    vector<ll>a(n), b;
    for(auto&i:a) cin>>i;
    b = a;
    vector<pair<ll, ll>>v;
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]<b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j], b[j+1]});
            }
        }
    }
    for(ll i = 0; i<n; i++) {
        for(ll j = 0; j<n-1; j++) {
            if(b[j]>b[j+1]){
                swap(b[j], b[j+1]);
                v.push_back({b[j], b[j+1]});
            }
        }
    }
    reverse(v.begin(), v.end());

    cout<<v.size()<<"\n";
    for(auto&i:v) cout<<i.first<<" "<<i.second<<"\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) solve();

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll l, r;
    cin>>l>>r;
    ll a = 0, b = 0, c = 0;
    ll x = __builtin_clz(r), y = __builtin_clz(l);
    bool ueq = 0;
    for(ll i = 31; i>=0; i--) {
        ll u = l&(1<<i);
        ll v = r&(1<<i);
        // cout<<u<<" "<<v<<"\n";
        if(u!=v) {
            ueq = 1;
        }
        if(ueq) {
            b+=(v^(1<<i));
            c+=(v^(1<<i));
        }
        else {
            b+=v;
            c+=v;
        }
        a+=v;
    }
    c+=1;
    if(c==a) {
        c-=2;
    }
    cout<<a<<" "<<b<<" "<<c<<"\n";

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--) solve();

    return 0;
}

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll l, r;
    cin>>l>>r;
    ll a = 0, b = 0, c = 0;
    bool ueq = 0;
    for(ll i = 31; i>=0; i--) {
        ll u = l&(1<<i);
        ll v = r&(1<<i);
        // cout<<u<<" "<<v<<"\n";
        if(u!=v) {
            ueq = 1;
        }
        if(ueq) {
            b+=(v^(1<<i));
            c+=(v^(1<<i));
        }
        else {
            b+=v;
            c+=v;
        }
        a+=v;
    }
    c+=1;
    if(c==a) {
        c-=2;
    }
    if(b<l) {
        b = l;
        c = b+1;
    }
    cout<<a<<" "<<b<<" "<<c<<"\n";

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--) solve();

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll l, r;
    cin>>l>>r;
    ll a = 0, b = 0, c = 0;
    ll x = __builtin_clz(r), y = __builtin_clz(l);
    bool ueq = 0;
    for(ll i = 31; i>=0; i--) {
        ll u = l&(1<<i);
        ll v = r&(1<<i);
        // cout<<u<<" "<<v<<"\n";
        if(u!=v) {
            ueq = 1;
        }
        if(ueq) {
            b+=(v^(1<<i));
            c+=(v^(1<<i));
        }
        else {
            b+=v;
            c+=v;
        }
        a+=v;
    }
    c+=1;
    if(c==a) {
        c-=2;
    }
    cout<<a<<" "<<b<<" "<<c<<"\n";

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--) solve();

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll l, r;
    cin>>l>>r;
    ll a = 0, b = 0, c = 0;
    bool ueq = 0;
    for(ll i = 31; i>=0; i--) {
        ll u = l&(1<<i);
        ll v = r&(1<<i);
        // cout<<u<<" "<<v<<"\n";
        if(u!=v) {
            ueq = 1;
        }
        if(ueq) {
            b+=(v^(1<<i));
            c+=(v^(1<<i));
        }
        else {
            b+=v;
            c+=v;
        }
        a+=v;
    }
    c+=1;
    if(c==a) {
        c-=2;
    }
    if(b<l) {
        b = l;
        c = b+1;
    }
    cout<<a<<" "<<b<<" "<<c<<"\n";

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--) solve();

    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll l, r;
    cin>>l>>r;
    ll a = 0, b = 0, c = 0;
    for(ll i = 31; i>=0; i--) {
        ll u = r&(1<<i);
        ll v = l&(1<<i);
        if(u==v) {
            a+=u;
        }
        else {
            a+=u;
            break;
        }
    }
    b=a-1;
    c=r;
    if(c==a) c = l;
    cout<<a<<" "<<b<<" "<<c<<"\n";

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;

    while (t--) solve();

    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


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

using ll = long long;
const ll mod = 1e9 + 7;
const ll modd = 998244353;


void solve() {
    ll n, m;
    cin>>n>>m;
    map<ll, ll>m1, m2;
    for(ll i = 0; i<n; i++) {
        ll x;
        cin>>x;
        m1[x]++;
    }
    for(ll i = 0; i<m; i++) {
        ll x;
        cin>>x;
        m2[x]++;
    }

    set<ll>s1, s2;
    for(auto&i:m1) {
        if(m2.find(i.first)!=m2.end()){
            ll k = m2[i.first];
            if(k>i.second) {
                m2[i.first]-=i.second;
                s1.insert(i.first);
            }
            else {
                i.second-=k;
                s2.insert(i.first);
                if(i.second == 0) s1.insert(i.first);
            }
        }
    }
    for(auto&i:s1) {
        m1.erase(i);
    }
    for(auto&i:s2) {
        m2.erase(i);
    }
    vector<ll>a, b;
    for(auto&i:m1) {
        ll k = i.second;
       //  cout<<i.first<<" "<<k<<"\n";
        while(k--) {
            a.push_back(i.first);
           //  cout<<i.first<<" ";
        }
    }
  //  cout<<"\n";

    for(auto&i:m2) {
        ll k = i.second;
       // cout<<i.first<<" "<<k<<"\n";
        while(k--) {
            b.push_back(i.first);
           // <F5> cout<<i.first<<" ";
        }
    }
   //  cout<<"\n";
    n = a.size(), m = b.size();
    if(n<m) {
        cout<<"NO\n";
        return;
    }

    ll i = 0, j = 0;

    while(i<n && j<m) {
        if(a[i]==b[j]) {
            i++;
            j++;
        }
        else if(b[j]<a[i]) {
            cout<<"NO\n";
            return;
        }
        else {
            ll prev = -1, s = 0;
            while(i<n && (prev == -1 ||abs(a[i]-prev<=1)) ){
                s+=a[i];
                prev = s;
                i++;
                if(b[j]==s) {
                    j++;
                    break;
                }
                else if(s>b[j]) {
                    cout<<"NO\n";
                    return;
                }
            }
  
        }
    }
    if(i<n ||  j<m) {
        cout<<"NO\n";
        return;
    }
    cout<<"YES\n";


}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    cin >> t;
    
    while (t--) solve();

    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


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

#define int long long
#define INF LLONG_MAX
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define all(v) v.begin(),v.end()

void solve() {
    int n;
    cin>>n;
    vi a(n);
    map<int,int>pos;
    for(int i=0;i<n;i++){
        cin>>a[i];
        pos[a[i]]=i;
    }
    if(n==1){
        cout<<0<<endl;
        return;
    }
    map<pair<int,int>,int>flag;
    int cnt=0;
    int n1=n*n;
    vi temp(n);
    // for(auto i : pos){
    //     cout<<i.first<<" "<<i.second<<endl;
    // }
    for(int i=0;i<n;i++)temp[i]=i+1;
    // for(auto i : temp)cout<<i<<" ";
    // cout<<endl;
    vp ans;
    while(n1--){
        for(int i=0;i<n-1;i++){
            int x=min(temp[i],temp[i+1]);
            int y=max(temp[i],temp[i+1]);
            if(flag.find({x,y})==flag.end()){
                if(temp[i]<temp[i+1]){
                    if(pos[temp[i]]<pos[temp[i+1]]){
                        cnt+=2;
                        ans.pb({temp[i+1],temp[i]});
                        ans.pb({temp[i],temp[i+1]});

                        flag[{temp[i],temp[i+1]}]=1;
                    }else{
                        cnt++;
                        ans.pb({temp[i+1],temp[i]});
                        swap(temp[i],temp[i+1]);
                    }
                }
            }
        }
    }
    cout<<cnt<<endl;
    for(auto i : ans){
        cout<<i.first<<" "<<i.second<<endl;
    }
}

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

    int t;
    // cin >> t;
    t=1;

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

    return 0;
}