Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 77 ms):
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    vector<lli> v(n);
	    for(int i=0;i<n;i++)
	    {
	        cin>>v[i];
	    }
	        lli count =1;
	        vector<lli> v1,v2;
	        v1.push_back(1);
	        lli sum=0,final_ans=0;
	        for(int i=0;i<v.size();i++)
	        final_ans+=v[i];
	        while(count<=n)
	        {
	            sum=0;
	            for(int i=0;(i+v1.size())<=v.size();i++)
	            {
	                for(int j=0;j<v1.size();j++)
	                {
	                    sum += v1[j]*v[i+j];
	                    
	                }
	            }
	            if(v1.size()>1 && max(sum,-sum)>final_ans)
	            {
	                final_ans=max(sum,-sum);
	            }
	            
	            v2.push_back(1);
	            for(int i=1;i<v1.size();i++)
	            {
	                v2.push_back(v1[i]-v1[i-1]);
	            }
	            if(v2.size()%2)
	            {
	                v2.push_back(-1);
	            }
	            else
	            {
	                v2.push_back(1);
	            }
	            v1=v2;
	            v2.clear();
	            count++;
	        }
	        cout<<final_ans<<endl;
	        
	    
	}

}


Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
#include<iostream>
#include<set>
using namespace std;
 
// CONSTANTS
const long long inf = 1e18;
#define ll long long
#define num1 1000000007
#define num2 998244353

// DEBUG FUNCTIONS 
#ifndef ONLINE_JUDGE
 
template<typename T>
void __p(T a) {
    cout<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
    cout<<"{";
    __p(a.first);
    cout<<",";
    __p(a.second);
    cout<<"}";
}
template<typename T>
void __p(std::vector<T> a) {
    cout<<"{";
    for(auto it=a.begin(); it<a.end(); it++)
        __p(*it),cout<<",}"[it+1==a.end()];
}
template<typename T>
void __p(std::set<T> a) {
    cout<<"{";
    for(auto it=a.begin(); it!=a.end();){
        __p(*it); 
        cout<<",}"[++it==a.end()];
    }
 
}
template<typename T>
void __p(std::multiset<T> a) {
    cout<<"{";
    for(auto it=a.begin(); it!=a.end();){
        __p(*it); 
        cout<<",}"[++it==a.end()];
    }
}
template<typename T, typename F>
void __p(std::map<T,F> a) {
    cout<<"{\n";
    for(auto it=a.begin(); it!=a.end();++it)
    {
        __p(it->first);
        cout << ": ";
        __p(it->second);
        cout<<"\n";
    }
    cout << "}\n";
}
 
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
    __p(a1);
    __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cout<<name<<" : ";
    __p(arg1);
    cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    int bracket=0,i=0;
    for(;; i++)
        if(names[i]==','&&bracket==0)
            break;
        else if(names[i]=='(')
            bracket++;
        else if(names[i]==')')
            bracket--;
    const char *comma=names+i;
    cout.write(names,comma-names)<<" : ";
    __p(arg1);
    cout<<" | ";
    __f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#define error(...)
#endif


void solve(){

    ll n;
    cin >> n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin >> v[i];
    if(n==1){
        cout << v[0] << "\n";
        return;
    }
    ll sum = 0;
    for(ll i=0;i<n;i++) sum += v[i];
    for(ll i=0;i<n-1;i++){
        vector<ll> b;
        for(ll j=1;j<v.size();j++) b.push_back(v[j]-v[j-1]);
        v = b;
        ll temp = 0;
        for(ll j=0;j<v.size();j++){
            temp += v[j];
        }
        trace(temp);
        sum = max(sum,abs(temp));
    }
    cout << sum << "\n";

}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    cin>>t;
    while(t--) {
        solve();
    }
    return 0;
}