ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

using namespace std;


int main() {
    int t;
    cin >> t; 
    while (t--) {
        int n, k;
        cin >> n >> k; 
        if(n==k){
            cout<<1<<endl;
            return 0;
        }
        vector<int> arr(n);
        map<int, int> mp;
        int maxi = 0;
        int maxiF = 0;

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

            if (mp[arr[i]] > maxi) {
                maxiF = arr[i];
                maxi = mp[arr[i]];
            }
        }

        vector<pair<int,int>> freq;
        for(auto it : mp){
            freq.push_back({it.second,it.first});
        }
        sort(freq.begin(),freq.end());
        
        int cnt = freq.size(); 
        
        int i = 0;
        
        while (k > 0 && i < freq.size()) {
            if (freq[i].first <= k) {  
                k -= freq[i].first;
                cnt--;
                i++;  
            } else {
                break;
            }
        }

        cout << cnt << endl;

    }

    return 0;
}


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

using namespace std;


int main() {
    int t;
    cin >> t; 
    while (t--) {
        int n, k;
        cin >> n >> k; 
        if(n==k){
            cout<<1<<endl;
            continue;
        }
        vector<int> arr(n);
        map<int, int> mp;
        int maxi = 0;
        int maxiF = 0;

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

            if (mp[arr[i]] > maxi) {
                maxiF = arr[i];
                maxi = mp[arr[i]];
            }
        }

        vector<pair<int,int>> freq;
        for(auto it : mp){
            freq.push_back({it.second,it.first});
        }
        sort(freq.begin(),freq.end());
        
        int cnt = freq.size(); 
        
        int i = 0;
        
        while (k > 0 && i < freq.size()) {
            if (freq[i].first <= k) {  
                k -= freq[i].first;
                cnt--;
                i++;  
            } else {
                break;
            }
        }

        cout << cnt << endl;

    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

using namespace std;


int main() {
    int t;
    cin >> t; 
    while (t--) {
        int n, k;
        cin >> n >> k; 
        if(n==k){
            cout<<1<<endl;
            continue;
        }
        vector<int> arr(n);
        map<int, int> mp;
        int maxi = 0;
        int maxiF = 0;

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

            if (mp[arr[i]] > maxi) {
                maxiF = arr[i];
                maxi = mp[arr[i]];
            }
        }

        vector<pair<int,int>> freq;
        for(auto it : mp){
            freq.push_back({it.second,it.first});
        }
        sort(freq.begin(),freq.end());
        
        int cnt = freq.size(); 
        
        int i = 0;
        
        while (k > 0 && i < freq.size()) {
            if (freq[i].first <= k) {  
                k -= freq[i].first;
                cnt--;
                i++;  
            } else {
                break;
            }
        }
        if(cnt<=0)cnt=1;
        cout << cnt << endl;

    }

    return 0;
}


Submission (verdict: Accepted):
#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> arr(n);
        map<int, int> mp;


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

        vector<int> freq;
        for(auto it : mp){
            freq.push_back(it.second);
        }
        sort(freq.begin(),freq.end());
        
        
        int t=0,j=0;
        
        for(int i=0;i<freq.size();i++){
            if(t+freq[i] > k)break;
            t += freq[i]; j++;
        }
        
        int cnt = freq.size()-j;
        
        cout<<max(cnt,1)<<endl;

    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

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

using namespace std;


int main() {
    int t;
    cin >> t; 
    while (t--) {
        int n, k;
        cin >> n >> k; 
        if(n==k){
            cout<<1<<endl;
            continue;
        }
        vector<int> arr(n);
        map<int, int> mp;
        int maxi = 0;
        int maxiF = 0;

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

            if (mp[arr[i]] > maxi) {
                maxiF = arr[i];
                maxi = mp[arr[i]];
            }
        }

        vector<pair<int,int>> freq;
        for(auto it : mp){
            freq.push_back({it.second,it.first});
        }
        sort(freq.begin(),freq.end());
        
        int cnt = freq.size(); 
        
        int i = 0;
        
        while (k > 0 && i < freq.size()) {
            if (freq[i].first <= k) {  
                k -= freq[i].first;
                cnt--;
                i++;  
            } else {
                break;
            }
        }

        cout << cnt << endl;

    }

    return 0;
}


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

