ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    vector<int> deg(n);
    for (int i = 1;i < n;i++)
    {
        int v,u;
        cin >> v >> u;
        v--;
        u--;
        e[u].push_back(v);
        e[v].push_back(u);
        deg[u]++;
        deg[v]++;
    }
    sort(e.begin(),e.end(),[](vector<int> a,vector<int> b) {return a.size() > b.size();});
    int mx = e[0].size();
    int premx = -1;
    int cntmx = 0;
    int cntpremx = 0;
    for (int i = 0;i < n;i++)
    {
        if (e[i].size() == mx) cntmx++;
        if (i && e[i - 1].size() == mx && e[i].size() != mx) premx = e[i].size();
        if (e[i].size() == premx) cntpremx++;
    }
    int ans = 0;
    for (int i = 0;e[i].size() == mx && i < n;i++)
    {
        int curcntmx = 0;
        int curcntpremx = 0;
        for (auto& adj : e[i])
        {
            if (deg[adj] == mx) curcntmx++;
            else if (deg[adj] == premx) curcntpremx++;
        }
        if (cntmx - curcntmx - 1 > 0) ans = max(ans,mx * 2 - 1);
        else if (cntpremx - curcntpremx > 0) ans = max(ans,mx + premx - 1);
        else if (i != 0) ans = max(ans,mx * 2 - 2);
        else ans = max(ans,mx + premx - 2);
    }
    cout << ans << '\n';
} 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    vector<int> deg(n);
    for (int i = 1;i < n;i++)
    {
        int v,u;
        cin >> v >> u;
        v--;
        u--;
        e[u].push_back(v);
        e[v].push_back(u);
        deg[u]++;
        deg[v]++;
    }
    sort(e.begin(),e.end(),[](vector<int> a,vector<int> b) {return a.size() > b.size();});
    int mx = e[0].size();
    int premx = -1;
    int cntmx = 0;
    int cntpremx = 0;
    for (int i = 0;i < n;i++)
    {
        if (e[i].size() == mx) cntmx++;
        if (i && e[i - 1].size() == mx && e[i].size() != mx) premx = e[i].size();
        if (e[i].size() == premx) cntpremx++;
    }
    int ans = 0;
    for (int i = 0; i < n && e[i].size() == mx;i++)
    {
        int curcntmx = 0;
        int curcntpremx = 0;
        for (auto& adj : e[i])
        {
            if (deg[adj] == mx) curcntmx++;
            else if (deg[adj] == premx) curcntpremx++;
        }
        if (cntmx - curcntmx - 1 > 0) ans = max(ans,mx * 2 - 1);
        else if (cntpremx - curcntpremx > 0) ans = max(ans,mx + premx - 1);
        if (i != 0) ans = max(ans,mx * 2 - 2);
        else ans = max(ans,mx + premx - 2);
    }
    cout << ans << '\n';
} 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    vector<int> deg(n,0);
    int mx = 0;
    for (int i = 1;i < n;i++)
    {
        int v,u;
        cin >> v >> u;
        v--;
        u--;
        e[u].push_back(v);
        e[v].push_back(u);
        deg[u]++;
        deg[v]++;
        mx = max(mx,max(deg[u],deg[v]));
    }
    int vert = -1;
    int adjmx = 0;
    vector<bool> v(n);
    for (int i = 0;i < n;i++)
    {
        if (deg[i] == mx)
        {
            vert = i;
            for (auto& adj : e[i])
            {
                v[adj] = 1;
                adjmx = max(adjmx,deg[adj]);
                if (deg[adj] == mx)
                {
                    v[i] = 1;
                    vert = -1;
                }
            }
        }
    }
    int nonadjmx = 0;
    for (int i = 0;i < n;i++)
    {
        if (!v[i] && i != vert) nonadjmx = max(nonadjmx,deg[i]);
    }
    cout << max(mx + nonadjmx - 1,mx + adjmx - 2) << '\n';
} 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    vector<int> deg(n);
    for (int i = 1;i < n;i++)
    {
        int v,u;
        cin >> v >> u;
        v--;
        u--;
        e[u].push_back(v);
        e[v].push_back(u);
        deg[u]++;
        deg[v]++;
    }
    sort(e.begin(),e.end(),[](vector<int> a,vector<int> b) {return a.size() > b.size();});
    int mx = e[0].size();
    int premx = -1;
    int cntmx = 0;
    int cntpremx = 0;
    for (int i = 0;i < n;i++)
    {
        if (e[i].size() == mx) cntmx++;
        if (i && e[i - 1].size() == mx && e[i].size() != mx) premx = e[i].size();
        if (e[i].size() == premx) cntpremx++;
    }
    int ans = 0;
    for (int i = 0;e[i].size() == mx;i++)
    {
        int curcntmx = 0;
        int curcntpremx = 0;
        for (auto& adj : e[i])
        {
            if (deg[adj] == mx) curcntmx++;
            else if (deg[adj] == premx) curcntpremx++;
        }
        if (cntmx - curcntmx - 1 > 0) ans = max(ans,mx * 2 - 1);
        else if (cntpremx - curcntpremx > 0) ans = max(ans,mx + premx - 1);
        else if (i != 0) ans = max(ans,mx * 2 - 2);
        else ans = max(ans,mx + premx - 2);
    }
    cout << ans << '\n';
} 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    vector<int> deg(n,0);
    int mx = 0;
    for (int i = 1;i < n;i++)
    {
        int v,u;
        cin >> v >> u;
        v--;
        u--;
        e[u].push_back(v);
        e[v].push_back(u);
        deg[u]++;
        deg[v]++;
        mx = max(mx,max(deg[u],deg[v]));
    }
    int vert = -1;
    int adjmx = 0;
    vector<bool> v(n);
    for (int i = 0;i < n;i++)
    {
        if (deg[i] == mx)
        {
            vert = i;
            for (auto& adj : e[i])
            {
                v[adj] = 1;
                adjmx = max(adjmx,deg[adj]);
                if (deg[adj] == mx)
                {
                    v[i] = 1;
                    vert = -1;
                }
            }
        }
    }
    int nonadjmx = 0;
    for (int i = 0;i < n;i++)
    {
        if (!v[i] && i != vert) nonadjmx = max(nonadjmx,deg[i]);
    }
    cout << max(mx + nonadjmx - 1,mx + adjmx - 2) << '\n';
} 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    vector<int> deg(n);
    for (int i = 1;i < n;i++)
    {
        int v,u;
        cin >> v >> u;
        v--;
        u--;
        e[u].push_back(v);
        e[v].push_back(u);
        deg[u]++;
        deg[v]++;
    }
    sort(e.begin(),e.end(),[](vector<int> a,vector<int> b) {return a.size() > b.size();});
    int mx = e[0].size();
    int premx = -1;
    int cntmx = 0;
    int cntpremx = 0;
    for (int i = 0;i < n;i++)
    {
        if (e[i].size() == mx) cntmx++;
        if (i && e[i - 1].size() == mx && e[i].size() != mx) premx = e[i].size();
        if (e[i].size() == premx) cntpremx++;
    }
    int ans = 0;
    for (int i = 0;e[i].size() == mx;i++)
    {
        int curcntmx = 0;
        int curcntpremx = 0;
        for (auto& adj : e[i])
        {
            if (deg[adj] == mx) curcntmx++;
            else if (deg[adj] == premx) curcntpremx++;
        }
        if (cntmx - curcntmx - 1 > 0) ans = max(ans,mx * 2 - 1);
        else if (cntpremx - curcntpremx > 0) ans = max(ans,mx + premx - 1);
        else if (i != 0) ans = max(ans,mx * 2 - 2);
        else ans = max(ans,mx + premx - 2);
    }
    cout << ans << '\n';
} 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    vector<int> deg(n);
    for (int i = 1;i < n;i++)
    {
        int v,u;
        cin >> v >> u;
        v--;
        u--;
        e[u].push_back(v);
        e[v].push_back(u);
        deg[u]++;
        deg[v]++;
    }
    sort(e.begin(),e.end(),[](vector<int> a,vector<int> b) {return a.size() > b.size();});
    int mx = e[0].size();
    int premx = -1;
    int cntmx = 0;
    int cntpremx = 0;
    for (int i = 0;i < n;i++)
    {
        if (e[i].size() == mx) cntmx++;
        if (i && e[i - 1].size() == mx && e[i].size() != mx) premx = e[i].size();
        if (e[i].size() == premx) cntpremx++;
    }
    int ans = 0;
    for (int i = 0;e[i].size() == mx && i < n;i++)
    {
        int curcntmx = 0;
        int curcntpremx = 0;
        for (auto& adj : e[i])
        {
            if (deg[adj] == mx) curcntmx++;
            else if (deg[adj] == premx) curcntpremx++;
        }
        if (cntmx - curcntmx - 1 > 0) ans = max(ans,mx * 2 - 1);
        else if (cntpremx - curcntpremx > 0) ans = max(ans,mx + premx - 1);
        else if (i != 0) ans = max(ans,mx * 2 - 2);
        else ans = max(ans,mx + premx - 2);
    }
    cout << ans << '\n';
} 
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

