ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
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 int
#define all(a) (a).begin(), (a).end()
#define lup(i,j,n) for(int i = j; i < n; ++i)
#define lupr(i,j,n) for(int i = j; i >= n; --i)
#define endl '\n'
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define vvi vector<vector<int> >
#define pii pair<int, int>
#define MP make_pair
#define F first
#define S second
#define bitcount(x) __builtin_popcount(x)
#define INF 1e9
#define MOD 1000000007
#define MAXN ((int)2e5 + 4)

void solve() {
    int l, r;
    cin >> l >> r;
    
    int a = l, b = l, c = r;
    lupr(i, log2(l ^ r), 0) {
        int l_bit = (l >> i) & 1;
        int r_bit = (r >> i) & 1;

        if(l_bit == r_bit) {
            int temp = b ^ (1 << i);
            if(temp >= l && temp <= r) {
                b = temp;
            }
        }
    }

    if(b == a) ++b;
    cout << a << ' ' << b << ' ' << c << endl;
}   

signed main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    
    int _t = 1;
    cin >> _t;
    while(_t--) {
        solve();
    }
}

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

#define int long long int
#define all(a) (a).begin(), (a).end()
#define lup(i,j,n) for(int i = j; i < n; ++i)
#define lupr(i,j,n) for(int i = j; i >= n; --i)
#define endl '\n'
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define vvi vector<vector<int> >
#define pii pair<int, int>
#define MP make_pair
#define F first
#define S second
#define bitcount(x) __builtin_popcount(x)
#define INF 1e9
#define MOD 1000000007
#define MAXN ((int)2e5 + 4)

void solve() {
    int l, r;
    cin >> l >> r;
    
    int a = l, b = l + 1, c = r;
    lupr(i, log2(l ^ r), 0) {
        int l_bit = (l >> i) & 1;
        int r_bit = (r >> i) & 1;

        if(l_bit == r_bit) {
            int temp = c ^ (1 << i);
            if(temp >= l && temp <= r) {
                c = temp;
            }
        }
    }

    cout << a << ' ' << b << ' ' << c << endl;
}   

