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;


void solve() {
	int N;
	cin >> N;

	vector<int>final_order_of_race(N + 1);
	vector<int>rank_of_which_car(N + 1);
	for (int rank = 1; rank <= N; rank++) {
		int car;
		cin >> car;
		final_order_of_race[car] = rank;
		rank_of_which_car[rank] = car;
	}
	vector<pair<int, int>>maximum_long_over_seq;
	set<int>order;
	for (int car = N; car >= 1; car--) {
		for (int front_car = car - 1; front_car >= 1; front_car--) {
			maximum_long_over_seq.push_back({car, front_car});
		}
		if (order.empty()) {
			order.insert(final_order_of_race[car]);
		}
		else {
			for (auto rank : order) {
				if (final_order_of_race[car] < rank) {
					maximum_long_over_seq.push_back({car, rank_of_which_car[rank]});
				}
				else {
					break;
				}
			}
			order.insert(final_order_of_race[car]);
		}
	}

	int M = maximum_long_over_seq.size();
	cout << M << "\n";
	for (int i = 0; i < M; i++ ) {
		cout << maximum_long_over_seq[i].first << " " << maximum_long_over_seq[i].second << "\n";
	}
}



int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif


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

	solve();

	return 0;
}

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


void solve() {
	int N;
	cin >> N;

	vector<int>final_order_of_race(N + 1);
	vector<int>rank_of_which_car(N + 1);
	for (int rank = 1; rank <= N; rank++) {
		int car;
		cin >> car;
		final_order_of_race[car] = rank;
		rank_of_which_car[rank] = car;
	}
	vector<pair<int, int>>maximum_long_over_seq;
	set<int, greater<int>>order;
	for (int car = N; car >= 1; car--) {
		for (int front_car = car - 1; front_car >= 1; front_car--) {
			maximum_long_over_seq.push_back({car, front_car});
		}
		if (order.empty()) {
			order.insert(final_order_of_race[car]);
		}
		else {
			for (auto rank : order) {
				if (final_order_of_race[car] < rank) {
					maximum_long_over_seq.push_back({car, rank_of_which_car[rank]});
				}
				else {
					break;
				}
			}
			order.insert(final_order_of_race[car]);
		}
	}

	int M = maximum_long_over_seq.size();
	cout << M << "\n";
	for (int i = 0; i < M; i++ ) {
		cout << maximum_long_over_seq[i].first << " " << maximum_long_over_seq[i].second << "\n";
	}
}



int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif


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

	solve();

	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 2):
#include<iostream>

#include <bits/stdc++.h>

#include<set>

using namespace std;

 

#define ll long long

#define TC(_) ll (_); cin >> (_) ; while((_)-->0)

#define rep(i, a, b) for(ll (i) = (a); (i) < (b); (i)++)

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

#define dPrintVec(a) for(auto elem : a) cout << elem << ' '; cout << endl







int main(){

 

    TC(_){

        int n, l, r;

        cin >> n >> l >> r; // they are one indexed

        l--;

        r--; // make them zero indexed



        vector<int> a(n);

        rep(i, 0, n) cin >> a[i];

        vector<int> b(r+1, -1);

        vector<int> c(n-l, -1);

        rep(i, 0, n){

            if(i < l) b[i] = a[i];

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

                b[i] = a[i];

                c[i-l] = a[i];

            }

            else c[i-l] = a[i];

        }

        // dPrintVec(a);

        // dPrintVec(b);

        // dPrintVec(c);



        sort(all(b));

        sort(all(c));



        int sum1 = 0, sum2 = 0;

        rep(i, 0, r-l+1) sum1 += b[i];

        rep(i, 0, r-l+1) sum2 += c[i];

        

        // cout << sum1 << " " << sum2 << endl;

        cout << min(sum1, sum2) << endl;

    }

}

Submission (verdict: Wrong answer on test 8):
#include<iostream>
#include <bits/stdc++.h>
#include<set>
using namespace std;
 
#define ll long long
#define TC(_) ll (_); cin >> (_) ; while((_)-->0)
#define rep(i, a, b) for(ll (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(), (x).end()
#define dPrintVec(a) for(auto elem : a) cout << elem << ' '; cout << endl



