ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#include <numeric>
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    vll a(n);
    f(i, 0, n) cin >> a[i];
    ll mx = LLONG_MIN;
    ll sm = accumulate(a.begin(), a.end(), 0LL);
    mx = max(mx, sm);
    while (a.size() > 1)
    {
        reverse(all(a));
        sm = 0;
        for (int i = 0; i < a.size() - 1; i++)
        {
            a[i] = a[i + 1] - a[i];
            sm += a[i];
        }
        a.pop_back();
        mx = max(mx, sm);
    }
    cout << mx << endl;

    return;
}

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

    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#include <numeric>
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    vll a(n);
    f(i, 0, n) cin >> a[i];
    ll mx = LLONG_MIN;
    ll sm = accumulate(a.begin(), a.end(), 0LL);
    mx = max(mx, sm);
    while (a.size() > 1)
    {
        reverse(all(a));
        sm = *(a.end() - 1)- a[0];
        for (int i = 0; i < a.size() - 1; i++)
        {
            a[i] = a[i + 1] - a[i];
        }
        a.pop_back();
        mx = max(mx, sm);
    }
    cout << mx << endl;

    return;
}

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

    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 2):
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define vii vector<int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define isON(n, k) (((n) >> (k)) & 1)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#include <numeric>
// int dx[8] = { 1, 0, -1, 0, -1, 1, -1, 1 };
// int dy[8] = { 0, 1, 0, -1, -1, 1, 1, -1 };
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;
ll t = 1;

void solve()
{
    ll n;
    cin >> n;
    vll a(n);
    f(i, 0, n) cin >> a[i];
    ll mx = LLONG_MIN;
    ll sm = accumulate(a.begin(), a.end(), 0LL);
    mx = max(mx, sm);
    while (a.size() > 1)
    {
        reverse(all(a));
        sm = 0;
        for (int i = 0; i < a.size() - 1; i++)
        {
            a[i] = a[i + 1] - a[i];
            sm += a[i];
        }
        a.pop_back();
        mx = max(mx, sm);
    }
    cout << mx << endl;

    return;
}

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

    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

const int N =33;

int le[N],ri[N];

void solve()
{
	int l,r;cin>>l>>r;
	for(int i=31;i>=0;--i){
		if(l>>i&1) le[i]=1;
		else le[i]=0;
	}
	for(int i=31;i>=0;--i){
		if(r>>i&1) ri[i]=1;
		else ri[i]=0;
	}
	int res=0;
	for(int i=31;i>=0;--i){
		if(le[i]!=ri[i]){
			res=i;
		}
	}
	bool flag=true;
	for(int i=res-1;i>=0;--i){
		if(ri[i]==1){
			flag=false;
		}
	}
	if(flag){
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res&&i) a+=pow(2,i);
			if(i<res) b+=pow(2,i);
			if(i==res) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}else{
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res) a+=pow(2,i);
			if(i==res) b+=pow(2,i),c+=pow(2,i);
			if(i<res&&i==0) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}
}

signed main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _;cin>>_;
	while(_--) solve();
	return 0;
}

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

const int N =33;

int le[N],ri[N];

void solve()
{
	int l,r;cin>>l>>r;
	for(int i=31;i>=0;--i){
		if(l>>i&1) le[i]=1;
		else le[i]=0;
	}
	for(int i=31;i>=0;--i){
		if(r>>i&1) ri[i]=1;
		else ri[i]=0;
	}
	int res=0;
	for(int i=30;i>=0;--i){
		if(le[i]!=ri[i]){
			res=i;
			break ;
		}
	}
	bool flag=true;
	for(int i=res-1;i>=0;--i){
		if(ri[i]){
			flag=false;
		}
	}
	if(flag){
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res&&i) a+=pow(2,i);
			if(i<res) b+=pow(2,i);
			if(i==res) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}else{
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res) a+=pow(2,i);
			if(i==res) b+=pow(2,i),c+=pow(2,i);
			if(i<res&&i==0) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}
}

signed main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _;cin>>_;
	while(_--) solve();
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

const int N =33;

