ShaysXIA/CodeInsightBench huggingface dataset:
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==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();
   }
}

Submission (verdict: Accepted):
#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+1);
  map<ll,ll>mp;
  for(int i=1;i<=n;i++){
    cin>>v[i];
     mp[v[i]]++;
  }
  vector<int>v1;
  for(auto it:mp){
    v1.push_back(it.second);
  }
  sort(v1.begin(),v1.end());
  int x = v1.size();
    for(int i=0;i<v1.size(); i++){
        if(k>=v1[i]) k-= v1[i],x--;
        else break;
    }
    cout<<max(x,1)<<endl;
}

int main() 
{ 
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int t=1;
   cin>>t;
   while(t--){
     fns();
   }
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve() {
    ll n;
    cin >> n;
    vector <ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = n - 2; i > 0; i--){
        ll d = min(a[i], a[i-1]);
        ll k = (a[i+1] / d) + 1;
        a[i] -= (k * d);
        a[i-1] -= (k * d);
        // cout << a[i] << " ";
    }
    bool ok = true;
    for(int i = 1; i < n; i++){
        // cout << a[i] << " ";
        if(a[i] < a[i-1]) ok = false;
    }
    if(ok) cout << "YES\n";
    else cout << "NO\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1, st = clock();
    cin >> t;
    while(t--){
        solve();
    }
    // cerr << "[Time : " << 1000 * (clock() - st) / CLOCKS_PER_SEC << " ms]\n";
    return 0;
}

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

void solve() {
    ll n;
    cin >> n;
    vector <ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = n - 2; i > 0; i--){
        ll d = min(a[i], a[i-1]);
        if(d == 0) continue;
        ll k = (abs(a[i+1] - a[i]) + d - 1) / d;
        if(a[i] > a[i+1]){
            a[i] -= (k * d);
            a[i-1] -= (k * d);
            // cout << "k";
        }
        // cout << a[i] << " ";
    }
    bool ok = true;
    for(int i = 1; i < n; i++){
        // cout << a[i] << " ";
        if(a[i] < a[i-1]) ok = false;
    }
    if(ok) cout << "YES\n";
    else cout << "NO\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1, st = clock();
    cin >> t;
    while(t--){
        solve();
    }
    // cerr << "[Time : " << 1000 * (clock() - st) / CLOCKS_PER_SEC << " ms]\n";
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve() {
    ll n;
    cin >> n;
    vector <ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = n - 2; i > 0; i--){
        ll d = min(a[i], a[i-1]);
        ll k = (a[i+1] / d) + 1;
        a[i] -= (k * d);
        a[i-1] -= (k * d);
        // cout << a[i] << " ";
    }
    bool ok = true;
    for(int i = 1; i < n; i++){
        // cout << a[i] << " ";
        if(a[i] < a[i-1]) ok = false;
    }
    if(ok) cout << "YES\n";
    else cout << "NO\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1, st = clock();
    cin >> t;
    while(t--){
        solve();
    }
    // cerr << "[Time : " << 1000 * (clock() - st) / CLOCKS_PER_SEC << " ms]\n";
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

void solve() {
    ll n;
    cin >> n;
    vector <ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = n - 2; i > 0; i--){
        ll d = min(a[i], a[i-1]);
        if(d == 0) continue;
        ll k = (abs(a[i+1] - a[i]) + d - 1) / d;
        if(a[i] > a[i+1]){
            a[i] -= (k * d);
            a[i-1] -= (k * d);
            // cout << "k";
        }
        // cout << a[i] << " ";
    }
    bool ok = true;
    for(int i = 1; i < n; i++){
        // cout << a[i] << " ";
        if(a[i] < a[i-1]) ok = false;
    }
    if(ok) cout << "YES\n";
    else cout << "NO\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1, st = clock();
    cin >> t;
    while(t--){
        solve();
    }
    // cerr << "[Time : " << 1000 * (clock() - st) / CLOCKS_PER_SEC << " ms]\n";
    return 0;
}

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

void solve() {
    ll n;
    cin >> n;
    vector <ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n - 1; i++){
        ll d = min(a[i], a[i+1]);
        a[i] -= d;
        a[i+1] -= d;
    }
    bool ok = true;
    for(int i = 1; i < n; i++){
        // cout << a[i] << " ";
        if(a[i] < a[i-1]) ok = false;
    }
    if(ok) cout << "YES\n";
    else cout << "NO\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1, st = clock();
    cin >> t;
    while(t--){
        solve();
    }
    // cerr << "[Time : " << 1000 * (clock() - st) / CLOCKS_PER_SEC << " ms]\n";
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>

