ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: c++23 

Code 1:
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e9 + 10;
const ll INF = 1e18 + 100;
const int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    ll ans = -INF;
    int now = n;
    for (int i = 1; i <= n; i++) {
        ll sum = 0;
        for (int i = 1; i <= now; i++) sum += a[i];
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, abs(sum));
        for (int j = 1; j < now; j++)
            a[j] = a[j + 1] - a[j];
        now--;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while (T--)
        solve();

    return 0;
}
/*

1
4
1 1 1 1
1 1 1 1
1 1 1 2
1 1 1 2


*/

Code 2:
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e9 + 10;
const int INF = 1e9 + 100;
const int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = -INF, now = n;
    for (int i = 1; i <= n; i++) {
        int sum = accumulate(a.begin(), a.begin() + now + 1, 0);
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, abs(sum));
        for (int j = 1; j < now; j++)
            a[j] = a[j + 1] - a[j];
        now--;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while (T--)
        solve();

    return 0;
}
/*

1
4
1 1 1 1
1 1 1 1
1 1 1 2
1 1 1 2


*/

Answer: 1
Problem: 2062C - Cirno and Operations
Language: c++20 

Code 1:
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int _, n, ans, sum, a[51], b[51];
int main() {
	scanf("%d", &_);
	for (; _--; ) {
		ans = 0;
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%d", &a[i]), ans += a[i];
		if (n == 1) {
			printf("%d\n", a[1]);
			continue;
		}
		for (; n > 1; ) {
			sum = 0;
			for (int i = 1; i < n; i++)
				b[i] = a[i + 1] - a[i], sum += b[i];
			ans = max(ans, abs(sum));
			--n;
			for (int i = 1; i <= n; i++)
				a[i] = b[i];
		}
		printf("%d\n", ans);
	}
}


Code 2:
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int _, n;
ll ans, sum, a[51];
int main() {
	scanf("%d", &_);
	for (; _--; ) {
		ans = 0;
		scanf("%d", &n);
		for (int i = 1; i <= n; i++)
			scanf("%lld", &a[i]), ans += a[i];
		for (int i = 1; i < n; i++) {
			sum = 0;
			for (int j = 1; i + j <= n; j++)
				a[j] -= a[j + 1], sum += a[j];
			if (sum < 0)
				sum *= -1;
			ans = max(ans, sum);
		}
		printf("%lld\n", ans);
	}
}


Answer: 2
Problem: 2062C - Cirno and Operations
Language: c++20 

Code 1:
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define int long long

void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    int ans = 0;
    for(int i=0;i<n; i++) cin>>v[i], ans+=v[i];


    vector<int> t;
    while(v.size()!=1)
    {
        for(int i=1; i<v.size(); i++) t.push_back(v[i]-v[i-1]);
        v = t;
        int sum = 0;
        for(int i=0;i<t.size(); i++){
            sum+=(v[i]);
        }
        ans = max(ans, abs(sum));
        t.clear();

    }
    cout<<ans<<endl;
}
int32_t main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}





Code 2:
#include<bits/stdc++.h>
#define TC int t;cin>>t;while(t--)
#define Tanveer ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
#ifdef LOKAL
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define int long long
int ans;
void fun(vector<int> v)
{
    if(v.size()==1){
        ans = max(ans, v[0]); return;
    }
    int n = v.size();
    vector<int> t;
    for(int i=1; i<n; i++) t.push_back(v[i]-v[i-1]);
    fun(t);
    reverse(v.begin(), v.end());
    vector<int> tt;
    for(int i=1; i<n; i++) tt.push_back(v[i]-v[i-1]);
    fun(tt);
}
void solve()
{
    int n; cin>>n;
    vector<int> v(n);
    ans = 0;
    for(int i=0;i<n; i++) cin>>v[i], ans+=v[i];
    fun(v);
    cout<<ans<<endl;
}
int32_t main()
{
    #ifndef LOKAL
    Tanveer
    #endif
    TC
    solve();
    return 0;
}





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

Code 1:
#include <bits/stdc++.h>