#include <string>

#include <algorithm>

using namespace std;



int main(){

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;



while(t--) {

string s;

cin >> s;



int i = 1;

while (i < s.size()) {

if (s[i] == '0') {

i++;

continue;

}



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

int left = s[i - 1] - '0';

if (current > left) {

s[i] = char((current - 1) + '0');

swap(s[i], s[i - 1]);

if (i > i)

i--;

} else {

i++;

}

}



cout << s << endl;

}



return 0;

}

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

#include <string>

#include <algorithm>

using namespace std;



int main(){

int t;

cin >> t;



while(t--){

string s;

cin >> s;

int n = s.size();

int i = 1;

while(i < n){

if(s[i] > '0' && (s[i] - 1) > s[i-1]){

char temp = s[i-1];

s[i-1] = s[i] - 1;

s[i] = temp;

if(i > 1) i--;

else i++;

} else {

i++;

}

}

cout << s << endl;

}

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>

#include <string>

#include <algorithm>

using namespace std;



int main(){

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;



while(t--) {

string s;

cin >> s;

bool changed = true;



while(changed) {

changed = false;

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

if (s[i] != '0') {

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

int lDigit  = s[i-1] - '0';

if (rDigit > lDigit + 1) {

s[i] = char((rDigit - 1) + '0');

swap(s[i], s[i-1]);

changed = true;

break;

}

}

}

}



cout << s << endl;

}



return 0;

}

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

