ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
std::set<int> generateSums(int count2, int count3) {
    std::set<int> sums;

    // Iterate through all possible numbers of 2s (0 to count2)
    for (int i = 0; i <= count2; ++i) {
        // Iterate through all possible numbers of 3s (0 to count3)
        for (int j = 0; j <= count3; ++j) {
            // Calculate the sum for the current combination
            int sum = i * 2 + j * 6;
            sums.insert(sum);
        }
    }

    return sums;
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    // Log output to console
    int t;
         cin >> t;

 while(t--){
    string s;
    cin >> s;
    int c2=0;
    int c3=0;
    rep(i,0,s.size()){
       if(s[i]=='2') c2++;
       if(s[i]=='3') c3++;
    }
    auto x = generateSums(min(9,c2),min(2,c3));
    ll os=0;
    rep(i,0,s.size()){
        int y=s[i]-'0';
        os+=y;
    }
    // cout << os << endl;
    bool f=false;  
    if(os%9==0){
     cout << "YES" << endl;
     f=true;
    }
    for(int sum: x){
        if((sum+os)%9==0 && sum!=0){
            // cout << os <<" " << sum;
            cout << "YES" << endl;
            f=true;
            break;
        }
    }
    if(not f){
        cout << "NO" << endl;
    }
     

 }
    return 0;
}
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;
typedef long long ll;
typedef vector<ll> vl;
void solve() {
    ll n;
    cin>>n;
    vl c(n+1),a(n+1);
    for(ll i=1;i<=n;i++)cin>>c[i];
    vector<vector<ll>> ans;
    for(ll i=n;i>=2;i--){
        for(ll j=i-1;j>=1;j--){
            ans.push_back({i,j});
        }
    }
    for(int i=n;i>=1;i--)a[i]=n-i+1;
    for(int i = n;i>=1;i--)
    {
        // i->c
        // j->a
        if(a[i]==c[i])continue;
        int temp = c[i];
        int j =i;
        for(;j>=1 && c[i]!=a[i];j--){
            ans.push_back({a[j],c[i]});
            int t2 = a[j];
            a[j] = temp;
            temp = t2;
        }
        c[i] = a[j];
        a[j] = temp;
    } 
    cout<<ans.size()<<endl;
    for(auto it: ans)cout<<it[0]<<" "<<it[1]<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll t=1;
    // cin >> t;
    while (t--) solve();
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
void solve() {
    ll n;
    cin>>n;
    vl c(n+1),a(n+1);
    for(ll i=1;i<=n;i++)cin>>c[i];
    vector<vector<ll>> ans;
    for(ll i=n;i>=2;i--){
        for(ll j=i-1;j>=1;j--){
            ans.push_back({i,j});
        }
    }
    for(int i=n;i>=1;i--)a[i]=n-i+1;
    for(int i = n;i>=1;i--)
    {
        // i->c
        // j->a
        if(a[i]==c[i])continue;
        int temp = a[i];
        int j =i;
        vector<vector<ll>> ans2;
        while(j>=1 && c[i]!=a[j]){
            ans2.push_back({c[i],a[j]});
            int t2 = a[j];
            a[j] = temp;
            temp = t2;
            j--;
        }
        a[j] = temp;
        a[i] = c[i]; 
        for(int k=ans2.size()-1;k>=0;k--)ans.push_back(ans2[k]);
    } 
    cout<<ans.size()<<endl;
    for(auto it: ans)cout<<it[0]<<" "<<it[1]<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll 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;
typedef long long ll;
typedef vector<ll> vl;
void solve() {
    ll n;
    cin>>n;
    vl c(n+1),a(n+1);
    for(ll i=1;i<=n;i++)cin>>c[i];
    vector<vector<ll>> ans;
    for(ll i=n;i>=2;i--){
        for(ll j=i-1;j>=1;j--){
            ans.push_back({i,j});
        }
    }
    for(int i=n;i>=1;i--)a[i]=n-i+1;
    for(int i = n;i>=1;i--)
    {
        // i->c
        // j->a
        if(a[i]==c[i])continue;
        int temp = c[i];
        int j =i;
        for(;j>=1 && c[i]!=a[i];j--){
            ans.push_back({a[j],c[i]});
            int t2 = a[j];
            a[j] = temp;
            temp = t2;
        }
        c[i] = a[j];
        a[j] = temp;
    } 
    cout<<ans.size()<<endl;
    for(auto it: ans)cout<<it[0]<<" "<<it[1]<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll t=1;
    // cin >> t;
    while (t--) solve();
    return 0;
}
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;
typedef long long ll;
typedef vector<ll> vl;
void solve() {
    ll n;
    cin>>n;
    vl c(n+1),a(n+1);
    for(ll i=1;i<=n;i++)cin>>c[i];
    vector<vector<ll>> ans;
    for(ll i=n;i>=2;i--){
        for(ll j=i-1;j>=1;j--){
            ans.push_back({i,j});
        }
    }
    for(int i=n;i>=1;i--)a[i]=n-i+1;
    for(int i = n;i>=1;i--)
    {
        // i->c
        // j->a
        if(a[i]==c[i])continue;
        int temp = a[i];
        int j =i;
        vector<vector<ll>> ans2;
        while(j>=1 && c[i]!=a[j]){
            ans2.push_back({c[i],a[j]});
            int t2 = a[j];
            a[j] = temp;
            temp = t2;
            j--;
        }
        a[j] = temp;
        a[i] = c[i]; 
        for(int k=ans2.size()-1;k>=0;k--)ans.push_back(ans2[k]);
    } 
    cout<<ans.size()<<endl;
    for(auto it: ans)cout<<it[0]<<" "<<it[1]<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll t=1;
    // cin >> t;
    while (t--) solve();
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
void solve() {
    ll n;
    cin>>n;
    vl c(n+1),a(n+1);
    for(ll i=1;i<=n;i++)cin>>c[i];
    vector<vector<ll>> ans;
    for(ll i=n;i>=2;i--){
        for(ll j=i-1;j>=1;j--){
            ans.push_back({i,j});
        }
    }
    for(int i=n;i>=1;i--)a[i]=n-i+1;
    for(int i = n;i>=1;i--)
    {
        // i->c
        // j->a
        if(a[i]==c[i])continue;
        int temp = a[i];
        int j =i;
        vector<vector<ll>> ans2;
        while(j>=1 && c[i]!=a[j]){
            ans2.push_back({a[j],c[i]});
            int t2 = a[j];
            a[j] = temp;
            temp = t2;
            j--;
        }
        a[j] = temp;
        a[i] = c[i]; 
        for(int k=ans2.size()-1;k>=0;k--)ans.push_back(ans2[k]);
    } 
    cout<<ans.size()<<endl;
    for(auto it: ans)cout<<it[0]<<" "<<it[1]<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll t=1;
    // cin >> t;
    while (t--) solve();
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>

using namespace std;
int sov(){
    int ma=-100, k;
    string a , ans;
    cin>>a;
    for(int i = 0 ; i < a.size(); i++){
        for (int j = i  ; j<i+9 && j<a.size() ; j++){
            if(ma < (a[j]-'0') - (j-i)){
                ma = (a[j]-'0') - (j-i);
                k = j;
            }
        }

    a[k]=0;
    for (int j = k ; j>0 ; j--){
        swap(a[j], a[j-1]);

    }
    cout<<ma;
    ma=-100;
    }




    cout<<ans<<endl;
    return 0;
}


int main()
{
    long long t;
    cin>>t;
    vector <string> ans(t);
    for (long long i=0; i<t;i++){
        ans[i]=sov();
    }
    //3for (long long i=0; i<t;i++){
  //      cout << ans[i]<<endl;
//    }

    return 0;
}


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>

using namespace std;
int sov(){
    int ma=-100, k;
    string a , ans;
    cin>>a;
    for(int i = 0 ; i < a.size(); i++){
        for (int j = i  ; j<min(i+9 ,int(a.size())) ; j++){
            if(ma < (a[j]-'0') - (j-i)){
                ma = (a[j]-'0') - (j-i);
                k = j;
            }
        }

    a[k]=0;
    for (int j = k ; j>0 ; j--){
        swap(a[j], a[j-1]);
    }
    ans.push_back(char(ma+'0'));
    ma=-100;
    }
    cout<<ans<<endl;
    return 0;
}


int main()
{
    long long t;
    cin>>t;
    vector <string> ans(t);
    for (long long i=0; i<t;i++){
        ans[i]=sov();
    }
    //3for (long long i=0; i<t;i++){
  //      cout << ans[i]<<endl;
//    }

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

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>

using namespace std;
int sov(){
    int ma=-100, k;
    string a , ans;
    cin>>a;
    for(int i = 0 ; i < a.size(); i++){
        for (int j = i  ; j<min(i+9 ,int(a.size())) ; j++){
            if(ma < (a[j]-'0') - (j-i)){
                ma = (a[j]-'0') - (j-i);
                k = j;
            }
        }

    a[k]=0;
    for (int j = k ; j>0 ; j--){
        swap(a[j], a[j-1]);
    }
    ans.push_back(char(ma+'0'));
    ma=-100;
    }
    cout<<ans<<'\n';
    return 0;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long t;
    cin>>t;
    for (long long i=0; i<t;i++){
        sov();
    }
    //3for (long long i=0; i<t;i++){
  //      cout << ans[i]<<endl;
//    }

    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>

using namespace std;
int sov(){
    int ma=-100, pos;
    string a , ans;
    cin>>a;
    for(int i = 0 ; i < a.size(); i++){
        for (int j = i  ; j<min(i+10 ,int(a.size())) ; j++){
            if(ma < (a[j]-'0') - (j-i)){
                ma = (a[j]-'0') - (j-i);
                pos = j;
            }
        }

    a[pos]=0;
    while (pos > i) {
            swap(a[pos], a[pos - 1]);
            pos--;
    }
    ans.push_back(char(ma+'0'));
    ma=-100;
    }
    cout<<ans<<'\n';
    return 0;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long t;
    cin>>t;
    for (long long i=0; i<t;i++){
        sov();
    }
    //3for (long long i=0; i<t;i++){
  //      cout << ans[i]<<endl;
//    }

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


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>

using namespace std;
int sov(){
    int ma=-100, k;
    string a , ans;
    cin>>a;
    for(int i = 0 ; i < a.size(); i++){
        for (int j = i  ; j<i+9 && j<a.size() ; j++){
            if(ma < (a[j]-'0') - (j-i)){
                ma = (a[j]-'0') - (j-i);
                k = j;
            }
        }

    a[k]=0;
    for (int j = k ; j>0 ; j--){
        swap(a[j], a[j-1]);

    }
    cout<<ma;
    ma=-100;
    }




    cout<<ans<<endl;
    return 0;
}


int main()
{
    long long t;
    cin>>t;
    vector <string> ans(t);
    for (long long i=0; i<t;i++){
        ans[i]=sov();
    }
    //3for (long long i=0; i<t;i++){
  //      cout << ans[i]<<endl;
//    }

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

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>

using namespace std;
int sov(){
    int ma=-100, k;
    string a , ans;
    cin>>a;
    for(int i = 0 ; i < a.size(); i++){
        for (int j = i  ; j<min(i+9 ,int(a.size())) ; j++){
            if(ma < (a[j]-'0') - (j-i)){
                ma = (a[j]-'0') - (j-i);
                k = j;
            }
        }

    a[k]=0;
    for (int j = k ; j>0 ; j--){
        swap(a[j], a[j-1]);
    }
    ans.push_back(char(ma+'0'));
    ma=-100;
    }
    cout<<ans<<endl;
    return 0;
}


int main()
{
    long long t;
    cin>>t;
    vector <string> ans(t);
    for (long long i=0; i<t;i++){
        ans[i]=sov();
    }
    //3for (long long i=0; i<t;i++){
  //      cout << ans[i]<<endl;
//    }

    return 0;
}


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
#include <stdio.h>

using namespace std;
int sov(){
    int ma=-100, k;
    string a , ans;
    cin>>a;
    for(int i = 0 ; i < a.size(); i++){
        for (int j = i  ; j<min(i+9 ,int(a.size())) ; j++){
            if(ma < (a[j]-'0') - (j-i)){
                ma = (a[j]-'0') - (j-i);
                k = j;
            }
        }

    a[k]=0;
    for (int j = k ; j>0 ; j--){
        swap(a[j], a[j-1]);
    }
    ans.push_back(char(ma+'0'));
    ma=-100;
    }
    cout<<ans<<'\n';
    return 0;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long t;
    cin>>t;
    for (long long i=0; i<t;i++){
        sov();
    }
    //3for (long long i=0; i<t;i++){
  //      cout << ans[i]<<endl;
//    }

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

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
const long long INF = (ll)1e17;

multiset<ll> a;

bool tr(ll ch) {
    //cout << ch << "! ";
    if (ch == 0) return false;
    if (a.find(ch) != a.end()) {
        a.erase(a.find(ch));
        return true;
    }
    if (ch == 1) return false;
    ll l = ch / 2, r = (ch + 1) / 2;
    return tr(l) & tr(r);
}

void solve() {
    ll n, m, s = 0, s1 = 0;
    cin >> n >> m;
    a.clear();
    for (int i = 0, fi; i < n; i++) {
        cin >> fi;
        s += fi;
        a.insert(fi);
    }
    vector<ll> b(m);

    for (auto & i : b) {cin >> i; s1 += i;}
    if (s != s1) {
        cout << "No\n";
        return;
    }sort(b.begin(), b.end());
    for (auto & ch : b) {
        if (!tr(ch)) {cout << "No\n"; return;}
    }
    cout << "Yes\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll q;
    cin >> q;
    while (q--) {
        solve();
    }
    cout.flush();
    return 0;
}


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
const long long INF = (ll)1e17;

multiset<ll> a;

bool tr(ll ch) {
    //cout << ch << "! ";
    if (ch == 0) return false;
    if (a.find(ch) != a.end()) {
        a.erase(a.find(ch));
        return true;
    }
    if (ch == 1) return false;
    ll l = ch / 2, r = (ch + 1) / 2;
    return tr(l) & tr(r);
}

bool comp(ll & A, ll & B) {
    return A > B;
}

void solve() {
    ll n, m, s = 0, s1 = 0;
    cin >> n >> m;
    a.clear();
    for (int i = 0, fi; i < n; i++) {
        cin >> fi;
        s += fi;
        a.insert(fi);
    }
    vector<ll> b(m);

    for (auto & i : b) {cin >> i; s1 += i;}
    if (s != s1) {
        cout << "No\n";
        return;
    }sort(b.begin(), b.end(), comp);
    for (auto & ch : b) {
        if (!tr(ch)) {cout << "No\n"; return;}
    }
    cout << "Yes\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll q;
    cin >> q;
    while (q--) {
        solve();
    }
    cout.flush();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
const long long INF = (ll)1e17;

multiset<ll> a;

bool tr(ll ch) {
    //cout << ch << "! ";
    if (ch == 0) return false;
    if (a.find(ch) != a.end()) {
        a.erase(a.find(ch));
        return true;
    }
    if (ch == 1) return false;
    ll l = ch / 2, r = (ch + 1) / 2;
    return tr(l) & tr(r);
}

void solve() {
    ll n, m, s = 0, s1 = 0;
    cin >> n >> m;
    a.clear();
    for (int i = 0, fi; i < n; i++) {
        cin >> fi;
        s += fi;
        a.insert(fi);
    }
    vector<ll> b(m);
    for (auto & i : b) {cin >> i; s1 += i;}
    if (s != s1) {
        cout << "No\n";
        return;
    }
    for (auto & ch : b) {
        if (!tr(ch)) {cout << "No\n"; return;}
    }
    cout << "Yes\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll q;
    cin >> q;
    while (q--) {
        solve();
    }
    cout.flush();
    return 0;
}


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
const long long INF = (ll)1e17;

multiset<ll> a;

bool tr(ll ch) {
    //cout << ch << "! ";
    if (ch == 0) return false;
    if (a.find(ch) != a.end()) {
        a.erase(a.find(ch));
        return true;
    }
    if (ch == 1) return false;
    ll l = ch / 2, r = (ch + 1) / 2;
    return tr(l) & tr(r);
}

void solve() {
    ll n, m, s = 0, s1 = 0;
    cin >> n >> m;
    a.clear();
    for (int i = 0, fi; i < n; i++) {
        cin >> fi;
        s += fi;
        a.insert(fi);
    }
    vector<ll> b(m);

    for (auto & i : b) {cin >> i; s1 += i;}
    if (s != s1) {
        cout << "No\n";
        return;
    }sort(b.begin(), b.end());
    for (auto & ch : b) {
        if (!tr(ch)) {cout << "No\n"; return;}
    }
    cout << "Yes\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll q;
    cin >> q;
    while (q--) {
        solve();
    }
    cout.flush();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
const long long INF = (ll)1e17;

multiset<ll> a;

bool tr(ll ch) {
    //cout << ch << "! ";
    if (ch == 0) return false;
    if (a.find(ch) != a.end()) {
        a.erase(a.find(ch));
        return true;
    }
    if (ch == 1) return false;
    ll l = ch / 2, r = (ch + 1) / 2;
    return tr(l) & tr(r);
}

bool comp(ll & A, ll & B) {
    return A > B;
}

void solve() {
    ll n, m, s = 0, s1 = 0;
    cin >> n >> m;
    a.clear();
    for (int i = 0, fi; i < n; i++) {
        cin >> fi;
        s += fi;
        a.insert(fi);
    }
    vector<ll> b(m);

    for (auto & i : b) {cin >> i; s1 += i;}
    if (s != s1) {
        cout << "No\n";
        return;
    }sort(b.begin(), b.end(), comp);
    for (auto & ch : b) {
        if (!tr(ch)) {cout << "No\n"; return;}
    }
    cout << "Yes\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll q;
    cin >> q;
    while (q--) {
        solve();
    }
    cout.flush();
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
const long long INF = (ll)1e17;

multiset<ll> a;
ll kol = 0, n, m;

bool tr(ll ch) {
    //cout << ch << "! ";
    if (kol > n) return false;
    if (ch == 0) return false;
    if (a.find(ch) != a.end()) {
        a.erase(a.find(ch));
        return true;
    }
    if (ch == 1) return false;
    ll l = ch / 2, r = (ch + 1) / 2;
    kol += 1;
    return tr(l) & tr(r);
}

bool comp(ll & A, ll & B) {
    return A > B;
}

void solve() {
    kol = 0;
    ll s = 0, s1 = 0;
    cin >> n >> m;
    a.clear();
    for (int i = 0, fi; i < n; i++) {
        cin >> fi;
        s += fi;
        a.insert(fi);
    }
    vector<ll> b(m);

    for (auto & i : b) {cin >> i; s1 += i;}
    if (s != s1) {
        cout << "No\n";
        return;
    }sort(b.begin(), b.end(), comp);
    for (auto & ch : b) {
        if (!tr(ch)) {cout << "No\n"; return;}
    }
    cout << "Yes\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll q;
    cin >> q;
    while (q--) {
        solve();
    }
    cout.flush();
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
const long long INF = (ll)1e17;

multiset<ll> a;

bool tr(ll ch) {
    //cout << ch << "! ";
    if (ch == 0) return false;
    if (a.find(ch) != a.end()) {
        a.erase(a.find(ch));
        return true;
    }
    if (ch == 1) return false;
    ll l = ch / 2, r = (ch + 1) / 2;
    return tr(l) & tr(r);
}

void solve() {
    ll n, m, s = 0, s1 = 0;
    cin >> n >> m;
    a.clear();
    for (int i = 0, fi; i < n; i++) {
        cin >> fi;
        s += fi;
        a.insert(fi);
    }
    vector<ll> b(m);
    for (auto & i : b) {cin >> i; s1 += i;}
    if (s != s1) {
        cout << "No\n";
        return;
    }
    for (auto & ch : b) {
        if (!tr(ch)) {cout << "No\n"; return;}
    }
    cout << "Yes\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll q;
    cin >> q;
    while (q--) {
        solve();
    }
    cout.flush();
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

string solve() {
    int n;
    cin >> n;
    vector< int > v(n);
    for(auto &it : v) cin >> it;
    
    int flag = 1;
    for(int i = 1; i < n; i++) {
        if(v[i] < v[i - 1]) flag = 0;
    }
    if(flag) return "YES";
    
    for(int i = n - 1; i > 0; i--) {
        if(v[i] > v[i - 1]) flag = 1;
    }
    if(flag == 0) return "NO";
    
    int mini = INT_MAX;
    for(int i = 0; i < n - 1; i++) {
        mini = min(v[i], v[i + 1]);
        v[i] -= mini;
        v[i + 1] -= mini;
    }
    
    for(int i = 1; i < n; i++) {
        if(v[i] < v[i - 1]) return "NO";
    }
    
    return "YES";
}

int main() {
    long long t;
    cin >> t;
    while(t--) {
        // solve();
        cout << solve() << "\n";
    }
}


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

string solve() {
    int n;
    cin >> n;
    vector< int > v(n);
    for(auto &it : v) cin >> it;
    
    int flag = 1;
    for(int i = 1; i < n; i++) {
        if(v[i] < v[i - 1]) flag = 0;
    }
    if(flag) return "YES";
    
    // flag = 0;
    // for(int i = n - 1; i > 0; i--) {
    //     if(v[i] > v[i - 1]) flag = 1;
    // }
    // if(flag == 0) return "1NO";
    
    int mini = INT_MAX;
    for(int i = 0; i < n - 1; i++) {
        mini = min(v[i], v[i + 1]);
        v[i] -= mini;
        v[i + 1] -= mini;
    }
    
    for(int i = 1; i < n; i++) {
        if(v[i] < v[i - 1]) return "NO";
    }
    for(int i = n - 1; i > 0; i--) {
        if(v[i - 1] > v[i]) return "NO";
    }
    
    return "YES";
}

int main() {
    long long t;
    cin >> t;
    while(t--) {
        // solve();
        cout << solve() << "\n";
    }
}