ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: Python 3


Submission (verdict: Wrong answer on test 2):
import sys

# Fast Input
def inp(): return sys.stdin.readline().strip()
def inplist(): return list(map(int, inp().split()))

# Debugging function
def debug(*args):
    print("DEBUG:", *args, file=sys.stderr)

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = sum(a)
    while n > 1:
        n -= 1
        a = a[::-1]
        a = [a[i+1] - a[i] for i in range(n)]
        ans = max(ans, sum(a))
    print(ans)

def main():
    t = 1
    t = int(inp())  # Uncomment if multiple test cases exist
    for _ in range(t):
        solve()

if __name__ == "__main__":
    main()
Problem: 2062C - Cirno and Operations
Language: Python 3

Previous submission (verdict: Wrong answer on test 2):
import sys

# Fast Input
def inp(): return sys.stdin.readline().strip()
def inplist(): return list(map(int, inp().split()))

# Debugging function
def debug(*args):
    print("DEBUG:", *args, file=sys.stderr)

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    if n == 1:
        print(a[0])
        return
    ans = sum(a)
    while n > 1:
        a = a[::-1]
        n -= 1
        a = [a[i+1] - a[i] for i in range(n)]
        ans = max(ans, sum(a))
    print(ans)

def main():
    t = 1
    t = int(inp())  # Uncomment if multiple test cases exist
    for _ in range(t):
        solve()

if __name__ == "__main__":
    main()

Submission (verdict: Accepted):
import sys

# Fast Input
def inp(): return sys.stdin.readline().strip()
def inplist(): return list(map(int, inp().split()))

# Debugging function
def debug(*args):
    print("DEBUG:", *args, file=sys.stderr)

def solve():
    n = int(input())
    a = list(map(int, input().split()))

    if n == 1:
        print(a[0])
        return
    ans = sum(a)
    while n > 1:
        n -= 1
        a = a[::-1]
        a = [a[i+1] - a[i] for i in range(n)]
        ans = max(ans, abs(sum(a)))
    print(ans)

def main():
    t = 1
    t = int(inp())  # Uncomment if multiple test cases exist
    for _ in range(t):
        solve()

if __name__ == "__main__":
    main()
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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



using namespace std;



#define int long long

#define PB push_back

typedef vector<int> vi;

typedef vector<string> vs;



const int mod = 1e9 + 7;

const int inf = INT_MAX;



template<typename t>

vector<t> I(int n) {

    vector<t> vector;

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

        t input;

        cin >> input;

        vector.push_back(input);

    }



    return vector;

}



template<typename t>

void D(vector<t> vector) {

    for (auto i: vector) {

        cout << i << " ";

    }



    cout << "\n";

}





void solve() {

    int n, l , r;

    cin >> n >> l >> r;

    vi x = I<int>(n);

    vi first(x.begin(), x.begin() + r);

    vi second(x.begin() + l - 1, x.end());

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

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

    int sum1 = accumulate(first.begin(), first.begin() + r - l + 1, 0);

    int sum2 = accumulate(second.begin(), second.begin() + r - l + 1, 0);

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

}





int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }

}
Problem: 2063B - Subsequence Update
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 PB push_back

typedef vector<int> vi;

typedef vector<string> vs;



const int mod = 1e9 + 7;

const int inf = INT_MAX;



template<typename t>

vector<t> I(int n) {

    vector<t> vector;

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

        t input;

        cin >> input;

        vector.push_back(input);

    }



    return vector;

}



template<typename t>

void D(vector<t> vector) {

    for (auto i: vector) {

        cout << i << " ";

    }



    cout << "\n";

}





void solve() {

    int n, l , r;

    cin >> n >> l >> r;

    vi x = I<int>(n);

    vi first(x.begin(), x.begin() + r);

    vi second(x.begin() + l - 1, x.end());

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

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

    long long sum1 = accumulate(first.begin(), first.begin() + (r - l + 1), 0);

    long long sum2 = accumulate(second.begin(), second.begin() + (r - l + 1), 0);

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

}





int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }

}



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



using namespace std;



#define int long long

#define PB push_back

typedef vector<int> vi;

typedef vector<string> vs;



const int mod = 1e9 + 7;

const int inf = INT_MAX;



template<typename t>

vector<t> I(int n) {

    vector<t> vector;

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

        t input;

        cin >> input;

        vector.push_back(input);

    }



    return vector;

}