#include <string>

#include <algorithm>

using namespace std;



int main(){

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;



while(t--) {

string s;

cin >> s;



int i = 1;

while (i < s.size()) {

if (s[i] == '0') {

i++;

continue;

}



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

int left = s[i - 1] - '0';

if (current > left) {

s[i] = char((current - 1) + '0');

swap(s[i], s[i - 1]);

if (i > i)

i--;

} else {

i++;

}

}



cout << s << endl;

}



return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>

#include <string>

#include <algorithm>

using namespace std;



int main(){

int t;

cin >> t;



while(t--) {

string s;

cin >> s;

bool changed = true;



while(changed) {

changed = false;

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

if (s[i] != '0') {

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

int lDigit  = s[i-1] - '0';

if (rDigit > lDigit + 1) {

s[i] = char((rDigit - 1) + '0');

swap(s[i], s[i-1]);

changed = true;

break;

}

}

}

}



cout << s << endl;

}



return 0;

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include <iostream>

#include <string>

#include <algorithm>

using namespace std;



int main(){

int t;

cin >> t;



while(t--) {

string s;

cin >> s;

bool changed = true;



while(changed) {

changed = false;

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

if (s[i] != '0') {

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

int lDigit  = s[i-1] - '0';

if (rDigit > lDigit + 1) {

s[i] = char((rDigit - 1) + '0');

swap(s[i], s[i-1]);

changed = true;

break;

}

}

}

}



cout << s << endl;

}



return 0;

}

Submission (verdict: Time limit exceeded on test 6):
#include <iostream>

#include <string>

#include <algorithm>

using namespace std;



int main(){

ios::sync_with_stdio(false);

cin.tie(nullptr);



int t;

cin >> t;



while(t--) {

string s;

cin >> s;

bool changed = true;



while(changed) {

changed = false;

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

if (s[i] != '0') {

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

int lDigit  = s[i-1] - '0';

if (rDigit > lDigit + 1) {

s[i] = char((rDigit - 1) + '0');

swap(s[i], s[i-1]);

changed = true;

break;

}

}

}

}



cout << s << endl;

}



return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


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



#define int long long

#define IOS                           \

    ios_base::sync_with_stdio(false); \

    cin.tie(0);                       \

    cout.tie(0);

#define Max(a, b) (a > b ? a : b)