#include <climits>



using namespace std;



int main (){

ios_base::sync_with_stdio(0);

cin.tie(0);

cout.tie(0);



int t;

cin >> t;

while (t--) {

string s;

cin >> s;

for (int i = 0; i < s.size(); i++) {

int mx = 0, k;

for (int j = i + 1; j <= 9 - (s[i] - '0'); j++) {

if (s[j] - '0' - (s[i] - '0') - (j - i) > mx) {

mx = s[j] - '0' - (s[i] - '0') - (j - i);

k = j;

}

}

if (mx > 0) {

for (int j = k; j >= i+1; j--) {

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

}

s[i] += mx;

}

}

for (int i = 0; i < s.size(); i++) {

cout << s[i];

}

cout << "\n";

}

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>

#include <climits>



using namespace std;



int main (){

ios_base::sync_with_stdio(0);

cin.tie(0);

cout.tie(0);



int t;

cin >> t;

while (t--) {

string s;

cin >> s;

for (int i = 0; i < s.size(); i++) {

int mx = 0, k;

for (int j = i + 1; j <= 9 - (s[i] - '0'); j++) {

if (s[j] - '0' - (s[i] - '0') - (j - i) > mx) {

mx = s[j] - '0' - (s[i] - '0') - (j - i);

k = j;

}

}

if (mx > 0) {

for (int j = k; j >= i+1; j--) {

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

}

s[i] += mx;

}

}

for (int i = 0; i < s.size(); i++) {

cout << s[i];

}

cout << "\n";

}

}



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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>

#include <climits>



using namespace std;



int main (){

ios_base::sync_with_stdio(0);

cin.tie(0);

cout.tie(0);



int t;

cin >> t;

while (t--) {

string s;

cin >> s;

for (int i = 0; i < s.size() - 1; i++) {

int mx = 0, k, t;

// t = min(9 - (s[i] - '0'), )

for (int j = i + 1; j <= i + 9 - (s[i] - '0'); j++) {

if (s[j] - '0' - (s[i] - '0') - (j - i) > mx) {

mx = s[j] - '0' - (s[i] - '0') - (j - i);

k = j;

}

}

if (mx > 0) {

for (int j = k; j >= i+1; j--) {

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

}

s[i] += mx;

}

}

for (int i = 0; i < s.size(); i++) {

cout << s[i];

}

cout << "\n";

}

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>

#include <climits>



using namespace std;



int main (){

ios_base::sync_with_stdio(0);

cin.tie(0);

cout.tie(0);



int t;

cin >> t;

while (t--) {

string s;

cin >> s;

for (int i = 0; i < s.size() - 1; i++) {

int mx = 0, k, t;

// t = min(9 - (s[i] - '0'), )

for (int j = i + 1; j <= i + 9 - (s[i] - '0'); j++) {

if (s[j] - '0' - (s[i] - '0') - (j - i) > mx) {

mx = s[j] - '0' - (s[i] - '0') - (j - i);

k = j;

}

}

if (mx > 0) {

for (int j = k; j >= i+1; j--) {

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

}

s[i] += mx;

}

}

for (int i = 0; i < s.size(); i++) {

cout << s[i];

}

cout << "\n";

}

}



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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>

#include <climits>



using namespace std;



int main (){

ios_base::sync_with_stdio(0);

cin.tie(0);

cout.tie(0);



int t;

cin >> t;

while (t--) {

string s;

cin >> s;

for (int i = 0; i < s.size() - 1; i++) {

int mx = 0, k = 0, t;

t = min(i + 9 - (s[i] - '0'), (int)s.size() - 1);

for (int j = i + 1; j <= t; j++) {

if (s[j] - '0' - (s[i] - '0') - (j - i) > mx) {

mx = s[j] - '0' - (s[i] - '0') - (j - i);

k = j;

}

}

if (mx > 0) {

for (int j = k; j >= i+1; j--) {

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

}

s[i] += mx;

}

}

for (int i = 0; i < s.size(); i++) {

cout << s[i];

}

cout << "\n";

}

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

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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>



using namespace std;



long long a[300001];



int main (){

    // freopen("censor.in", "r", stdin);

    // freopen("censor.out", "w", stdout);

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

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

            cin >> a[i];

        }

        int k = 0;

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

            if (a[i] >= a[i-1]) {

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

            }

            else {

                if (a[i-1] > a[i]) {

                    cout << "No" <<"\n";

                    k = 1;

                    break;

                }

            }

        }

        if (k == 0) {

            cout << "yes" <<"\n";

        }

    }



}



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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>



