ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
// Author: Youssef ben youssef
// Template for Competitive Programming

#include<utility>
#include<map>
#include<unordered_map>
#include<vector>
#include<set>
#include<ios>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<long long>;
using pi = pair<int, int>;
using pll = pair<long long, long long>;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const ld EPS = 1e-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
ll mod_exp(ll base, ll exp, ll mod = MOD) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = (res * base) % mod;
        base = (base * base) % mod;
        exp >>= 1;
    }
    return res;
}
ll min(ll a,int b) { if (a<b) return a; return b; }
ll min(int a,ll b) { if (a<b) return a; return b; }
ll max(ll a,int b) { if (a>b) return a; return b; }
ll max(int a,ll b) { if (a>b) return a; return b; }
ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll exgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = exgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }
string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }
bool prime(ll a) { if (a==1) return 0; for (int i=2;i<=round(sqrt(a));++i) if (a%i==0) return 0; return 1; }
void yes() { cout<<"YES\n"; }
void no() { cout<<"NO\n"; }
template <typename T>
void read(vector<T>& v) {
    for (auto& x : v) cin >> x;
}

template <typename T>
void print(const vector<T>& v) {
    for (const auto& x : v) cout << x << ' ';
    cout << '\n';
}
void solve() {
    
}

int main() {
    fastio;
    int t;
    cin >> t;
    while (t--)
    {
        string s;cin >> s;
        ll sum=0,twos=0,threes=0;
        for (int i = 0; i < s.size(); i++)
        {
            sum+= s[i]-'0';
            if(s[i]-'0'==2)twos++;
            if(s[i]-'0'==3)threes++;
        }
        int f=0;
        for (int i = 0; i <min(10,twos+1); i++)
        {
            for (int j = 0; j < min(10,threes+1); j++)
            {
                if((sum+i*2+6*j)%9==0){yes();f=1;break;}
                if(f)break;
            }
        }
        if(!f)no();
        
        

    }
    
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#pragma comment(linker, "/STACK:40000000")

#define _CRT_SECURE_NO_WARNINGS

#include<set>

#include<map>

#include<unordered_map>

#include<iostream>

#include<queue>

#include<sstream>

#include<cstdlib>

#include<cstdio>

#include<vector>

#include<string>

#include<cstring>

#include<algorithm>

#include<cassert>

#include<ctime>

using namespace std;

typedef vector<int>VI; typedef vector<VI>VVI;

typedef vector<string>VS;

typedef pair<int, int>PII;

#define FOR(i,n) for((i)=0;(i)<(n);(i)++)

#define FORN(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define FOR1(i,n) for((i)=1;(i)<=(n);(i)++)

#define BE(a) ((a).begin()),((a).end())

#define SI(a) ((int)(a).size())

#define CLR(a) memset(a,0,sizeof(a))

#define PB push_back

#define MP make_pair



int n, x, y;

int a[200005];



void Solve()

{

    int i;

    FOR(i, n) a[i] = i % 2;

    if (n % 2) a[n - 1] = 2;

    if ((x + 1) % n == y || (y + 1) % n == x || a[x] != a[y]) return;

    a[x ? x : y] = 2;

}



void WriteAnswer()

{

    int i;

    FOR(i, n)

    {

        if (i) cout << " ";

        cout << a[i];

    }

    cout << endl;

}



void ReadInput()

{

    cin >> n >> x >> y;

    x--, y--;

}



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0), cout.tie(0);

#if !ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

#endif

    int t;

    for (cin >> t; t > 0; t--)

    {

        ReadInput();

        Solve();

        WriteAnswer();

    }

    return 0;

}



Submission (verdict: Wrong answer on test 1):
#pragma comment(linker, "/STACK:40000000")

#define _CRT_SECURE_NO_WARNINGS

#include<set>

#include<map>

#include<unordered_map>

#include<iostream>

#include<queue>

#include<sstream>

#include<cstdlib>

#include<cstdio>

#include<vector>

#include<string>

#include<cstring>

#include<algorithm>