int main(){
 
    TC(_){
        int n, l, r;
        cin >> n >> l >> r; // they are one indexed
        l--;
        r--; // make them zero indexed

        vector<int> a(n);
        rep(i, 0, n) cin >> a[i];
        vector<int> b(r+1, -1);
        vector<int> c(n-l, -1);
        rep(i, 0, n){
            if(i < l) b[i] = a[i];
            else if(i >= l && i <= r){
                b[i] = a[i];
                c[i-l] = a[i];
            }
            else c[i-l] = a[i];
        }
        // dPrintVec(a);
        // dPrintVec(b);
        // dPrintVec(c);

        sort(all(b));
        sort(all(c));

        int sum1 = 0, sum2 = 0;
        rep(i, 0, r-l+1) sum1 += b[i];
        rep(i, 0, r-l+1) sum2 += c[i];
        
        // cout << sum1 << " " << sum2 << endl;
        cout << min(sum1, sum2) << endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include<iostream>
#include <bits/stdc++.h>
#include<set>
using namespace std;
 
#define ll long long
#define TC(_) ll (_); cin >> (_) ; while((_)-->0)
#define rep(i, a, b) for(ll (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(), (x).end()
#define dPrintVec(a) for(auto elem : a) cout << elem << ' '; cout << endl



int main(){
 
    TC(_){
        int n, l, r;
        cin >> n >> l >> r; // they are one indexed
        l--;
        r--; // make them zero indexed

        vector<int> a(n);
        rep(i, 0, n) cin >> a[i];
        vector<int> b(r+1, -1);
        vector<int> c(n-l, -1);
        rep(i, 0, n){
            if(i < l) b[i] = a[i];
            else if(i >= l && i <= r){
                b[i] = a[i];
                c[i-l] = a[i];
            }
            else c[i-l] = a[i];
        }
        // dPrintVec(a);
        // dPrintVec(b);
        // dPrintVec(c);

        sort(all(b));
        sort(all(c));

        int sum1 = 0, sum2 = 0;
        rep(i, 0, r-l+1) sum1 += b[i];
        rep(i, 0, r-l+1) sum2 += c[i];
        
        // cout << sum1 << " " << sum2 << endl;
        cout << min(sum1, sum2) << endl;
    }
}

Submission (verdict: Accepted):
#include<iostream>

#include <bits/stdc++.h>

#include<set>

using namespace std;

 

#define ll long long

#define TC(_) ll (_); cin >> (_) ; while((_)-->0)

#define rep(i, a, b) for(ll (i) = (a); (i) < (b); (i)++)

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

#define dPrintVec(a) for(auto elem : a) cout << elem << ' '; cout << endl







int main(){

 

    TC(_){

        int n, l, r;

        cin >> n >> l >> r; // they are one indexed

        l--;

        r--; // make them zero indexed



        vector<int> a(n);

        rep(i, 0, n) cin >> a[i];

        vector<int> b(r+1, -1);

        vector<int> c(n-l, -1);

        rep(i, 0, n){

            if(i < l) b[i] = a[i];

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

                b[i] = a[i];

                c[i-l] = a[i];

            }

            else c[i-l] = a[i];

        }

        // dPrintVec(a);

        // dPrintVec(b);

        // dPrintVec(c);



        sort(all(b));

        sort(all(c));



        ll sum1 = 0, sum2 = 0;

        rep(i, 0, r-l+1) sum1 += b[i];

        rep(i, 0, r-l+1) sum2 += c[i];

        

        // cout << sum1 << " " << sum2 << endl;

        cout << min(sum1, sum2) << endl;

    }

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Runtime error on test 2):
#include<iostream>

#include <bits/stdc++.h>

#include<set>

using namespace std;

 

#define ll long long

#define TC(_) ll (_); cin >> (_) ; while((_)-->0)

#define rep(i, a, b) for(ll (i) = (a); (i) < (b); (i)++)

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

#define dPrintVec(a) for(auto elem : a) cout << elem << ' '; cout << endl







int main(){

 

    TC(_){

        int n, l, r;

        cin >> n >> l >> r; // they are one indexed

        l--;

        r--; // make them zero indexed



        vector<int> a(n);

        rep(i, 0, n) cin >> a[i];

        vector<int> b(r+1, -1);

        vector<int> c(n-l, -1);

        rep(i, 0, n){

            if(i < l) b[i] = a[i];

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

                b[i] = a[i];

                c[i-l] = a[i];

            }

            else c[i-l] = a[i];

        }

        // dPrintVec(a);

        // dPrintVec(b);

        // dPrintVec(c);



        sort(all(b));

        sort(all(c));



        int sum1 = 0, sum2 = 0;

        rep(i, 0, r-l+1) sum1 += b[i];

        rep(i, 0, r-l+1) sum2 += c[i];

        

        // cout << sum1 << " " << sum2 << endl;

        cout << min(sum1, sum2) << endl;

    }

}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	int ans = 0;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		int sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		ans = max(ans, abs(sum));

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	int ans = 0;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		int sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		if (s == v.size()) {
			ans = max(ans, sum);
		}
		else {
			ans = max(ans, abs(sum));
		}

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	int ans;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		int sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		if (s == v.size()) {
			ans = max(ans, sum);
		}
		else {
			ans = sum;
		}

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	int ans = 0;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		int sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		if (s == v.size()) {
			ans = sum;
		}
		else {
			ans = max(ans, abs(sum));
		}

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	int ans = 0;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		int sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		if (s == v.size()) {
			ans = sum;
		}
		else {
			ans = max(ans, abs(sum));
		}

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Submission (verdict: Accepted):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	ll ans = 0;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		ll sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		if (s == v.size()) {
			ans = sum;
		}
		else {
			ans = max(ans, abs(sum));
		}

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	int ans = 0;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		int sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		ans = max(ans, abs(sum));

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	int ans = 0;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		int sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		if (s == v.size()) {
			ans = max(ans, sum);
		}
		else {
			ans = max(ans, abs(sum));
		}

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<unordered_map>
#include<stack>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int inf = 1e9;
const ll infl = 1e18;
void solve() {
	int n;
	cin >> n;

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

	int ans;
	int s = v.size();
	for (int i = 0;i < n ;i++) {
		int sum = 0;
		for (int j = 0;j < s;j++) {
			sum += v[j];
		}
		if (s == v.size()) {
			ans = max(ans, sum);
		}
		else {
			ans = sum;
		}

		for (int j = 0;j < s-1;j++) {
			v[j] = v[j + 1] - v[j];
		}
		s--;
	}

	cout << ans << endl;
	return;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 1):