using namespace std;


int main() {
    int t;
    cin >> t; 
    while (t--) {
        int n, k;
        cin >> n >> k; 
        if(n==k){
            cout<<1<<endl;
            continue;
        }
        vector<int> arr(n);
        map<int, int> mp;
        int maxi = 0;
        int maxiF = 0;

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

            if (mp[arr[i]] > maxi) {
                maxiF = arr[i];
                maxi = mp[arr[i]];
            }
        }

        vector<pair<int,int>> freq;
        for(auto it : mp){
            freq.push_back({it.second,it.first});
        }
        sort(freq.begin(),freq.end());
        
        int cnt = freq.size(); 
        
        int i = 0;
        
        while (k > 0 && i < freq.size()) {
            if (freq[i].first <= k) {  
                k -= freq[i].first;
                cnt--;
                i++;  
            } else {
                break;
            }
        }
        if(cnt<=0)cnt=1;
        cout << cnt << endl;

    }

    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


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

using namespace std;


int main() {
    int t;
    cin >> t; 
    while (t--) {
        int n, k;
        cin >> n >> k; 
        if(n==k){
            cout<<1<<endl;
            return 0;
        }
        vector<int> arr(n);
        map<int, int> mp;
        int maxi = 0;
        int maxiF = 0;

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

            if (mp[arr[i]] > maxi) {
                maxiF = arr[i];
                maxi = mp[arr[i]];
            }
        }

        vector<pair<int,int>> freq;
        for(auto it : mp){
            freq.push_back({it.second,it.first});
        }
        sort(freq.begin(),freq.end());
        
        int cnt = freq.size(); 
        
        int i = 0;
        
        while (k > 0 && i < freq.size()) {
            if (freq[i].first <= k) {  
                k -= freq[i].first;
                cnt--;
                i++;  
            } else {
                break;
            }
        }

        cout << cnt << endl;

    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
 #include<bits/stdc++.h>
#include<algorithm>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define nl cout<<"\n"
#define all(a) a.begin(),a.end()
#define ivec(vec) for(int i=0;i<vec.size();i++){cin>>vec[i];}
#define ovec(vec) for(int i=0;i<vec.size();i++){cout<<vec[i]<<" ";}
#define pb push_back
using ll=long long;
using ull=unsigned long long;
const int mod=1e9+7;
using namespace std;
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
    ll l,r;
    cin>>l>>r;
    ll a=0;
    ll b=0;
    ll c=0;
    int ind=0;
    c=l;
    for(int i=30;i>=0;i--){
        int shi=(1<<i);
        if(((l&shi)>0) && ((r&shi)>0)){
            a=a|(shi);
            b=b|(shi);
        }
        else if ((r&shi)>0){
            a=a|shi;
            ind=i;
            // cout<<ind<<endl;
            break;
        }
        else if ((l&shi)>0){
            a=a|shi;
            ind=i;
            break;
        }
    }
    for(int j=0;j<ind;j++){
        b=b|(1<<j);
    }
    for(int i=0;i<30;i++){
        if ((l&(1<<i))>0 && (r&(1<<i))>0){
            c=c|(1<<i);
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
 #include<bits/stdc++.h>
#include<algorithm>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define nl cout<<"\n"
#define all(a) a.begin(),a.end()
#define ivec(vec) for(int i=0;i<vec.size();i++){cin>>vec[i];}
#define ovec(vec) for(int i=0;i<vec.size();i++){cout<<vec[i]<<" ";}
#define pb push_back
using ll=long long;
using ull=unsigned long long;
const int mod=1e9+7;
using namespace std;
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
    ll l,r;
    cin>>l>>r;
    ll a=0;
    ll b=0;
    ll c=0;
    int ind=0;
    c=l;
    for(int i=30;i>=0;i--){
        int shi=(1<<i);
        if(((l&shi)>0) && ((r&shi)>0)){
            a=a|(shi);
            b=b|(shi);
        }
        else if ((r&shi)>0){
            a=a|shi;
            ind=i;
            // cout<<ind<<endl;
            break;
        }
        else if ((l&shi)>0){
            a=a|shi;
            ind=i;
            break;
        }
    }
    for(int j=0;j<ind;j++){
        b=b|(1<<j);
    }
    for(int i=0;i<30;i++){
        if ((l&(1<<i))>0 && (r&(1<<i))>0){
            c=c|(1<<i);
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        solve();
    }
}

Submission (verdict: Wrong answer on test 1):
 #include<bits/stdc++.h>
#include<algorithm>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define nl cout<<"\n"
#define all(a) a.begin(),a.end()
#define ivec(vec) for(int i=0;i<vec.size();i++){cin>>vec[i];}
#define ovec(vec) for(int i=0;i<vec.size();i++){cout<<vec[i]<<" ";}
#define pb push_back
using ll=long long;
using ull=unsigned long long;
const int mod=1e9+7;
using namespace std;
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
    ll l,r;
    cin>>l>>r;
    ll a=0;
    ll b=0;
    ll c=0;
    int ind=0;
    // c=l;
    for(int i=30;i>=0;i--){
        int shi=(1<<i);
        if(((l&shi)>0) && ((r&shi)>0)){
            a=a|(shi);
            b=b|(shi);
        }
        else if ((r&shi)>0){
            a=a|shi;
            ind=i;
            break;
        }
        else if ((l&shi)>0){
            a=a|shi;
            ind=i;
            break;
        }
    }
    for(int j=0;j<ind;j++){
        b=b|(1<<j);
    }
    if (b==l || a==l){
        c=r;
    }
    for(int i=0;i<30;i++){
        if ((l&(1<<i))>0 && (r&(1<<i))>0){
            c=c|(1<<i);
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
 #include<bits/stdc++.h>
#include<algorithm>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define nl cout<<"\n"
#define all(a) a.begin(),a.end()
#define ivec(vec) for(int i=0;i<vec.size();i++){cin>>vec[i];}
#define ovec(vec) for(int i=0;i<vec.size();i++){cout<<vec[i]<<" ";}
#define pb push_back
using ll=long long;
using ull=unsigned long long;
const int mod=1e9+7;
using namespace std;
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
    ll l,r;
    cin>>l>>r;
    ll a=0;
    ll b=0;
    ll c=0;
    int ind=0;
    // c=l;
    for(int i=30;i>=0;i--){
        int shi=(1<<i);
        if(((l&shi)>0) && ((r&shi)>0)){
            a=a|(shi);
            b=b|(shi);
        }
        else if ((r&shi)>0){
            a=a|shi;
            ind=i;
            break;
        }
        else if ((l&shi)>0){
            a=a|shi;
            ind=i;
            break;
        }
    }
    for(int j=0;j<ind;j++){
        b=b|(1<<j);
    }
    if (b==l || a==l){
        c=r;
    }
    for(int i=0;i<30;i++){
        if ((l&(1<<i))>0 && (r&(1<<i))>0){
            c=c|(1<<i);
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        solve();
    }
}

Submission (verdict: Accepted):
 #include<bits/stdc++.h>
#include<algorithm>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define nl cout<<"\n"
#define all(a) a.begin(),a.end()
#define ivec(vec) for(int i=0;i<vec.size();i++){cin>>vec[i];}
#define ovec(vec) for(int i=0;i<vec.size();i++){cout<<vec[i]<<" ";}
#define pb push_back
using ll=long long;
using ull=unsigned long long;
const int mod=1e9+7;
using namespace std;
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
    ll l,r;
    cin>>l>>r;
    ll a=0;
    ll b=0;
    ll c=0;
    int ind=0;
    c=l;
    for(int i=30;i>=0;i--){
        int shi=(1<<i);
        if(((l&shi)>0) && ((r&shi)>0)){
            a=a|(shi);
            b=b|(shi);
        }
        else if ((r&shi)>0){
            a=a|shi;
            ind=i;
            break;
        }
        else if ((l&shi)>0){
            a=a|shi;
            ind=i;
            break;
        }
    }
    for(int j=0;j<ind;j++){
        b=b|(1<<j);
    }
    if (b==l || a==l){
        c=r;
    }
    for(int i=0;i<30;i++){
        if ((l&(1<<i))>0 && (r&(1<<i))>0){
            c=c|(1<<i);
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}
int main(){
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        solve();
    }
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	int l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r+1);
	int flag=l;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		if(flag==r)	break;
		flag++;
	}
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=l;i<=n;i++)
	{
		k+=b[i];
		if(flag==r)	break;
		flag++;
	}
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}

Submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	int l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r+1);
	int flag=l;
	for(int i=1;i<=r-l+1;i++)
		sum+=a[i];
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=l;i<=r;i++)
		k+=b[i];
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	int l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r+1);
	int flag=l;
	for(int i=1;i<=r-l+1;i++)
		sum+=a[i];
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=l;i<=r;i++)
		k+=b[i];
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}

Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	ll l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r+1);
	int flag=l;
	for(int i=1;i<=r-l+1;i++)
		sum+=a[i];
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=l;i<=r;i++)
		k+=b[i];
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	int l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r+1);
	int flag=l;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		if(flag==r)	break;
		flag++;
	}
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=1;i<=n;i++)
	{
		k+=b[i];
		if(flag==r)	break;
		flag++;
	}
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}