signed main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    
    int _t = 1;
    cin >> _t;
    while(_t--) {
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

#define int long long int
#define all(a) (a).begin(), (a).end()
#define lup(i,j,n) for(int i = j; i < n; ++i)
#define lupr(i,j,n) for(int i = j; i >= n; --i)
#define endl '\n'
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define vvi vector<vector<int> >
#define pii pair<int, int>
#define MP make_pair
#define F first
#define S second
#define bitcount(x) __builtin_popcount(x)
#define INF 1e9
#define MOD 1000000007
#define MAXN ((int)2e5 + 4)

void solve() {
    int l, r;
    cin >> l >> r;
    
    int a = l, b = l + 1, c = r;
    lupr(i, log2(l ^ r), 0) {
        int l_bit = (l >> i) & 1;
        int r_bit = (r >> i) & 1;

        if(l_bit == r_bit) {
            int temp = c ^ (1 << i);
            if(temp >= l && temp <= r) {
                c = temp;
            }
        }
    }

    cout << a << ' ' << b << ' ' << c << endl;
}   

signed main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    
    int _t = 1;
    cin >> _t;
    while(_t--) {
        solve();
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll>PII;
typedef pair<ll, string>PIS;
const int N = 1e6 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e9 + 7;

int main()
{
	int t;
	cin >> t;
	while(t --){
		ll l, r;
		cin >> l >> r;
        ll a = l, b = 0, c = r, k = 0;
		if(r - l == 2) cout << l << ' ' << l + 1 << ' ' << r << endl;
		else {
			for(ll i = 30; i >= 0; i --)
			{
				ll o1 = (l >> i) & 1, o2 = (r >> i) & 1;
				if(o1 == o2 && (o1)) 
				{
					a += (1 << i);
					b += (1 << i);
				}
				else if(o1 != o2){
				    b += (1 << i) - 1;
					a += (1 << i);
					break;
				}
			}
			if(a + 1 <= r && a + 1 >= l) 
			{
				c = a + 1;
				cout << a << ' ' << b << ' ' << c << endl;
			}
			else {
				c = b - 1;
			    cout << a << ' ' << b << ' ' << c << endl;
			}
		}	
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
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 pair<ll, ll>PII;
typedef pair<ll, string>PIS;
const int N = 1e6 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e9 + 7;

int main()
{
	int t;
	cin >> t;
	while(t --){
		ll l, r;
		cin >> l >> r;
        ll a = l, b = 0, c = r, k = 0;
		if(r - l == 2) cout << l << ' ' << l + 1 << ' ' << r << endl;
		else {
			for(ll i = 30; i >= 0; i --)
			{
				ll o1 = (l >> i) & 1, o2 = (r >> i) & 1;
				if(o1 == o2 && (o1)) 
				{
					a += (1 << i);
					b += (1 << i);
				}
				else if(o1 != o2){
				    b += (1 << i) - 1;
					a += (1 << i);
					break;
				}
			}
			if(a + 1 <= r && a + 1 >= l) 
			{
				c = a + 1;
				cout << a << ' ' << b << ' ' << c << endl;
			}
			else {
				c = b - 1;
			    cout << a << ' ' << b << ' ' << c << endl;
			}
		}	
	}
	return 0;
}

Submission (verdict: Accepted):
import math

for _ in range(int(input())):
    a, b = [int(i) for i in input().split()]
    
    x = 2 ** int(math.log(b , 2) // 1)
    
    ans = [x , x-1, x-2]
    
    if x-2 >= a:
        print(*ans)
    
    else:
        ans = [b , b - 1, b-2]
        print(*ans)
    

''' 
                            ╱|、
                           (˚ˎ。7  
                           |、˜ 〵          
                           じしˍ,)ノ
'''
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;



#ifndef ONLINE_JUDGE

    #define debug(x) cerr<<#x<<": "<<x<<endl;

#else

    #define debug(x)

    #define cerr if (false) cerr

#endif



#define endl "\n"       //remove this for interactive problems

#define space " "

#define int long long

typedef long long ll;

typedef vector<int> vi;

typedef pair<int, int> pii;



template <class T> void printit(vector<T> v, int x=1) {if(x==2) return; for (T i : v) if (x==1) cout<<i<<" "; else cerr<<i<<" "; if (x==1) cout<<endl; else cerr<<endl;}



//---------------------------------------------------------------------------------------------------//



/*

auto check = [&](int mid) -> bool{

        //conditions

        return true;

    };

*/

int MOD = 1e9 + 7;

// (a += (b*c)%MOD ) %= MOD ;



void solve()

{

    int n,l,r;

    cin>>n>>l>>r;

    

    l--;

    r--;



    vector<int> arr(n, 0);

    vector<int> segment, left, right;

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

    {

        cin>>arr[i];

        if (i<l)

        {

            left.push_back(arr[i]);

        }

        else if (i>=l && i<=r)

        {

            segment.push_back(arr[i]);

        } else

        {

            right.push_back(arr[i]);

        }

    }



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

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

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



    int sum = accumulate(segment.begin(), segment.end(), 0);



    int answer = sum;

    int i=0, j=segment.size();

    j--;

    while (j>=0 && i<left.size())

    {

        sum = sum - segment[j] + left[i];

        j--;

        i++;



        answer = min(answer, sum);

    }

    sum = accumulate(segment.begin(), segment.end(), 0);

    while (j >= 0 && i < right.size())

    {

        sum = sum - segment[j] + right[i];

        j--;

        i++;



        answer = min(answer, sum);

    }



    cout<<answer<<endl;

}



signed main()

{

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



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

    solve();



    

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int a[200005];
void solve()
{
	int n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int j=0;
	for(int i=2;i<n;i++){
		if(a[i-1]>a[i]){
			j=i;
		}
	}
	if(j==0){
		cout<<"YES\n";
		return;
	}
	for(int i=1;i<j;i++){
		int minn=min(a[i],a[i+1]);
		a[i]-=minn;
		a[i+1]-=minn;
	}
	for(int i=1;i<=n;i++){
		if(a[i-1]>a[i]){
			cout<<"NO\n";
			return;
		}
	}
	cout<<"YES\n";
}
int main()
{
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int a[200005];
void solve()
{
	int n;
	cin>>n;
	vector<int> a(n);
	int j=0;
	for(int i=1;i<n;i++){
		if(a[i-1]>a[i]) j=i;
	}
	if(j==0){
		cout<<"YES\n";
		return;
	}
	for(int i=0;i<j;i++){
		int minn=min(a[i],a[i+1]);
		a[i]-=minn;
		a[i+1]-=minn;
	}
	for(int i=0;i<n;i++){
		if(a[i]>a[i+1]){
			cout<<"NO\n";
			return;
		}
	}
	cout<<"YES\n";
}
int main()
{
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
void solve()
{
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	string ans="YES";
	for(int i=0;i<n-1;i++){
		if(v[i]>v[i+1])ans="NO";
		else{
			v[i+1]-=v[i];
			v[i]=0;
		}
	}
	cout<<ans<<endl;
}
int main()
{
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
int a[200005];
void solve()
{
	int n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int j=0;
	for(int i=2;i<n;i++){
		if(a[i-1]>a[i]){
			j=i;
		}
	}
	if(j==0){
		cout<<"YES\n";
		return;
	}
	for(int i=1;i<j;i++){
		int minn=min(a[i],a[i+1]);
		a[i]-=minn;
		a[i+1]-=minn;
	}
	for(int i=1;i<=n;i++){
		if(a[i-1]>a[i]){
			cout<<"NO\n";
			return;
		}
	}
	cout<<"YES\n";
}
int main()
{
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
int a[200005];
void solve()
{
	int n;
	cin>>n;
	vector<int> a(n);
	int j=0;
	for(int i=1;i<n;i++){
		if(a[i-1]>a[i]) j=i;
	}
	if(j==0){
		cout<<"YES\n";
		return;
	}
	for(int i=0;i<j;i++){
		int minn=min(a[i],a[i+1]);
		a[i]-=minn;
		a[i+1]-=minn;
	}
	for(int i=0;i<n;i++){
		if(a[i]>a[i+1]){
			cout<<"NO\n";
			return;
		}
	}
	cout<<"YES\n";
}
int main()
{
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define db double
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
using namespace std;
ll read(){
	ll sum=0,f=1;char st=getchar();
	while(st<'0'||st>'9'){
		if(st=='-')f=-1;
		st=getchar();
	}
	while('0'<=st&&st<='9'){
		sum=(sum<<3)+(sum<<1)+st-'0';
		st=getchar();
	}
	return sum*f;
}
const int maxn=100010,mod=998244353;
map<int,int> p;
int cnt[maxn];
int main(){
	int TT=read();
	while(TT--){
		int l=read(),r=read(),a=0,b=0,c=0;
		for(int i=30;i>=0;--i){
			int op1=(l>>i)&1,op2=(r>>i)&1;
			if(!op1&&op2){
				c=1<<i;
				for(int j=i-1;j>=0;--j)
					a|=(1<<j);
				break;
			}
			a|=op1<<i,c|=op1<<i;
		}
		if(c+1<=r)b=c+1;
		if(a-1>=l)b=a-1;
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define db double
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
using namespace std;
ll read(){
	ll sum=0,f=1;char st=getchar();
	while(st<'0'||st>'9'){
		if(st=='-')f=-1;
		st=getchar();
	}
	while('0'<=st&&st<='9'){
		sum=(sum<<3)+(sum<<1)+st-'0';
		st=getchar();
	}
	return sum*f;
}
const int maxn=100010,mod=998244353;
map<int,int> p;
int cnt[maxn];
int main(){
	int TT=read();
	while(TT--){
		int l=read(),r=read(),a=0,b=0,c=0;
		for(int i=30;i>=0;--i){
			int op1=(l>>i)&1,op2=(r>>i)&1;
			if(!op1&&op2){
				c|=1<<i;
				for(int j=i-1;j>=0;--j)
					a|=(1<<j);
				break;
			}
			a|=op1<<i,c|=op1<<i;
		}
		if(c+1<=r)b=c+1;
		if(a-1>=l)b=a-1;
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define db double
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
using namespace std;
ll read(){
	ll sum=0,f=1;char st=getchar();
	while(st<'0'||st>'9'){
		if(st=='-')f=-1;
		st=getchar();
	}
	while('0'<=st&&st<='9'){
		sum=(sum<<3)+(sum<<1)+st-'0';
		st=getchar();
	}
	return sum*f;
}
const int maxn=100010,mod=998244353;
map<int,int> p;
int cnt[maxn];
int main(){
	int TT=read();
	while(TT--){
		int l=read(),r=read(),a=0,b=0,c=0;
		for(int i=30;i>=0;--i){
			int op1=(l>>i)&1,op2=(r>>i)&1;
			if(!op1&&op2){
				c=1<<i;
				for(int j=i-1;j>=0;--j)
					a|=(1<<j);
				break;
			}
			a|=op1<<i,c|=op1<<i;
		}
		if(c+1<=r)b=c+1;
		if(a-1>=l)b=a-1;
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define db double
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
using namespace std;
ll read(){
	ll sum=0,f=1;char st=getchar();
	while(st<'0'||st>'9'){
		if(st=='-')f=-1;
		st=getchar();
	}
	while('0'<=st&&st<='9'){
		sum=(sum<<3)+(sum<<1)+st-'0';
		st=getchar();
	}
	return sum*f;
}
const int maxn=100010,mod=998244353;
map<int,int> p;
int cnt[maxn];
int main(){
	int TT=read();
	while(TT--){
		int l=read(),r=read(),a=0,b=0,c=0;
		for(int i=30;i>=0;--i){
			int op1=(l>>i)&1,op2=(r>>i)&1;
			if(!op1&&op2){
				c|=1<<i;
				for(int j=i-1;j>=0;--j)
					a|=(1<<j);
				break;
			}
			a|=op1<<i,c|=op1<<i;
		}
		if(c+1<=r)b=c+1;
		if(a-1>=l)b=a-1;
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <bitset>
using namespace std;

int T, l, r;

typedef pair<int, pair<int, int> > triple;
#define fir first
#define sec second.first
#define thr second.second

int highbit(int x) {
	int res = 1;
	while (res <= x) res <<= 1;
	return res >> 1;
}

triple solve(int l, int r) {
	int hh = highbit(r);
	if (hh <= l) {
		triple res = solve(l ^ hh, r ^ hh);
		res.fir ^= hh;
		res.sec ^= hh;
		res.thr ^= hh;
		return res;
	}
	triple res;
	if (l == hh - 1) {
		res.fir = hh - 1;
		res.sec = hh;
		res.thr = hh + 1;
		return res;
	}
	res.fir = hh - 2;
	res.sec = hh - 1;
	res.thr = hh;
	return res;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	for (cin >> T; T --; ) {
		cin >> l >> r;
		triple res = solve(l, r);
		cout << res.fir << ' ' << res.sec << ' ' << res.thr << '\n';
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
#define ll long long
#define map unordered_map
using namespace std;
int t;
int n,k;
int a[500000];

int main(){
//freopen("a.txt","r",stdin);
//freopen("a.txt","w",stdout);
cin>>t;
while(t--)
{
	cin>>n>>k;
	if(k==n) 
	{
		cout<<1<<endl;
		continue;
	}
	for(int q=1;q<=n;q++) cin>>a[q];
	map<int,int> g;
	for(int q=1;q<=n;q++) g[a[q]]++;
	
	multiset<int> f;
	for(int q=1;q<=n;q++) if(g[a[q]]) f.insert(g[a[q]]),g[a[q]]=0;
	while(k)
	{
		int p=*f.begin();
		if(k>=p) k-=p,f.erase(f.begin());
		else k=0;
	}
	cout<<f.size()<<endl;
}

return 0;
}







Submission (verdict: Time limit exceeded on test 13):
#include<bits/stdc++.h>
#define ll long long
#define map unordered_map
using namespace std;
int t;
int n,k;
int a[500000];

int main(){
//freopen("a.txt","r",stdin);
//freopen("a.txt","w",stdout);
cin>>t;
while(t--)
{
	cin>>n>>k;
	for(int q=1;q<=n;q++) cin>>a[q];
	if(k==n) 
	{
		cout<<1<<endl;
		continue;
	}
	
	map<int,int> g;
	for(int q=1;q<=n;q++) g[a[q]]++;
	
	multiset<int> f;
	for(int q=1;q<=n;q++) if(g[a[q]]) f.insert(g[a[q]]),g[a[q]]=0;
	
	while(k)
	{
		int p=*f.begin();
		if(k>=p) k-=p,f.erase(f.begin());
		else k=0;
	}
	
	cout<<f.size()<<endl;
}

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


Submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
#define ll long long
#define map unordered_map
using namespace std;
int t;
int n,k;
int a[500000];

int main(){
//freopen("a.txt","r",stdin);
//freopen("a.txt","w",stdout);
cin>>t;
while(t--)
{
	cin>>n>>k;
	if(k==n) 
	{
		cout<<1<<endl;
		continue;
	}
	for(int q=1;q<=n;q++) cin>>a[q];
	map<int,int> g;
	for(int q=1;q<=n;q++) g[a[q]]++;
	
	multiset<int> f;
	for(int q=1;q<=n;q++) if(g[a[q]]) f.insert(g[a[q]]),g[a[q]]=0;
	while(k)
	{
		int p=*f.begin();
		if(k>=p) k-=p,f.erase(f.begin());
		else k=0;
	}
	cout<<f.size()<<endl;
}

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

Previous submission (verdict: Time limit exceeded on test 13):
#include<bits/stdc++.h>
#define ll long long
#define map unordered_map
using namespace std;
int t;
int n,k;
int a[500000];

int main(){
//freopen("a.txt","r",stdin);
//freopen("a.txt","w",stdout);
cin>>t;
while(t--)
{
	cin>>n>>k;
	for(int q=1;q<=n;q++) cin>>a[q];
	if(k==n) 
	{
		cout<<1<<endl;
		continue;
	}
	
	map<int,int> g;
	for(int q=1;q<=n;q++) g[a[q]]++;
	
	multiset<int> f;
	for(int q=1;q<=n;q++) if(g[a[q]]) f.insert(g[a[q]]),g[a[q]]=0;
	
	while(k)
	{
		int p=*f.begin();
		if(k>=p) k-=p,f.erase(f.begin());
		else k=0;
	}
	
	cout<<f.size()<<endl;
}

return 0;
}







Submission (verdict: Time limit exceeded on test 13):
#include<bits/stdc++.h>
#define ll long long
#define map unordered_map
using namespace std;
int t;
int n,k;
int a[500000];
int b[500000],bb;

int main(){
//freopen("a.txt","r",stdin);
//freopen("a.txt","w",stdout);
cin>>t;
while(t--)
{
	bb=0;
	cin>>n>>k;
	for(int q=1;q<=n;q++) cin>>a[q];
	if(k==n) 
	{
		cout<<1<<endl;
		continue;
	}
	
	map<int,int> g;
	for(int q=1;q<=n;q++) g[a[q]]++;
	
//	multiset<int> f;
	for(int q=1;q<=n;q++) if(g[a[q]]) b[++bb]=g[a[q]],g[a[q]]=0;
	sort(b+1,b+bb+1);
	int p=1;
	
	while(k)
	{
		if(k>=b[p]) k-=b[p],p++;
		else k=0;
	}
	
	cout<<bb-p+1<<endl;
}

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

Previous submission (verdict: Time limit exceeded on test 13):
#include<bits/stdc++.h>
#define ll long long
#define map unordered_map
using namespace std;
int t;
int n,k;
int a[500000];
int b[500000],bb;

int main(){
//freopen("a.txt","r",stdin);
//freopen("a.txt","w",stdout);
cin>>t;
while(t--)
{
	bb=0;
	cin>>n>>k;
	for(int q=1;q<=n;q++) cin>>a[q];
	if(k==n) 
	{
		cout<<1<<endl;
		continue;
	}
	
	map<int,int> g;
	for(int q=1;q<=n;q++) g[a[q]]++;
	
//	multiset<int> f;
	for(int q=1;q<=n;q++) if(g[a[q]]) b[++bb]=g[a[q]],g[a[q]]=0;
	sort(b+1,b+bb+1);
	int p=1;
	
	while(k)
	{
		if(k>=b[p]) k-=b[p],p++;
		else k=0;
	}
	
	cout<<bb-p+1<<endl;
}

return 0;
}







Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long
#define int long long
//#define map unordered_map
using namespace std;
int t;
int n,k;
int a[5000000];
int b[5000000],bb;

signed main(){
//freopen("a.txt","r",stdin);
//freopen("a.txt","w",stdout);
cin>>t;
while(t--)
{
	bb=0;
	cin>>n>>k;
	for(int q=1;q<=n;q++) cin>>a[q];
	if(k==n) 
	{
		cout<<1<<endl;
		continue;
	}
	
	map<int,int> g;
	for(int q=1;q<=n;q++) g[a[q]]++;
	
//	multiset<int> f;
	for(int q=1;q<=n;q++) if(g[a[q]]) b[++bb]=g[a[q]],g[a[q]]=0;
	sort(b+1,b+bb+1);
	
	int p=1;
	while(k)
	{
		if(k>=b[p]) k-=b[p],p++;
		else k=0;
	}
	
	cout<<bb-p+1<<endl;
}

return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct answer{
    ll a;
    ll b;
    ll c;
};
int main(){
    int t;
    cin>>t; // 读取测试用例的数量
    while(t--){
        ll l,r;
        cin>>l>>r;
        ll ans = 0;
        answer a;
        for(ll i=l;i<=r-2;i++){
            for(ll j=i+1;j<=r-1;j++){
                for(ll k=j+1;k<=r;k++){
                    if((i^j)+(j^k)+(i^k) > ans){
                        ans = (i^j)+(j^k)+(i^k);
                        a.a=i;
                        a.b=j;
                        a.c=k;
                    }
                }
            }
        }
        cout<<a.a<<" "<<a.b<<" "<<a.c<<endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct answer{
    ll a;
    ll b;
    ll c;
};
int main(){
    int t;
    cin>>t; // 读取测试用例的数量
    while(t--){
        ll l,r;
        cin>>l>>r;
        ll ans = 0;
        answer a;
        for(ll i=l;i<=r-2;i++){
            for(ll j=i+1;j<=r-1;j++){
                for(ll k=j+1;k<=r;k++){
                    if((i^j)+(j^k)+(i^k) > ans){
                        ans = (i^j)+(j^k)+(i^k);
                        a.a=i;
                        a.b=j;
                        a.c=k;
                    }
                }
            }
        }
        cout<<a.a<<" "<<a.b<<" "<<a.c<<endl;
    }
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t;
    cin>>t; // 读取测试用例的数量
    while(t--){
        ll l,r;
        cin>>l>>r;
        cout<<r<<" "<<(r-1)<<" "<<(r-2)<<endl;
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int t;
    cin>>t; // 读取测试用例的数量
    while(t--){
        ll l,r;
        cin>>l>>r;
        cout<<r<<" "<<(r-1)<<" "<<(r-2)<<endl;
    }
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t; // 读取测试用例的数量
    while(t--){
        int l,r;
        cin>>l>>r;
        int k = 31 - __builtin_clz(l ^ r);
        int a = l | ((1<<k)-1), b=a+1,c=(a==l?r:l);
        cout<<a<<' '<<b<<' '<<c<<endl;
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;


void solve(){
	string s;
	cin >> s;
	int n = s.length();
	
	int i = 1;
	while(i < n){
		bool condition = false;
		if(s[i] != 0 and s[i] - s[i-1] > 1){
			char temp = s[i] - 1;
			s[i] = s[i-1];
			s[i-1] = temp;
			condition = true;
		}
		i++;
		if(condition){
			i = 1;
		}
	}
	
	cout<<s<<endl;
	return;
}

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