def read_list():
    return list(map(int, input().split()))


def f(a, b, c):
    return (a ^ b) + (b ^ c) + (c ^ a)


class Solution:
    def solve(self):
        l, r = tuple(read_list())

        t = 1
        while t * 2 <= r:
            t *= 2

        rm = 0
        while l >= t:
            l -= t
            r -= t
            rm += t
            t //= 2

        if l < t - 1:
            print(l + rm, t - 1 + rm, t + rm)
        elif l == t - 1:
            print(l + rm, t + rm, r + rm)


if __name__ == "__main__":
    tests = int(input())
    for _ in range(tests):
        Solution().solve()


Submission (verdict: Accepted):
def read_list():
    return list(map(int, input().split()))


def f(a, b, c):
    return (a ^ b) + (b ^ c) + (c ^ a)


class Solution:
    def solve(self):
        l, r = tuple(read_list())
        L = l
        R = r
        lb = []
        rb = []
        for _ in range(32):
            lb.append(l % 2)
            l //= 2
            rb.append(r % 2)
            r //= 2
        for i in range(31, -1, -1):
            if lb[i] != rb[i]:
                assert lb[i] == 0 and rb[i] == 1
                X = L | ((1 << i) - 1)
                if L < X:
                    print(L, X, X + 1)
                else:
                    print(X, X + 1, X + 2)
                break


if __name__ == "__main__":
    tests = int(input())
    for _ in range(tests):
        Solution().solve()
Problem: 2057C - Trip to the Olympiad
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 1):
def read_list():
    return list(map(int, input().split()))