template<typename t>

void D(vector<t> vector) {

    for (auto i: vector) {

        cout << i << " ";

    }



    cout << "\n";

}





void solve() {

    int n, l , r;

    cin >> n >> l >> r;

    vi x = I<int>(n);

    vi first(x.begin(), x.begin() + r);

    vi second(x.begin() + l - 1, x.end());

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

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

    long long sum1 = accumulate(first.begin(), first.begin() + (r - l + 1), 0LL);

    long long sum2 = accumulate(second.begin(), second.begin() + (r - l + 1), 0LL);

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

}





int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }

}
Problem: 2063B - Subsequence Update
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 PB push_back

typedef vector<int> vi;

typedef vector<string> vs;



const int mod = 1e9 + 7;

const int inf = INT_MAX;



template<typename t>

vector<t> I(int n) {

    vector<t> vector;

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

        t input;

        cin >> input;

        vector.push_back(input);

    }



    return vector;

}



template<typename t>

void D(vector<t> vector) {

    for (auto i: vector) {

        cout << i << " ";

    }



    cout << "\n";

}





void solve() {

    int n, l , r;

    cin >> n >> l >> r;

    vi x = I<int>(n);

    vi first(x.begin(), x.begin() + r);

    vi second(x.begin() + l - 1, x.end());

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

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

    int sum1 = accumulate(first.begin(), first.begin() + r - l + 1, 0);

    int sum2 = accumulate(second.begin(), second.begin() + r - l + 1, 0);

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

}





int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }

}



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



using namespace std;



#define int long long

#define PB push_back

typedef vector<int> vi;

typedef vector<string> vs;



const int mod = 1e9 + 7;

const int inf = INT_MAX;



template<typename t>

vector<t> I(int n) {

    vector<t> vector;

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

        t input;

        cin >> input;

        vector.push_back(input);

    }



    return vector;

}



template<typename t>

void D(vector<t> vector) {

    for (auto i: vector) {

        cout << i << " ";

    }



    cout << "\n";

}





void solve() {

    int n, l , r;

    cin >> n >> l >> r;

    vi x = I<int>(n);

    vi first(x.begin(), x.begin() + r);

    vi second(x.begin() + l - 1, x.end());

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

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

    long long sum1 = accumulate(first.begin(), first.begin() + (r - l + 1), 0);

    long long sum2 = accumulate(second.begin(), second.begin() + (r - l + 1), 0);

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

}