using namespace std;



long long a[300001];



int main (){

    // freopen("censor.in", "r", stdin);

    // freopen("censor.out", "w", stdout);

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

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

            cin >> a[i];

        }

        int k = 0;

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

            if (a[i] >= a[i-1]) {

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

            }

            else {

                if (a[i-1] > a[i]) {

                    cout << "No" <<"\n";

                    k = 1;

                    break;

                }

            }

        }

        if (k == 0) {

            cout << "yes" <<"\n";

        }

    }



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

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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>



using namespace std;



long long a[300001];



int main (){

    // freopen("censor.in", "r", stdin);

    // freopen("censor.out", "w", stdout);

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

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

            cin >> a[i];

        }

        int k = 0;

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

            if (a[i] >= a[i-1]) {

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

            }

            else {

                if (a[i-1] - a[i-2] > a[i]) {

                    cout << "No" <<"\n";

                    k = 1;

                    break;

                }

            }

        }

        if (k == 0) {

            cout << "yes" <<"\n";

        }

    }



}



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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>



using namespace std;



long long a[300001];



int main (){

    // freopen("censor.in", "r", stdin);

    // freopen("censor.out", "w", stdout);

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

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

            cin >> a[i];

        }

        int k = 0;

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

            if (a[i] >= a[i-1]) {

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

            }

            else {

                if (a[i-1] > a[i]) {

                    cout << "No" <<"\n";

                    k = 1;

                    break;

                }

            }

        }

        if (k == 0) {

            cout << "yes" <<"\n";

        }

    }



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


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

#include <algorithm>

#include <cmath>

#include <vector>

#include <map>

#include <set>

#include <stack>

#include <string>

#include <queue>

#include <numeric>

#include <bitset>

#include <stdio.h>

#include <time.h>

#include <assert.h>

#include <unordered_map>



using namespace std;



long long a[300001];