#define Min(a, b) (a < b ? a : b)

#define isPower2(a) (a == 0 ? false : ((a & (a - 1)) == 0 ? true : false))

#define isEven(a) ((a & 1) == 0 ? true : false)

// Check if the kth bit (from right -> left) is set ( Ex: (8,1) -> false || (7,1) -> true)

#define checkKBit(a, k) ((a & (1 << k)) != 0 ? true : false)

#define setKBit(a, k) (a | (1 << k))

#define unsetKBit(a, k) (a & ~(1 << k))

#define toggleKBit(a, k) (a ^ (1 << k))

#define divideByPower2(a, k) (a >> k)

#define moduloByPower2(a, k) ((a & ((1 << k) - 1)))

#define multiplyByPower2(a, k) (a << k)

#define getNumberOfSetBits(a) (__builtin_popcountll(a))

#define getNumberOfLeadingZeros(a) (__builtin_clzll(a))

#define xorOp(a, b) (a ^ b)

#define swap(a, b) \

    {              \

        a = a ^ b; \

        b = a ^ b; \

        a = a ^ b; \

    }

// if x == a -> x = b else if x == b -> x = a

#define swapConditional(a, b, x) {a ^ b ^ x}

const int maxn = 2e5 + 5;

using namespace std;



const int M = 1e9 + 7;



#define add(a, b, m) ((a + b) % m)

#define sub(a, b, m) ((a - b + m) % m)

/*

3 6 6 4 3 2

1 2 3 4 5 6

0 1 2 3 4 5 

l   r



3 6 6



2 3 3 4 6 6



*/



void solve()

{   

    int n, l , r; cin >> n >> l >> r;

    // cout << l << " " << r << endl;

    int ssum = 0;

    l--; r--;n--;

    vector<int> ll, rr, arr;

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

        int aux; cin >> aux;

        arr.push_back(aux);

    }

    for(int i = 0; i <= r; i++) ll.push_back(arr[i]);

    for(int i = l; i <= n; i++) rr.push_back(arr[i]);

    int sum= 0;

    int ans = maxn;

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

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

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

        // cout << ll[i] << " ";

        sum += ll[i];

    }

    // cout << endl;

    ans = min(sum, ans);

    sum= 0;

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

        // cout << rr[i] << " ";

        sum += rr[i];

    }

    // cout << endl;

    ans = min(sum, ans);

    cout << ans << endl;

}



signed main()

{

    IOS;

    int t = 1;

    // int t;

    cin >> t;

    while (t--)

    {

        // cout << "TESTE: " << t << endl;

        solve();

    }

    return 0;

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

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
using namespace std;
const int N=55;
int a[N];
int b[N];
void aaa()
{
	ll n,ans=0,max1=-1001;cin>>n;
	memset(a,0,sizeof(0)); 
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i],ans+=a[i];
	if(n==1)
	{
		cout<<a[n]<<endl;
		return;
	}
	ans=max(ans,abs(a[n]-a[1]));
	for(int i=1;i<=n-1;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			b[j]=b[j+1]-b[j];
		}
		ans=max(ans,abs(b[n-i]-b[1]));
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;cin>>t;
	while(t--) 	aaa();
 } 

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
using namespace std;
const int N=55;
ll a[N];
ll b[N];
void aaa()
{
	ll n,ans=0,max1=-1001;cin>>n;
	memset(a,0,sizeof(0)); 
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i],ans+=a[i];
	if(n==1)
	{
		cout<<a[n]<<endl;
		return;
	}
	ans=max(ans,abs(a[n]-a[1]));
	for(int i=1;i<=n-1;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			b[j]=b[j+1]-b[j];
		}
		ans=max(ans,abs(b[n-i]-b[1]));
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;cin>>t;
	while(t--) 	aaa();
 }
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
using namespace std;
const int N=55;
int a[N];
int b[N];
void aaa()
{
	int n,ans=0,max1=-1001;cin>>n;
	memset(a,0,sizeof(0)); 
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i],ans+=a[i];
	for(int i=1;i<=n-1;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			b[j]=b[j+1]-b[j];
		}
		ans=max(ans,abs(b[n-i]-b[1]));
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;cin>>t;
	while(t--) 	aaa();
 }
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
using namespace std;
const int N=55;
int a[N];
int b[N];
void aaa()
{
	int n,ans=0,max1=-1001;cin>>n;
	memset(a,0,sizeof(0)); 
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i],ans+=a[i];
	if(n==1)
	{
		cout<<a[n]<<endl;
		return;
	}
	ans=max(ans,abs(a[n]-a[1]));
	for(int i=1;i<=n-1;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			b[j]=b[j+1]-b[j];
		}
		ans=max(ans,abs(b[n-i]-b[1]));
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;cin>>t;
	while(t--) 	aaa();
 } 