using namespace std;

int n, t;

void solve() {
    scanf("%d", &n);
    long long a[n];

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lli", a + i);
        ans += a[i];
    }

    for (int i = 1; i < n; i++) {
        long long curr = 0;
        for (int j = n - 1; j >= i; j--) {
            a[j] -= a[j - 1];
            curr += a[j];
        }
        ans = max(ans, abs(curr));
    }

    printf("%lli\n", ans);
}

int main() {
    scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}


Code 2:
#include <bits/stdc++.h>

using namespace std;

int n, t;

void solve() {
    scanf("%d", &n);
    int a[n], ans = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d", a + i);
        ans += a[i];
    }

    for (int i = 1; i < n; i++) {
        int curr = 0;
        for (int j = n - 1; j >= i; j--) {
            a[j] -= a[j - 1];
            curr += a[j];
        }
        ans = max(ans, abs(curr));
    }

    printf("%d\n", ans);
}

int main() {
    scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}


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

Code 1:
#include <iostream>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);init_code();
#include<bits/stdc++.h>
#define ll long long 
#define read(x) int x;cin>>x;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vl>
#define vb vector<bool>
#define ld long double 
using namespace std;

void init_code(){
	#ifndef ONLINE_JUDGE
	freopen("inputf.txt","r",stdin);
	freopen("outputf.txt","w",stdout);
	#endif
}

ll min(ll a, ll b){
	if (a<b)return a;
	return b;
}

ll max(ll a, ll b){
	if (a>b)return a;
	return b;
}

void solve(){
	ll n ; cin >> n;
	vl arr(n);
	ll sum =0;
	for (int i=0;i<n;i++){cin>>arr[i];sum+=arr[i];}
	if (n==1){
		cout <<arr[0]<<endl;
		return ;
	}
	for (int i=0;i<n-1;i++){
		ll s =0;
		for (int j=0;j<n-1-i;j++){
			arr[j] = arr[j]-arr[j+1];
			s+=arr[j];
		}
		sum = max(abs(s),sum);
	}
	cout <<sum<<endl;
}

int main(){
	fast ;
	read(t);
	while (t--)solve();
	return 0;
}



Code 2:
#include <iostream>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);init_code();
#include<bits/stdc++.h>
#define ll long long 
#define read(x) int x;cin>>x;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vl>
#define vb vector<bool>
#define ld long double 
#define vld vector<ld>
using namespace std;

void init_code(){
	#ifndef ONLINE_JUDGE
	freopen("inputf.txt","r",stdin);
	freopen("outputf.txt","w",stdout);
	#endif
}

int solve2(int pos, vvl &edges,int n){
	int maxi = INT_MIN;
	for (int i=0;i<n;i++){
		if (i == pos)continue;
		bool p = false;
		for (int j=0;j<edges[i].size();j++){
			if (pos == edges[i][j]){
				p = true;
				break;
			}
		}
		int sz = edges[i].size()-p;
		maxi = max(maxi,sz);
	}

	return maxi ;
}

ld max(ld a , ld b){
	if (a>b)return a;
	return b;
}

void solve(){
	ld n; cin >>n;
	ld sum =0;
	vld arr(n);
	for (int i=0;i<n;i++){
		cin>>arr[i];
		sum += arr[i];
	}
	if (n==1 and arr[0] < 0){
		cout <<arr[0]<<endl;
		return ;
	}
	for (int i=0;i<n-1;i++){
		for (int j=0;j<n-1-i;j++){
			arr[j] = arr[j]-arr[j+1];
		}
	}
	cout <<max(sum,abs(arr[0]))<<endl;

}

int main(){
	fast ;
	read(t);
	while (t--)solve();
	return 0;
}



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