class Solution:
    def solve(self):
        l, r = tuple(read_list())

        t = 1
        while t * 2 <= r:
            t *= 2

        rm = 0
        while l >= t:
            l -= t
            r -= t
            rm += t
            t //= 2

        if l < t - 1:
            print(l + rm, t - 1 + rm, r + rm)
        elif l == t - 1:
            print(l + rm, t + rm, r + rm)


if __name__ == "__main__":
    tests = int(input())
    for _ in range(tests):
        Solution().solve()


Submission (verdict: Wrong answer on test 1):
def read_list():
    return list(map(int, input().split()))


def f(a, b, c):
    return (a ^ b) + (b ^ c) + (c ^ a)


class Solution:
    def solve(self):
        l, r = tuple(read_list())

        t = 1
        while t * 2 <= r:
            t *= 2

        rm = 0
        while l >= t:
            l -= t
            r -= t
            rm += t
            t //= 2

        if l < t - 1:
            print(l + rm, t - 1 + rm, t + rm)
        elif l == t - 1:
            print(l + rm, t + rm, r + rm)


if __name__ == "__main__":
    tests = int(input())
    for _ in range(tests):
        Solution().solve()
Problem: 2057C - Trip to the Olympiad
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 1):
def read_list():
    return list(map(int, input().split()))


class Solution:
    def solve(self):
        l, r = tuple(read_list())

        t = 1
        while t * 2 <= r:
            t *= 2

        rm = 0
        while l >= t:
            l -= t
            r -= t
            rm += t
            t //= 2

        if l < t - 1:
            print(l + rm, t - 1 + rm, r + rm)
        elif l == t - 1:
            print(l + rm, t + rm, r + rm)


if __name__ == "__main__":
    tests = int(input())
    for _ in range(tests):
        Solution().solve()
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void fns()
{
  ll n,k;
  cin>>n>>k;
  int maxi=1;
  vector<int>v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  map<ll,ll>mp;
  for(int i=0;i<n;i++){
    mp[v[i]]++;
  }
  vector<int>v1;
  for(auto it:mp){
    v1.push_back(it.second);
  }
  sort(v1.begin(),v1.end());
  if(k==0){
    cout<<v1.size()<<endl;
    return;
  }
  sort(v1.begin(),v1.end());
  ll s=0;
  int i=0;
  int cnt=0;
  while(s<k){
    s+=v1[i];
    cnt++;
    i++;
  }
   if(cnt==v.size()){
     cout<<1<<endl;
     return;
   }
  cout<<v1.size()-cnt<<endl;
}

int main() 
{ 
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int t=1;
   cin>>t;
   while(t--){
     fns();
   }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void fns()
{
  ll n,k;
  cin>>n>>k;
  int maxi=1;
  vector<int>v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  map<ll,ll>mp;
  for(int i=0;i<n;i++){
    mp[v[i]]++;
  }
  vector<int>v1;
  for(auto it:mp){
    v1.push_back(it.second);
  }
  sort(v1.begin(),v1.end());
  if(k==0){
    cout<<v1.size()<<endl;
    return;
  }
  sort(v1.begin(),v1.end());
  ll s=0;
  int i=0;
  int cnt=0;
  while(s<k){
    s+=v1[i];
    cnt++;
    i++;
  }
   if(cnt==v1.size()){
     cout<<1<<endl;
     return;
   }
  cout<<v1.size()-cnt<<endl;
}

int main() 
{ 
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int t=1;
   cin>>t;
   while(t--){
     fns();
   }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void fns()
{
  ll n,k;
  cin>>n>>k;
  int maxi=1;
  vector<int>v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  map<ll,ll>mp;
  for(int i=0;i<n;i++){
    mp[v[i]]++;
  }
  vector<int>v1;
  for(auto it:mp){
    v1.push_back(it.second);
  }
  sort(v1.begin(),v1.end());
  if(k==0){
    cout<<v1.size()<<endl;
    return;
  }
  sort(v1.begin(),v1.end());
  ll s=0;
  int i=0;
  int cnt=0;
  while(s<k){
    s+=v1[i];
    cnt++;
    i++;
  }
   if(cnt==v.size()){
     cout<<1<<endl;
     return;
   }
  cout<<v1.size()-cnt<<endl;
}

int main() 
{ 
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int t=1;
   cin>>t;
   while(t--){
     fns();
   }
}