int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);



    int t;

    cin >> t;

    while (t--) {

        solve();

    }

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; int a[n+1];

		for(int i=1;i<=n;i++) a[i]=i%2;

		if(n%2||(y-x)%2==0) a[x]=2;

		for(int i=1;i<=n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; vector<int> a(n+1);

		for(int i=1;i<=n;i++) a[(x+i-1)%n]=i%2;

		if(n%2||(x-y)%2==0) a[x]=2;

		for(int i=1;i<=n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}

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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; x--; y--; vector<int> a(n);

		for(int i=0;i<n;i++) a[(x+i)%n]=i%2;

		if(n%2||(x-y)%2==0) a[x]=2;

		for(int i=0;i<n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; vector<int> a(n+1);

		for(int i=1;i<=n;i++) a[(x+i)%n]=i%2;

		if(n%2||(x-y)%2==0) a[x]=2;

		for(int i=1;i<=n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}

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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; vector<int> a(n+1);

		for(int i=1;i<=n;i++) a[(x+i-1)%n]=i%2;

		if(n%2||(x-y)%2==0) a[x]=2;

		for(int i=1;i<=n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; int a[n+1];

		for(int i=1;i<=n;i++) a[i]=i%2;

		if(n%2||(y-x)%2==0) a[x]=2;

		for(int i=1;i<=n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}

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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; int a[n+1];

		for(int i=1;i<=n;i++) a[(x+i)%n]=i%2;

		if(n%2||(y-x)%2==0) a[x]=2;

		for(int i=1;i<=n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; int a[n+1];

		for(int i=1;i<=n;i++) a[(x+i)%n]=i%2;

		if(n%2||(y-x)%2==0) a[x]=2;

		for(int i=1;i<=n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}

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

using namespace std;

int main(){

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

	int t; cin>>t;

	while(t--){

		int n,x,y; cin>>n>>x>>y; vector<int> a(n+1);

		for(int i=1;i<=n;i++) a[(x+i)%n]=i%2;

		if(n%2||(x-y)%2==0) a[x]=2;

		for(int i=1;i<=n;i++) cout<<a[i]<<" ";

		cout<<endl;

	}

	return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

string s;

cin >> s;



int n = (int)s.size();

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

int val = s[i] - '0';

int idx = i;

for(int j = i; j < min(i + 9, n); j ++){

if(s[i] == '0') continue;

int num = (s[j] - '0') - j + i;

if(val < num){

val = num;

idx = j;

}

}

int number = s[idx] - idx + i;

for(int j = idx ; j > i; j --){

s[j] = s[j - 1];

}

s[i] = number;

}

cout << s <<"\n";

}



signed main() {

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;

// t=1;

while (t--) {

solve();

}

}

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

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

string s;

cin >> s;



int n = (int)s.size();

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

int val = s[i] - '0';

int idx = i;

for(int j = i; j < min(i + 9, n); j ++){

if(s[j] == '0') continue;

int num = (s[j] - '0') - j + i;

if(val < num){

val = num;

idx = j;

}

}

int number = s[idx] - idx + i;

for(int j = idx ; j > i; j --){

s[j] = s[j - 1];

}

s[i] = number;

}

cout << s <<"\n";

}



signed main() {

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;

// t=1;

while (t--) {

solve();

}

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

string s;

cin >> s;



int n = (int)s.size();

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

if(s[i] == '0') continue;

int val = s[i] - '0';

int idx = i;

for(int j = i; j < min(i + 9, n); j ++){

if(s[i] == '0') continue;

int num = (s[j] - '0') - j + i;

if(val < num){

val = num;

idx = j;

}

}

int number = s[idx] - idx + i;

for(int j = idx ; j > i; j --){

s[j] = s[j - 1];

}

s[i] = number;

}

cout << s <<"\n";

}



signed main() {

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;

// t=1;

while (t--) {

solve();

}

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

string s;

cin >> s;



int n = (int)s.size();

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

if(s[i] == '0') continue;

int val = s[i] - '0';

int idx = i;

for(int j = i; j < min(i + 9, n); j ++){

if(s[i] == '0') continue;

int num = (s[j] - '0') - j + i;

if(val < num){

val = num;

idx = j;

}

}

int number = s[idx] - idx + i;

for(int j = idx ; j > i; j --){

s[j] = s[j - 1];

}

s[i] = number;

}

cout << s <<"\n";

}



signed main() {

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;

// t=1;

while (t--) {

solve();

}

}

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

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

string s;

cin >> s;



int n = (int)s.size();

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

int val = s[i] - '0';

int idx = i;

for(int j = i; j < min(i + 9, n); j ++){

if(s[i] == '0') continue;

int num = (s[j] - '0') - j + i;

if(val < num){

val = num;

idx = j;

}

}

int number = s[idx] - idx + i;

for(int j = idx ; j > i; j --){

s[j] = s[j - 1];

}

s[i] = number;

}

cout << s <<"\n";

}



signed main() {

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;

// t=1;

while (t--) {

solve();

}

}
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;

#define int long long

const int INF = 1e18;



void solve(){

    int n;



    cin >> n;



    vector<int> arr(n);

    for(auto &i : arr){

        cin >> i;

    }



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

        arr[i] = min(arr[i], arr[i + 1]) - arr[i];

        arr[i + 1] = min(arr[i], arr[i + 1]) - arr[i + 1];

    }



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

        if(arr[i] > arr[i + 1]){

            cout <<"NO\n";

            return;

        }

    }



    cout<<"YES\n";



}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    // t=1;

    while (t--) {

        solve();

    }

}

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

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

    int n;



    cin >> n;



    vector<int> arr(n);

    for(auto &i : arr){

        cin >> i;

    }



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

        int val = min(arr[i], arr[i + 1]);

        arr[i] = arr[i] - val;

        arr[i + 1] = arr[i + 1] - val;

    }



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

        if(arr[i] > arr[i + 1]){

            cout <<"NO\n";

            return;

        }

    }



    cout<<"YES\n";



}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    // t=1;

    while (t--) {

        solve();

    }

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


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

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

    int n;



    cin >> n;



    vector<int> arr(n);

    for(auto &i : arr){

        cin >> i;

    }



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

        arr[i] = min(arr[i], arr[i + 1]) - arr[i];

        arr[i + 1] = min(arr[i], arr[i + 1]) - arr[i + 1];

    }



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

        if(arr[i] > arr[i + 1]){

            cout <<"NO\n";

            return;

        }

    }



    cout<<"YES\n";



}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    // t=1;

    while (t--) {

        solve();

    }

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

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

    int n;



    cin >> n;



    vector<int> arr(n);

    for(auto &i : arr){

        cin >> i;

    }



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

        arr[i] = min(arr[i], arr[i + 1]) - arr[i];

        arr[i + 1] = min(arr[i], arr[i + 1]) - arr[i + 1];

    }



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

        if(arr[i] > arr[i + 1]){

            cout <<"NO\n";

            return;

        }

    }



    cout<<"YES\n";



}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    // t=1;

    while (t--) {

        solve();

    }

}

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