Code 1:
//Bharti Nema
#include<bits/stdc++.h>
using namespace std;
bool isValid(int,int);
int n,m;
int main() {
	int t;
	cin>>t;
	while(t--) {
		long long int n,baari=0,ans=0,sum1=0,sum2=0;
		cin>>n;
		long long int a[n+1],b[n+1];
		for(int i=0;i<n;i++)
			cin>>a[i];

		for(int i=0;i<n;i++) {
			ans+=a[i];
		}
		if(n==1) {
			cout<<a[0]<<endl;
			continue;
		}
		while(n>1) {
			for(int i=0;i<n-1;i++) {
				a[i]=a[i]-a[i+1];
			}
			n-=1;
		}

		cout<<max(ans,abs(a[0]))<<endl;


		// while(n>1) {
		// for(int i=1,j=0;i<n && j<n-1;i++,j++) {

		// }
	// 		sum1+=(a[i]-a[i-1]);
	// 		sum2+=(a[j]-a[j+1]);
	// 	}
	// 	if(sum1>sum2) {
	// 		ans=max(ans,sum1);
	// 		for(int i=1;i<n;i++) {
	// 			if(baari==0)
	// 			    b[i-1]=a[i]-a[i-1];
	// 		    else
	// 		        a[i-1]=b[i]-b[i-1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// 	else {
	// 		ans=max(ans,sum2);
	// 		for(int i=0,kahan=n-2;i<n-1;i++,kahan--) {
	// 			if(baari==0)
	// 			    b[kahan]=a[i]-a[i+1];
	// 		    else
	// 		    	a[kahan]=b[i]-b[i+1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// }

	// 	if(baari==0)
	// 		cout<<max(ans,a[0]);
	// 	else
	// 		cout<<max(ans,b[0]);
	}
}

Code 2:
//Bharti Nema
#include<bits/stdc++.h>
using namespace std;
bool isValid(int,int);
int n,m;
int main() {
	int t;
	cin>>t;
	while(t--) {
		long long int n,baari=0,ans=0,sum=0,sum2=0;
		cin>>n;
		long long int a[n+1],b[n+1];
		for(int i=0;i<n;i++)
			cin>>a[i];

		for(int i=0;i<n;i++) {
			ans+=a[i];
		}
		if(n==1) {
			cout<<a[0]<<endl;
			continue;
		}
		while(n>1) {
			for(int i=0;i<n-1;i++) {
				a[i]=a[i]-a[i+1];
			}
			n-=1;
			for(int i=0;i<n;i++) {
				sum+=a[i];
			}
			ans=max(ans,sum);
			sum=0;
			for(int i=0;i<n;i++) {
				sum+=(-a[i]);
			}
			ans=max(ans,sum);
			sum=0;
		}

		cout<<max(ans,abs(a[0]))<<endl;


		// while(n>1) {
		// for(int i=1,j=0;i<n && j<n-1;i++,j++) {

		// }
	// 		sum1+=(a[i]-a[i-1]);
	// 		sum2+=(a[j]-a[j+1]);
	// 	}
	// 	if(sum1>sum2) {
	// 		ans=max(ans,sum1);
	// 		for(int i=1;i<n;i++) {
	// 			if(baari==0)
	// 			    b[i-1]=a[i]-a[i-1];
	// 		    else
	// 		        a[i-1]=b[i]-b[i-1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// 	else {
	// 		ans=max(ans,sum2);
	// 		for(int i=0,kahan=n-2;i<n-1;i++,kahan--) {
	// 			if(baari==0)
	// 			    b[kahan]=a[i]-a[i+1];
	// 		    else
	// 		    	a[kahan]=b[i]-b[i+1];
	// 		}
	// 		n-=1;
	// 		if(baari==0)
	// 			baari=1;
	// 		else
	// 			baari=0;
	// 	}
	// }

	// 	if(baari==0)
	// 		cout<<max(ans,a[0]);
	// 	else
	// 		cout<<max(ans,b[0]);
	}
}


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

Code 1:
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <climits>
#include <cmath>
#include <queue>
#include <tuple>
using namespace std;