int le[N],ri[N];

void solve()
{
	int l,r;cin>>l>>r;
	for(int i=31;i>=0;--i){
		if(l>>i&1) le[i]=1;
		else le[i]=0;
	}
	for(int i=31;i>=0;--i){
		if(r>>i&1) ri[i]=1;
		else ri[i]=0;
	}
	int res=0;
	for(int i=31;i>=0;--i){
		if(le[i]!=ri[i]){
			res=i;
		}
	}
	bool flag=true;
	for(int i=res;i>=0;--i){
		if(ri[i]==1){
			flag=false;
		}
	}
	if(flag){
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res&&i) a+=pow(2,i);
			if(i<res) b+=pow(2,i);
			if(i==res) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}else{
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res) a+=pow(2,i);
			if(i==res) b+=pow(2,i),c+=pow(2,i);
			if(i<res&&i==0) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}
}

signed main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _;cin>>_;
	while(_--) solve();
	return 0;
}

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

const int N =33;

int le[N],ri[N];

void solve()
{
	int l,r;cin>>l>>r;
	for(int i=31;i>=0;--i){
		if(l>>i&1) le[i]=1;
		else le[i]=0;
	}
	for(int i=31;i>=0;--i){
		if(r>>i&1) ri[i]=1;
		else ri[i]=0;
	}
	int res=0;
	for(int i=31;i>=0;--i){
		if(le[i]!=ri[i]){
			res=i;
		}
	}
	bool flag=true;
	for(int i=res-1;i>=0;--i){
		if(ri[i]==1){
			flag=false;
		}
	}
	if(flag){
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res&&i) a+=pow(2,i);
			if(i<res) b+=pow(2,i);
			if(i==res) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}else{
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res) a+=pow(2,i);
			if(i==res) b+=pow(2,i),c+=pow(2,i);
			if(i<res&&i==0) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}
}

signed main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _;cin>>_;
	while(_--) solve();
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

const int N =33;

int le[N],ri[N];

void solve()
{
	int l,r;cin>>l>>r;
	for(int i=31;i>=0;--i){
		if(l>>i&1) le[i]=1;
		else le[i]=0;
	}
	for(int i=31;i>=0;--i){
		if(r>>i&1) ri[i]=1;
		else ri[i]=0;
	}
	int res=0;
	for(int i=31;i>=0;--i){
		if(le[i]!=ri[i]){
			res=i;
		}
	}
	bool flag=true;
	for(int i=res;i>=0;--i){
		if(ri[i]==1){
			flag=false;
		}
	}
	if(flag){
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res&&i) a+=pow(2,i);
			if(i<res) b+=pow(2,i);
			if(i==res) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}else{
		int a=0,b=0,c=0;
		for(int i=0;i<=32;++i){
			if(i<res) a+=pow(2,i);
			if(i==res) b+=pow(2,i),c+=pow(2,i);
			if(i<res&&i==0) c+=pow(2,i);
			if(i>res){
				if(le[i]) a+=pow(2,i),b+=pow(2,i),c+=pow(2,i);
			}
		}
		cout<<a<<' '<<b<<' '<<c<<'\n';
	}
}

signed main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int _;cin>>_;
	while(_--) solve();
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+5;
ll t,n,k;
ll a[N],f[N];
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		memset(f,0,sizeof(f));
		cin>>n>>k;
		for(int i=1;i<=n;i++){
			cin>>a[i];
//			f[a[i]]++;
		}
		sort(a+1,a+1+n);
		f[1]=1;
		ll l=1;
		for(int i=1;i<=n-1;i++){
			if(a[i+1]==a[i]) f[l]++;
			else{
				l++;
				f[l]=1;
			}
		}
		sort(f+1,f+1+l);
		ll d=0;
		for(int i=1;i<=l;i++){
			if(f[i]>k){
				cout<<l-i+1<<'\n';
				d=1;
				break;
			}
			else k-=f[i];
		}
		if(d==0)
			cout<<"1"<<'\n';
	}
	return 0;
}