#include<cassert>

#include<ctime>

using namespace std;

typedef vector<int>VI; typedef vector<VI>VVI;

typedef vector<string>VS;

typedef pair<int, int>PII;

#define FOR(i,n) for((i)=0;(i)<(n);(i)++)

#define FORN(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define FOR1(i,n) for((i)=1;(i)<=(n);(i)++)

#define BE(a) ((a).begin()),((a).end())

#define SI(a) ((int)(a).size())

#define CLR(a) memset(a,0,sizeof(a))

#define PB push_back

#define MP make_pair



int n, x, y;

int a[200005];



void Solve()

{

    int i;

    FOR(i, n) a[i] = i % 2;

    if (n % 2) a[n - 1] = 2;

    if ((x + 1) % n == y || (y + 1) % n == x) return;

    if (n % 2)

    {

        FOR(i, n) a[(x + i) % n] = i % 2;

        a[x] = 2;

    }

    else a[x] = 2;

}



void WriteAnswer()

{

    int i;

    FOR(i, n)

    {

        if (i) cout << " ";

        cout << a[i];

    }

    cout << endl;

}



void ReadInput()

{

    cin >> n >> x >> y;

    x--, y--;

}



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0), cout.tie(0);

#if !ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

#endif

    int t;

    for (cin >> t; t > 0; t--)

    {

        ReadInput();

        Solve();

        WriteAnswer();

    }

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#pragma comment(linker, "/STACK:40000000")

#define _CRT_SECURE_NO_WARNINGS

#include<set>

#include<map>

#include<unordered_map>

#include<iostream>

#include<queue>

#include<sstream>

#include<cstdlib>

#include<cstdio>

#include<vector>

#include<string>

#include<cstring>

#include<algorithm>

#include<cassert>

#include<ctime>

using namespace std;

typedef vector<int>VI; typedef vector<VI>VVI;

typedef vector<string>VS;

typedef pair<int, int>PII;

#define FOR(i,n) for((i)=0;(i)<(n);(i)++)

#define FORN(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define FOR1(i,n) for((i)=1;(i)<=(n);(i)++)

#define BE(a) ((a).begin()),((a).end())

#define SI(a) ((int)(a).size())

#define CLR(a) memset(a,0,sizeof(a))

#define PB push_back

#define MP make_pair



int n, x, y;

int a[200005];



void Solve()

{

    int i;

    FOR(i, n) a[i] = i % 2;

    if (n % 2) a[n - 1] = 2;

    if ((x + 1) % n == y || (y + 1) % n == x || a[x] != a[y]) return;

    a[x ? x : y] = 2;

}



void WriteAnswer()

{

    int i;

    FOR(i, n)

    {

        if (i) cout << " ";

        cout << a[i];

    }

    cout << endl;

}



void ReadInput()

{

    cin >> n >> x >> y;

    x--, y--;

}



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0), cout.tie(0);

#if !ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

#endif

    int t;

    for (cin >> t; t > 0; t--)

    {

        ReadInput();

        Solve();

        WriteAnswer();

    }

    return 0;

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

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int t;cin>>t;
	while(t--){
		int n,k;cin>>n>>k;
		int st[n],sp[n]={0};
		for(int i=0;i<n;i++){
			cin>>st[i];
		}
		sort(st,st+n);
		int p=0;
		sp[0]=1;
		for(int i=1;i<n;i++){
			if(st[i]==st[i-1]){
				sp[p]+=1;
			}
			else{
				p++;
				sp[p]=1;
			}
		}
		sort(sp,sp+p);
		int ss=p;
		while(k>0&&p>=0){
			k=k-sp[ss-p];
			p--;
		}
		p++;
		if(p<=1) p=1;
		cout<<p<<endl;
	}
	
	
	return 0;
}