vector<int> diff(vector<int> arr){
    vector<int> ans(arr.size() - 1);
    for (int i = 0; i < ans.size(); i++){
        ans[i] = arr[i+1] - arr[i];
    }
    return ans;
}
void solve(){
    int n;
    cin >> n;
    vector<int> arr(n);
    long long ans = 0;
    for (int i = 0; i < n; i++){
        cin >> arr[i];
        ans += arr[i];
    }
    for (int i = 0; i < n - 1; i++){
        ans = max(ans, 1LL * abs(arr[arr.size() - 1] - arr[0]));
        arr = diff(arr);
    }
    cout << ans << "\n";
}

int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
        solve();
    }
    return 0;
    
}

Code 2:
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <climits>
#include <cmath>
#include <queue>
#include <tuple>
using namespace std;

vector<long long> diff(vector<long long> arr){
    vector<long long> ans(arr.size() - 1);
    for (int i = 0; i < ans.size(); i++){
        ans[i] = arr[i+1] - arr[i];
    }
    return ans;
}
void solve(){
    int n;
    cin >> n;
    vector<long long> arr(n);
    long long ans = 0;
    for (int i = 0; i < n; i++){
        cin >> arr[i];
        ans += arr[i];
    }
    for (int i = 0; i < n - 1; i++){
        ans = max(ans, 1LL * abs(arr[arr.size() - 1] - arr[0]));
        arr = diff(arr);
    }
    cout << ans << "\n";
}

int main(){
    int t;
    cin >> t;
    for (int i = 0; i < t; i++){
        solve();
    }
    return 0;
    
}

Answer: 2
Problem: 2062C - Cirno and Operations
Language: c++23 

Code 1:
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <bits/stdc++.h>
#include <bitset>
#include <cstdio>
#include <cctype>
#define ll long long
#define all(vc) vc.begin() , vc.end()
#define inf  0x3f3f3f3f3f3f3f3f
#define N 1000005
#define khatun ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Time   ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define MOD 1000000007
using namespace std;
const ll mod = 1e9+7, infinity = 1e4;

vector<pair<int, int>> dir = {
        {0, 1},  // right
        {0, -1}, // left
        {1, 0},  // down
        {-1, 0}  // up
};
void solve() {
    ll n,ans=LONG_LONG_MIN;
    cin>>n;
    vector<ll>vc(n);
    for (int i=0 ;  i<n ; ++i){
        cin>>vc[i];
    }
    ll sz=n;
    for (int i=0 ; i<n ; ++i){
        ll sum=0;
        for (int j=0 ; j<sz ; ++j)
            sum+=vc[j];
        if(!i)
            ans=max(ans,sum);
        else
            ans=max(ans,max(sum ,(-sum)));
        for (int k=0 ; k<sz-1;++k){
            vc[k]=vc[k+1]-vc[k];
        }
        sz--;
    }
    cout<<ans<<"\n";
}
int main (){
    khatun
    Time
    //cout<<fixed<< setprecision(9)<<( double )5/3 ;
    int tc=1;
    cin>>tc;
    for (int i=1 ; i<= tc ; ++i){
        solve();
    }
    return 0;
}


Code 2:
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <bits/stdc++.h>
#include <bitset>
#include <cstdio>
#include <cctype>
#define ll long long
#define all(vc) vc.begin() , vc.end()
#define inf  0x3f3f3f3f3f3f3f3f
#define N 1000005
#define khatun ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Time   ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define MOD 1000000007
using namespace std;
const ll mod = 1e9+7, infinity = 1e4;

vector<pair<int, int>> dir = {
        {0, 1},  // right
        {0, -1}, // left
        {1, 0},  // down
        {-1, 0}  // up
};
void solve() {
    int n,ans=INT_MIN;
    cin>>n;
    vector<int>vc(n);
    for (int i=0 ;  i<n ; ++i){
        cin>>vc[i];
    }
    int sz=n;
    for (int i=0 ; i<n ; ++i){
        int sum=0;
        for (int j=0 ; j<sz ; ++j)
            sum+=vc[j];
        if(!i)
            ans=max(ans,sum);
        else
            ans=max(ans,max(sum ,(-sum)));
        for (int k=0 ; k<sz-1;++k){
            vc[k]=vc[k+1]-vc[k];
        }
        sz--;
    }
    cout<<ans<<"\n";
}
int main (){
    khatun
    Time
    //cout<<fixed<< setprecision(9)<<( double )5/3 ;
    int tc=1;
    cin>>tc;
    for (int i=1 ; i<= tc ; ++i){
        solve();
    }
    return 0;
}