Submission (verdict: Accepted):
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
const int N=1e6+5;
ll t,n,k;
ll a;
map<ll,ll>f;
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		f.clear();
		cin>>n>>k;
		int cnt=0;
		for(int i=1;i<=n;i++){
			cin>>a;
			if(f[a]==0) cnt++;
			f[a]++;
		}
		if(k==0) cout<<cnt<<'\n';
		else{
			vector<ll>r;
			for(auto [x,y]:f){
				r.push_back(y);
			}
			sort(r.begin(),r.end());
			for(int i=0;i<r.size();i++){
				if(r[i]<=k){
					k-=r[i];
					cnt--;
				}
				else break;
			}
			cout<<max(1,cnt)<<'\n';
		}
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+5;
ll t,n,k;
ll a[N],f[N],v[N],r[N];
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		memset(f,0,sizeof(f));
		memset(v,0,sizeof(v));
		cin>>n>>k;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			f[a[i]]++;
		}
		ll c=0;
		for(int i=1;i<=n;i++){
			if(f[a[i]]>0&&v[a[i]]==0){
				r[++c]=f[a[i]];
				v[a[i]]=1;
			}
		}
		sort(r+1,r+1+c);
		ll d=0;
		for(int i=1;i<=c;i++){
			if(r[i]<=k){
				k-=r[i];
			}
			else d++;
		}
		if(d!=0)
			cout<<d<<'\n';
		else cout<<d+1<<'\n';
	}
	return 0;
}


Submission (verdict: Time limit exceeded on test 2):
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+5;
ll t,n,k;
ll a[N],f[N];
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		memset(f,0,sizeof(f));
		cin>>n>>k;
		for(int i=1;i<=n;i++){
			cin>>a[i];
//			f[a[i]]++;
		}
		sort(a+1,a+1+n);
		f[1]=1;
		ll l=1;
		for(int i=1;i<=n-1;i++){
			if(a[i+1]==a[i]) f[l]++;
			else{
				l++;
				f[l]=1;
			}
		}
		sort(f+1,f+1+l);
		ll d=0;
		for(int i=1;i<=l;i++){
			if(f[i]>k){
				cout<<l-i+1<<'\n';
				d=1;
				break;
			}
			else k-=f[i];
		}
		if(d==0)
			cout<<"1"<<'\n';
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 2):
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+5;
ll t,n,k;
ll a[N],f[N],v[N],r[N];
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		memset(f,0,sizeof(f));
		memset(v,0,sizeof(v));
		cin>>n>>k;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			f[a[i]]++;
		}
		ll c=0;
		for(int i=1;i<=n;i++){
			if(f[a[i]]>0&&v[a[i]]==0){
				r[++c]=f[a[i]];
				v[a[i]]=1;
			}
		}
//		if(c<=k){
//			cout<<"1"<<'\n';
//		}
		if(1){
			sort(r+1,r+1+c);
			ll d=c;
			for(int i=1;i<=c;i++){
				if(r[i]<=k){
					k-=r[i];
					d--;
				}
				if(f[r[i]]>k) break;
			}
			if(d>k)
				cout<<d-k<<'\n';
			else cout<<"1"<<'\n';
		}
	}
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+5;
ll t,n,k;
ll a[N],f[N],v[N],r[N];
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		memset(f,0,sizeof(f));
		memset(v,0,sizeof(v));
		cin>>n>>k;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			f[a[i]]++;
		}
		ll c=0;
		for(int i=1;i<=n;i++){
			if(f[a[i]]>0&&v[a[i]]==0){
				r[++c]=f[a[i]];
				v[a[i]]=1;
			}
		}
//		if(c<=k){
//			cout<<"1"<<'\n';
//		}
		if(1){
			sort(r+1,r+1+c);
			ll d=c;
			for(int i=1;i<=c;i++){
				if(r[i]<=k){
					k-=r[i];
					d--;
				}
				if(f[r[i]]>k) break;
			}
			if(d>k)
				cout<<d-k<<'\n';
			else cout<<"1"<<'\n';
		}
	}
	return 0;
}