Submission (verdict: Accepted):
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int t;cin>>t;
	while(t--){
		int n,k;cin>>n>>k;
		int st[n],sp[n]={0};
		for(int i=0;i<n;i++){
			cin>>st[i];
		}
		sort(st,st+n);
		int p=0;
		sp[0]=1;
		for(int i=1;i<n;i++){
			if(st[i]==st[i-1]){
				sp[p]+=1;
			}
			else{
				p++;
				sp[p]=1;
			}
		}
		p++;
		sort(sp,sp+p);
		for(int i=0;i<p;i++){
			//cout<<sp[i]<<"|";
		}
		int ss=p;
		while(k>0){
			if(p==0){
				break;
			}
			if(k>=sp[ss-p]){
				k=k-sp[ss-p];
			}
			else{
				break;
			}
			p--;
		}
		if(p<=1) p=1;
		cout<<p<<endl;
	}
	
	
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int t;cin>>t;
	while(t--){
		int n,k;cin>>n>>k;
		int st[n],sp[n]={0};
		for(int i=0;i<n;i++){
			cin>>st[i];
		}
		sort(st,st+n);
		int p=0;
		sp[0]=1;
		for(int i=1;i<n;i++){
			if(st[i]==st[i-1]){
				sp[p]+=1;
			}
			else{
				p++;
				sp[p]=1;
			}
		}
		sort(sp,sp+p);
		int ss=p;
		while(k>0){
			k=k-sp[ss-p];
			p--;
		}
		p++;
		if(p<=1) p=1;
		cout<<p<<endl;
	}
	
	
	return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int t;cin>>t;
	while(t--){
		int n,k;cin>>n>>k;
		int st[n],sp[n]={0};
		for(int i=0;i<n;i++){
			cin>>st[i];
		}
		sort(st,st+n);
		int p=0;
		sp[0]=1;
		for(int i=1;i<n;i++){
			if(st[i]==st[i-1]){
				sp[p]+=1;
			}
			else{
				p++;
				sp[p]=1;
			}
		}
		sort(sp,sp+p);
		int ss=p;
		while(k>0&&p>=0){
			k=k-sp[ss-p];
			p--;
		}
		p++;
		if(p<=1) p=1;
		cout<<p<<endl;
	}
	
	
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int t;cin>>t;
	while(t--){
		int n,k;cin>>n>>k;
		int st[n],sp[n]={0};
		for(int i=0;i<n;i++){
			cin>>st[i];
		}
		sort(st,st+n);
		int p=0;
		sp[0]=1;
		for(int i=1;i<n;i++){
			if(st[i]==st[i-1]){
				sp[p]+=1;
			}
			else{
				p++;
				sp[p]=1;
			}
		}
		sort(sp,sp+p);
		int ss=p;
		while(k>0){
			k=k-sp[ss-p];
			p--;
		}
		p++;
		if(p<=1) p=1;
		cout<<p<<endl;
	}
	
	
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "C:\Users\Ghanif PE\Documents\code\debug.h"
#else
#define debug(...)
#define debugArr(...)
#endif
#define tc int t; cin >> t; while (t--)

void hi() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.exceptions(cin.failbit);}

int n;

int cirno(int ar[], int sz) {
    int sum = 0;
    int newSz = sz - 1, newAr[sz];
    for (int i = 0; i < sz; i++) {
        sum += ar[i];
        if (i > 0) {
            newAr[i - 1] = ar[i] - ar[i - 1];
        }
    }
    if (sz == 1) {
        return abs(sum);
    } else if (sz < n) {
        return max(cirno(newAr, newSz), abs(sum));
    } else {
        return max(cirno(newAr, newSz), sum);
    }
    
}

int main(){
    hi();
    tc {
        cin >> n;
        int arr[n];
        int maks = INT_MIN;
        for (int i = 0; i < n; i++) {
            int haha;
            cin >> haha;
            arr[i] = haha;
        }
        (n == 1) ? cout << arr[0] << endl : cout << cirno(arr, n) << endl;
    }
}
/*
9 + 7 + 9 + -9 + 9 + -8 + 7 + -8 + 9
9 + -8 + 7 + -8 + 9 + -9 + 9 + 7 + 9

- 2 + 2 - 18 + 18 - 17 + 15 - 15 + 17
- 17 + 15 - 15 + 17 - 18 + 18 - 2 + 2

4 -20 36 -35 32 -30 32

-24 56 -71 67 -62 62

80 -127 138 -129 124

-207 265 -267 253

472 -532 520

-1004 1052

2056
*/

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "C:\Users\Ghanif PE\Documents\code\debug.h"
#else
#define debug(...)
#define debugArr(...)
#endif
#define tc int t; cin >> t; while (t--)
#define ll long long