int main (){

    // freopen("censor.in", "r", stdin);

    // freopen("censor.out", "w", stdout);

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    int t;

    cin >> t;

    while (t--) {

        int n;

        cin >> n;

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

            cin >> a[i];

        }

        int k = 0;

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

            if (a[i] >= a[i-1]) {

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

            }

            else {

                if (a[i-1] - a[i-2] > a[i]) {

                    cout << "No" <<"\n";

                    k = 1;

                    break;

                }

            }

        }

        if (k == 0) {

            cout << "yes" <<"\n";

        }

    }



}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#define ll long long
#define endl "\n"
//#define debug(x) cout<<x<<endl;
#define debug(x) ;
using namespace std;
ll sum(vector<ll>arr) {
	ll answer = 0;
	for (auto val : arr) {
		answer += val;
	}
	return answer;
}
void print(vector<ll>arr) {
	for (auto point : arr) {
		cout << point << endl;
	}
}
ll func(vector<ll>arr, ll times) {
	if (times == 12) {
		return sum(arr);
	}
	else {
		vector<ll>_1, _2;
		_1 = arr;
		reverse(_1.begin(), _1.end());
		for (ll q = 1; q < arr.size(); ++q) {
			_2.push_back(arr[q] - arr[q - 1]);
		}
		return max(func(arr, times + 1), max(func(_1, times + 1), func(_2, times + 1)));
	}
}
void solve() {
	ll n;
	cin >> n;
	vector<ll>arr(n);
	for (ll q = 0; q < n; ++q) {
		cin >> arr[q];
	}
	vector<ll>now = arr;
	//for (ll q = 1; q <= n; ++q) {
	//	//cout << sum(now) << endl;
	//	vector<ll>_1;
	//	for (ll i = 1; i < now.size(); ++i) {
	//		_1.push_back(now[i] - now[i - 1]);
	//	}
	//	now = _1;
	//}
	while (now.size() > 1) {
		vector<ll>_1;
		for (ll i = 1; i < now.size(); ++i) {
			_1.push_back(now[i] - now[i - 1]);
		}
		now = _1;
	}
	cout << max(sum(arr), abs(sum(now))) << endl;
}
//while (now.size() > 1) {
//	vector<ll>_1;
//	for (ll i = 1; i < now.size(); ++i) {
//		_1.push_back(now[i] - now[i - 1]);
//	}
//	now = _1;
//}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#define ll long long
#define endl "\n"
//#define debug(x) cout<<x<<endl;
#define debug(x) ;
using namespace std;
ll sum(vector<ll>arr) {
	ll answer = 0;
	for (auto val : arr) {
		answer += val;
	}
	return answer;
}
void print(vector<ll>arr) {
	for (auto point : arr) {
		cout << point << endl;
	}
}
ll func(vector<ll>arr, ll times) {
	if (times == 12) {
		return sum(arr);
	}
	else {
		vector<ll>_1, _2;
		_1 = arr;
		reverse(_1.begin(), _1.end());
		for (ll q = 1; q < arr.size(); ++q) {
			_2.push_back(arr[q] - arr[q - 1]);
		}
		return max(func(arr, times + 1), max(func(_1, times + 1), func(_2, times + 1)));
	}
}
void solve() {
	ll n;
	cin >> n;
	vector<ll>arr(n);
	for (ll q = 0; q < n; ++q) {
		cin >> arr[q];
	}
	vector<ll>now = arr;
	//for (ll q = 1; q <= n; ++q) {
	//	//cout << sum(now) << endl;
	//	vector<ll>_1;
	//	for (ll i = 1; i < now.size(); ++i) {
	//		_1.push_back(now[i] - now[i - 1]);
	//	}
	//	now = _1;
	//}
	while (now.size() > 1) {
		vector<ll>_1;
		for (ll i = 1; i < now.size(); ++i) {
			_1.push_back(now[i] - now[i - 1]);
		}
		now = _1;
	}
	cout << max(sum(arr), abs(sum(now))) << endl;
}
//while (now.size() > 1) {
//	vector<ll>_1;
//	for (ll i = 1; i < now.size(); ++i) {
//		_1.push_back(now[i] - now[i - 1]);
//	}
//	now = _1;
//}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
}

Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#define ll long long
#define endl "\n"
//#define debug(x) cout<<x<<endl;
#define debug(x) ;
using namespace std;
ll sum(vector<ll>arr) {
	ll answer = 0;
	for (auto val : arr) {
		answer += val;
	}
	return answer;
}
void print(vector<ll>arr) {
	for (auto point : arr) {
		cout << point << endl;
	}
}
ll func(vector<ll>arr, ll times) {
	if (times == 12) {
		return sum(arr);
	}
	else {
		vector<ll>_1, _2;
		_1 = arr;
		reverse(_1.begin(), _1.end());
		for (ll q = 1; q < arr.size(); ++q) {
			_2.push_back(arr[q] - arr[q - 1]);
		}
		return max(func(arr, times + 1), max(func(_1, times + 1), func(_2, times + 1)));
	}
}
void solve() {
	ll n;
	cin >> n;
	vector<ll>arr(n);
	for (ll q = 0; q < n; ++q) {
		cin >> arr[q];
	}
	vector<ll>now = arr;
	//for (ll q = 1; q <= n; ++q) {
	//	//cout << sum(now) << endl;
	//	vector<ll>_1;
	//	for (ll i = 1; i < now.size(); ++i) {
	//		_1.push_back(now[i] - now[i - 1]);
	//	}
	//	now = _1;
	//}
	while (now.size() > 1) {
		vector<ll>_1;
		for (ll i = 1; i < now.size(); ++i) {
			_1.push_back(now[i] - now[i - 1]);
		}
		now = _1;
	}
	cout << max(abs(sum(arr)), abs(sum(now))) << endl;
}
//while (now.size() > 1) {
//	vector<ll>_1;
//	for (ll i = 1; i < now.size(); ++i) {
//		_1.push_back(now[i] - now[i - 1]);
//	}
//	now = _1;
//}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long t;
    cin >> t;

    while (t--) {
        long long n, k;
        cin >> n >> k;
        vector<long long> array(n);
        for (long long i = 0; i < n; i++) {
            cin >> array[i];
        }

        unordered_map<long long, long long> frequency;
        for (long long num : array) {
            frequency[num]++;
        }

        vector<pair<long long, long long>> freqVec(frequency.begin(), frequency.end());
        sort(freqVec.begin(), freqVec.end(), [](const pair<long long, long long>& a, const pair<long long, long long>& b) {
            return a.second < b.second;
        });

        long long sum = 0;
        long long removedBlocks = 0;

        for (const auto& pair : freqVec) {
            if (sum + pair.second > k) break;
            sum += pair.second;
            removedBlocks++;
        }

        if (k >= n) {
            cout << 1 << endl;
        } else {
            cout << freqVec.size() - removedBlocks << endl;
        }
    }

    return 0;
}