Submission (verdict: Time limit exceeded on test 2):
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
const int N=1e6+5;
ll t,n,k;
ll a[N],f[N],v[N],r[N];
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		memset(f,0,sizeof(f));
		memset(v,0,sizeof(v));
		cin>>n>>k;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			f[a[i]]++;
		}
		ll c=0;
		for(int i=1;i<=n;i++){
			if(f[a[i]]>0&&v[a[i]]==0){
				r[++c]=f[a[i]];
				v[a[i]]=1;
			}
		}
		sort(r+1,r+1+c);
		ll d=0;
		for(int i=1;i<=c;i++){
			if(r[i]<=k){
				k-=r[i];
			}
			else d++;
		}
		if(d!=0)
			cout<<d<<'\n';
		else cout<<d+1<<'\n';
	}
	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<vector>
#include<algorithm>
using namespace std;

long long sum(vector<int>& v) {
	if (v.size() == 1)
		return abs(v[0]);
	long long tmp = abs(v.back() - v[0]);
	for (int i = 0; i < v.size() - 1; i++) {
		v[i] = v[i + 1] - v[i];
	}
	v.pop_back();
	return max(tmp,sum(v));
}

int main() {
	int t, n,tmp;
	long long s;
	vector<int> v;
	cin >> t;
	while (t--) {
		s = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			s += tmp;
			v.push_back(tmp);
		}
		cout << max(s, (v.size()>1?sum(v):s))<<endl;
		v.clear();
	}
}

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

long long sum(vector<long long>& v) {
	if (v.size() == 1)
		return abs(v[0]);
	long long tmp = abs(v.back() - v[0]);
	for (int i = 0; i < v.size() - 1; i++) {
		v[i] = v[i + 1] - v[i];
	}
	v.pop_back();
	return max(tmp,sum(v));
}

int main() {
	int t, n,tmp;
	long long s;
	vector<long long> v;
	cin >> t;
	while (t--) {
		s = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			s += tmp;
			v.push_back(tmp);
		}
		cout << max(s, (v.size()>1?sum(v):s))<<endl;
		v.clear();
	}
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int sum(vector<int>& v) {
	if (v.size() == 1)
		return abs(v[0]);
	int tmp = abs(v.back() - v[0]);
	for (int i = 0; i < v.size() - 1; i++) {
		v[i] = v[i + 1] - v[i];
	}
	v.pop_back();
	return max(tmp,sum(v));
}

int main() {
	int t, n,tmp;
	long long s;
	vector<int> v;
	cin >> t;
	while (t--) {
		s = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			s += tmp;
			v.push_back(tmp);
		}
		cout << max(s, (v.size()>1?sum(v):s))<<endl;
		v.clear();
	}
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

long long sum(vector<int>& v) {
	if (v.size() == 1)
		return abs(v[0]);
	long long tmp = abs(v.back() - v[0]);
	for (int i = 0; i < v.size() - 1; i++) {
		v[i] = v[i + 1] - v[i];
	}
	v.pop_back();
	return max(tmp,sum(v));
}

int main() {
	int t, n,tmp;
	long long s;
	vector<int> v;
	cin >> t;
	while (t--) {
		s = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			s += tmp;
			v.push_back(tmp);
		}
		cout << max(s, (v.size()>1?sum(v):s))<<endl;
		v.clear();
	}
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Compilation error):
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

long long sum(vector<int>& v) {
	if (v.size() == 1)
		return abs(v[0]);
	int tmp = abs(v.back() - v[0]);
	for (int i = 0; i < v.size() - 1; i++) {
		v[i] = v[i + 1] - v[i];
	}
	v.pop_back();
	return max(tmp,sum(v));
}

int main() {
	int t, n,s,tmp;
	vector<int> v;
	cin >> t;
	while (t--) {
		s = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			s += tmp;
			v.push_back(tmp);
		}
		cout << max(s, (v.size()>1?sum(v):s))<<endl;
		v.clear();
	}
}