void hi() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.exceptions(cin.failbit);}

ll n;

ll cirno(ll ar[], ll sz) {
    ll sum = 0;
    ll newSz = sz - 1, newAr[sz];
    for (ll i = 0; i < sz; i++) {
        sum += ar[i];
        if (i > 0) {
            newAr[i - 1] = ar[i] - ar[i - 1];
        }
    }
    if (sz == 1) {
        return abs(sum);
    } else if (sz < n) {
        return max(cirno(newAr, newSz), abs(sum));
    } else {
        return max(cirno(newAr, newSz), sum);
    }
    
}

int main(){
    hi();
    tc {
        cin >> n;
        ll arr[n];
        ll maks = INT_MIN;
        for (ll i = 0; i < n; i++) {
            ll haha;
            cin >> haha;
            arr[i] = haha;
        }
        (n == 1) ? cout << arr[0] << endl : cout << cirno(arr, n) << endl;
    }
}
/*
9 + 7 + 9 + -9 + 9 + -8 + 7 + -8 + 9
9 + -8 + 7 + -8 + 9 + -9 + 9 + 7 + 9

- 2 + 2 - 18 + 18 - 17 + 15 - 15 + 17
- 17 + 15 - 15 + 17 - 18 + 18 - 2 + 2

4 -20 36 -35 32 -30 32

-24 56 -71 67 -62 62

80 -127 138 -129 124

-207 265 -267 253

472 -532 520

-1004 1052

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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "C:\Users\Ghanif PE\Documents\code\debug.h"
#else
#define debug(...)
#define debugArr(...)
#endif
#define tc int t; cin >> t; while (t--)

void hi() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.exceptions(cin.failbit);}

int n;

int cirno(int ar[], int sz) {
    int sum = 0;
    int newSz = sz - 1, newAr[newSz];
    for (int i = 0; i < sz; i++) {
        sum += ar[i];
        if (i > 0) {
            newAr[i - 1] = ar[i] - ar[i - 1];
        }
    }
    if (sz == 1) {
        return abs(sum);
    } else {
        return max(cirno(newAr, newSz), abs(sum));
    }
    
}

int main(){
    hi();
    tc {
        cin >> n;
        int arr[n];
        int maks = INT_MIN;
        for (int i = 0; i < n; i++) {
            int haha;
            cin >> haha;
            arr[i] = haha;
        }
        (n == 1) ? cout << arr[0] << endl : cout << cirno(arr, n) << endl;
    }
}
/*
9 + 7 + 9 + -9 + 9 + -8 + 7 + -8 + 9
9 + -8 + 7 + -8 + 9 + -9 + 9 + 7 + 9

- 2 + 2 - 18 + 18 - 17 + 15 - 15 + 17
- 17 + 15 - 15 + 17 - 18 + 18 - 2 + 2

4 -20 36 -35 32 -30 32

-24 56 -71 67 -62 62

80 -127 138 -129 124

-207 265 -267 253

472 -532 520

-1004 1052

2056
*/

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "C:\Users\Ghanif PE\Documents\code\debug.h"
#else
#define debug(...)
#define debugArr(...)
#endif
#define tc int t; cin >> t; while (t--)

void hi() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.exceptions(cin.failbit);}

int n;

int cirno(int ar[], int sz) {
    int sum = 0;
    int newSz = sz - 1, newAr[sz];
    for (int i = 0; i < sz; i++) {
        sum += ar[i];
        if (i > 0) {
            newAr[i - 1] = ar[i] - ar[i - 1];
        }
    }
    if (sz == 1) {
        return abs(sum);
    } else if (sz < n) {
        return max(cirno(newAr, newSz), abs(sum));
    } else {
        return max(cirno(newAr, newSz), sum);
    }
    
}