Answer: 1
Problem: 2062C - Cirno and Operations
Language: c++23 

Code 1:
#include <bits/stdc++.h>
using namespace std;
int res=-2e9;
int a[60],bk[60];
int n;
void solve() {
    long long ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        ans+=a[i];
    }
    for(int j=n;j>=2;j--) {
        long long sum=0;
        for(int i=1;i<j;i++) {
            a[i]=a[i+1]-a[i];
            sum+=a[i];
        }
        ans=max(ans,sum);
        ans=max(ans,-sum);

    }
    cout<<ans<<endl;
}


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

Code 2:
#include <bits/stdc++.h>
using namespace std;
int res=-2e9;
long long a[60];
int n;
void solve() {
    long long ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        ans+=a[i];
    }
    for(int j=n;j>=2;j--) {
        long long sum=0;
        for(int i=1;i<j;i++) {
            a[i]=a[i+1]-a[i];
            sum+=a[i];
        }
        ans=max(ans,sum);
        ans=max(ans,-sum);

    }
    cout<<ans<<endl;
}


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

Answer: 2
Problem: 2062C - Cirno and Operations
Language: c++23 

Code 1:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef unordered_set<int> usi;
typedef set<int> si; 
#define Pb push_back
#define Mp make_pair
#define FOR(i,a,b) for(int i = a ; i<b ; i++)
#define int long long


void solve(){
    int n;cin>>n;
    vector<int> arr(n);
    int sum = 0;
    FOR(i,0,n){
        cin>>arr[i];
        sum+=arr[i];
    }
    FOR(i,1,n)
    {
        int nsum = 0;
        int prevbefore = arr[i-1];
        int prev = arr[i-1];
        FOR(j,i,n)
        {
            prevbefore = arr[j];
            arr[j] = arr[j] - prev;
            prev = prevbefore;
            nsum+=arr[j];
        }
        if(abs(nsum)>sum){
            sum = abs(nsum);
            // cout<<i<<". "<<nsum<<endl;
        }
        // cout<<i<<". "<<nsum<<endl;
    }
    cout<<sum<<endl;
}


signed main(){
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
}

Code 2:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef unordered_set<int> usi;
typedef set<int> si; 
#define Pb push_back
#define Mp make_pair
#define FOR(i,a,b) for(int i = a ; i<b ; i++)



void solve(){
    int n;cin>>n;
    vector<int> arr(n);
    int sum = 0;
    FOR(i,0,n){
        cin>>arr[i];
        sum+=arr[i];
    }
    FOR(i,0,n)
    {
        int nsum = 0;
        FOR(j,0,n-1)
        {
            arr[j] = arr[j+1] - arr[j];
            nsum+=arr[j];
        }
        if(abs(nsum)>sum){
            sum = abs(nsum);
        }
    }
    cout<<sum<<endl;
}


int main(){
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        solve();
    }
}

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