Submission (verdict: Compilation error):
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
using namespace std;
const int N=55;
int a[N];
int b[N];
void aaa()
{
	ll n,ans=0,max1=-1001;cin>>n;
	memset(a,0,sizeof(0)); 
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i],ans+=a[i];
	if(n==1)
	{
		cout<<a[n]<<endl;
		return;
	}
	ans=max(ans,abs(a[n]-a[1]));
	for(int i=1;i<=n-1;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			b[j]=b[j+1]-b[j];
		}
		ans=max(ans,abs(b[n-i]-b[1]));
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;cin>>t;
	while(t--) 	aaa();
 }
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
using namespace std;
const int N=55;
int a[N];
int b[N];
void aaa()
{
	int n,ans=0,max1=-1001;cin>>n;
	memset(a,0,sizeof(0)); 
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i],ans+=a[i];
	for(int i=1;i<=n-1;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			b[j]=b[j+1]-b[j];
		}
		ans=max(ans,abs(b[n-i]-b[1]));
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;cin>>t;
	while(t--) 	aaa();
 } 

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
using namespace std;
const int N=55;
int a[N];
int b[N];
void aaa()
{
	int n,ans=0,max1=-1001;cin>>n;
	memset(a,0,sizeof(0)); 
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i],ans+=a[i];
	if(n==1)
	{
		cout<<a[n]<<endl;
		return;
	}
	ans=max(ans,abs(a[n]-a[1]));
	for(int i=1;i<=n-1;i++)
	{
		for(int j=1;j<=n-i;j++)
		{
			b[j]=b[j+1]-b[j];
		}
		ans=max(ans,abs(b[n-i]-b[1]));
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	int t;cin>>t;
	while(t--) 	aaa();
 }
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define int long long

inline void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> q;
    vector<int> b(m + 1);
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        q.push(x);
    }
    for (int i = 1; i <= m; i++) cin >> b[i];
    sort(b.begin() + 1, b.end());
    int p = 1;
    while (q.size()) {
        int x = q.top();
        q.pop();
      //   cout << "x=" << x << '\n';
        if (p > n) {
            cout << "NO\n";
            return;
        }
        if (x == b[p]) {
            p++;
        } else {
            if (q.empty()) {
                cout << "NO\n";
                return;
            } else {
                int y = q.top();
                q.pop();
               //  cout << "y=" << y << '\n';
                if (abs(x - y) <= 1) {
                    if (x + y == b[p]) {
                        p++;
                    } else {
                        q.push(x + y);
                    }
                } else {
                    cout << "NO\n";
                    return;
                }
            }
        }
      //   cout << p << '\n';
    }
    cout << "YES\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) solve();
}
/*
1
4 2
1 1 3 3
3 5
*/

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

#define int long long

inline void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> q;
    vector<int> b(m + 1);
    for (int i = 1, x; i <= n; i++) {
        cin >> x;
        q.push(x);
    }
    for (int i = 1; i <= m; i++) cin >> b[i];
    sort(b.begin() + 1, b.end());
    int p = 1;
    while (q.size()) {
        int x = q.top();
        q.pop();
        //   cout << "x=" << x << '\n';
        if (p > n) {
            cout << "NO\n";
            return;
        }
        if (x == b[p]) {
            p++;
        } else {
            if (q.empty()) {
                cout << "NO\n";
                return;
            } else {
                int y = q.top();
                q.pop();
                //  cout << "y=" << y << '\n';
                if (abs(x - y) <= 1) {
                    if (x + y == b[p]) {
                        p++;
                    } else {
                        q.push(x + y);
                    }
                } else {
                    cout << "NO\n";
                    return;
                }
            }
        }
        //   cout << p << '\n';
    }
    if (p > m)
        cout << "YES\n";
    else
        cout << "NO\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) solve();
}
/*
1
4 2
1 1 3 3
3 5
*/