int main(){
    hi();
    tc {
        cin >> n;
        int arr[n];
        int maks = INT_MIN;
        for (int i = 0; i < n; i++) {
            int haha;
            cin >> haha;
            arr[i] = haha;
        }
        (n == 1) ? cout << arr[0] << endl : cout << cirno(arr, n) << endl;
    }
}
/*
9 + 7 + 9 + -9 + 9 + -8 + 7 + -8 + 9
9 + -8 + 7 + -8 + 9 + -9 + 9 + 7 + 9

- 2 + 2 - 18 + 18 - 17 + 15 - 15 + 17
- 17 + 15 - 15 + 17 - 18 + 18 - 2 + 2

4 -20 36 -35 32 -30 32

-24 56 -71 67 -62 62

80 -127 138 -129 124

-207 265 -267 253

472 -532 520

-1004 1052

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


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "C:\Users\Ghanif PE\Documents\code\debug.h"
#else
#define debug(...)
#define debugArr(...)
#endif
#define tc int t; cin >> t; while (t--)

void hi() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.exceptions(cin.failbit);}

int n;

int cirno(int ar[], int sz) {
    int sum = 0;
    int newSz = sz - 1, newAr[newSz];
    for (int i = 0; i < sz; i++) {
        sum += ar[i];
        if (i > 0) {
            newAr[i - 1] = ar[i] - ar[i - 1];
        }
    }
    if (sz == 1) {
        return abs(sum);
    } else {
        return max(cirno(newAr, newSz), abs(sum));
    }
    
}

int main(){
    hi();
    tc {
        cin >> n;
        int arr[n];
        int maks = INT_MIN;
        for (int i = 0; i < n; i++) {
            int haha;
            cin >> haha;
            arr[i] = haha;
        }
        (n == 1) ? cout << arr[0] << endl : cout << cirno(arr, n) << endl;
    }
}
/*
9 + 7 + 9 + -9 + 9 + -8 + 7 + -8 + 9
9 + -8 + 7 + -8 + 9 + -9 + 9 + 7 + 9

- 2 + 2 - 18 + 18 - 17 + 15 - 15 + 17
- 17 + 15 - 15 + 17 - 18 + 18 - 2 + 2

4 -20 36 -35 32 -30 32

-24 56 -71 67 -62 62

80 -127 138 -129 124

-207 265 -267 253

472 -532 520

-1004 1052

2056
*/
Problem: 2062C - Cirno and Operations
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;
	    cin >> n;
        vector <long long> arr(n);
        int index=n-1;
	    for (int i=0;i<n;i++)
	    {
            cin >> arr[i];
	    }
    	if (n>2)
    	{
    	    while(index>0)
    	    {
    	        for (int i=0;i<index;i++)
    	        {
    	            arr[i]=arr[i+1]-arr[i];
    	        }
    	        index-=1;
    	    }
    	    if (arr[0]>0) cout << arr[0] << "\n";
    	    else cout << -1*arr[0] << "\n";
    	}
    	else if (n==1)
    	{
    	    cout << arr[0] << "\n";
    	}
    	else cout << abs(arr[0])+ abs(arr[1]) << "\n";
	}

}


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