using namespace std;

#define int long long

const int INF = 1e18;



void solve(){

    int n;



    cin >> n;



    vector<int> arr(n);

    for(auto &i : arr){

        cin >> i;

    }



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

        arr[i] = min(arr[i], arr[i + 1]) - arr[i];

        arr[i + 1] = min(arr[i], arr[i + 1]) - arr[i + 1];

    }



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

        if(arr[i] > arr[i + 1]){

            cout <<"NO\n";

            return;

        }

    }



    cout<<"YES\n";



}



signed main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);



    int t;

    cin >> t;

    // t=1;

    while (t--) {

        solve();

    }

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


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        sort(a, a + n);
        int y = a[0];
        int countt = 1;
        int b[n] = {0};
        for (int i = 1; i < n; i++)
        {
            if(y == a[i])
            {
                countt++;
            }
            else
            {
                b[countt - 1]++;
                y = a[i];
                countt = 1;
            }
        }
        b[countt - 1]++;
        int ans = 0;
        for (int i = 0; i < int(sizeof(b) / sizeof(int)); i++)
        {
            ans += b[i];
        }
        // cout << ans << endl;
        for (int i = 0; i < int(sizeof(b) / sizeof(int)); i++)
        {
            if(k == 0)
            {
                break;
            }
            if(k < b[i])
            {
                ans -= k;
            }
            else
            {
                k -= b[i]*(i+1);
                ans -= b[i];
            }
        }
        if(ans == 0)
        {
            ans = 1;
        }
        cout << ans << endl;
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        sort(a, a + n);
        int y = a[0];
        int countt = 1;
        int b[n] = {0};
        for (int i = 1; i < n; i++)
        {
            if(y == a[i])
            {
                countt++;
            }
            else
            {
                b[countt - 1]++;
                y = a[i];
                countt = 1;
            }
        }
        b[countt - 1]++;
        int ans = 0;
        for (int i = 0; i < int(sizeof(b) / sizeof(int)); i++)
        {
            ans += b[i];
        }
        // cout << ans << endl;
        for (int i = 0; i < int(sizeof(b) / sizeof(int)); i++)
        {
            if(k == 0)
            {
                break;
            }
            if(k < b[i])
            {
                ans -= k;
            }
            else
            {
                k -= b[i]*(i+1);
                ans -= b[i];
            }
        }
        if(ans == 0)
        {
            ans = 1;
        }
        cout << ans << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        sort(a, a + n);
        int y = a[0];
        int countt = 1;
        int b[n] = {0};
        for (int i = 1; i < n; i++)
        {
            if(y == a[i])
            {
                countt++;
            }
            else
            {
                b[countt - 1]++;
                y = a[i];
                countt = 1;
            }
        }
        b[countt - 1]++;
        int ans = 0;
        for (int i = 0; i < int(sizeof(b) / sizeof(int)); i++)
        {
            ans += b[i];
        }
        // cout << ans << endl;
        for (int i = 0; i < int(sizeof(b) / sizeof(int)); i++)
        {
            if(k == 0)
            {
                break;
            }
            if(k < b[i]*(i+1))
            {
                ans -= k/(i+1);
            }
            else
            {
                k -= b[i]*(i+1);
                ans -= b[i];
            }
        }
        if(ans == 0)
        {
            ans = 1;
        }
        cout << ans << endl;
    }
    return 0;
}