Code 1:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define rr(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define nn '\n'

// Fast Input-Output
void fastIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main()
{
    fastIO();

    int t;
    cin >> t;
   

    while (t--){
		int n;
		cin >> n;
        vector<ll>a(n+1);
		for (int i = 1; i <= n; i++) cin >> a[i];
		int now = n;
		long long ans = -1e18;
		for (int i = 1; i <= n; i++){
			long long sum = 0;
			for (int i = 1; i <= now; i++) sum = (sum + a[i]) ;
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < now; i++) a[i] = (a[i + 1] - a[i]) ;
			now--;
		}
		cout << ans << endl; 
    }
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define rr(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define nn '\n'

// Fast Input-Output
void fastIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main()
{
    fastIO();

    int t;
    cin >> t;
   

    while (t--){
		int n;
		cin >> n;
        vector<int>a(n+1);
		for (int i = 1; i <= n; i++) cin >> a[i];
		int now = n;
		long long ans = -1e18;
		for (int i = 1; i <= n; i++){
			long long sum = 0;
			for (int i = 1; i <= now; i++) sum = (sum + a[i]) ;
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < now; i++) a[i] = (a[i + 1] - a[i]) ;
			now--;
		}
		cout << ans << endl; 
    }
    return 0;
}


Answer: 1
Problem: 2062C - Cirno and Operations
Language: c++20 

Code 1:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using ll = long long;

using namespace std;

vector<ll> replace( vector <ll> a){
    ll size = a.size();
    vector<ll> rep_a;

    for( ll i = 1;i < size; i++){
        rep_a.push_back(a[i] - a[i-1]);
    }

    return rep_a;

}

ll sum_array( vector<ll> a){
    ll sum = 0;
    for( ll i =0; i < a.size(); i++){

        sum += a[i];
    }

    return sum;

}

ll max_sum_sequence(ll n , vector <ll>& a){
    vector<ll> temp;

    if (n == 1) {
        return a[0];
    } else {
        ll sum = 0;
        sum = sum_array(a);

        for( ll j =0; j < n-1; j++ ){
        ll rep_sum = 0;
        temp = replace(a);
        a = temp;
        rep_sum = abs(sum_array(a));
        if( rep_sum > sum ) sum = rep_sum;
        }

            return sum;
    }
}


int main(){
    ll t;
    cin >> t;
    while (t--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        for (ll i = 0; i < n; ++i) {
            cin >> a[i];
        }
        ll result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}

Code 2:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>


using namespace std;

int max_sum_sequence(int n , vector <int>& a){
    if (n == 1) {
        return a[0];
    } else if (n == 2) {
        return max(a[0] + a[1], abs(a[0] - a[1]));
    } else {
        int sum = 0;
        for (int num : a) {
            sum += num;
        }
        return sum;
    }
}


int main(){
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        int result = max_sum_sequence(n, a);
        cout << result << endl;
    }
    return 0;
}

Answer: 1
Problem: 2062C - Cirno and Operations
Language: c++23 

Code 1:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n; cin>>n;
    vector<ll> vi;
    ll ans=0;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        vi.push_back(x);
        ans+=x;
    }
    if(n==1){
        cout<<vi[0];
        return;
    }
    else if(n>2){
        for(int i=1;i<=n-2;i++){
            ll check=0;
            for(auto j:vi){
                check+=j;
            }
            ans=max(ans,check);
            ll sum=0;
            for(auto it=vi.begin();it!=vi.end()-1;it++){
                *it=*(it+1)-*(it);
                sum+=(*it);
            }
            ans=max(ans,max(sum,-sum));
            vi.pop_back();
        }
    }
    ll a=vi[0]+vi[1]; ll b=vi[0]-vi[1];
    ans=max(ans,(max(a,max(b,-b))));
    cout<<ans;
}

int main() {
    int t; cin >> t;
    while (t-- > 0) {
        solve();
        cout << "\n";
    }
    return 0;
}


Code 2:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n; cin>>n;
    vector<ll> vi;
    ll ans=0;
    for(int i=0;i<n;i++){
        int x; cin>>x;
        vi.push_back(x);
        ans+=x;
    }
    if(n==1){
        cout<<vi[0];
        return;
    }
    else if(n>2){
        for(int i=1;i<=n-2;i++){
            for(auto it=vi.begin();it!=vi.end()-1;it++){
                ll sum=0;
                *it=*(it)-*(it+1);
                sum+=(*it);
                sum=abs(sum);
                ans=max(ans,sum);
            }
            vi.pop_back();
        }
    }
    auto it=vi.begin();
    ll a=*(it+1)+*it; ll b=(*it)-*(it+1); ll c=*(it+1)-(*it);
    ans=max(ans,max(a,max(b,c)));
    cout<<ans;
}

int main() {
    int t; cin >> t;
    while (t-- > 0) {
        solve();
        cout << "\n";
    }
    return 0;
}


Answer: 1