ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=2e5+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n+3;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;
        node[u].cnt++;
        node[v].cnt++;
    }
    if(n<=2){
        cout<<0<<endl;
        return;
    }
    sort(node,node+n+1,cmp);
    int ans,temp;
    ans=node[0].cnt+node[1].cnt-1;
    if(edges[{node[0].p,node[1].p}]) ans--;
    temp=node[1].cnt+node[2].cnt-1;
    if(edges[{node[1].p,node[2].p}]) temp--;
    ans=max(ans,temp);
    temp=node[0].cnt+node[2].cnt-1;
    if(edges[{node[0].p,node[2].p}]) temp--;
    ans=max(ans,temp);
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}

Submission (verdict: Runtime error on test 3):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=25+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n+3;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;//记一下边，等会看两个要删的点是否相连
        node[u].cnt++;//记录每个点的度数
        node[v].cnt++;
    }
    if(n<=2){//两个点直接删没
        cout<<0<<endl;
        return;
    }
    sort(node+1,node+n+1,cmp);//按度数从大到小排序
    int ans,temp;
    ans=node[1].cnt+node[2].cnt-1;
    if(edges[{node[1].p,node[2].p}]) ans--;

    for(int i=2;i<=n;i++){
        temp=node[1].cnt+node[i].cnt-1;
        if(edges[{node[1].p,node[i].p}]) temp--;
        ans=max(ans,temp);
    }
    for(int i=3;i<=n;i++){
        temp=node[2].cnt+node[i].cnt-1;
        if(edges[{node[2].p,node[i].p}]) temp--;
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=2e5+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;
        node[u].cnt++;
        node[v].cnt++;
    }
    sort(node,node+n+1,cmp);
    int ans=n,del1=node[0].cnt,del2;
    for(int i=1;i<=n;i++){
        if(i!=1&&node[i].cnt<node[i-1].cnt){
            del2=node[i-1].cnt-1;
            break;
        }
        if(!edges[{node[0].p,node[i].p}]){
            del2=node[i].cnt;
            break;
        }
        if(i==n-1){
            del2=node[i].cnt-1;
            break;            
        }
    }
    ans=del1+del2-1;
    if(ans>n-2) ans=n-2;
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=25+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n+3;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;
        node[u].cnt++;
        node[v].cnt++;
    }
    if(n<=2){
        cout<<0<<endl;
        return;
    }
    sort(node,node+n+1,cmp);
    int ans,temp;
    ans=node[0].cnt+node[1].cnt-1;
    if(edges[{node[0].p,node[1].p}]) ans--;
    temp=node[1].cnt+node[2].cnt-1;
    if(edges[{node[1].p,node[2].p}]) temp--;
    ans=max(ans,temp);
    temp=node[0].cnt+node[2].cnt-1;
    if(edges[{node[0].p,node[2].p}]) temp--;
    ans=max(ans,temp);
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=25+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n+3;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;
        node[u].cnt++;
        node[v].cnt++;
    }
    if(n<=2){
        cout<<0<<endl;
        return;
    }
    sort(node,node+n+1,cmp);
    int ans,temp;
    ans=node[0].cnt+node[1].cnt-1;
    if(edges[{node[0].p,node[1].p}]) ans--;
    temp=node[1].cnt+node[2].cnt-1;
    if(edges[{node[1].p,node[2].p}]) temp--;
    ans=max(ans,temp);
    temp=node[0].cnt+node[2].cnt-1;
    if(edges[{node[0].p,node[2].p}]) temp--;
    ans=max(ans,temp);
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=2e5+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n+3;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;
        node[u].cnt++;
        node[v].cnt++;
    }
    if(n<=2){
        cout<<0<<endl;
        return;
    }
    sort(node,node+n+1,cmp);
    int ans,temp;
    ans=node[0].cnt+node[1].cnt-1;
    if(edges[{node[0].p,node[1].p}]) ans--;
    temp=node[1].cnt+node[2].cnt-1;
    if(edges[{node[1].p,node[2].p}]) temp--;
    ans=max(ans,temp);
    temp=node[0].cnt+node[2].cnt-1;
    if(edges[{node[0].p,node[2].p}]) temp--;
    ans=max(ans,temp);
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 3):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=25+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n+3;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;//记一下边，等会看两个要删的点是否相连
        node[u].cnt++;//记录每个点的度数
        node[v].cnt++;
    }
    if(n<=2){//两个点直接删没
        cout<<0<<endl;
        return;
    }
    sort(node+1,node+n+1,cmp);//按度数从大到小排序
    int ans,temp;
    ans=node[1].cnt+node[2].cnt-1;
    if(edges[{node[1].p,node[2].p}]) ans--;

    for(int i=2;i<=n;i++){
        temp=node[1].cnt+node[i].cnt-1;
        if(edges[{node[1].p,node[i].p}]) temp--;
        ans=max(ans,temp);
    }
    for(int i=3;i<=n;i++){
        temp=node[2].cnt+node[i].cnt-1;
        if(edges[{node[2].p,node[i].p}]) temp--;
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int t,n;
const int N=2e5+5;
struct Node{
    int p;
    int cnt;
}node[N];
bool cmp(Node a,Node b){
    return a.cnt>b.cnt;
}
void solve(){
  cin>>n;
  map<pair<int,int>,bool>edges;
    for(int i=0;i<=n+3;i++){
        node[i].cnt=0;
        node[i].p=i;
    }
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        edges[{u,v}]=edges[{v,u}]=true;//记一下边，等会看两个要删的点是否相连
        node[u].cnt++;//记录每个点的度数
        node[v].cnt++;
    }
    if(n<=2){//两个点直接删没
        cout<<0<<endl;
        return;
    }
    sort(node+1,node+n+1,cmp);//按度数从大到小排序
    int ans,temp;
    ans=node[1].cnt+node[2].cnt-1;
    if(edges[{node[1].p,node[2].p}]) ans--;

    for(int i=2;i<=n;i++){
        temp=node[1].cnt+node[i].cnt-1;
        if(edges[{node[1].p,node[i].p}]) temp--;
        ans=max(ans,temp);
    }
    for(int i=3;i<=n;i++){
        temp=node[2].cnt+node[i].cnt-1;
        if(edges[{node[2].p,node[i].p}]) temp--;
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
}
int main (){
  cin>>t;
  while(t--){
    solve();
    }
  return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << ' ' << x << endl;
#define mod 998244353LL
#define inf 1e10
#define ll long long
using namespace std;

void printvec(vector<ll> vec)
{
    for (auto &&e : vec)
    {
        cout << e << ' ';
    }
    cout << endl;
}
void ans(ll cur,multiset<ll>& out,multiset<ll>& a)
{
    if(out.size() > a.size()) return;
    if(cur==1)
    {
        out.insert(cur);
        return;
    }
    if(cur == 0)
    {
        return;
    }
    if(a.count(cur))
    {
        out.insert(cur);
        return;
    }
    ans(cur/2,out,a);
    ans(ceil(cur/2.0),out,a);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); 
    ll t;
    cin >>t;
    // t = 1;
    while(t--)
    { 
        ll n,m;
        cin>>n>>m;
        multiset<ll> a;
        multiset<ll> b;
        for (int i = 0;i<n;i++)
        {
            ll x;
            cin>>x;
            a.insert(x);
        }
        for (int i = 0;i<m;i++) 
        {
            ll x;
            cin >> x;
            b.insert(x);
        }
        
        
        multiset<ll> out;
        for (auto &&e : b)
        {
            ans(e,out,a);
        }
        
        if(out == a)
        {
            cout<<"YES" << endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << ' ' << x << endl;
#define mod 998244353LL
#define inf 1e10
#define ll long long
using namespace std;

void printvec(vector<ll> vec)
{
    for (auto &&e : vec)
    {
        cout << e << ' ';
    }
    cout << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); 
    ll t;
    cin >>t;
    // t = 1;
    while(t--)
    { 
        priority_queue<ll> a,b;
        ll n, m;
        cin >>n>>m;
        for (int i = 0;i<n;i++) 
        {
            ll x;
            cin >> x;
            a.push(x);
        }
        for (int i = 0;i<m;i++)
        {
            ll x;
            cin >> x;
            b.push(x);
        }
        bool ans = true;
        
        while(!a.empty())
        {
            if(b.empty()||b.size()>a.size())
            {
                ans=false;
                break;
            }
            ll x = b.top();
            b.pop();
            ll y = a.top();
            if(x < y)
            {
                ans = false; break;
            }
            if(x==y)
            {
                a.pop();
            }
            else
            {
                b.push(x/2);
                b.push((x+1)/2);
            }
        }
        if(!b.empty())
        {
            ans = false;
        }
        if(ans)
        {
            cout<<"YES"<<endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << ' ' << x << endl;
#define mod 998244353LL
#define inf 1e10
#define ll long long
using namespace std;

void printvec(vector<ll> vec)
{
    for (auto &&e : vec)
    {
        cout << e << ' ';
    }
    cout << endl;
}

map<ll,ll> ans(ll cur,map<ll,ll>& a,map<ll,map<ll,ll>>& memo)
{
    if(!memo[cur].empty()|| cur==0)
    {
        return memo[cur];
    }
    map<ll,ll> mp1 = ans(cur/2,a,memo);
    map<ll,ll> mp2 = ans(ceil(cur/2.0),a,memo);
    for (auto &&e : mp1)
    {
        mp2[e.first]+=e.second;   
    }
    return memo[cur] = mp2;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); 
    ll t;
    cin >>t;
    // t = 1;
    while(t--)
    { 
        map<ll,map<ll,ll>> memo;
        memo[1][1] = 1;
        ll n,m;
        cin>>n>>m;
        map<ll,ll> a;
        map<ll,ll> b;
        for (int i = 0;i<n;i++)
        {
            ll x;
            cin>>x;
            a[x]++;
        }
        for (int i = 0;i<m;i++) 
        {
            ll x;
            cin >> x;
            b[x]++;
        }
        
        for (auto &&e : a)
        {
            memo[e.first] = {{e.first,1}};
        }
        
        map<ll,ll> as;
        for (auto &&e : b)
        {
            map<ll,ll> mp = ans(e.first,a,memo);
            for (auto &&e1 : mp)
            {
                as[e1.first]+=e.second*e1.second;
            }
        }
        
        if(as == a)
        {
            cout<<"YES" << endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << ' ' << x << endl;
#define mod 998244353LL
#define inf 1e10
#define ll long long
using namespace std;

void printvec(vector<ll> vec)
{
    for (auto &&e : vec)
    {
        cout << e << ' ';
    }
    cout << endl;
}

map<ll,ll> ans(ll cur,map<ll,ll>& a,map<ll,map<ll,ll>>& memo)
{
    if(!memo[cur].empty()|| cur==0)
    {
        return memo[cur];
    }
    map<ll,ll> mp1 = ans(cur/2,a,memo);
    map<ll,ll> mp2 = ans(ceil(cur/2.0),a,memo);
    for (auto &&e : mp1)
    {
        mp2[e.first]+=e.second;   
    }
    return memo[cur] = mp2;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); 
    ll t;
    cin >>t;
    // t = 1;
    while(t--)
    { 
        map<ll,map<ll,ll>> memo;
        memo[1][1] = 1;
        ll n,m;
        cin>>n>>m;
        map<ll,ll> a;
        map<ll,ll> b;
        for (int i = 0;i<n;i++)
        {
            ll x;
            cin>>x;
            a[x]++;
        }
        for (int i = 0;i<m;i++) 
        {
            ll x;
            cin >> x;
            b[x]++;
        }
        
        for (auto &&e : a)
        {
            memo[e.first] = {{e.first,1}};
        }
        
        map<ll,ll> as;
        for (auto &&e : b)
        {
            map<ll,ll> mp = ans(e.first,a,memo);
            for (auto &&e1 : mp)
            {
                as[e1.first]+=e.second*e1.second;
            }
        }
        
        if(as == a)
        {
            cout<<"YES" << endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << ' ' << x << endl;
#define mod 998244353LL
#define inf 1e10
#define ll long long
using namespace std;

void printvec(vector<ll> vec)
{
    for (auto &&e : vec)
    {
        cout << e << ' ';
    }
    cout << endl;
}
void ans(ll cur,multiset<ll>& out,multiset<ll>& a)
{
    if(out.size() > a.size()) return;
    if(cur==1)
    {
        out.insert(cur);
        return;
    }
    if(cur == 0)
    {
        return;
    }
    if(a.count(cur))
    {
        out.insert(cur);
        return;
    }
    ans(cur/2,out,a);
    ans(ceil(cur/2.0),out,a);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); 
    ll t;
    cin >>t;
    // t = 1;
    while(t--)
    { 
        ll n,m;
        cin>>n>>m;
        multiset<ll> a;
        multiset<ll> b;
        for (int i = 0;i<n;i++)
        {
            ll x;
            cin>>x;
            a.insert(x);
        }
        for (int i = 0;i<m;i++) 
        {
            ll x;
            cin >> x;
            b.insert(x);
        }
        
        
        multiset<ll> out;
        for (auto &&e : b)
        {
            ans(e,out,a);
        }
        
        if(out == a)
        {
            cout<<"YES" << endl;
        }
        else cout << "NO" << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
   ll n;
   cin>>n;
   vector<ll>a(n);
   vector<ll>b(n);
   vector<ll>c(n);
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       b[0]+=a[i];
   }
   for(int i=1;i<n;i++)
   {
       if(i%2==1){
       for(int j=i;j<n;j++)
       {
           c[j]=a[j]-a[j-1];
       }
       b[i]=abs(c[n-1]-c[i]);}
       else
       {
           for(int j=i;j<n;j++)
            {
                a[j]=c[j]-c[j-1];
            }
            b[i]=abs(a[n-1]-a[i]);
       }
   }
   ll ans=LONG_MIN;
   for(int i=0;i<n;i++)
   {
       ans=max(ans,b[i]);
   }
   cout<<ans<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 6):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
   ll n;
   cin>>n;
   vector<ll>a(n);
   vector<ll>b(n);
   vector<ll>c(n);
   c[0]=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       b[0]+=a[i];
   }
   for(int i=1;i<n;i++)
   {
       if(n==2)
       {
           cout<<max(b[0],abs(a[1]-a[0]))<<endl;
           return;
       }
       if(i%2==1){
       for(int j=i;j<n;j++)
       {
           c[j]=a[j]-a[j-1];
       }
       b[i]=abs(c[n-1]-c[i]);}
       else
       {
           for(int j=i;j<n;j++)
            {
                a[j]=c[j]-c[j-1];
            }
            b[i]=abs(a[n-1]-a[i]);
       }
   }
   ll ans=LONG_MIN;
   for(int i=0;i<n;i++)
   {
       ans=max(ans,b[i]);
   }
   cout<<ans<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
   ll n;
   cin>>n;
   ll ans=0;
   vector<ll>a(n);
   vector<ll>b(n);
   vector<ll>c(n);
   c[0]=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       ans+=a[i];
   }
   b[0]=abs(a[n-1]-a[0]);
   for(int i=1;i<n;i++)
   {
       if(n==2)
       {
           cout<<max(b[0],abs(a[1]-a[0]))<<endl;
           return;
       }
       if(i%2==1){
       for(int j=i;j<n;j++)
       {
           c[j]=a[j]-a[j-1];
       }
       b[i]=abs(c[n-1]-c[i]);}
       else
       {
           for(int j=i;j<n;j++)
            {
                a[j]=c[j]-c[j-1];
            }
            b[i]=abs(a[n-1]-a[i]);
       }
   }
   for(int i=0;i<n;i++)
   {
       ans=max(ans,b[i]);
   }
   cout<<ans<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
   ll n;
   cin>>n;
   ll ans=0;
   vector<ll>a(n);
   vector<ll>b(n);
   vector<ll>c(n);
   c[0]=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       ans+=a[i];
   }
   b[0]=abs(a[n-1]-a[0]);
   for(int i=1;i<n;i++)
   {
       if(n==2)
       {
           cout<<max(b[0],abs(a[1]-a[0]))<<endl;
           return;
       }
       if(i%2==1){
       for(int j=i;j<n;j++)
       {
           c[j]=a[j]-a[j-1];
       }
       b[i]=abs(c[n-1]-c[i]);}
       else
       {
           for(int j=i;j<n;j++)
            {
                a[j]=c[j]-c[j-1];
            }
            b[i]=abs(a[n-1]-a[i]);
       }
   }
   for(int i=0;i<n;i++)
   {
       ans=max(ans,b[i]);
   }
   cout<<ans<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
   ll n;
   cin>>n;
   ll ans=0;
   vector<ll>a(n);
   vector<ll>b(n);
   vector<ll>c(n);
   c[0]=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       ans+=a[i];
   }
   b[0]=abs(a[n-1]-a[0]);
   for(int i=1;i<n;i++)
   {
       if(n==2)
       {
           cout<<max(ans,abs(a[1]-a[0]))<<endl;
           return;
       }
       if(i%2==1){
       for(int j=i;j<n;j++)
       {
           c[j]=a[j]-a[j-1];
       }
       b[i]=abs(c[n-1]-c[i]);}
       else
       {
           for(int j=i;j<n;j++)
            {
                a[j]=c[j]-c[j-1];
            }
            b[i]=abs(a[n-1]-a[i]);
       }
   }
   for(int i=0;i<n;i++)
   {
       ans=max(ans,b[i]);
   }
   cout<<ans<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
   ll n;
   cin>>n;
   ll ans=0;
   vector<ll>a(n);
   vector<ll>b(n);
   vector<ll>c(n);
   c[0]=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       ans+=a[i];
   }
   b[0]=abs(a[n-1]-a[0]);
   for(int i=1;i<n;i++)
   {
       if(n==2)
       {
           cout<<max(ans,abs(a[1]-a[0]))<<endl;
           return;
       }
       if(i%2==1){
       for(int j=i;j<n;j++)
       {
           c[j]=a[j]-a[j-1];
       }
       b[i]=abs(c[n-1]-c[i]);}
       else
       {
           for(int j=i;j<n;j++)
            {
                a[j]=c[j]-c[j-1];
            }
            b[i]=abs(a[n-1]-a[i]);
       }
   }
   for(int i=0;i<n;i++)
   {
       ans=max(ans,b[i]);
   }
   cout<<ans<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
   ll n;
   cin>>n;
   ll ans=0;
   vector<ll>a(n);
   vector<ll>b(n);
   vector<ll>c(n);
   c[0]=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       ans+=a[i];
   }
   if(n==1){
    cout<<a[0]<<endl;
    return;
   }
   b[0]=abs(a[n-1]-a[0]);
   for(int i=1;i<n;i++)
   {
       if(n==2)
       {
           cout<<max(ans,abs(a[1]-a[0]))<<endl;
           return;
       }
       if(i%2==1){
       for(int j=i;j<n;j++)
       {
           c[j]=a[j]-a[j-1];
       }
       b[i]=abs(c[n-1]-c[i]);}
       else
       {
           for(int j=i;j<n;j++)
            {
                a[j]=c[j]-c[j-1];
            }
            b[i]=abs(a[n-1]-a[i]);
       }
   }
   for(int i=0;i<n;i++)
   {
       ans=max(ans,b[i]);
   }
   cout<<ans<<endl;
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0;
}