Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<vector>
#include<bitset>
#include<random>
#include<ctime>
#include<queue>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define FF fflush(stdout)
#define inf 0x3f3f3f3f
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
    int s=0,f=1;
    char x=getchar();
    while(!isdigit(x))f=(x=='-'?-1:1),x=getchar();
    while(isdigit(x))s=s*10+x-'0',x=getchar();
    return s*f;
}
const int p=1e9+7;
//ll ksm(int a,int b){ll ans=1,bs=a;while(b){if(b&1)ans=ans*bs%p;bs=bs*bs%p;b>>=1;}return ans;}
mt19937 rd(time(0));
#define reaD read
ll a[55];
ll C[55][55];
ll cal(int k)
{
    ll s=0;
    for(int i=0;i<=k;i++)
    s+=((i+k)%2?-1:1)*C[k][i]*a[i];
    return s;
}
int main()
{
    C[0][0]=1;
    for(int i=1;i<=50;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++)
        C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
    int T=read();
    while(T--)
    {
        ll ans=0;
        int n=read();
        for(int i=0;i<n;i++)
        a[i]=read(),ans+=a[i];
        for(int i=0;i<=n-2;i++)
        {
            ll a1=cal(i);
            reverse(a,a+n);
            ll an=cal(i);
            reverse(a,a+n);
            ans=max(ans,abs(a1-an));
        }
        if(n>1)
        ans=max(ans,abs(cal(n-1)));
        printf("%lld\n",ans);  
    }
    
    return 0;
}

Submission (verdict: Accepted):
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<vector>
#include<bitset>
#include<random>
#include<ctime>
#include<queue>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define FF fflush(stdout)
#define inf 0x3f3f3f3f
#define endl "\n"
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
    int s=0,f=1;
    char x=getchar();
    while(!isdigit(x))f=(x=='-'?-1:1),x=getchar();
    while(isdigit(x))s=s*10+x-'0',x=getchar();
    return s*f;
}
const int p=1e9+7;
//ll ksm(int a,int b){ll ans=1,bs=a;while(b){if(b&1)ans=ans*bs%p;bs=bs*bs%p;b>>=1;}return ans;}
mt19937 rd(time(0));
#define reaD read
ll a[55];
ll C[55][55];
ll cal(int k,int op)
{
    ll s=0;
    for(int i=0;i<=k;i++)
    s+=((i+op)%2?-1:1)*C[k][i]*a[i];
    return s;
}
int main()
{
    C[0][0]=1;
    for(int i=1;i<=50;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++)
        C[i][j]=C[i-1][j-1]+C[i-1][j];
    }
    int T=read();
    while(T--)
    {
        ll ans=0;
        int n=read();
        for(int i=0;i<n;i++)
        a[i]=read(),ans+=a[i];
        for(int i=0;i<=n-2;i++)
        {
            ll a1=cal(i,i);
            reverse(a,a+n);
            ll an=cal(i,0);
            reverse(a,a+n);
            ans=max(ans,abs(a1-an));
        }
        // if(n>1)
        // ans=max(ans,abs(cal(n-1)));
        printf("%lld\n",ans);  
    }
    
    return 0;
}