int main() {
	int t;
	cin >> t;
	while(t--)
	{
	    int n;
	    cin >> n;
        vector <long long> arr(n);
        int index=n-1;
	    for (int i=0;i<n;i++)
	    {
            cin >> arr[i];
	    }
	    long long a=-1e18;
	    for (int i=0;i<n;i++)
	    {
	        long long s=0;
	        for (int j=0;j<=index;j++)
	        {
	            s+=arr[j];
	        }
	        if (i==0) a=max(a,s);
	        else a=max(a,max(s,(-s)));
	        for (int j=0;j<index;j++)
	        {
	            arr[j]=arr[j+1]-arr[j];
	        }
	        index-=1;
	        
	    }
    	cout << a << "\n";
	}

}
Problem: 2062C - Cirno and Operations
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;
	    cin >> n;
        vector <int> arr(n);
        int index=n-1;
	    for (int i=0;i<n;i++)
	    {
            cin >> arr[i];
	    }
    	if (n>2)
    	{
    	    while(index>0)
    	    {
    	        for (int i=0;i<index;i++)
    	        {
    	            arr[i]=arr[i+1]-arr[i];
    	        }
    	        index-=1;
    	    }
    	    if (arr[0]>0) cout << arr[0] << "\n";
    	    else cout << -1*arr[0] << "\n";
    	}
    	else if (n==1)
    	{
    	    cout << arr[0] << "\n";
    	}
    	else cout << abs(arr[0])+ abs(arr[1]) << "\n";
	}

}


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

int main() {
	int t;
	cin >> t;
	while(t--)
	{
	    int n;
	    cin >> n;
        vector <long long> arr(n);
        int index=n-1;
	    for (int i=0;i<n;i++)
	    {
            cin >> arr[i];
	    }
    	if (n>2)
    	{
    	    while(index>0)
    	    {
    	        for (int i=0;i<index;i++)
    	        {
    	            arr[i]=arr[i+1]-arr[i];
    	        }
    	        index-=1;
    	    }
    	    if (arr[0]>0) cout << arr[0] << "\n";
    	    else cout << -1*arr[0] << "\n";
    	}
    	else if (n==1)
    	{
    	    cout << arr[0] << "\n";
    	}
    	else cout << abs(arr[0])+ abs(arr[1]) << "\n";
	}

}
Problem: 2062C - Cirno and Operations
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;
	    cin >> n;
        vector <int> arr(n);
        int index=n-1;
	    for (int i=0;i<n;i++)
	    {
            cin >> arr[i];
	    }
    	if (n>2)
    	{
    	    while(index>0)
    	    {
    	        for (int i=0;i<index;i++)
    	        {
    	            arr[i]=arr[i+1]-arr[i];
    	        }
    	        index-=1;
    	    }
    	    if (arr[0]>0) cout << arr[0] << "\n";
    	    else cout << -1*arr[0] << "\n";
    	}
    	else if (n==1)
    	{
    	    cout << arr[0] << "\n";
    	}
    	else cout << abs(arr[0])+ abs(arr[1]) << "\n";
	}

}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

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

    ll t;
    cin >> t;

    while (t--) {
        ll n, k;
        cin >> n >> k;

        vector<ll> v(n);
        unordered_map<ll, ll> freq;

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

        vector<ll> counts;
        for (auto& [key, value] : freq) {
            counts.push_back(value);
        }
        sort(counts.begin(), counts.end());

        ll distinct = counts.size();
        for (ll count : counts) {
            if (k >= count) {
                k -= count;
                distinct--;
            } else {
                break;
            }
        }

        cout << max(1LL, distinct) << "\n";
    }

    return 0;
}


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

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

    ll t;
    cin >> t;

    while (t--) {
        ll n, k;
        cin >> n >> k;

        vector<ll> a(n);
        map<ll, ll> compress;
        vector<ll> freq;

        for (ll i = 0; i < n; i++) {
            cin >> a[i];
            compress[a[i]]++;
        }
        // Chuyển giá trị tần suất từ map vào vector
        for (auto& [value, count] : compress) {
            freq.push_back(count);
        }

        // Sắp xếp tần suất tăng dần
        sort(freq.begin(), freq.end());

        ll distinct = freq.size(); // Ban đầu là số giá trị khác nhau
        for (ll count : freq) {
            if (k >= count) {
                k -= count; // Dùng k để xóa các giá trị ít xuất hiện
                distinct--; // Giảm số lượng giá trị khác biệt
            } else {
                break; // Không còn k đủ để giảm tiếp
            }
        }

        // In kết quả
        cout << max(1LL, distinct) << "\n";
    }

    return 0;
}