Submission (verdict: Wrong answer on test 2):
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int sum(vector<int>& v) {
	if (v.size() == 1)
		return abs(v[0]);
	int tmp = abs(v.back() - v[0]);
	for (int i = 0; i < v.size() - 1; i++) {
		v[i] = v[i + 1] - v[i];
	}
	v.pop_back();
	return max(tmp,sum(v));
}

int main() {
	int t, n,tmp;
	long long s;
	vector<int> v;
	cin >> t;
	while (t--) {
		s = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			s += tmp;
			v.push_back(tmp);
		}
		cout << max(s, (v.size()>1?sum(v):s))<<endl;
		v.clear();
	}
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Compilation error):
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

long long sum(vector<int>& v) {
	if (v.size() == 1)
		return abs(v[0]);
	int tmp = abs(v.back() - v[0]);
	for (int i = 0; i < v.size() - 1; i++) {
		v[i] = v[i + 1] - v[i];
	}
	v.pop_back();
	return max(tmp,sum(v));
}

int main() {
	int t, n,s,tmp;
	vector<int> v;
	cin >> t;
	while (t--) {
		s = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			s += tmp;
			v.push_back(tmp);
		}
		cout << max(s, (v.size()>1?sum(v):s))<<endl;
		v.clear();
	}
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


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

using namespace std;



typedef long long ll;



template<typename X, typename Y> bool ckmin(X& x , const Y& y ) { return (y < x) ? (x = y, 1) : 0; }

template<typename X, typename Y> bool ckmax(X& x , const Y& y ) { return (x < y) ? (x = y, 1) : 0; }



const int mx = 1e5+1;



bool can(ll sum , ll two, ll three) {

    if(sum%9 == 0) return true;

    if(two > 0) {

        if(can(sum + 2, two-1, three)) return true;

    }

    if(three > 0) {

        if(can(sum + 6, two, three-1)) return true;

    }



    return false;

}



void solve() {

    ll n;

    cin >> n;



    ll sum = 0;

    ll two = 0, three = 0;

    while(n != 0) {

        sum += n%10;

        if(n%10 == 2) two++;

        else if(n%10 == 3) three++;

        n/=10;

    }

    if(can(sum, two, three)) cout << "YES" << endl;

    else cout << "NO" << endl;



}

 

int main(){

    ios::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    // solve();

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

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

using namespace std;



typedef long long ll;



template<typename X, typename Y> bool ckmin(X& x , const Y& y ) { return (y < x) ? (x = y, 1) : 0; }

template<typename X, typename Y> bool ckmax(X& x , const Y& y ) { return (x < y) ? (x = y, 1) : 0; }



const int mx = 1e5+1;



void solve() {

    ll n;

    cin >> n;



    ll sum = 0;

    ll two = 0, three = 0;

    while(n != 0) {

        sum += n%10;

        if(n%10 == 2) two++;

        else if(n%10 == 3) three++;

        n/=10;

    }

    

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

        for(int j = 0; j <= three; j++) {

            if((sum + 2*i + 6*j)%9 == 0) {

                cout << "YES" << endl;

                return;

            }

        }

    }

    cout << "NO" << endl;



}

 

int main(){

    ios::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    // solve();

    return 0;

}

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

using namespace std;



typedef long long ll;



template<typename X, typename Y> bool ckmin(X& x , const Y& y ) { return (y < x) ? (x = y, 1) : 0; }

template<typename X, typename Y> bool ckmax(X& x , const Y& y ) { return (x < y) ? (x = y, 1) : 0; }



const int mx = 1e5+1;



void solve() {

    string n;

    cin >> n;



    ll sum = 0;

    ll two = 0, three = 0;

    for(char ele : n) {

        if(ele == '2') two++;

        else if(ele == '3') three++;

        sum += (ele-'0');

    }

    for(int i = 0; i <= min(9ll, two); i++) {

        for(int j = 0; j <= min(9ll, three); j++) {

            if((sum + 2*i + 6*j)%9 == 0) {

                cout << "YES" << endl;

                return;

            }

        }

    }

    cout << "NO" << endl;



}

 

int main(){

    ios::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);

    int t;

    cin >> t;

    while(t--){

        solve();

    }

    // solve();

    return 0;

}