ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) (x).begin() , (x).end()
#define bg begin()
#define rng(i,l,r,d) for(auto i = (l); ((d)>0)? (i< (r)):( (d)<0 ? (i>(r)) :0) ;i+=(d))

#ifndef ONLINE_JUDGE
#include "C:\Users\Parth\OneDrive\Desktop\CP\deb_temp.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif


int main(){
    ll n ; cin >> n;
    if(n==1){cout << 0 <<"\n";return 0;}
    vector<ll> a(n); rng(i,0,n,1) {cin >> a[i]; a[i]--;}
    vector<ll> pos(n); rng(i,0,n,1) pos[a[i]]=i;
    vector<pair<ll,ll>> ans; ll cnt = 0;
    vector<ll> act(n);
    rng(i,0,n,1) act[i]=i;
    rng(i,0,n,1){
        ll ind = -1;
        rng(j,0,n,1) if(pos[j]==i) ind = j;
        rng(j,ind+1,n,1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
        rng(j,n-1,ind+1,1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
    }
    cout << ans.size() <<"\n";
    for(auto &val : ans) cout << val.first+1 << " "<< val.second +1 <<"\n";
    cerr << "\nWorked in " << 1000*((double)clock())/(double)CLOCKS_PER_SEC<< "ms \n";
    return 0;
}

/*
    1 2 3
    1 3 2
    1 2 3
    2 1 3
    2 3 1
*/

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) (x).begin() , (x).end()
#define bg begin()
#define rng(i,l,r,d) for(auto i = (l); ((d)>0)? (i< (r)):( (d)<0 ? (i>(r)) :0) ;i+=(d))

#ifndef ONLINE_JUDGE
#include "C:\Users\Parth\OneDrive\Desktop\CP\deb_temp.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif


int main(){
    ll n ; cin >> n;
    if(n==1){cout << 0 <<"\n";return 0;}
    vector<ll> a(n); rng(i,0,n,1) {cin >> a[i]; a[i]--;}
    vector<ll> pos(n); rng(i,0,n,1) pos[a[i]]=i;
    vector<pair<ll,ll>> ans; ll cnt = 0;
    vector<ll> act(n);
    rng(i,0,n,1) act[i]=i;
    rng(i,0,n,1){
        ll ind = -1;
        rng(j,0,n,1) if(pos[j]==i) ind = j;
        // debug(act);
        // cerr << ind <<"\n";
        rng(j,ind+1,n,1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
        // debug(act);
        rng(j,n-1,i,-1){
            ans.push_back({act[j],act[j-1]});
            swap(act[j-1],act[j]);
        }
    }
    cout << ans.size() <<"\n";
    for(auto &val : ans) cout << val.first+1 << " "<< val.second +1 <<"\n";
    cerr << "\nWorked in " << 1000*((double)clock())/(double)CLOCKS_PER_SEC<< "ms \n";
    return 0;
}

/*
    1 2 3
    1 3 2
    1 2 3
    2 1 3
    2 3 1
*/
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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

#include <stdio.h>

#include <vector>

#include <numeric>

#include <unordered_map>





#define ll long long



using namespace std;



void solve()

{

    int n, l, r; cin >> n >>l >>r;



    vector<int> a(n);



    for(auto &i: a) cin >> i;



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

    ll sum = 0;

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

    {

        sum += a[i];

    }



    cout << sum << "\n";

    



}

int main(int argc, char const *argv[])

{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;

    cin >> t;



    while (t--)

    {

        solve();

    }



    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

#include <stdio.h>

#include <vector>

#include <numeric>

#include <unordered_map>





#define ll long long



using namespace std;



void solve()

{

    int n, l, r; cin >> n >>l >>r;



    vector<int> a(n);



    for(auto &i: a) cin >> i;



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

    ll sum = 0;

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

    {

        sum += a[i];

    }



    cout << sum << "\n";

    



}

int main(int argc, char const *argv[])

{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;

    cin >> t;



    while (t--)

    {

        solve();

    }



    return 0;

}



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

#include <stdio.h>

#include <vector>

#include <numeric>

#include <unordered_map>

#include <algorithm>



#define ll long long



using namespace std;



void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    l--;

    // cout << n << l << r << "\n";



    vector<int> a(n);

    vector<int> b(n);



    for (size_t i = 0; i < n; i++)

    {

        cin >> a[i];

    }





    // for(auto &i: a)

    // {

    //     cout <<  i << " ";

    // }

    // cout << "\n";



    partial_sort(a.begin(), a.begin()+r, a.end());

    ll sum1 = 0;

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

    {

        sum1+=a[i];

    }



    partial_sort(a.begin()+l, a.end(), a.end());

    ll sum2 = 0;



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

    {

        sum2+=a[i+l];

    }

    cout <<  min(sum1, sum2) << "\n";

}

int main(int argc, char const *argv[])

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin >> t;



    while (t--)

    {

        solve();

    }



    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

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

#include <stdio.h>

#include <vector>

#include <numeric>

#include <unordered_map>

#include <algorithm>



#define ll long long



using namespace std;



void solve()

{

    int n, l, r;

    cin >> n >> l >> r;

    l--;

    // cout << n << l << r << "\n";



    vector<int> a(n);

    vector<int> b(n);



    for (size_t i = 0; i < n; i++)

    {

        cin >> a[i];

    }





    // for(auto &i: a)

    // {

    //     cout <<  i << " ";

    // }

    // cout << "\n";



    partial_sort(a.begin(), a.begin()+r, a.end());

    ll sum1 = 0;

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

    {

        sum1+=a[i];

    }



    partial_sort(a.begin()+l, a.end(), a.end());

    ll sum2 = 0;



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

    {

        sum2+=a[i+l];

    }

    cout <<  min(sum1, sum2) << "\n";

}

int main(int argc, char const *argv[])

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin >> t;



    while (t--)

    {

        solve();

    }



    return 0;

}



Submission (verdict: Accepted):
#include <iostream>
#include <stdio.h>
#include <vector>
#include <numeric>
#include <unordered_map>


#define ll long long

using namespace std;

void solve()
{
    int n, l, r; cin >> n >>l >>r; 

    // cout << n << l << r << "\n";

    vector<int> a;
    vector<int> b;

    for (size_t i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        if (i < r)
        {
            a.push_back(t);
        }
      if(i >= l-1)b.push_back(t);
    }

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

    ll sum1 = 0;
    ll sum2 = 0;

    for (size_t i = 0; i < r-l+1; i++)
    {
        sum1  += a[i];
        sum2  += b[i];
    }
    

    cout <<  min(sum1, sum2) << "\n";
    

    

}
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin >> t;

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

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
                  
#include <iostream>     // For input/output operations
#include <vector>       // For vector container
#include <string>       // For string operations
#include <algorithm>    // For algorithms like sort, binary_search, etc.
#include <cmath>        // For mathematical functions
#include <map>          // For map container
#include <set>          // For set container
#include <queue>        // For queue and priority_queue
#include <stack>        // For stack container
#include <deque>        // For deque container
#include <list>         // For list container
#include <bitset>       // For bitset operations
#include <cstring>      // For C-style string functions
#include <cstdio>       // For C-style I/O functions
#include <cstdlib>      // For general purpose functions
#include <ctime>        // For time-related functions
#include <utility>      // For pair, make_pair, etc.
#include <numeric>      // For numeric operations
using namespace std;
#define ll long long int
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define fo(i, n) for (int i = 0; i < int(n); i++)
#define fi(i,n,x)  for (int i = x; i < int(n); i++)
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define ss(a) sort(a.begin(),a.end())
/*
      "Beloved,
       never avenge yourselves,
        but leave it to the wrath of God, for it is written,
        Vengeance is mine, I will repay" - ROMAN 12:19
 */

/*
    Remeber the pain
    Remeber how worthless they made you feel
    Turn that pain into anger
    and show them who you're really are
*/
ll pow(ll x,ll g)
{
    if(x==0) return 1;
    ll gg=pow(x/2,g);
    if(x%2) return gg*gg*g;
    return gg*gg; 
}
ll findp1(ll n)
{
    ll a=n,b=n;
    b++;
    a--;
    if(a%6==0 || b%6==0) return 1;
    return 0;
}
using namespace std;



void solve() {
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    map<ll,ll> g;
    fi(i,n+1,1)cin>>a[i],g[a[i]]++;
    sort(a+1,a+n+1);
    a[0]=-1;
    priority_queue<ll,vi,greater<ll>> q;
    for(auto x:g)
    {
         q.push(x.second);
    }
    ll ans=q.size();
  
    while(q.size())
    {
        ll val=q.top();
        if(val<=k)
        {
            k-=val;
            ans--;
        }
        else break;
    }
    cout<<max(ans,1LL)<<endl;
 
   
  
 

  

    
}

  
int main()
{
   ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  ll t;
  cin>>t;
  while(t--)
  {
    solve();
  }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#define int long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define rep(i, n) for (auto i = 1; i <= n; ++i)
#define per(i, n) for (auto i = n; i >= 1; --i)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

const int MAXN = 2e5 + 10;
const int INF = 1e18 + 5;
const int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int n = s.size();

    for (int i = 0; i < n; ++i) {
        int mx = s[i] - '0', mxi = i;
        for (int j = i + 1; j < min(n, i + 10); ++j) {
            if ((s[j] - '0') - j + i > mx) {
                mx = (s[j] - '0') - j + 1;
                mxi = j;
            }
        }
        s[mxi] = ((s[mxi] - '0') - mxi + i) + '0';

        for (int j = mxi; j > i; --j) {
            swap(s[j], s[j - 1]);
        }
    }
    cout << s << '\n';
}

void setIO(string name = "") {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (!name.empty()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int32_t main() {
    setIO();
    int tt = 1;
    cin >> tt;

    while (tt-- > 0) solve();
}


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

#define int long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define rep(i, n) for (auto i = 1; i <= n; ++i)
#define per(i, n) for (auto i = n; i >= 1; --i)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

const int MAXN = 2e5 + 10;
const int INF = 1e18 + 5;
const int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int n = s.size();

    for (int i = 0; i < n; ++i) {
        int mx = s[i] - '0', mxi = i;
        for (int j = i + 1; j < min(n, i + 10); ++j) {
            if (((s[j] - '0') - j + i) > mx) {
                mx = (s[j] - '0') - j + i;
                mxi = j;
            }
        }
        s[mxi] = ((s[mxi] - '0') - mxi + i) + '0';

        for (int j = mxi; j > i; --j) {
            swap(s[j], s[j - 1]);
        }
    }
    cout << s << '\n';
}

void setIO(string name = "") {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (!name.empty()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int32_t main() {
    setIO();
    int tt = 1;
    cin >> tt;

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

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

#define int long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define rep(i, n) for (auto i = 1; i <= n; ++i)
#define per(i, n) for (auto i = n; i >= 1; --i)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

const int MAXN = 2e5 + 10;
const int INF = 1e18 + 5;
const int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int n = s.size();

    rep(k, 100) {
        for (int i = n-1; i >= 1; --i) {
            int a = s[i - 1] - '0', b = s[i] - '0';
            if(b > a + 1 && b > 0) {
                b--;
                s[i] = b + '0';
                swap(s[i - 1], s[i]); 
            }
        }
    }
    cout << s << '\n';
}

void setIO(string name = "") {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (!name.empty()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int32_t main() {
    setIO();
    int tt = 1;
    cin >> tt;

    while (tt-- > 0) solve();
}


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

#define int long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define rep(i, n) for (auto i = 1; i <= n; ++i)
#define per(i, n) for (auto i = n; i >= 1; --i)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

const int MAXN = 2e5 + 10;
const int INF = 1e18 + 5;
const int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int n = s.size();

    for (int i = 0; i < n; ++i) {
        int mx = s[i] - '0', mxi = i;
        for (int j = i + 1; j < min(n, i + 10); ++j) {
            if ((s[j] - '0') - j + i > mx) {
                mx = (s[j] - '0') - j + 1;
                mxi = j;
            }
        }
        s[mxi] = ((s[mxi] - '0') - mxi + i) + '0';

        for (int j = mxi; j > i; --j) {
            swap(s[j], s[j - 1]);
        }
    }
    cout << s << '\n';
}

void setIO(string name = "") {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (!name.empty()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int32_t main() {
    setIO();
    int tt = 1;
    cin >> tt;

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


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

#define int long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define rep(i, n) for (auto i = 1; i <= n; ++i)
#define per(i, n) for (auto i = n; i >= 1; --i)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

const int MAXN = 2e5 + 10;
const int INF = 1e18 + 5;
const int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int n = s.size();

    rep(k, 9) {
        for (int i = n-1; i >= 1; --i) {
            int a = s[i - 1] - '0', b = s[i] - '0';
            if(b > a + 1 && b > 0) {
                b--;
                s[i] = b + '0';
                swap(s[i - 1], s[i]); 
            }
        }
    }
    cout << s << '\n';
}

void setIO(string name = "") {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (!name.empty()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int32_t main() {
    setIO();
    int tt = 1;
    cin >> tt;

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

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

#define int long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define rep(i, n) for (auto i = 1; i <= n; ++i)
#define per(i, n) for (auto i = n; i >= 1; --i)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

const int MAXN = 2e5 + 10;
const int INF = 1e18 + 5;
const int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int n = s.size();

    rep(k, 9) {
        for (int i = n-1; i >= 1; --i) {
            int a = s[i - 1] - '0', b = s[i] - '0';
            if(b > a + 1 && b > 0) {
                b--;
                s[i] = b + '0';
                swap(s[i - 1], s[i]); 
            }
        }
    }
    cout << s << '\n';
}

void setIO(string name = "") {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (!name.empty()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int32_t main() {
    setIO();
    int tt = 1;
    cin >> tt;

    while (tt-- > 0) solve();
}


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

#define int long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define rep(i, n) for (auto i = 1; i <= n; ++i)
#define per(i, n) for (auto i = n; i >= 1; --i)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

const int MAXN = 2e5 + 10;
const int INF = 1e18 + 5;
const int MOD = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    int n = s.size();

    rep(k, 100) {
        for (int i = n-1; i >= 1; --i) {
            int a = s[i - 1] - '0', b = s[i] - '0';
            if(b > a + 1 && b > 0) {
                b--;
                s[i] = b + '0';
                swap(s[i - 1], s[i]); 
            }
        }
    }
    cout << s << '\n';
}

void setIO(string name = "") {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (!name.empty()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int32_t main() {
    setIO();
    int tt = 1;
    cin >> tt;

    while (tt-- > 0) solve();
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
// Online C++ compiler to run C++ program online
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--){
        int n , k;
        cin >> n >> k;
        vector<int> nums(n);
        for(int i = 0; i < n; i++) cin >> nums[i];
        map<int,int> mp;
        for(auto num : nums) mp[num]++;
        vector<int> vec;
        for(auto [x, y] : mp) vec.push_back(y);//
        sort(vec.begin(), vec.end());
        int i = 0;
        int sum = 0;
        while(i < n && (sum + vec[i] <= k) ){
            sum += vec[i];
            i++;
        }
        if(i >= n) cout << 1 << endl;
        else cout << (n - i) << endl;
        
    }

    return 0;
}

Submission (verdict: Accepted):
// Online C++ compiler to run C++ program online
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--){
        int n , k;
        cin >> n >> k;
        vector<int> nums(n);
        for(int i = 0; i < n; i++) cin >> nums[i];
        map<int,int> mp;
        for(auto num : nums) mp[num]++;
        vector<int> vec;
        for(auto [x, y] : mp) vec.push_back(y);
        sort(vec.begin(), vec.end());
        int i = 0;
        int sum = 0;
        while(i < vec.size() && (sum + vec[i] <= k) ){
            sum += vec[i];
            i++;
        }
        if(i >= vec.size()) cout << 1 << endl;
        else cout << (vec.size() - i) << endl;
        
    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
// Online C++ compiler to run C++ program online
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--){
        int n , k;
        cin >> n >> k;
        vector<int> nums(n);
        for(int i = 0; i < n; i++) cin >> nums[i];
        map<int,int> mp;
        for(auto num : nums) mp[num]++;
        vector<int> vec;
        for(auto [x, y] : mp) vec.push_back(y);
        sort(vec.begin(), vec.end());
        int i = 0;
        int sum = 0;
        while(i < n && (sum + vec[i] <= k) ){
            sum += vec[i];
            i++;
        }
        if(i >= n) cout << 1 << endl;
        else cout << (n - i) << endl;
        
    }

    return 0;
}

Submission (verdict: Wrong answer on test 1):
// Online C++ compiler to run C++ program online
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--){
        int n , k;
        cin >> n >> k;
        vector<int> nums(n);
        for(int i = 0; i < n; i++) cin >> nums[i];
        map<int,int> mp;
        for(auto num : nums) mp[num]++;
        vector<int> vec;
        for(auto [x, y] : mp) vec.push_back(y);//
        sort(vec.begin(), vec.end());
        int i = 0;
        int sum = 0;
        while(i < n && (sum + vec[i] <= k) ){
            sum += vec[i];
            i++;
        }
        if(i >= n) cout << 1 << endl;
        else cout << (n - i) << endl;
        
    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
// Online C++ compiler to run C++ program online
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while(t--){
        int n , k;
        cin >> n >> k;
        vector<int> nums(n);
        for(int i = 0; i < n; i++) cin >> nums[i];
        map<int,int> mp;
        for(auto num : nums) mp[num]++;
        vector<int> vec;
        for(auto [x, y] : mp) vec.push_back(y);
        sort(vec.begin(), vec.end());
        int i = 0;
        int sum = 0;
        while(i < n && (sum + vec[i] <= k) ){
            sum += vec[i];
            i++;
        }
        if(i >= n) cout << 1 << endl;
        else cout << (n - i) << endl;
        
    }

    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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

using namespace std;



#define int long long



#define all(a) a.begin(), a.end()

#define pb push_back

#define yes cout << "Yes\n"

#define no cout << "No\n"

#define F first

#define S second



const int MOD = 1e9 + 7;



template <typename T>

istream &operator>>(istream &istream, vector<T> &v){

    for (auto &it : v)

        cin >> it;

    return istream;

}

template <typename T>

ostream &operator<<(ostream &ostream, vector<T> &v){

    for (auto &it : v)

        cout << it << ' ';

    return ostream;

}



template <typename T>

vector<T> prefixsum(const vector<T> &a){

    int n = a.size();

    vector<T> psum(n, 0);

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

        psum[i] = psum[i - 1] + a[i];

    return psum;

}





void solve(){

    int n;

    cin >> n;

    vector<int> a(n);

    cin >> a;

    int idx = -1;

    if(a[0] < a[1]) {

        cout << "YES" << endl;

        return;

    }

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

        if(a[0] == a[i]) idx = i;

        else break;

    }

    cout << idx << endl;

    if(idx == -1 || idx == n-1 || a[idx+1] < a[idx+2]) cout << "YES" << endl;

    else cout << "NO" << endl;

}



int32_t main(){



    ios::sync_with_stdio(false);

    cin.tie(nullptr);



#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif



    int t;

    cin >> t;



    while (t--)

        solve();



    return 0;

}