Submission (verdict: Wrong answer on test 8):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	int l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r+1);
	int flag=l;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		if(flag==r)	break;
		flag++;
	}
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=l;i<=n;i++)
	{
		k+=b[i];
		if(flag==r)	break;
		flag++;
	}
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	int l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r);
	int flag=l;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		if(flag==r)	break;
		flag++;
	}
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=1;i<=n;i++)
	{
		k+=b[i];
		if(flag==r)	break;
		flag++;
	}
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	int l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r);
	int flag=l;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		if(flag==r)	break;
		flag++;
	}
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=1;i<=n;i++)
	{
		k+=b[i];
		if(flag==r)	break;
		flag++;
	}
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<math.h> 
using namespace std;
#define ll long long
#define get(a,b)	((a>>b)&1)
//void close(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//}
void solve()
{
	int l,r,n,sum=0,k=0;
	cin>>n>>l>>r;
	vector<int>a(n+10);
	vector<int>b(n+10);
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	b=a;
	sort(a.begin()+1,a.begin()+r+1);
	int flag=l;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		if(flag==r)	break;
		flag++;
	}
	flag=l;
	sort(b.begin()+l,b.begin()+n+1);
	for(int i=1;i<=n;i++)
	{
		k+=b[i];
		if(flag==r)	break;
		flag++;
	}
	cout<<min(k,sum)<<endl;
}
int main()
{
	//close();
	int t;
	scanf("%d",&t);
	while(t--)
		solve(); 
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;

void init_code() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

void solve() {
	int n, k;
	int res = 0;

	cin >> n >> k;

	vector<int> a(n);
	unordered_map<int, int> freq;

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

	vector<int> frequency;
	for (auto& f : freq) {
		frequency.push_back(f.second);
	}

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

	int unique = frequency.size();
	for (int i = 0; i<frequency.size(); i++) {
		if (frequency[i] > k) {
			cout << unique - i << endl;
			return;
		}
		k -= frequency[i];
	}

	cout << 1 << endl;
}

int main() {
	init_code();

	int t;
	cin >> t;

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

	return 0;
}

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

void init_code() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

void solve() {
	int n, k;
	int res = 0;

	cin >> n >> k;

	vector<int> a(n);

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

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

	vector<int> frequency = {1};
	for (int i = 1; i<n; i++) {
		if (a[i] == a[i-1]) frequency.back()++;
		else frequency.emplace_back(1);
	}

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

	int unique = frequency.size();
	for (int i = 0; i<frequency.size(); i++) {
		if (frequency[i] > k) {
			cout << unique - i << endl;
			return;
		}
		k -= frequency[i];
	}

	cout << 1 << endl;
}

int main() {
	init_code();

	int t;
	cin >> t;

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

	return 0;
}